'Do required network setup and create domain.'

def _create_domain_and_network(self, context, xml, instance, network_info, block_device_info=None, power_on=True, reboot=False, vifs_already_plugged=False, post_xml_callback=None, destroy_disks_on_failure=False):

    block_device_mapping = driver.block_device_info_get_mapping(block_device_info)
    for vol in block_device_mapping:
        connection_info = vol['connection_info']
        if ((not reboot) and ('data' in connection_info) and ('volume_id' in connection_info['data'])):
            volume_id = connection_info['data']['volume_id']
            encryption = encryptors.get_encryption_metadata(context, self._volume_api, volume_id, connection_info)
            if encryption:
                encryptor = self._get_volume_encryptor(connection_info, encryption)
                encryptor.attach_volume(context, **encryption)
    timeout = CONF.vif_plugging_timeout
    if (self._conn_supports_start_paused and utils.is_neutron() and (not vifs_already_plugged) and power_on and timeout):
        events = self._get_neutron_events(network_info)
    else:
        events = []
    pause = bool(events)
    guest = None
    try:
        with self.virtapi.wait_for_instance_event(instance, events, deadline=timeout, error_callback=self._neutron_failed_callback):
            self.plug_vifs(instance, network_info)
            self.firewall_driver.setup_basic_filtering(instance, network_info)
            self.firewall_driver.prepare_instance_filter(instance, network_info)
            with self._lxc_disk_handler(instance, instance.image_meta, block_device_info):
                guest = self._create_domain(xml, pause=pause, power_on=power_on, post_xml_callback=post_xml_callback)
            self.firewall_driver.apply_instance_filter(instance, network_info)
    except exception.VirtualInterfaceCreateException:
        with excutils.save_and_reraise_exception():
            self._cleanup_failed_start(context, instance, network_info, block_device_info, guest, destroy_disks_on_failure)
    except eventlet.timeout.Timeout:
        LOG.warning('Timeout    waiting    for    vif    plugging    callback    for    instance    with    vm_state    %(vm_state)s    and    task_state    %(task_state)s.', {'vm_state': instance.vm_state, 'task_state': instance.task_state}, instance=instance)
        if CONF.vif_plugging_is_fatal:
            self._cleanup_failed_start(context, instance, network_info, block_device_info, guest, destroy_disks_on_failure)
            raise exception.VirtualInterfaceCreateException()
    except Exception:
        LOG.error('Failed    to    start    libvirt    guest', instance=instance)
        with excutils.save_and_reraise_exception():
            self._cleanup_failed_start(context, instance, network_info, block_device_info, guest, destroy_disks_on_failure)
    if pause:
        guest.resume()
    return guest
