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);
}
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;
}
Aggregations