Merge "Switch nova-baremetal-deploy-helper to use sfdisk."
This commit is contained in:
@@ -45,6 +45,7 @@ from wsgiref import simple_server
|
|||||||
|
|
||||||
from nova import config
|
from nova import config
|
||||||
from nova import context as nova_context
|
from nova import context as nova_context
|
||||||
|
from nova import exception
|
||||||
from nova.openstack.common import log as logging
|
from nova.openstack.common import log as logging
|
||||||
from nova import utils
|
from nova import utils
|
||||||
from nova.virt.baremetal import baremetal_states
|
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):
|
def make_partitions(dev, root_mb, swap_mb):
|
||||||
"""Create partitions for root and swap on a disk device."""
|
"""Create partitions for root and swap on a disk device."""
|
||||||
commands = ['o,w',
|
stdin_command = ('0 0;\n0 0;\n0 0;\n0 0;\n')
|
||||||
'n,p,1,,+%dM,t,1,83,w' % root_mb,
|
utils.execute('sfdisk', '-D', '-uM', dev, process_input=stdin_command,
|
||||||
'n,p,2,,+%dM,t,2,82,w' % swap_mb,
|
run_as_root=True,
|
||||||
]
|
check_exit_code=[0])
|
||||||
for command in commands:
|
# create new partitions
|
||||||
command = command.replace(',', '\n')
|
commandp1 = '- %d 83;\n;\n;\n;' % root_mb
|
||||||
utils.execute('fdisk', dev,
|
p1outraw, err = utils.execute('sfdisk', '-D', '-uM', '-N1', dev,
|
||||||
process_input=command,
|
process_input=commandp1,
|
||||||
run_as_root=True,
|
run_as_root=True,
|
||||||
check_exit_code=[0])
|
check_exit_code=[0])
|
||||||
# avoid "device is busy"
|
# get end location of 1st partition
|
||||||
time.sleep(3)
|
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):
|
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)
|
login_iscsi(address, port, iqn)
|
||||||
try:
|
try:
|
||||||
root_uuid = work_on_disk(dev, root_mb, swap_mb, image_path)
|
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:
|
finally:
|
||||||
logout_iscsi(address, port, iqn)
|
logout_iscsi(address, port, iqn)
|
||||||
switch_pxe_config(pxe_config_path, root_uuid)
|
switch_pxe_config(pxe_config_path, root_uuid)
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
[Filters]
|
[Filters]
|
||||||
# nova-baremetal-deploy-helper
|
# nova-baremetal-deploy-helper
|
||||||
iscsiadm: CommandFilter, /sbin/iscsiadm, root
|
iscsiadm: CommandFilter, /sbin/iscsiadm, root
|
||||||
fdisk: CommandFilter, /sbin/fdisk, root
|
sfdisk: CommandFilter, /sbin/sfdisk, root
|
||||||
dd: CommandFilter, /bin/dd, root
|
dd: CommandFilter, /bin/dd, root
|
||||||
mkswap: CommandFilter, /sbin/mkswap, root
|
mkswap: CommandFilter, /sbin/mkswap, root
|
||||||
blkid: CommandFilter, /sbin/blkid, root
|
blkid: CommandFilter, /sbin/blkid, root
|
||||||
|
Reference in New Issue
Block a user