def _inject_data(self, instance, network_info, admin_pass, files, suffix):
    'Injects data in a disk image\n\n        Helper used for injecting data in a disk image file system.\n\n        Keyword arguments:\n          instance -- a dict that refers instance specifications\n          network_info -- a dict that refers network speficications\n          admin_pass -- a string used to set an admin password\n          files -- a list of files needs to be injected\n          suffix -- a string used as an image name suffix\n        '
    target_partition = None
    if (not instance['kernel_id']):
        target_partition = CONF.libvirt.inject_partition
        if (target_partition == 0):
            target_partition = None
    if (CONF.libvirt.virt_type == 'lxc'):
        target_partition = None
    if (CONF.libvirt.inject_key and instance.get('key_data')):
        key = str(instance['key_data'])
    else:
        key = None
    if (not CONF.libvirt.inject_password):
        admin_pass = None
    net = netutils.get_injected_network_template(network_info, libvirt_virt_type=CONF.libvirt.virt_type)
    metadata = instance.get('metadata')
    image_type = CONF.libvirt.images_type
    if any((key, net, metadata, admin_pass, files)):
        injection_image = self.image_backend.image(instance, ('disk' + suffix), image_type)
        img_id = instance['image_ref']
        if (not injection_image.check_image_exists()):
            LOG.warn(_LW('Image %s not found on disk storage. Continue without injecting data'), injection_image.path, instance=instance)
            return
        try:
            disk.inject_data(injection_image.path, key, net, metadata, admin_pass, files, partition=target_partition, use_cow=CONF.use_cow_images, mandatory=('files',))
        except Exception as e:
            with excutils.save_and_reraise_exception():
                LOG.error(_LE('Error injecting data into image %(img_id)s (%(e)s)'), {'img_id': img_id, 'e': e}, instance=instance)
Injects data in a disk image

Helper used for injecting data in a disk image file system.

Keyword arguments:
  instance -- a dict that refers instance specifications
  network_info -- a dict that refers network speficications
  admin_pass -- a string used to set an admin password
  files -- a list of files needs to be injected
  suffix -- a string used as an image name suffix
def _inject_data(self, instance, network_info, admin_pass, files, suffix):
    'Injects data in a disk image\n\n        Helper used for injecting data in a disk image file system.\n\n        Keyword arguments:\n          instance -- a dict that refers instance specifications\n          network_info -- a dict that refers network speficications\n          admin_pass -- a string used to set an admin password\n          files -- a list of files needs to be injected\n          suffix -- a string used as an image name suffix\n        '
    target_partition = None
    if (not instance['kernel_id']):
        target_partition = CONF.libvirt.inject_partition
        if (target_partition == 0):
            target_partition = None
    if (CONF.libvirt.virt_type == 'lxc'):
        target_partition = None
    if (CONF.libvirt.inject_key and instance.get('key_data')):
        key = str(instance['key_data'])
    else:
        key = None
    if (not CONF.libvirt.inject_password):
        admin_pass = None
    net = netutils.get_injected_network_template(network_info, libvirt_virt_type=CONF.libvirt.virt_type)
    metadata = instance.get('metadata')
    image_type = CONF.libvirt.images_type
    if any((key, net, metadata, admin_pass, files)):
        injection_image = self.image_backend.image(instance, ('disk' + suffix), image_type)
        img_id = instance['image_ref']
        if (not injection_image.check_image_exists()):
            LOG.warn(_LW('Image %s not found on disk storage. Continue without injecting data'), injection_image.path, instance=instance)
            return
        try:
            disk.inject_data(injection_image.path, key, net, metadata, admin_pass, files, partition=target_partition, use_cow=CONF.use_cow_images, mandatory=('files',))
        except Exception as e:
            with excutils.save_and_reraise_exception():
                LOG.error(_LE('Error injecting data into image %(img_id)s (%(e)s)'), {'img_id': img_id, 'e': e}, instance=instance)