|
4 | 4 | import getpass |
5 | 5 | import commands |
6 | 6 | import os |
| 7 | +import shutil |
| 8 | +from os.path import expanduser |
7 | 9 |
|
8 | 10 | LOG = logging.getLogger(__name__) |
9 | 11 |
|
@@ -330,10 +332,10 @@ def cinder_create(user_conf): |
330 | 332 | (user_conf['os_cinder_dev'])) |
331 | 333 |
|
332 | 334 | 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') |
335 | 337 | # 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) |
337 | 339 | if status != 0: |
338 | 340 | LOG.warn(out) |
339 | 341 | raise RuntimeError('Failed to generate answer file') |
@@ -371,15 +373,12 @@ def packstack(user_conf): |
371 | 373 | for option in configs: |
372 | 374 | # Update options |
373 | 375 | (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])) |
375 | 377 | if status != 0: |
376 | 378 | LOG.warn(out) |
377 | 379 | raise RuntimeError('Failed to update option %s in answer file' % option) |
378 | 380 | # 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) |
383 | 382 | # Invoke packstack, currently not hide the output from packstack. |
384 | 383 | LOG.info('Starting openstack deployment') |
385 | 384 | os.system('/usr/bin/packstack --answer-file=%s' % ANSWER_FILE) |
|
0 commit comments