Skip to content

Commit eeeee46

Browse files
committed
Save answer file using shutil.copyfile
Signed-off-by: apporc <appleorchard2000@gmail.com>
1 parent 5f96594 commit eeeee46

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

es_setup/cfg.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import getpass
55
import commands
66
import os
7+
import shutil
8+
from os.path import expanduser
79

810
LOG = logging.getLogger(__name__)
911

@@ -330,10 +332,10 @@ def cinder_create(user_conf):
330332
(user_conf['os_cinder_dev']))
331333

332334
def packstack(user_conf):
333-
TMP_ANSWER_FILE = '/tmp/eayunstack.answer'
334-
ANSWER_FILE = '.eayunstack.answer'
335+
ANSWER_FILE = '/tmp/eayunstack.answer'
336+
ANSWER_SAVE = os.path.join(expanduser("~"), '.es-setup.answer')
335337
# Generate answer file with packstack.
336-
(status, out) = commands.getstatusoutput('/usr/bin/packstack --gen-answer-file=%s' % TMP_ANSWER_FILE)
338+
(status, out) = commands.getstatusoutput('/usr/bin/packstack --gen-answer-file=%s' % ANSWER_FILE)
337339
if status != 0:
338340
LOG.warn(out)
339341
raise RuntimeError('Failed to generate answer file')
@@ -371,15 +373,12 @@ def packstack(user_conf):
371373
for option in configs:
372374
# Update options
373375
(status, out) = commands.getstatusoutput('/usr/bin/openstack-config --set %s general %s %s'
374-
% (TMP_ANSWER_FILE, option, configs[option]))
376+
% (ANSWER_FILE, option, configs[option]))
375377
if status != 0:
376378
LOG.warn(out)
377379
raise RuntimeError('Failed to update option %s in answer file' % option)
378380
# Save answer file
379-
os.chdir(os.environ['HOME'])
380-
if os.path.exists(ANSWER_FILE):
381-
os.unlink(ANSWER_FILE)
382-
os.link(TMP_ANSWER_FILE, ANSWER_FILE)
381+
shutil.copyfile(ANSWER_FILE, ANSWER_SAVE)
383382
# Invoke packstack, currently not hide the output from packstack.
384383
LOG.info('Starting openstack deployment')
385384
os.system('/usr/bin/packstack --answer-file=%s' % ANSWER_FILE)

0 commit comments

Comments
 (0)