30
30
HBA_CONF_FILE , \
31
31
RECOVERY_CONF_FILE , \
32
32
PG_LOG_FILE , \
33
- UTILS_LOG_FILE , \
34
- DEFAULT_XLOG_METHOD
33
+ UTILS_LOG_FILE
35
34
36
35
from .decorators import \
37
36
method_decorator , \
@@ -112,7 +111,7 @@ def __enter__(self):
112
111
def __exit__ (self , type , value , traceback ):
113
112
self .free_port ()
114
113
115
- # NOTE: ctrl +C does not count!
114
+ # NOTE: Ctrl +C does not count!
116
115
got_exception = type is not None and type != KeyboardInterrupt
117
116
118
117
c1 = self .cleanup_on_good_exit and not got_exception
@@ -254,19 +253,15 @@ def _collect_special_files(self):
254
253
255
254
return result
256
255
257
- def init (self ,
258
- fsync = False ,
259
- unix_sockets = True ,
260
- allow_streaming = True ,
261
- initdb_params = None ):
256
+ def init (self , initdb_params = None , ** kwargs ):
262
257
"""
263
258
Perform initdb for this node.
264
259
265
260
Args:
261
+ initdb_params: parameters for initdb (list).
266
262
fsync: should this node use fsync to keep data safe?
267
263
unix_sockets: should we enable UNIX sockets?
268
264
allow_streaming: should this node add a hba entry for replication?
269
- initdb_params: parameters for initdb (list).
270
265
271
266
Returns:
272
267
This instance of PostgresNode.
@@ -281,9 +276,7 @@ def init(self,
281
276
params = initdb_params )
282
277
283
278
# initialize default config files
284
- self .default_conf (fsync = fsync ,
285
- unix_sockets = unix_sockets ,
286
- allow_streaming = allow_streaming )
279
+ self .default_conf (** kwargs )
287
280
288
281
return self
289
282
@@ -682,16 +675,13 @@ def psql(self,
682
675
return process .returncode , out , err
683
676
684
677
@method_decorator (positional_args_hack (['dbname' , 'query' ]))
685
- def safe_psql (self ,
686
- query ,
687
- dbname = None ,
688
- username = None ,
689
- input = None ):
678
+ def safe_psql (self , query = None , ** kwargs ):
690
679
"""
691
680
Execute a query using psql.
692
681
693
682
Args:
694
683
query: query to be executed.
684
+ filename: file with a query.
695
685
dbname: database name to connect to.
696
686
username: database user name.
697
687
input: raw input to be passed.
@@ -700,10 +690,7 @@ def safe_psql(self,
700
690
psql's output as str.
701
691
"""
702
692
703
- ret , out , err = self .psql (query = query ,
704
- dbname = dbname ,
705
- username = username ,
706
- input = input )
693
+ ret , out , err = self .psql (query = query , ** kwargs )
707
694
if ret :
708
695
raise QueryException ((err or b'' ).decode ('utf-8' ), query )
709
696
@@ -859,37 +846,34 @@ def execute(self,
859
846
860
847
return res
861
848
862
- def backup (self , username = None , xlog_method = DEFAULT_XLOG_METHOD ):
849
+ def backup (self , ** kwargs ):
863
850
"""
864
851
Perform pg_basebackup.
865
852
866
853
Args:
867
854
username: database user name.
868
855
xlog_method: a method for collecting the logs ('fetch' | 'stream').
856
+ base_dir: the base directory for data files and logs
869
857
870
858
Returns:
871
859
A smart object of type NodeBackup.
872
860
"""
873
861
874
862
from .backup import NodeBackup
875
- return NodeBackup (node = self ,
876
- username = username ,
877
- xlog_method = xlog_method )
863
+ return NodeBackup (node = self , ** kwargs )
878
864
879
- def replicate (self ,
880
- name = None ,
881
- username = None ,
882
- xlog_method = DEFAULT_XLOG_METHOD ):
865
+ def replicate (self , name = None , ** kwargs ):
883
866
"""
884
867
Create a binary replica of this node.
885
868
886
869
Args:
887
870
name: replica's application name.
888
871
username: database user name.
889
872
xlog_method: a method for collecting the logs ('fetch' | 'stream').
873
+ base_dir: the base directory for data files and logs
890
874
"""
891
875
892
- backup = self .backup (username = username , xlog_method = xlog_method )
876
+ backup = self .backup (** kwargs )
893
877
894
878
# transform backup into a replica
895
879
return backup .spawn_replica (name = name , destroy = True )
0 commit comments