Merge "separate libvirt injection and configdrive config variables"
This commit is contained in:
commit
08499b9c2d
@ -1501,28 +1501,6 @@ class LibvirtDriver(driver.ComputeDriver):
|
|||||||
size=size,
|
size=size,
|
||||||
swap_mb=swap_mb)
|
swap_mb=swap_mb)
|
||||||
|
|
||||||
# target partition for file injection
|
|
||||||
target_partition = None
|
|
||||||
if not instance['kernel_id']:
|
|
||||||
target_partition = CONF.libvirt_inject_partition
|
|
||||||
if target_partition == 0:
|
|
||||||
target_partition = None
|
|
||||||
if CONF.libvirt_type == 'lxc':
|
|
||||||
target_partition = None
|
|
||||||
|
|
||||||
if CONF.libvirt_inject_key and instance['key_data']:
|
|
||||||
key = str(instance['key_data'])
|
|
||||||
else:
|
|
||||||
key = None
|
|
||||||
|
|
||||||
# File injection
|
|
||||||
metadata = instance.get('metadata')
|
|
||||||
|
|
||||||
if not CONF.libvirt_inject_password:
|
|
||||||
admin_pass = None
|
|
||||||
|
|
||||||
net = netutils.get_injected_network_template(network_info)
|
|
||||||
|
|
||||||
# Config drive
|
# Config drive
|
||||||
if configdrive.required_by(instance):
|
if configdrive.required_by(instance):
|
||||||
LOG.info(_('Using config drive'), instance=instance)
|
LOG.info(_('Using config drive'), instance=instance)
|
||||||
@ -1544,26 +1522,48 @@ class LibvirtDriver(driver.ComputeDriver):
|
|||||||
e, instance=instance)
|
e, instance=instance)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
elif any((key, net, metadata, admin_pass, files)):
|
# File injection
|
||||||
# If we're not using config_drive, inject into root fs
|
else:
|
||||||
injection_path = image('disk').path
|
target_partition = None
|
||||||
img_id = instance['image_ref']
|
if not instance['kernel_id']:
|
||||||
|
target_partition = CONF.libvirt_inject_partition
|
||||||
|
if target_partition == 0:
|
||||||
|
target_partition = None
|
||||||
|
if CONF.libvirt_type == 'lxc':
|
||||||
|
target_partition = None
|
||||||
|
|
||||||
for inject in ('key', 'net', 'metadata', 'admin_pass', 'files'):
|
if CONF.libvirt_inject_key and instance['key_data']:
|
||||||
if locals()[inject]:
|
key = str(instance['key_data'])
|
||||||
LOG.info(_('Injecting %(inject)s into image'
|
else:
|
||||||
' %(img_id)s'), locals(), instance=instance)
|
key = None
|
||||||
try:
|
|
||||||
disk.inject_data(injection_path,
|
net = netutils.get_injected_network_template(network_info)
|
||||||
key, net, metadata, admin_pass, files,
|
|
||||||
partition=target_partition,
|
metadata = instance.get('metadata')
|
||||||
use_cow=CONF.use_cow_images,
|
|
||||||
mandatory=('files',))
|
if not CONF.libvirt_inject_password:
|
||||||
except Exception as e:
|
admin_pass = None
|
||||||
LOG.error(_('Error injecting data into image '
|
|
||||||
'%(img_id)s (%(e)s)') % locals(),
|
if any((key, net, metadata, admin_pass, files)):
|
||||||
instance=instance)
|
# If we're not using config_drive, inject into root fs
|
||||||
raise
|
injection_path = image('disk').path
|
||||||
|
img_id = instance['image_ref']
|
||||||
|
|
||||||
|
for inj in ('key', 'net', 'metadata', 'admin_pass', 'files'):
|
||||||
|
if locals()[inj]:
|
||||||
|
LOG.info(_('Injecting %(inj)s into image '
|
||||||
|
'%(img_id)s'), locals(), instance=instance)
|
||||||
|
try:
|
||||||
|
disk.inject_data(injection_path,
|
||||||
|
key, net, metadata, admin_pass, files,
|
||||||
|
partition=target_partition,
|
||||||
|
use_cow=CONF.use_cow_images,
|
||||||
|
mandatory=('files',))
|
||||||
|
except Exception as e:
|
||||||
|
LOG.error(_('Error injecting data into image '
|
||||||
|
'%(img_id)s (%(e)s)') % locals(),
|
||||||
|
instance=instance)
|
||||||
|
raise
|
||||||
|
|
||||||
if CONF.libvirt_type == 'uml':
|
if CONF.libvirt_type == 'uml':
|
||||||
libvirt_utils.chown(image('disk').path, 'root')
|
libvirt_utils.chown(image('disk').path, 'root')
|
||||||
|
Loading…
Reference in New Issue
Block a user