'Injects data in a disk image
Helper used for injecting data in a disk image file system.
:param disk: The disk we\'re injecting into (an Image object)
:param instance: The instance we\'re injecting into
:param injection_info: Injection info'

def _inject_data(self, disk, instance, injection_info):

    LOG.debug('Checking    root    disk    injection    %(info)s', info=str(injection_info), instance=instance)
    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
    else:
        admin_pass = injection_info.admin_pass
    net = netutils.get_injected_network_template(injection_info.network_info, libvirt_virt_type=CONF.libvirt.virt_type)
    metadata = instance.get('metadata')
    if any((key, net, metadata, admin_pass, injection_info.files)):
        LOG.debug('Injecting    %(info)s', info=str(injection_info), instance=instance)
        img_id = instance.image_ref
        try:
            disk_api.inject_data(disk.get_model(self._conn), key, net, metadata, admin_pass, injection_info.files, partition=target_partition, mandatory=('files',))
        except Exception as e:
            with excutils.save_and_reraise_exception():
                LOG.error('Error    injecting    data    into    image    %(img_id)s    (%(e)s)', {'img_id': img_id, 'e': e}, instance=instance)
