@@ -294,16 +294,15 @@ def __enter__(self):
294
294
def __exit__ (self , type , value , traceback ):
295
295
self .cleanup ()
296
296
297
- def spawn_primary (self , name , destroy = True ):
297
+ def _prepare_dir (self , destroy ):
298
298
"""
299
- Create a primary node from a backup .
299
+ Provide a data directory for a copy of node .
300
300
301
301
Args:
302
- name: name for a new node (str).
303
302
destroy: should we convert this backup into a node?
304
303
305
304
Returns:
306
- New instance of PostgresNode .
305
+ Path to data directory .
307
306
"""
308
307
309
308
if not self .available :
@@ -326,14 +325,32 @@ def spawn_primary(self, name, destroy=True):
326
325
else :
327
326
base_dir = self .base_dir
328
327
328
+ # update value
329
+ self .available = available
330
+
331
+ return base_dir
332
+
333
+ def spawn_primary (self , name , destroy = True ):
334
+ """
335
+ Create a primary node from a backup.
336
+
337
+ Args:
338
+ name: name for a new node (str).
339
+ destroy: should we convert this backup into a node?
340
+
341
+ Returns:
342
+ New instance of PostgresNode.
343
+ """
344
+
345
+ base_dir = self ._prepare_dir (destroy )
346
+
329
347
# build a new PostgresNode
330
348
node = PostgresNode (name = name ,
331
349
base_dir = base_dir ,
332
350
master = self .original_node )
333
- node .append_conf ("postgresql.conf" , "port = {}" .format (node .port ))
334
351
335
- # record new status
336
- self . available = available
352
+ node . append_conf ( "postgresql.conf" , " \n " )
353
+ node . append_conf ( "postgresql.conf" , "port = {}" . format ( node . port ))
337
354
338
355
return node
339
356
0 commit comments