def build_virtual_machine(self, instance, instance_name, image_info, dc_info, datastore, network_info, pg_vlan_instance_map): node_mo_id = vm_util.get_mo_id_from_instance(instance) res_pool_ref = vm_util.get_res_pool_ref(self._session, self._cluster, node_mo_id) vif_infos = vmwarevif.get_vif_info(self._session, self._cluster, utils.is_neutron(), image_info.vif_model, network_info, pg_vlan_instance_map) allocations = self._get_cpu_allocations(instance.instance_type_id) # Get the create vm config spec client_factory = self._session._get_vim().client.factory config_spec = vm_util.get_vm_create_spec(client_factory, instance, instance_name, datastore.name, vif_infos, image_info.os_type, allocations=allocations) # Create the VM vm_ref = vm_util.create_vm(self._session, instance, dc_info.vmFolder, config_spec, res_pool_ref) return vm_ref
def check_can_live_migrate_source(self, context, instance, dest_check_data, block_device_info=None): cluster_name = dest_check_data.cluster_name cluster_ref = vm_util.get_cluster_ref_by_name(self._session, cluster_name) if cluster_ref is None: msg = (_("Cannot find destination cluster %s for live migration") % cluster_name) raise exception.MigrationPreCheckError(reason=msg) res_pool_ref = vm_util.get_res_pool_ref(self._session, cluster_ref) if res_pool_ref is None: msg = _("Cannot find destination resource pool for live migration") raise exception.MigrationPreCheckError(reason=msg) return dest_check_data
def check_can_live_migrate_source(self, context, instance, dest_check_data, block_device_info=None): cluster_name = dest_check_data.cluster_name cluster_ref = vm_util.get_cluster_ref_by_name(self._session, cluster_name) if cluster_ref is None: msg = (_("Cannot find destination cluster %s for live migration") % cluster_name) raise exception.MigrationPreCheckError(reason=msg) res_pool_ref = vm_util.get_res_pool_ref(self._session, cluster_ref) if res_pool_ref is None: msg = _("Cannot find destination resource pool for live migration") raise exception.MigrationPreCheckError(reason=msg) return dest_check_data