44
55from six import raise_from
66
7- from .os_ops import OsOperations
7+ from .op_ops .local_ops import LocalOperations
8+ from .op_ops .os_ops import OsOperations
89from .config import testgres_config
910
1011from .consts import XLOG_CONTROL_FILE
2021 execute_utility
2122
2223
23- def cached_initdb (data_dir , logfile = None , hostname = 'localhost' , ssh_key = None , params = None ):
24+ def cached_initdb (data_dir , logfile = None , params = None , os_ops : OsOperations = LocalOperations () ):
2425 """
2526 Perform initdb or use cached node files.
2627 """
27- os_ops = OsOperations (hostname = hostname , ssh_key = ssh_key )
2828
2929 def call_initdb (initdb_dir , log = None ):
3030 try :
3131 _params = [get_bin_path ("initdb" ), "-D" , initdb_dir , "-N" ]
32- execute_utility (_params + (params or []), log , hostname = hostname , ssh_key = ssh_key )
32+ execute_utility (_params + (params or []), log , os_ops )
3333 except ExecUtilException as e :
3434 raise_from (InitNodeException ("Failed to run initdb" ), e )
3535
@@ -42,7 +42,7 @@ def call_initdb(initdb_dir, log=None):
4242 # Initialize cached initdb
4343
4444 if not os_ops .path_exists (cached_data_dir ) or \
45- not os_ops .listdir (cached_data_dir ):
45+ not os_ops .listdir (cached_data_dir ):
4646 call_initdb (cached_data_dir )
4747
4848 try :
@@ -60,7 +60,7 @@ def call_initdb(initdb_dir, log=None):
6060
6161 # XXX: build new WAL segment with our system id
6262 _params = [get_bin_path ("pg_resetwal" ), "-D" , data_dir , "-f" ]
63- execute_utility (_params , logfile , hostname = hostname , ssh_key = ssh_key )
63+ execute_utility (_params , logfile , os_ops )
6464
6565 except ExecUtilException as e :
6666 msg = "Failed to reset WAL for system id"
0 commit comments