diff options
author | Chris Krelle <nobodycam@gmail.com> | 2013-03-14 15:14:01 -0700 |
---|---|---|
committer | Chris Krelle <nobodycam@gmail.com> | 2013-03-26 18:19:46 -0700 |
commit | 0ee0eba0efc264b94856d2e6b43a5fabe3eeaac0 (patch) | |
tree | ab456bbe9d962326a7b78cd14d9f0a7ccf190b75 /bin | |
parent | 66a8721c4319d971ea9ca1dc0de285c195f244df (diff) | |
download | nova-0ee0eba0efc264b94856d2e6b43a5fabe3eeaac0.tar.gz nova-0ee0eba0efc264b94856d2e6b43a5fabe3eeaac0.tar.xz nova-0ee0eba0efc264b94856d2e6b43a5fabe3eeaac0.zip |
Switch nova-baremetal-deploy-helper to use sfdisk.
This patch changes make_partitions function to use sfdisk instead
of fdisk. Also added logging of cmd, stdout, and stderr should
command fail.
Fixes Bug 1088652
Change-Id: Ia2711a5450900c95598253f2a7b02e7c3e83a3d8
Authored-by: Chris Krelle <nobodycam@gmail.com>
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/nova-baremetal-deploy-helper | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/bin/nova-baremetal-deploy-helper b/bin/nova-baremetal-deploy-helper index 756305776..e9ae41249 100755 --- a/bin/nova-baremetal-deploy-helper +++ b/bin/nova-baremetal-deploy-helper @@ -45,6 +45,7 @@ from wsgiref import simple_server from nova import config from nova import context as nova_context +from nova import exception from nova.openstack.common import log as logging from nova import utils from nova.virt.baremetal import baremetal_states @@ -95,18 +96,27 @@ def logout_iscsi(portal_address, portal_port, target_iqn): def make_partitions(dev, root_mb, swap_mb): """Create partitions for root and swap on a disk device.""" - commands = ['o,w', - 'n,p,1,,+%dM,t,1,83,w' % root_mb, - 'n,p,2,,+%dM,t,2,82,w' % swap_mb, - ] - for command in commands: - command = command.replace(',', '\n') - utils.execute('fdisk', dev, - process_input=command, - run_as_root=True, - check_exit_code=[0]) - # avoid "device is busy" - time.sleep(3) + stdin_command = ('0 0;\n0 0;\n0 0;\n0 0;\n') + utils.execute('sfdisk', '-D', '-uM', dev, process_input=stdin_command, + run_as_root=True, + check_exit_code=[0]) + # create new partitions + commandp1 = '- %d 83;\n;\n;\n;' % root_mb + p1outraw, err = utils.execute('sfdisk', '-D', '-uM', '-N1', dev, + process_input=commandp1, + run_as_root=True, + check_exit_code=[0]) + # get end location of 1st partition + p1re = re.compile('^%s-part1.*$' % dev, re.U + re.M) + p1balist = p1re.findall(p1outraw) + p1endraw = p1balist[1] + p1end = int(p1endraw.split()[2]) + commandp2 = ('%d %d 82\n;\n;' % (p1end + 1, swap_mb)) + utils.execute('sfdisk', '-D', '-uM', '-N2', dev, process_input=commandp2, + run_as_root=True, + check_exit_code=[0]) + # avoid "device is busy" + time.sleep(3) def is_block_device(dev): @@ -215,6 +225,11 @@ def deploy(address, port, iqn, lun, image_path, pxe_config_path, login_iscsi(address, port, iqn) try: root_uuid = work_on_disk(dev, root_mb, swap_mb, image_path) + except exception.ProcessExecutionError, err: + # Log output if there was a error + LOG.error("Cmd : %s" % err.cmd) + LOG.error("StdOut : %s" % err.stdout) + LOG.error("StdErr : %s" % err.stderr) finally: logout_iscsi(address, port, iqn) switch_pxe_config(pxe_config_path, root_uuid) |