Search in sources :

Example 1 with PbmProfileManagerMO

use of com.cloud.hypervisor.vmware.mo.PbmProfileManagerMO in project cloudstack by apache.

the class VmwareResource method execute.

protected StartAnswer execute(StartCommand cmd) {
    VirtualMachineTO vmSpec = cmd.getVirtualMachine();
    boolean vmAlreadyExistsInVcenter = false;
    String existingVmName = null;
    VirtualMachineFileInfo existingVmFileInfo = null;
    VirtualMachineFileLayoutEx existingVmFileLayout = null;
    List<DatastoreMO> existingDatastores = new ArrayList<DatastoreMO>();
    String diskStoragePolicyId = null;
    String vmStoragePolicyId = null;
    VirtualMachineDefinedProfileSpec diskProfileSpec = null;
    VirtualMachineDefinedProfileSpec vmProfileSpec = null;
    DeployAsIsInfoTO deployAsIsInfo = vmSpec.getDeployAsIsInfo();
    boolean deployAsIs = deployAsIsInfo != null;
    Pair<String, String> names = composeVmNames(vmSpec);
    String vmInternalCSName = names.first();
    String vmNameOnVcenter = names.second();
    DiskTO rootDiskTO = null;
    String bootMode = getBootModeFromVmSpec(vmSpec, deployAsIs);
    Pair<String, String> controllerInfo = getControllerInfoFromVmSpec(vmSpec);
    Boolean systemVm = vmSpec.getType().isUsedBySystem();
    // Thus, vmInternalCSName always holds i-x-y, the cloudstack generated internal VM name.
    VmwareContext context = getServiceContext();
    DatacenterMO dcMo = null;
    try {
        VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
        VmwareHypervisorHost hyperHost = getHyperHost(context);
        dcMo = new DatacenterMO(hyperHost.getContext(), hyperHost.getHyperHostDatacenter());
        // Validate VM name is unique in Datacenter
        VirtualMachineMO vmInVcenter = dcMo.checkIfVmAlreadyExistsInVcenter(vmNameOnVcenter, vmInternalCSName);
        if (vmInVcenter != null) {
            vmAlreadyExistsInVcenter = true;
            String msg = "VM with name: " + vmNameOnVcenter + " already exists in vCenter.";
            s_logger.error(msg);
            throw new Exception(msg);
        }
        DiskTO[] specDisks = vmSpec.getDisks();
        String guestOsId = getGuestOsIdFromVmSpec(vmSpec, deployAsIs);
        DiskTO[] disks = validateDisks(vmSpec.getDisks());
        assert (disks.length > 0);
        NicTO[] nics = vmSpec.getNics();
        HashMap<String, Pair<ManagedObjectReference, DatastoreMO>> dataStoresDetails = inferDatastoreDetailsFromDiskInfo(hyperHost, context, disks, cmd);
        if ((dataStoresDetails == null) || (dataStoresDetails.isEmpty())) {
            String msg = "Unable to locate datastore details of the volumes to be attached";
            s_logger.error(msg);
            throw new Exception(msg);
        }
        VirtualMachineDiskInfoBuilder diskInfoBuilder = null;
        VirtualDevice[] nicDevices = null;
        VirtualMachineMO vmMo = hyperHost.findVmOnHyperHost(vmInternalCSName);
        DiskControllerType systemVmScsiControllerType = DiskControllerType.lsilogic;
        int firstScsiControllerBusNum = 0;
        int numScsiControllerForSystemVm = 1;
        boolean hasSnapshot = false;
        List<Pair<Integer, ManagedObjectReference>> diskDatastores = null;
        if (vmMo != null) {
            s_logger.info("VM " + vmInternalCSName + " already exists, tear down devices for reconfiguration");
            if (getVmPowerState(vmMo) != PowerState.PowerOff)
                vmMo.safePowerOff(_shutdownWaitMs);
            // retrieve disk information before we tear down
            diskDatastores = vmMo.getAllDiskDatastores();
            diskInfoBuilder = vmMo.getDiskInfoBuilder();
            hasSnapshot = vmMo.hasSnapshot();
            nicDevices = vmMo.getNicDevices();
            tearDownVmDevices(vmMo, hasSnapshot, deployAsIs);
            ensureDiskControllersInternal(vmMo, systemVm, controllerInfo, systemVmScsiControllerType, numScsiControllerForSystemVm, firstScsiControllerBusNum, deployAsIs);
        } else {
            ManagedObjectReference morDc = hyperHost.getHyperHostDatacenter();
            assert (morDc != null);
            vmMo = hyperHost.findVmOnPeerHyperHost(vmInternalCSName);
            if (vmMo != null) {
                if (s_logger.isInfoEnabled()) {
                    s_logger.info("Found vm " + vmInternalCSName + " at other host, relocate to " + hyperHost.getHyperHostName());
                }
                takeVmFromOtherHyperHost(hyperHost, vmInternalCSName);
                if (getVmPowerState(vmMo) != PowerState.PowerOff)
                    vmMo.safePowerOff(_shutdownWaitMs);
                diskInfoBuilder = vmMo.getDiskInfoBuilder();
                hasSnapshot = vmMo.hasSnapshot();
                diskDatastores = vmMo.getAllDiskDatastores();
                tearDownVmDevices(vmMo, hasSnapshot, deployAsIs);
                ensureDiskControllersInternal(vmMo, systemVm, controllerInfo, systemVmScsiControllerType, numScsiControllerForSystemVm, firstScsiControllerBusNum, deployAsIs);
            } else {
                // If a VM with the same name is found in a different cluster in the DC, unregister the old VM and configure a new VM (cold-migration).
                VirtualMachineMO existingVmInDc = dcMo.findVm(vmInternalCSName);
                if (existingVmInDc != null) {
                    s_logger.debug("Found VM: " + vmInternalCSName + " on a host in a different cluster. Unregistering the exisitng VM.");
                    existingVmName = existingVmInDc.getName();
                    existingVmFileInfo = existingVmInDc.getFileInfo();
                    existingVmFileLayout = existingVmInDc.getFileLayout();
                    existingDatastores = existingVmInDc.getAllDatastores();
                    existingVmInDc.unregisterVm();
                }
                if (deployAsIs) {
                    vmMo = hyperHost.findVmOnHyperHost(vmInternalCSName);
                    if (vmMo == null) {
                        s_logger.info("Cloned deploy-as-is VM " + vmInternalCSName + " is not in this host, relocating it");
                        vmMo = takeVmFromOtherHyperHost(hyperHost, vmInternalCSName);
                    }
                } else {
                    DiskTO rootDisk = null;
                    for (DiskTO vol : disks) {
                        if (vol.getType() == Volume.Type.ROOT) {
                            rootDisk = vol;
                        }
                    }
                    Pair<ManagedObjectReference, DatastoreMO> rootDiskDataStoreDetails = getDatastoreThatDiskIsOn(dataStoresDetails, rootDisk);
                    assert (vmSpec.getMinSpeed() != null) && (rootDiskDataStoreDetails != null);
                    DatastoreMO dsRootVolumeIsOn = rootDiskDataStoreDetails.second();
                    if (dsRootVolumeIsOn == null) {
                        String msg = "Unable to locate datastore details of root volume";
                        s_logger.error(msg);
                        throw new Exception(msg);
                    }
                    if (rootDisk.getDetails().get(DiskTO.PROTOCOL_TYPE) != null && rootDisk.getDetails().get(DiskTO.PROTOCOL_TYPE).equalsIgnoreCase(Storage.StoragePoolType.DatastoreCluster.toString())) {
                        if (diskInfoBuilder != null) {
                            DatastoreMO diskDatastoreMofromVM = getDataStoreWhereDiskExists(hyperHost, context, diskInfoBuilder, rootDisk, diskDatastores);
                            if (diskDatastoreMofromVM != null) {
                                String actualPoolUuid = diskDatastoreMofromVM.getCustomFieldValue(CustomFieldConstants.CLOUD_UUID);
                                if (!actualPoolUuid.equalsIgnoreCase(rootDisk.getData().getDataStore().getUuid())) {
                                    dsRootVolumeIsOn = diskDatastoreMofromVM;
                                }
                            }
                        }
                    }
                    boolean vmFolderExists = dsRootVolumeIsOn.folderExists(String.format("[%s]", dsRootVolumeIsOn.getName()), vmNameOnVcenter);
                    String vmxFileFullPath = dsRootVolumeIsOn.searchFileInSubFolders(vmNameOnVcenter + ".vmx", false, VmwareManager.s_vmwareSearchExcludeFolder.value());
                    if (vmFolderExists && vmxFileFullPath != null) {
                        // VM can be registered only if .vmx is present.
                        registerVm(vmNameOnVcenter, dsRootVolumeIsOn);
                        vmMo = hyperHost.findVmOnHyperHost(vmInternalCSName);
                        if (vmMo != null) {
                            if (s_logger.isDebugEnabled()) {
                                s_logger.debug("Found registered vm " + vmInternalCSName + " at host " + hyperHost.getHyperHostName());
                            }
                        }
                        tearDownVm(vmMo);
                    } else if (!hyperHost.createBlankVm(vmNameOnVcenter, vmInternalCSName, vmSpec.getCpus(), vmSpec.getMaxSpeed().intValue(), getReservedCpuMHZ(vmSpec), vmSpec.getLimitCpuUse(), (int) (vmSpec.getMaxRam() / ResourceType.bytesToMiB), getReservedMemoryMb(vmSpec), guestOsId, rootDiskDataStoreDetails.first(), false, controllerInfo, systemVm)) {
                        throw new Exception("Failed to create VM. vmName: " + vmInternalCSName);
                    }
                }
            }
            vmMo = hyperHost.findVmOnHyperHost(vmInternalCSName);
            if (vmMo == null) {
                throw new Exception("Failed to find the newly create or relocated VM. vmName: " + vmInternalCSName);
            }
        }
        if (deployAsIs) {
            s_logger.info("Mapping VM disks to spec disks and tearing down datadisks (if any)");
            mapSpecDisksToClonedDisksAndTearDownDatadisks(vmMo, vmInternalCSName, specDisks);
        }
        int disksChanges = getDisksChangesNumberFromDisksSpec(disks, deployAsIs);
        int totalChangeDevices = disksChanges + nics.length;
        if (deployAsIsInfo != null && deployAsIsInfo.getProperties() != null) {
            totalChangeDevices++;
        }
        DiskTO volIso = null;
        if (vmSpec.getType() != VirtualMachine.Type.User) {
            // system VM needs a patch ISO
            totalChangeDevices++;
        } else {
            volIso = getIsoDiskTO(disks);
            if (volIso == null && !deployAsIs) {
                totalChangeDevices++;
            }
        }
        VirtualMachineConfigSpec vmConfigSpec = new VirtualMachineConfigSpec();
        int i = 0;
        int ideUnitNumber = !deployAsIs ? 0 : vmMo.getNextIDEDeviceNumber();
        int scsiUnitNumber = !deployAsIs ? 0 : vmMo.getNextScsiDiskDeviceNumber();
        int ideControllerKey = vmMo.getIDEDeviceControllerKey();
        int scsiControllerKey = vmMo.getScsiDeviceControllerKeyNoException();
        VirtualDeviceConfigSpec[] deviceConfigSpecArray = new VirtualDeviceConfigSpec[totalChangeDevices];
        DiskTO[] sortedDisks = sortVolumesByDeviceId(disks);
        VmwareHelper.setBasicVmConfig(vmConfigSpec, vmSpec.getCpus(), vmSpec.getMaxSpeed(), getReservedCpuMHZ(vmSpec), (int) (vmSpec.getMaxRam() / (1024 * 1024)), getReservedMemoryMb(vmSpec), guestOsId, vmSpec.getLimitCpuUse(), deployAsIs);
        // Check for multi-cores per socket settings
        int numCoresPerSocket = 1;
        String coresPerSocket = vmSpec.getDetails().get(VmDetailConstants.CPU_CORE_PER_SOCKET);
        if (coresPerSocket != null) {
            String apiVersion = HypervisorHostHelper.getVcenterApiVersion(vmMo.getContext());
            // Property 'numCoresPerSocket' is supported since vSphere API 5.0
            if (apiVersion.compareTo("5.0") >= 0) {
                numCoresPerSocket = NumbersUtil.parseInt(coresPerSocket, 1);
                vmConfigSpec.setNumCoresPerSocket(numCoresPerSocket);
            }
        }
        // Check for hotadd settings
        vmConfigSpec.setMemoryHotAddEnabled(vmMo.isMemoryHotAddSupported(guestOsId) && vmSpec.isEnableDynamicallyScaleVm());
        String hostApiVersion = ((HostMO) hyperHost).getHostAboutInfo().getApiVersion();
        if (numCoresPerSocket > 1 && hostApiVersion.compareTo("5.0") < 0) {
            s_logger.warn("Dynamic scaling of CPU is not supported for Virtual Machines with multi-core vCPUs in case of ESXi hosts 4.1 and prior. Hence CpuHotAdd will not be" + " enabled for Virtual Machine: " + vmInternalCSName);
            vmConfigSpec.setCpuHotAddEnabled(false);
        } else {
            vmConfigSpec.setCpuHotAddEnabled(vmMo.isCpuHotAddSupported(guestOsId) && vmSpec.isEnableDynamicallyScaleVm());
        }
        if (!vmMo.isMemoryHotAddSupported(guestOsId) && vmSpec.isEnableDynamicallyScaleVm()) {
            s_logger.warn("hotadd of memory is not supported, dynamic scaling feature can not be applied to vm: " + vmInternalCSName);
        }
        if (!vmMo.isCpuHotAddSupported(guestOsId) && vmSpec.isEnableDynamicallyScaleVm()) {
            s_logger.warn("hotadd of cpu is not supported, dynamic scaling feature can not be applied to vm: " + vmInternalCSName);
        }
        configNestedHVSupport(vmMo, vmSpec, vmConfigSpec);
        // prepare systemvm patch ISO
        if (vmSpec.getType() != VirtualMachine.Type.User) {
            // attach ISO (for patching of system VM)
            Pair<String, Long> secStoreUrlAndId = mgr.getSecondaryStorageStoreUrlAndId(Long.parseLong(_dcId));
            String secStoreUrl = secStoreUrlAndId.first();
            Long secStoreId = secStoreUrlAndId.second();
            if (secStoreUrl == null) {
                String msg = "secondary storage for dc " + _dcId + " is not ready yet?";
                throw new Exception(msg);
            }
            mgr.prepareSecondaryStorageStore(secStoreUrl, secStoreId);
            ManagedObjectReference morSecDs = prepareSecondaryDatastoreOnHost(secStoreUrl);
            if (morSecDs == null) {
                String msg = "Failed to prepare secondary storage on host, secondary store url: " + secStoreUrl;
                throw new Exception(msg);
            }
            DatastoreMO secDsMo = new DatastoreMO(hyperHost.getContext(), morSecDs);
            deviceConfigSpecArray[i] = new VirtualDeviceConfigSpec();
            Pair<VirtualDevice, Boolean> isoInfo = VmwareHelper.prepareIsoDevice(vmMo, String.format("[%s] systemvm/%s", secDsMo.getName(), mgr.getSystemVMIsoFileNameOnDatastore()), secDsMo.getMor(), true, true, ideUnitNumber++, i + 1);
            deviceConfigSpecArray[i].setDevice(isoInfo.first());
            if (isoInfo.second()) {
                if (s_logger.isDebugEnabled())
                    s_logger.debug("Prepare ISO volume at new device " + _gson.toJson(isoInfo.first()));
                deviceConfigSpecArray[i].setOperation(VirtualDeviceConfigSpecOperation.ADD);
            } else {
                if (s_logger.isDebugEnabled())
                    s_logger.debug("Prepare ISO volume at existing device " + _gson.toJson(isoInfo.first()));
                deviceConfigSpecArray[i].setOperation(VirtualDeviceConfigSpecOperation.EDIT);
            }
            i++;
        } else if (!deployAsIs) {
            // Note: we will always plug a CDROM device
            if (volIso != null) {
                for (DiskTO vol : disks) {
                    if (vol.getType() == Volume.Type.ISO) {
                        configureIso(hyperHost, vmMo, vol, deviceConfigSpecArray, ideUnitNumber++, i);
                        i++;
                    }
                }
            } else {
                deviceConfigSpecArray[i] = new VirtualDeviceConfigSpec();
                Pair<VirtualDevice, Boolean> isoInfo = VmwareHelper.prepareIsoDevice(vmMo, null, null, true, true, ideUnitNumber++, i + 1);
                deviceConfigSpecArray[i].setDevice(isoInfo.first());
                if (isoInfo.second()) {
                    if (s_logger.isDebugEnabled())
                        s_logger.debug("Prepare ISO volume at existing device " + _gson.toJson(isoInfo.first()));
                    deviceConfigSpecArray[i].setOperation(VirtualDeviceConfigSpecOperation.ADD);
                } else {
                    if (s_logger.isDebugEnabled())
                        s_logger.debug("Prepare ISO volume at existing device " + _gson.toJson(isoInfo.first()));
                    deviceConfigSpecArray[i].setOperation(VirtualDeviceConfigSpecOperation.EDIT);
                }
                i++;
            }
        }
        int controllerKey;
        // 
        if (multipleIsosAtached(sortedDisks) && deployAsIs) {
            sortedDisks = getDisks(sortedDisks);
        }
        for (DiskTO vol : sortedDisks) {
            if (vol.getType() == Volume.Type.ISO) {
                if (deployAsIs) {
                    configureIso(hyperHost, vmMo, vol, deviceConfigSpecArray, ideUnitNumber++, i);
                    i++;
                }
                continue;
            }
            if (deployAsIs && vol.getType() == Volume.Type.ROOT) {
                rootDiskTO = vol;
                resizeRootDiskOnVMStart(vmMo, rootDiskTO, hyperHost, context);
                continue;
            }
            VirtualMachineDiskInfo matchingExistingDisk = getMatchingExistingDisk(diskInfoBuilder, vol, hyperHost, context);
            String diskController = getDiskController(vmMo, matchingExistingDisk, vol, controllerInfo, deployAsIs);
            if (DiskControllerType.getType(diskController) == DiskControllerType.osdefault) {
                diskController = vmMo.getRecommendedDiskController(null);
            }
            if (DiskControllerType.getType(diskController) == DiskControllerType.ide) {
                controllerKey = vmMo.getIDEControllerKey(ideUnitNumber);
                if (vol.getType() == Volume.Type.DATADISK) {
                    // Ensure maximum of 2 data volumes over IDE controller, 3 includeing root volume
                    if (vmMo.getNumberOfVirtualDisks() > 3) {
                        throw new CloudRuntimeException("Found more than 3 virtual disks attached to this VM [" + vmMo.getVmName() + "]. Unable to implement the disks over " + diskController + " controller, as maximum number of devices supported over IDE controller is 4 includeing CDROM device.");
                    }
                }
            } else {
                if (VmwareHelper.isReservedScsiDeviceNumber(scsiUnitNumber)) {
                    scsiUnitNumber++;
                }
                controllerKey = vmMo.getScsiDiskControllerKeyNoException(diskController, scsiUnitNumber);
                if (controllerKey == -1) {
                    // This may happen for ROOT legacy VMs which doesn't have recommended disk controller when global configuration parameter 'vmware.root.disk.controller' is set to "osdefault"
                    // Retrieve existing controller and use.
                    Ternary<Integer, Integer, DiskControllerType> vmScsiControllerInfo = vmMo.getScsiControllerInfo();
                    DiskControllerType existingControllerType = vmScsiControllerInfo.third();
                    controllerKey = vmMo.getScsiDiskControllerKeyNoException(existingControllerType.toString(), scsiUnitNumber);
                }
            }
            if (!hasSnapshot) {
                deviceConfigSpecArray[i] = new VirtualDeviceConfigSpec();
                VolumeObjectTO volumeTO = (VolumeObjectTO) vol.getData();
                DataStoreTO primaryStore = volumeTO.getDataStore();
                Map<String, String> details = vol.getDetails();
                boolean managed = false;
                String iScsiName = null;
                if (details != null) {
                    managed = Boolean.parseBoolean(details.get(DiskTO.MANAGED));
                    iScsiName = details.get(DiskTO.IQN);
                }
                String primaryStoreUuid = primaryStore.getUuid();
                // if the storage is managed, iScsiName should not be null
                String datastoreName = managed ? VmwareResource.getDatastoreName(iScsiName) : primaryStoreUuid;
                Pair<ManagedObjectReference, DatastoreMO> volumeDsDetails = dataStoresDetails.get(datastoreName);
                assert (volumeDsDetails != null);
                if (volumeDsDetails == null) {
                    throw new Exception("Primary datastore " + primaryStore.getUuid() + " is not mounted on host.");
                }
                if (vol.getDetails().get(DiskTO.PROTOCOL_TYPE) != null && vol.getDetails().get(DiskTO.PROTOCOL_TYPE).equalsIgnoreCase("DatastoreCluster")) {
                    if (diskInfoBuilder != null && matchingExistingDisk != null) {
                        String[] diskChain = matchingExistingDisk.getDiskChain();
                        if (diskChain != null && diskChain.length > 0) {
                            DatastoreFile file = new DatastoreFile(diskChain[0]);
                            if (!file.getFileBaseName().equalsIgnoreCase(volumeTO.getPath())) {
                                if (s_logger.isInfoEnabled())
                                    s_logger.info("Detected disk-chain top file change on volume: " + volumeTO.getId() + " " + volumeTO.getPath() + " -> " + file.getFileBaseName());
                                volumeTO.setPath(file.getFileBaseName());
                            }
                        }
                        DatastoreMO diskDatastoreMofromVM = getDataStoreWhereDiskExists(hyperHost, context, diskInfoBuilder, vol, diskDatastores);
                        if (diskDatastoreMofromVM != null) {
                            String actualPoolUuid = diskDatastoreMofromVM.getCustomFieldValue(CustomFieldConstants.CLOUD_UUID);
                            if (actualPoolUuid != null && !actualPoolUuid.equalsIgnoreCase(primaryStore.getUuid())) {
                                volumeDsDetails = new Pair<>(diskDatastoreMofromVM.getMor(), diskDatastoreMofromVM);
                                if (s_logger.isInfoEnabled())
                                    s_logger.info("Detected datastore uuid change on volume: " + volumeTO.getId() + " " + primaryStore.getUuid() + " -> " + actualPoolUuid);
                                ((PrimaryDataStoreTO) primaryStore).setUuid(actualPoolUuid);
                            }
                        }
                    }
                }
                String[] diskChain = syncDiskChain(dcMo, vmMo, vol, matchingExistingDisk, volumeDsDetails.second());
                int deviceNumber = -1;
                if (controllerKey == vmMo.getIDEControllerKey(ideUnitNumber)) {
                    deviceNumber = ideUnitNumber % VmwareHelper.MAX_ALLOWED_DEVICES_IDE_CONTROLLER;
                    ideUnitNumber++;
                } else {
                    deviceNumber = scsiUnitNumber % VmwareHelper.MAX_ALLOWED_DEVICES_SCSI_CONTROLLER;
                    scsiUnitNumber++;
                }
                VirtualDevice device = VmwareHelper.prepareDiskDevice(vmMo, null, controllerKey, diskChain, volumeDsDetails.first(), deviceNumber, i + 1);
                diskStoragePolicyId = volumeTO.getvSphereStoragePolicyId();
                if (StringUtils.isNotEmpty(diskStoragePolicyId)) {
                    PbmProfileManagerMO profMgrMo = new PbmProfileManagerMO(context);
                    diskProfileSpec = profMgrMo.getProfileSpec(diskStoragePolicyId);
                    deviceConfigSpecArray[i].getProfile().add(diskProfileSpec);
                    if (s_logger.isDebugEnabled()) {
                        s_logger.debug(String.format("Adding vSphere storage profile: %s to virtual disk [%s]", diskStoragePolicyId, _gson.toJson(device)));
                    }
                }
                if (vol.getType() == Volume.Type.ROOT) {
                    rootDiskTO = vol;
                    vmStoragePolicyId = diskStoragePolicyId;
                    vmProfileSpec = diskProfileSpec;
                }
                deviceConfigSpecArray[i].setDevice(device);
                deviceConfigSpecArray[i].setOperation(VirtualDeviceConfigSpecOperation.ADD);
                if (s_logger.isDebugEnabled())
                    s_logger.debug("Prepare volume at new device " + _gson.toJson(device));
                i++;
            } else {
                if (controllerKey == vmMo.getIDEControllerKey(ideUnitNumber))
                    ideUnitNumber++;
                else
                    scsiUnitNumber++;
            }
        }
        // 
        if (StringUtils.isNotBlank(guestOsId) && guestOsId.startsWith("darwin")) {
            // Mac OS
            VirtualDevice[] devices = vmMo.getMatchedDevices(new Class<?>[] { VirtualUSBController.class });
            if (devices.length == 0) {
                s_logger.debug("No USB Controller device on VM Start. Add USB Controller device for Mac OS VM " + vmInternalCSName);
                // For Mac OS X systems, the EHCI+UHCI controller is enabled by default and is required for USB mouse and keyboard access.
                VirtualDevice usbControllerDevice = VmwareHelper.prepareUSBControllerDevice();
                deviceConfigSpecArray[i] = new VirtualDeviceConfigSpec();
                deviceConfigSpecArray[i].setDevice(usbControllerDevice);
                deviceConfigSpecArray[i].setOperation(VirtualDeviceConfigSpecOperation.ADD);
                if (s_logger.isDebugEnabled())
                    s_logger.debug("Prepare USB controller at new device " + _gson.toJson(deviceConfigSpecArray[i]));
                i++;
            } else {
                s_logger.debug("USB Controller device exists on VM Start for Mac OS VM " + vmInternalCSName);
            }
        }
        // 
        // Setup NIC devices
        // 
        VirtualDevice nic;
        int nicMask = 0;
        int nicCount = 0;
        VirtualEthernetCardType nicDeviceType;
        NiciraNvpApiVersion.logNiciraApiVersion();
        Map<String, String> nicUuidToDvSwitchUuid = new HashMap<String, String>();
        for (NicTO nicTo : sortNicsByDeviceId(nics)) {
            s_logger.info("Prepare NIC device based on NicTO: " + _gson.toJson(nicTo));
            String adapterTypeStr = deployAsIs ? mapAdapterType(deployAsIsInfo.getNicAdapterMap().get(nicTo.getDeviceId())) : vmSpec.getDetails().get(VmDetailConstants.NIC_ADAPTER);
            nicDeviceType = VirtualEthernetCardType.valueOf(adapterTypeStr);
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("VM " + vmInternalCSName + " will be started with NIC device type: " + nicDeviceType + " on NIC device " + nicTo.getDeviceId());
            }
            boolean configureVServiceInNexus = (nicTo.getType() == TrafficType.Guest) && (vmSpec.getDetails().containsKey("ConfigureVServiceInNexus"));
            VirtualMachine.Type vmType = cmd.getVirtualMachine().getType();
            Pair<ManagedObjectReference, String> networkInfo = prepareNetworkFromNicInfo(vmMo.getRunningHost(), nicTo, configureVServiceInNexus, vmType);
            if ((nicTo.getBroadcastType() != BroadcastDomainType.Lswitch) || (nicTo.getBroadcastType() == BroadcastDomainType.Lswitch && NiciraNvpApiVersion.isApiVersionLowerThan("4.2"))) {
                if (VmwareHelper.isDvPortGroup(networkInfo.first())) {
                    String dvSwitchUuid;
                    ManagedObjectReference dcMor = hyperHost.getHyperHostDatacenter();
                    DatacenterMO dataCenterMo = new DatacenterMO(context, dcMor);
                    ManagedObjectReference dvsMor = dataCenterMo.getDvSwitchMor(networkInfo.first());
                    dvSwitchUuid = dataCenterMo.getDvSwitchUuid(dvsMor);
                    s_logger.info("Preparing NIC device on dvSwitch : " + dvSwitchUuid);
                    nic = VmwareHelper.prepareDvNicDevice(vmMo, networkInfo.first(), nicDeviceType, networkInfo.second(), dvSwitchUuid, nicTo.getMac(), i + 1, true, true);
                    if (nicTo.getUuid() != null) {
                        nicUuidToDvSwitchUuid.put(nicTo.getUuid(), dvSwitchUuid);
                    }
                } else {
                    s_logger.info("Preparing NIC device on network " + networkInfo.second());
                    nic = VmwareHelper.prepareNicDevice(vmMo, networkInfo.first(), nicDeviceType, networkInfo.second(), nicTo.getMac(), i + 1, true, true);
                }
            } else {
                // if NSX API VERSION >= 4.2, connect to br-int (nsx.network), do not create portgroup else previous behaviour
                nic = VmwareHelper.prepareNicOpaque(vmMo, nicDeviceType, networkInfo.second(), nicTo.getMac(), i + 1, true, true);
            }
            deviceConfigSpecArray[i] = new VirtualDeviceConfigSpec();
            deviceConfigSpecArray[i].setDevice(nic);
            deviceConfigSpecArray[i].setOperation(VirtualDeviceConfigSpecOperation.ADD);
            if (s_logger.isDebugEnabled())
                s_logger.debug("Prepare NIC at new device " + _gson.toJson(deviceConfigSpecArray[i]));
            // this is really a hacking for DomR, upon DomR startup, we will reset all the NIC allocation after eth3
            if (nicCount < 3)
                nicMask |= (1 << nicCount);
            i++;
            nicCount++;
        }
        for (int j = 0; j < i; j++) vmConfigSpec.getDeviceChange().add(deviceConfigSpecArray[j]);
        // 
        // Setup VM options
        // 
        // pass boot arguments through machine.id & perform customized options to VMX
        ArrayList<OptionValue> extraOptions = new ArrayList<OptionValue>();
        configBasicExtraOption(extraOptions, vmSpec);
        if (deployAsIs) {
            setDeployAsIsProperties(vmMo, deployAsIsInfo, vmConfigSpec, hyperHost);
        }
        configNvpExtraOption(extraOptions, vmSpec, nicUuidToDvSwitchUuid);
        configCustomExtraOption(extraOptions, vmSpec);
        // config for NCC
        VirtualMachine.Type vmType = cmd.getVirtualMachine().getType();
        if (vmType.equals(VirtualMachine.Type.NetScalerVm)) {
            NicTO mgmtNic = vmSpec.getNics()[0];
            OptionValue option = new OptionValue();
            option.setKey("machine.id");
            option.setValue("ip=" + mgmtNic.getIp() + "&netmask=" + mgmtNic.getNetmask() + "&gateway=" + mgmtNic.getGateway());
            extraOptions.add(option);
        }
        configureVNC(vmSpec, extraOptions, vmConfigSpec, hyperHost, vmInternalCSName);
        // config video card
        configureVideoCard(vmMo, vmSpec, vmConfigSpec);
        setBootOptions(vmSpec, bootMode, vmConfigSpec);
        if (StringUtils.isNotEmpty(vmStoragePolicyId)) {
            vmConfigSpec.getVmProfile().add(vmProfileSpec);
            if (s_logger.isTraceEnabled()) {
                s_logger.trace(String.format("Configuring the VM %s with storage policy: %s", vmInternalCSName, vmStoragePolicyId));
            }
        }
        // 
        if (!vmMo.configureVm(vmConfigSpec)) {
            throw new Exception("Failed to configure VM before start. vmName: " + vmInternalCSName);
        }
        if (vmSpec.getType() == VirtualMachine.Type.DomainRouter) {
            hyperHost.setRestartPriorityForVM(vmMo, DasVmPriority.HIGH.value());
        }
        // Resizing root disk only when explicit requested by user
        final Map<String, String> vmDetails = cmd.getVirtualMachine().getDetails();
        if (!deployAsIs && rootDiskTO != null && !hasSnapshot && (vmDetails != null && vmDetails.containsKey(ApiConstants.ROOT_DISK_SIZE))) {
            resizeRootDiskOnVMStart(vmMo, rootDiskTO, hyperHost, context);
        }
        // 
        // Post Configuration
        // 
        vmMo.setCustomFieldValue(CustomFieldConstants.CLOUD_NIC_MASK, String.valueOf(nicMask));
        postNvpConfigBeforeStart(vmMo, vmSpec);
        Map<String, Map<String, String>> iqnToData = new HashMap<>();
        postDiskConfigBeforeStart(vmMo, vmSpec, sortedDisks, ideControllerKey, scsiControllerKey, iqnToData, hyperHost, context);
        // 
        if (!vmMo.powerOn()) {
            throw new Exception("Failed to start VM. vmName: " + vmInternalCSName + " with hostname " + vmNameOnVcenter);
        }
        StartAnswer startAnswer = new StartAnswer(cmd);
        startAnswer.setIqnToData(iqnToData);
        // Since VM was successfully powered-on, if there was an existing VM in a different cluster that was unregistered, delete all the files associated with it.
        if (existingVmName != null && existingVmFileLayout != null) {
            List<String> vmDatastoreNames = new ArrayList<String>();
            for (DatastoreMO vmDatastore : vmMo.getAllDatastores()) {
                vmDatastoreNames.add(vmDatastore.getName());
            }
            // Don't delete files that are in a datastore that is being used by the new VM as well (zone-wide datastore).
            List<String> skipDatastores = new ArrayList<String>();
            for (DatastoreMO existingDatastore : existingDatastores) {
                if (vmDatastoreNames.contains(existingDatastore.getName())) {
                    skipDatastores.add(existingDatastore.getName());
                }
            }
            deleteUnregisteredVmFiles(existingVmFileLayout, dcMo, true, skipDatastores);
        }
        return startAnswer;
    } catch (Throwable e) {
        StartAnswer startAnswer = new StartAnswer(cmd, createLogMessageException(e, cmd));
        if (vmAlreadyExistsInVcenter) {
            startAnswer.setContextParam("stopRetry", "true");
        }
        if (existingVmName != null && existingVmFileInfo != null) {
            s_logger.debug(String.format("Since VM start failed, registering back an existing VM: [%s] that was unregistered.", existingVmName));
            try {
                DatastoreFile fileInDatastore = new DatastoreFile(existingVmFileInfo.getVmPathName());
                DatastoreMO existingVmDsMo = new DatastoreMO(dcMo.getContext(), dcMo.findDatastore(fileInDatastore.getDatastoreName()));
                registerVm(existingVmName, existingVmDsMo);
            } catch (Exception ex) {
                String message = String.format("Failed to register an existing VM: [%s] due to [%s].", existingVmName, VmwareHelper.getExceptionMessage(ex));
                s_logger.error(message, ex);
            }
        }
        return startAnswer;
    }
}
Also used : StartAnswer(com.cloud.agent.api.StartAnswer) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) VirtualMachineTO(com.cloud.agent.api.to.VirtualMachineTO) DatastoreFile(com.cloud.hypervisor.vmware.mo.DatastoreFile) VolumeObjectTO(org.apache.cloudstack.storage.to.VolumeObjectTO) VirtualMachineFileLayoutEx(com.vmware.vim25.VirtualMachineFileLayoutEx) NicTO(com.cloud.agent.api.to.NicTO) PrimaryDataStoreTO(org.apache.cloudstack.storage.to.PrimaryDataStoreTO) DataStoreTO(com.cloud.agent.api.to.DataStoreTO) VmwareManager(com.cloud.hypervisor.vmware.manager.VmwareManager) VirtualMachineMO(com.cloud.hypervisor.vmware.mo.VirtualMachineMO) VirtualDevice(com.vmware.vim25.VirtualDevice) VirtualMachineDiskInfoBuilder(com.cloud.hypervisor.vmware.mo.VirtualMachineDiskInfoBuilder) VirtualMachineDefinedProfileSpec(com.vmware.vim25.VirtualMachineDefinedProfileSpec) DatastoreMO(com.cloud.hypervisor.vmware.mo.DatastoreMO) VmwareContext(com.cloud.hypervisor.vmware.util.VmwareContext) PbmProfileManagerMO(com.cloud.hypervisor.vmware.mo.PbmProfileManagerMO) Map(java.util.Map) EnumMap(java.util.EnumMap) HashMap(java.util.HashMap) DeployAsIsInfoTO(com.cloud.agent.api.to.DeployAsIsInfoTO) DatacenterMO(com.cloud.hypervisor.vmware.mo.DatacenterMO) ManagedObjectReference(com.vmware.vim25.ManagedObjectReference) VirtualMachine(com.cloud.vm.VirtualMachine) VirtualDeviceConfigSpec(com.vmware.vim25.VirtualDeviceConfigSpec) DiskControllerType(com.cloud.hypervisor.vmware.mo.DiskControllerType) VirtualMachineConfigSpec(com.vmware.vim25.VirtualMachineConfigSpec) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) VirtualMachineDiskInfo(org.apache.cloudstack.utils.volume.VirtualMachineDiskInfo) OptionValue(com.vmware.vim25.OptionValue) Pair(com.cloud.utils.Pair) VirtualEthernetCardType(com.cloud.hypervisor.vmware.mo.VirtualEthernetCardType) VmwareHypervisorHost(com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost) ConnectException(java.net.ConnectException) IOException(java.io.IOException) RemoteException(java.rmi.RemoteException) InternalErrorException(com.cloud.exception.InternalErrorException) CloudException(com.cloud.exception.CloudException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ConfigurationException(javax.naming.ConfigurationException) PrimaryDataStoreTO(org.apache.cloudstack.storage.to.PrimaryDataStoreTO) VirtualMachineFileInfo(com.vmware.vim25.VirtualMachineFileInfo) DiskTO(com.cloud.agent.api.to.DiskTO)

Example 2 with PbmProfileManagerMO

use of com.cloud.hypervisor.vmware.mo.PbmProfileManagerMO in project cloudstack by apache.

the class VmwareManagerImpl method importVsphereStoragePoliciesInternal.

public List<? extends VsphereStoragePolicy> importVsphereStoragePoliciesInternal(Long zoneId, Long vmwareDcId) {
    // Get DC associated with this zone
    VmwareDatacenterVO vmwareDatacenter = vmwareDcDao.findById(vmwareDcId);
    String vmwareDcName = vmwareDatacenter.getVmwareDatacenterName();
    String vCenterHost = vmwareDatacenter.getVcenterHost();
    String userName = vmwareDatacenter.getUser();
    String password = vmwareDatacenter.getPassword();
    List<PbmProfile> storageProfiles = null;
    try {
        s_logger.debug(String.format("Importing vSphere Storage Policies for the vmware DC %d in zone %d", vmwareDcId, zoneId));
        VmwareContext context = VmwareContextFactory.getContext(vCenterHost, userName, password);
        PbmProfileManagerMO profileManagerMO = new PbmProfileManagerMO(context);
        storageProfiles = profileManagerMO.getStorageProfiles();
        s_logger.debug(String.format("Import vSphere Storage Policies for the vmware DC %d in zone %d is successful", vmwareDcId, zoneId));
    } catch (Exception e) {
        String msg = String.format("Unable to list storage profiles from DC %s due to : %s", vmwareDcName, VmwareHelper.getExceptionMessage(e));
        s_logger.error(msg);
        throw new CloudRuntimeException(msg);
    }
    for (PbmProfile storageProfile : storageProfiles) {
        VsphereStoragePolicyVO storagePolicyVO = vsphereStoragePolicyDao.findByPolicyId(zoneId, storageProfile.getProfileId().getUniqueId());
        if (storagePolicyVO == null) {
            storagePolicyVO = new VsphereStoragePolicyVO(zoneId, storageProfile.getProfileId().getUniqueId(), storageProfile.getName(), storageProfile.getDescription());
            vsphereStoragePolicyDao.persist(storagePolicyVO);
        } else {
            storagePolicyVO.setDescription(storageProfile.getDescription());
            storagePolicyVO.setName(storageProfile.getName());
            vsphereStoragePolicyDao.update(storagePolicyVO.getId(), storagePolicyVO);
        }
    }
    List<VsphereStoragePolicyVO> allStoragePolicies = vsphereStoragePolicyDao.listAll();
    List<PbmProfile> finalStorageProfiles = storageProfiles;
    List<VsphereStoragePolicyVO> needToMarkRemoved = allStoragePolicies.stream().filter(existingPolicy -> !finalStorageProfiles.stream().anyMatch(storageProfile -> storageProfile.getProfileId().getUniqueId().equals(existingPolicy.getPolicyId()))).collect(Collectors.toList());
    for (VsphereStoragePolicyVO storagePolicy : needToMarkRemoved) {
        vsphereStoragePolicyDao.remove(storagePolicy.getId());
    }
    List<VsphereStoragePolicyVO> storagePolicies = vsphereStoragePolicyDao.listAll();
    return storagePolicies;
}
Also used : DiscoveredWithErrorException(com.cloud.exception.DiscoveredWithErrorException) NetworkModel(com.cloud.network.NetworkModel) HostDao(com.cloud.host.dao.HostDao) HypervisorGuruManager(com.cloud.hypervisor.HypervisorGuruManager) VmwareDatacenterZoneMap(com.cloud.hypervisor.vmware.VmwareDatacenterZoneMap) Transaction(com.cloud.utils.db.Transaction) ClusterType(com.cloud.org.Cluster.ClusterType) StringUtils(org.apache.commons.lang3.StringUtils) AgentManager(com.cloud.agent.AgentManager) DatacenterMO(com.cloud.hypervisor.vmware.mo.DatacenterMO) AgentUnavailableException(com.cloud.exception.AgentUnavailableException) VirtualSwitchType(com.cloud.hypervisor.vmware.mo.VirtualSwitchType) VMTemplatePoolDao(com.cloud.storage.dao.VMTemplatePoolDao) RemoveVmwareDcCmd(org.apache.cloudstack.api.command.admin.zone.RemoveVmwareDcCmd) Duration(java.time.Duration) Map(java.util.Map) VsphereStoragePolicy(com.cloud.dc.VsphereStoragePolicy) TrafficType(com.cloud.network.Networks.TrafficType) AgentControlAnswer(com.cloud.agent.api.AgentControlAnswer) VmwareContextFactory(com.cloud.hypervisor.vmware.resource.VmwareContextFactory) AgentControlCommand(com.cloud.agent.api.AgentControlCommand) VmwareDatacenter(com.cloud.hypervisor.vmware.VmwareDatacenter) TransactionStatus(com.cloud.utils.db.TransactionStatus) OperationTimedoutException(com.cloud.exception.OperationTimedoutException) FileUtil(com.cloud.utils.FileUtil) Executors(java.util.concurrent.Executors) Script(com.cloud.utils.script.Script) ConfigurationServer(com.cloud.server.ConfigurationServer) StorageFilerTO(com.cloud.agent.api.to.StorageFilerTO) ImageStoreDetailsUtil(com.cloud.storage.ImageStoreDetailsUtil) AsyncJobManagerImpl(org.apache.cloudstack.framework.jobs.impl.AsyncJobManagerImpl) ClusterVSMMapDao(com.cloud.dc.dao.ClusterVSMMapDao) ManagementServerHostPeerDao(com.cloud.cluster.dao.ManagementServerHostPeerDao) HypervisorCapabilitiesDao(com.cloud.hypervisor.dao.HypervisorCapabilitiesDao) JavaStorageLayer(com.cloud.storage.JavaStorageLayer) NumbersUtil(com.cloud.utils.NumbersUtil) ManagerBase(com.cloud.utils.component.ManagerBase) DataCenterVO(com.cloud.dc.DataCenterVO) VirtualEthernetCardType(com.cloud.hypervisor.vmware.mo.VirtualEthernetCardType) CiscoNexusVSMDeviceVO(com.cloud.network.CiscoNexusVSMDeviceVO) ArrayList(java.util.ArrayList) LegacyZoneDao(com.cloud.hypervisor.vmware.dao.LegacyZoneDao) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ClusterDao(com.cloud.dc.dao.ClusterDao) DomainRouterVO(com.cloud.vm.DomainRouterVO) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) UpdateVmwareDcCmd(org.apache.cloudstack.api.command.admin.zone.UpdateVmwareDcCmd) ClusterVO(com.cloud.dc.ClusterVO) VMInstanceDao(com.cloud.vm.dao.VMInstanceDao) HypervisorType(com.cloud.hypervisor.Hypervisor.HypervisorType) VmwareCleanupMaid(com.cloud.hypervisor.vmware.VmwareCleanupMaid) VmwareDatacenterDao(com.cloud.hypervisor.vmware.dao.VmwareDatacenterDao) UserVmCloneSettingDao(com.cloud.vm.dao.UserVmCloneSettingDao) ClusterVSMMapVO(com.cloud.dc.ClusterVSMMapVO) StartupRoutingCommand(com.cloud.agent.api.StartupRoutingCommand) IOException(java.io.IOException) DB(com.cloud.utils.db.DB) File(java.io.File) ManagedObjectReference(com.vmware.vim25.ManagedObjectReference) ClusterManager(com.cloud.cluster.ClusterManager) VmwareHelper(com.cloud.hypervisor.vmware.util.VmwareHelper) Command(com.cloud.agent.api.Command) Host(com.cloud.host.Host) AddVmwareDcCmd(org.apache.cloudstack.api.command.admin.zone.AddVmwareDcCmd) ActionEvent(com.cloud.event.ActionEvent) ClusterDetailsDao(com.cloud.dc.ClusterDetailsDao) GlobalLock(com.cloud.utils.db.GlobalLock) ConfigurationDao(org.apache.cloudstack.framework.config.dao.ConfigurationDao) ResourceInUseException(com.cloud.exception.ResourceInUseException) StorageManager(com.cloud.storage.StorageManager) TemplateManager(com.cloud.template.TemplateManager) URLDecoder(java.net.URLDecoder) HypervisorHostHelper(com.cloud.hypervisor.vmware.mo.HypervisorHostHelper) URL(java.net.URL) URISyntaxException(java.net.URISyntaxException) DiscoveryException(com.cloud.exception.DiscoveryException) StoragePoolStatus(com.cloud.storage.StoragePoolStatus) Random(java.util.Random) StoragePool(com.cloud.storage.StoragePool) UriUtils(com.cloud.utils.UriUtils) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) Cluster(com.cloud.org.Cluster) Logger(org.apache.log4j.Logger) StartupCommand(com.cloud.agent.api.StartupCommand) CommandExecLogDao(com.cloud.secstorage.CommandExecLogDao) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) URI(java.net.URI) Answer(com.cloud.agent.api.Answer) Config(com.cloud.configuration.Config) VmwareHostType(com.cloud.hypervisor.vmware.mo.VmwareHostType) TransactionCallbackNoReturn(com.cloud.utils.db.TransactionCallbackNoReturn) PrimaryDataStoreDao(org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao) TransactionCallback(com.cloud.utils.db.TransactionCallback) UUID(java.util.UUID) Pair(com.cloud.utils.Pair) Instant(java.time.Instant) VsphereStoragePolicyVO(com.cloud.dc.VsphereStoragePolicyVO) HostFirewallSystemMO(com.cloud.hypervisor.vmware.mo.HostFirewallSystemMO) Collectors(java.util.stream.Collectors) CheckDataStoreStoragePolicyComplainceCommand(org.apache.cloudstack.storage.command.CheckDataStoreStoragePolicyComplainceCommand) RemoteException(java.rmi.RemoteException) Status(com.cloud.host.Status) List(java.util.List) DataCenterDao(com.cloud.dc.dao.DataCenterDao) DiskControllerType(com.cloud.hypervisor.vmware.mo.DiskControllerType) AboutInfo(com.vmware.vim25.AboutInfo) VmwareDatacenterZoneMapVO(com.cloud.hypervisor.vmware.VmwareDatacenterZoneMapVO) BroadcastDomainType(com.cloud.network.Networks.BroadcastDomainType) DataStoreManager(org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager) HashMap(java.util.HashMap) ListVsphereStoragePoliciesCmd(org.apache.cloudstack.api.command.admin.zone.ListVsphereStoragePoliciesCmd) ConfigurationException(javax.naming.ConfigurationException) EventTypes(com.cloud.event.EventTypes) CollectionUtils(com.amazonaws.util.CollectionUtils) Inject(javax.inject.Inject) ConfigKey(org.apache.cloudstack.framework.config.ConfigKey) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) Listener(com.cloud.agent.Listener) ListVmwareDcsCmd(org.apache.cloudstack.api.command.admin.zone.ListVmwareDcsCmd) SshHelper(com.cloud.utils.ssh.SshHelper) PbmProfile(com.vmware.pbm.PbmProfile) CiscoNexusVSMDeviceDao(com.cloud.network.dao.CiscoNexusVSMDeviceDao) VmwareContext(com.cloud.hypervisor.vmware.util.VmwareContext) Configurable(org.apache.cloudstack.framework.config.Configurable) ListVsphereStoragePolicyCompatiblePoolsCmd(org.apache.cloudstack.api.command.admin.zone.ListVsphereStoragePolicyCompatiblePoolsCmd) ManagementServerNode(org.apache.cloudstack.utils.identity.ManagementServerNode) NamedThreadFactory(com.cloud.utils.concurrency.NamedThreadFactory) HostVO(com.cloud.host.HostVO) VsphereStoragePolicyDao(com.cloud.dc.dao.VsphereStoragePolicyDao) MapUtils(org.apache.commons.collections.MapUtils) VmwareDatacenterZoneMapDao(com.cloud.hypervisor.vmware.dao.VmwareDatacenterZoneMapDao) CustomFieldConstants(com.cloud.hypervisor.vmware.mo.CustomFieldConstants) HostMO(com.cloud.hypervisor.vmware.mo.HostMO) Hypervisor(com.cloud.hypervisor.Hypervisor) LegacyZoneVO(com.cloud.hypervisor.vmware.LegacyZoneVO) FileInputStream(java.io.FileInputStream) PbmProfileManagerMO(com.cloud.hypervisor.vmware.mo.PbmProfileManagerMO) ImportVsphereStoragePoliciesCmd(org.apache.cloudstack.api.command.admin.zone.ImportVsphereStoragePoliciesCmd) HostDetailsDao(com.cloud.host.dao.HostDetailsDao) TimeUnit(java.util.concurrent.TimeUnit) TemplateJoinDao(com.cloud.api.query.dao.TemplateJoinDao) StoragePoolVO(org.apache.cloudstack.storage.datastore.db.StoragePoolVO) VmwareTrafficLabel(com.cloud.network.VmwareTrafficLabel) VmwareDatacenterVO(com.cloud.hypervisor.vmware.VmwareDatacenterVO) VmwareDatacenterService(com.cloud.hypervisor.vmware.VmwareDatacenterService) DigestUtils(org.apache.commons.codec.digest.DigestUtils) StorageLayer(com.cloud.storage.StorageLayer) Collections(java.util.Collections) ManagementServerHost(org.apache.cloudstack.management.ManagementServerHost) VmwareContext(com.cloud.hypervisor.vmware.util.VmwareContext) PbmProfile(com.vmware.pbm.PbmProfile) VmwareDatacenterVO(com.cloud.hypervisor.vmware.VmwareDatacenterVO) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) PbmProfileManagerMO(com.cloud.hypervisor.vmware.mo.PbmProfileManagerMO) DiscoveredWithErrorException(com.cloud.exception.DiscoveredWithErrorException) AgentUnavailableException(com.cloud.exception.AgentUnavailableException) OperationTimedoutException(com.cloud.exception.OperationTimedoutException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) IOException(java.io.IOException) ResourceInUseException(com.cloud.exception.ResourceInUseException) URISyntaxException(java.net.URISyntaxException) DiscoveryException(com.cloud.exception.DiscoveryException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) RemoteException(java.rmi.RemoteException) ConfigurationException(javax.naming.ConfigurationException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) VsphereStoragePolicyVO(com.cloud.dc.VsphereStoragePolicyVO)

Aggregations

DatacenterMO (com.cloud.hypervisor.vmware.mo.DatacenterMO)2 DiskControllerType (com.cloud.hypervisor.vmware.mo.DiskControllerType)2 PbmProfileManagerMO (com.cloud.hypervisor.vmware.mo.PbmProfileManagerMO)2 VirtualEthernetCardType (com.cloud.hypervisor.vmware.mo.VirtualEthernetCardType)2 VmwareContext (com.cloud.hypervisor.vmware.util.VmwareContext)2 Pair (com.cloud.utils.Pair)2 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)2 ManagedObjectReference (com.vmware.vim25.ManagedObjectReference)2 IOException (java.io.IOException)2 RemoteException (java.rmi.RemoteException)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ConfigurationException (javax.naming.ConfigurationException)2 CollectionUtils (com.amazonaws.util.CollectionUtils)1 AgentManager (com.cloud.agent.AgentManager)1 Listener (com.cloud.agent.Listener)1 AgentControlAnswer (com.cloud.agent.api.AgentControlAnswer)1 AgentControlCommand (com.cloud.agent.api.AgentControlCommand)1 Answer (com.cloud.agent.api.Answer)1