Rename inst in _create_image, and pass instance to log msgs.
This renames inst in _create_image to the more consistant name "instance". It also passes the instance through log messages in this method, and removes the instance name from the translatable text for the corresponding log messages. Change-Id: I9a085198d3bea5d073f4297cc57c84dc7fcb0349
This commit is contained in:
parent
54d7fdc0c8
commit
f7e5328e13
1
.mailmap
1
.mailmap
|
@ -39,6 +39,7 @@
|
|||
<masumotok@nttdata.co.jp> <root@openstack2-api>
|
||||
<matt.dietz@rackspace.com> <matthewdietz@Matthew-Dietzs-MacBook-Pro.local>
|
||||
<matt.dietz@rackspace.com> <mdietz@openstack>
|
||||
<mikal@stillhq.com> <michael.still@canonical.com>
|
||||
<mordred@inaugust.com> <mordred@hudson>
|
||||
<naveedm9@gmail.com> <naveed.massjouni@rackspace.com>
|
||||
<rnirmal@gmail.com> <nirmal.ranganathan@rackspace.com>
|
||||
|
|
|
@ -693,8 +693,7 @@ class LibvirtConnection(driver.ComputeDriver):
|
|||
block_device_info=block_device_info)
|
||||
|
||||
domain = self._create_new_domain(xml)
|
||||
LOG.debug(_("instance %s: is running"), instance['name'],
|
||||
instance=instance)
|
||||
LOG.debug(_("instance is running"), instance=instance)
|
||||
self.firewall_driver.apply_instance_filter(instance, network_info)
|
||||
|
||||
def _wait_for_boot():
|
||||
|
@ -704,13 +703,13 @@ class LibvirtConnection(driver.ComputeDriver):
|
|||
try:
|
||||
state = self.get_info(instance_name)['state']
|
||||
except exception.NotFound:
|
||||
msg = _("During reboot, %s disappeared.") % instance_name
|
||||
LOG.error(msg, instance=instance)
|
||||
LOG.error(_("During reboot, instance disappeared."),
|
||||
instance=instance)
|
||||
raise utils.LoopingCallDone
|
||||
|
||||
if state == power_state.RUNNING:
|
||||
msg = _("Instance %s spawned successfully.") % instance_name
|
||||
LOG.info(msg, instance=instance)
|
||||
LOG.info(_("Instance spawned successfully."),
|
||||
instance=instance)
|
||||
raise utils.LoopingCallDone
|
||||
|
||||
timer = utils.LoopingCall(_wait_for_boot)
|
||||
|
@ -900,7 +899,7 @@ class LibvirtConnection(driver.ComputeDriver):
|
|||
libvirt_utils.create_image('raw', target, '%dM' % swap_mb)
|
||||
libvirt_utils.mkfs('swap', target)
|
||||
|
||||
def _create_image(self, context, inst, libvirt_xml, suffix='',
|
||||
def _create_image(self, context, instance, libvirt_xml, suffix='',
|
||||
disk_images=None, network_info=None,
|
||||
block_device_info=None):
|
||||
if not suffix:
|
||||
|
@ -909,13 +908,13 @@ class LibvirtConnection(driver.ComputeDriver):
|
|||
# syntactic nicety
|
||||
def basepath(fname='', suffix=suffix):
|
||||
return os.path.join(FLAGS.instances_path,
|
||||
inst['name'],
|
||||
instance['name'],
|
||||
fname + suffix)
|
||||
|
||||
# ensure directories exist and are writable
|
||||
libvirt_utils.ensure_tree(basepath(suffix=''))
|
||||
|
||||
LOG.info(_('instance %s: Creating image'), inst['name'])
|
||||
LOG.info(_('Creating image'), instance=instance)
|
||||
libvirt_utils.write_to_file(basepath('libvirt.xml'), libvirt_xml)
|
||||
|
||||
if FLAGS.libvirt_type == 'lxc':
|
||||
|
@ -926,9 +925,9 @@ class LibvirtConnection(driver.ComputeDriver):
|
|||
libvirt_utils.write_to_file(basepath('console.log', ''), '', 007)
|
||||
|
||||
if not disk_images:
|
||||
disk_images = {'image_id': inst['image_ref'],
|
||||
'kernel_id': inst['kernel_id'],
|
||||
'ramdisk_id': inst['ramdisk_id']}
|
||||
disk_images = {'image_id': instance['image_ref'],
|
||||
'kernel_id': instance['kernel_id'],
|
||||
'ramdisk_id': instance['ramdisk_id']}
|
||||
|
||||
if disk_images['kernel_id']:
|
||||
fname = disk_images['kernel_id']
|
||||
|
@ -937,8 +936,8 @@ class LibvirtConnection(driver.ComputeDriver):
|
|||
target=basepath('kernel'),
|
||||
fname=fname,
|
||||
image_id=disk_images['kernel_id'],
|
||||
user_id=inst['user_id'],
|
||||
project_id=inst['project_id'])
|
||||
user_id=instance['user_id'],
|
||||
project_id=instance['project_id'])
|
||||
if disk_images['ramdisk_id']:
|
||||
fname = disk_images['ramdisk_id']
|
||||
self._cache_image(fn=libvirt_utils.fetch_image,
|
||||
|
@ -946,19 +945,19 @@ class LibvirtConnection(driver.ComputeDriver):
|
|||
target=basepath('ramdisk'),
|
||||
fname=fname,
|
||||
image_id=disk_images['ramdisk_id'],
|
||||
user_id=inst['user_id'],
|
||||
project_id=inst['project_id'])
|
||||
user_id=instance['user_id'],
|
||||
project_id=instance['project_id'])
|
||||
|
||||
root_fname = hashlib.sha1(str(disk_images['image_id'])).hexdigest()
|
||||
size = inst['root_gb'] * 1024 * 1024 * 1024
|
||||
size = instance['root_gb'] * 1024 * 1024 * 1024
|
||||
|
||||
inst_type_id = inst['instance_type_id']
|
||||
inst_type_id = instance['instance_type_id']
|
||||
inst_type = instance_types.get_instance_type(inst_type_id)
|
||||
if size == 0 or suffix == '.rescue':
|
||||
size = None
|
||||
root_fname += "_sm"
|
||||
else:
|
||||
root_fname += "_%d" % inst['root_gb']
|
||||
root_fname += "_%d" % instance['root_gb']
|
||||
|
||||
if not self._volume_in_mapping(self.default_root_device,
|
||||
block_device_info):
|
||||
|
@ -968,31 +967,31 @@ class LibvirtConnection(driver.ComputeDriver):
|
|||
fname=root_fname,
|
||||
cow=FLAGS.use_cow_images,
|
||||
image_id=disk_images['image_id'],
|
||||
user_id=inst['user_id'],
|
||||
project_id=inst['project_id'],
|
||||
user_id=instance['user_id'],
|
||||
project_id=instance['project_id'],
|
||||
size=size)
|
||||
|
||||
ephemeral_gb = inst['ephemeral_gb']
|
||||
ephemeral_gb = instance['ephemeral_gb']
|
||||
if ephemeral_gb and not self._volume_in_mapping(
|
||||
self.default_ephemeral_device, block_device_info):
|
||||
fn = functools.partial(self._create_ephemeral,
|
||||
fs_label='ephemeral0',
|
||||
os_type=inst.os_type)
|
||||
os_type=instance.os_type)
|
||||
self._cache_image(fn=fn,
|
||||
target=basepath('disk.local'),
|
||||
fname="ephemeral_%s_%s_%s" %
|
||||
("0", ephemeral_gb, inst.os_type),
|
||||
("0", ephemeral_gb, instance.os_type),
|
||||
cow=FLAGS.use_cow_images,
|
||||
ephemeral_size=ephemeral_gb)
|
||||
|
||||
for eph in driver.block_device_info_get_ephemerals(block_device_info):
|
||||
fn = functools.partial(self._create_ephemeral,
|
||||
fs_label='ephemeral%d' % eph['num'],
|
||||
os_type=inst.os_type)
|
||||
os_type=instance.os_type)
|
||||
self._cache_image(fn=fn,
|
||||
target=basepath(_get_eph_disk(eph)),
|
||||
fname="ephemeral_%s_%s_%s" %
|
||||
(eph['num'], eph['size'], inst.os_type),
|
||||
(eph['num'], eph['size'], instance.os_type),
|
||||
cow=FLAGS.use_cow_images,
|
||||
ephemeral_size=eph['size'])
|
||||
|
||||
|
@ -1017,11 +1016,11 @@ class LibvirtConnection(driver.ComputeDriver):
|
|||
# partitioned disk image where the target partition is the first
|
||||
# partition
|
||||
target_partition = None
|
||||
if not inst['kernel_id']:
|
||||
if not instance['kernel_id']:
|
||||
target_partition = "1"
|
||||
|
||||
config_drive_id = inst.get('config_drive_id')
|
||||
config_drive = inst.get('config_drive')
|
||||
config_drive_id = instance.get('config_drive_id')
|
||||
config_drive = instance.get('config_drive')
|
||||
|
||||
if any((FLAGS.libvirt_type == 'lxc', config_drive, config_drive_id)):
|
||||
target_partition = None
|
||||
|
@ -1032,14 +1031,14 @@ class LibvirtConnection(driver.ComputeDriver):
|
|||
target=basepath('disk.config'),
|
||||
fname=fname,
|
||||
image_id=config_drive_id,
|
||||
user_id=inst['user_id'],
|
||||
project_id=inst['project_id'],)
|
||||
user_id=instance['user_id'],
|
||||
project_id=instance['project_id'],)
|
||||
elif config_drive:
|
||||
self._create_local(basepath('disk.config'), 64, unit='M',
|
||||
fs_format='msdos') # 64MB
|
||||
|
||||
if inst['key_data']:
|
||||
key = str(inst['key_data'])
|
||||
if instance['key_data']:
|
||||
key = str(instance['key_data'])
|
||||
else:
|
||||
key = None
|
||||
net = None
|
||||
|
@ -1081,22 +1080,21 @@ class LibvirtConnection(driver.ComputeDriver):
|
|||
searchList=[{'interfaces': nets,
|
||||
'use_ipv6': FLAGS.use_ipv6}]))
|
||||
|
||||
metadata = inst.get('metadata')
|
||||
metadata = instance.get('metadata')
|
||||
if any((key, net, metadata)):
|
||||
inst_name = inst['name']
|
||||
instance_name = instance['name']
|
||||
|
||||
if config_drive: # Should be True or None by now.
|
||||
injection_path = basepath('disk.config')
|
||||
img_id = 'config-drive'
|
||||
else:
|
||||
injection_path = basepath('disk')
|
||||
img_id = inst.image_ref
|
||||
img_id = instance.image_ref
|
||||
|
||||
for injection in ('metadata', 'key', 'net'):
|
||||
if locals()[injection]:
|
||||
LOG.info(_('instance %(inst_name)s: injecting '
|
||||
'%(injection)s into image %(img_id)s'
|
||||
% locals()))
|
||||
LOG.info(_('Injecting %(injection)s into image %(img_id)s'
|
||||
% locals()), instance=instance)
|
||||
try:
|
||||
disk.inject_data(injection_path, key, net, metadata,
|
||||
partition=target_partition,
|
||||
|
@ -1104,8 +1102,9 @@ class LibvirtConnection(driver.ComputeDriver):
|
|||
|
||||
except Exception as e:
|
||||
# This could be a windows image, or a vmdk format disk
|
||||
LOG.warn(_('instance %(inst_name)s: ignoring error injecting'
|
||||
' data into image %(img_id)s (%(e)s)') % locals())
|
||||
LOG.warn(_('Ignoring error injecting data into image '
|
||||
'%(img_id)s (%(e)s)') % locals(),
|
||||
instance=instance)
|
||||
|
||||
if FLAGS.libvirt_type == 'lxc':
|
||||
self.container = disk.setup_container(basepath('disk'),
|
||||
|
@ -1115,9 +1114,9 @@ class LibvirtConnection(driver.ComputeDriver):
|
|||
if FLAGS.libvirt_type == 'uml':
|
||||
libvirt_utils.chown(basepath('disk'), 'root')
|
||||
|
||||
files_to_inject = inst.get('injected_files')
|
||||
files_to_inject = instance.get('injected_files')
|
||||
if files_to_inject:
|
||||
self._inject_files(inst, files_to_inject)
|
||||
self._inject_files(instance, files_to_inject)
|
||||
|
||||
@staticmethod
|
||||
def _volume_in_mapping(mount_device, block_device_info):
|
||||
|
|
Loading…
Reference in New Issue