Search in sources :

Example 1 with VirtualMachineConfigSummary

use of com.vmware.vim25.VirtualMachineConfigSummary in project cloudstack by apache.

the class VMwareGuru method getTemplatePoolId.

/**
 * Get template pool ID
 */
private Long getTemplatePoolId(VirtualMachineMO template) throws Exception {
    VirtualMachineConfigSummary configSummary = template.getConfigSummary();
    String vmPathName = configSummary.getVmPathName();
    String[] pathParts = vmPathName.split(" ");
    String dataStoreUuid = pathParts[0].replace("[", "").replace("]", "");
    return getPoolIdFromDatastoreUuid(dataStoreUuid);
}
Also used : VirtualMachineConfigSummary(com.vmware.vim25.VirtualMachineConfigSummary)

Example 2 with VirtualMachineConfigSummary

use of com.vmware.vim25.VirtualMachineConfigSummary in project cloudstack by apache.

the class VMwareGuru method importVirtualMachineFromBackup.

@Override
public VirtualMachine importVirtualMachineFromBackup(long zoneId, long domainId, long accountId, long userId, String vmInternalName, Backup backup) throws Exception {
    s_logger.debug(String.format("Trying to import VM [vmInternalName: %s] from Backup [%s].", vmInternalName, ReflectionToStringBuilderUtils.reflectOnlySelectedFields(backup, "id", "uuid", "vmId", "externalId", "backupType")));
    DatacenterMO dcMo = getDatacenterMO(zoneId);
    VirtualMachineMO vmToImport = dcMo.findVm(vmInternalName);
    if (vmToImport == null) {
        throw new CloudRuntimeException("Error finding VM: " + vmInternalName);
    }
    VirtualMachineConfigSummary configSummary = vmToImport.getConfigSummary();
    VirtualMachineRuntimeInfo runtimeInfo = vmToImport.getRuntimeInfo();
    List<VirtualDisk> virtualDisks = vmToImport.getVirtualDisks();
    String[] vmNetworkNames = vmToImport.getNetworks();
    VirtualDevice[] nicDevices = vmToImport.getNicDevices();
    Map<VirtualDisk, VolumeVO> disksMapping = getDisksMapping(backup, virtualDisks);
    Map<String, NetworkVO> networksMapping = getNetworksMapping(vmNetworkNames, accountId, zoneId, domainId);
    long guestOsId = getImportingVMGuestOs(configSummary);
    long serviceOfferingId = getImportingVMServiceOffering(configSummary, runtimeInfo);
    long templateId = getImportingVMTemplate(virtualDisks, dcMo, vmInternalName, guestOsId, accountId, disksMapping, backup);
    VMInstanceVO vm = getVM(vmInternalName, templateId, guestOsId, serviceOfferingId, zoneId, accountId, userId, domainId);
    syncVMVolumes(vm, virtualDisks, disksMapping, vmToImport, backup);
    syncVMNics(nicDevices, dcMo, networksMapping, vm);
    return vm;
}
Also used : PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) NetworkVO(com.cloud.network.dao.NetworkVO) VirtualMachineRuntimeInfo(com.vmware.vim25.VirtualMachineRuntimeInfo) VirtualMachineMO(com.cloud.hypervisor.vmware.mo.VirtualMachineMO) VirtualDevice(com.vmware.vim25.VirtualDevice) VMInstanceVO(com.cloud.vm.VMInstanceVO) VirtualDisk(com.vmware.vim25.VirtualDisk) VirtualMachineConfigSummary(com.vmware.vim25.VirtualMachineConfigSummary) VolumeVO(com.cloud.storage.VolumeVO) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) DatacenterMO(com.cloud.hypervisor.vmware.mo.DatacenterMO)

Aggregations

VirtualMachineConfigSummary (com.vmware.vim25.VirtualMachineConfigSummary)2 DatacenterMO (com.cloud.hypervisor.vmware.mo.DatacenterMO)1 VirtualMachineMO (com.cloud.hypervisor.vmware.mo.VirtualMachineMO)1 NetworkVO (com.cloud.network.dao.NetworkVO)1 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)1 VolumeVO (com.cloud.storage.VolumeVO)1 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)1 VMInstanceVO (com.cloud.vm.VMInstanceVO)1 VirtualDevice (com.vmware.vim25.VirtualDevice)1 VirtualDisk (com.vmware.vim25.VirtualDisk)1 VirtualMachineRuntimeInfo (com.vmware.vim25.VirtualMachineRuntimeInfo)1