Search in sources :

Example 11 with VirtualCdrom

use of com.vmware.vim25.VirtualCdrom in project photon-model by vmware.

the class ClientUtils method insertCdrom.

/**
 * Changes to backing of the cdrom to an iso-backed one.
 *
 * @param cdrom
 * @param imagePath
 *            path to iso on disk, sth. like "[datastore] /images/ubuntu-16.04-amd64.iso"
 */
public static void insertCdrom(VirtualCdrom cdrom, String imagePath) {
    VirtualCdromIsoBackingInfo backing = new VirtualCdromIsoBackingInfo();
    backing.setFileName(imagePath);
    cdrom.setBacking(backing);
}
Also used : VirtualCdromIsoBackingInfo(com.vmware.vim25.VirtualCdromIsoBackingInfo)

Example 12 with VirtualCdrom

use of com.vmware.vim25.VirtualCdrom in project photon-model by vmware.

the class ClientUtils method handleVirtualDeviceUpdate.

/**
 * Process VirtualCdRom and update the details in the diskLinks of the provisioned compute
 */
public static Operation handleVirtualDeviceUpdate(String endpointLink, DiskStateExpanded matchedDs, DiskType type, VirtualDevice disk, List<String> diskLinks, String regionId, Service service, boolean isBacking, String dcLink) {
    Operation operation;
    if (matchedDs == null) {
        DiskService.DiskState ds = createNewDiskState(type, disk, regionId, service);
        addEndpointLinks(ds, endpointLink);
        if (isBacking) {
            updateDiskStateFromVirtualDevice(disk, ds, disk.getBacking(), dcLink);
        } else {
            updateDiskStateFromVirtualDevice(disk, ds, null, dcLink);
        }
        operation = createDisk(ds, service);
        diskLinks.add(ds.documentSelfLink);
    } else {
        updateDiskStateFromVirtualDevice(disk, matchedDs, null, dcLink);
        if (matchedDs.persistent == null) {
            matchedDs.persistent = Boolean.FALSE;
        }
        addEndpointLinks(matchedDs, endpointLink);
        operation = createDiskPatch(matchedDs, service);
    }
    return operation;
}
Also used : VirtualDeviceConfigSpecFileOperation(com.vmware.vim25.VirtualDeviceConfigSpecFileOperation) Operation(com.vmware.xenon.common.Operation) VirtualDeviceConfigSpecOperation(com.vmware.vim25.VirtualDeviceConfigSpecOperation) DiskService(com.vmware.photon.controller.model.resources.DiskService)

Example 13 with VirtualCdrom

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

the class VmwareHelper method prepareIsoDevice.

public static Pair<VirtualDevice, Boolean> prepareIsoDevice(VirtualMachineMO vmMo, String isoDatastorePath, ManagedObjectReference morDs, boolean connect, boolean connectAtBoot, int deviceNumber, int contextNumber) throws Exception {
    boolean newCdRom = false;
    VirtualCdrom cdRom = (VirtualCdrom) vmMo.getIsoDevice();
    if (cdRom == null) {
        newCdRom = true;
        cdRom = new VirtualCdrom();
        assert (vmMo.getIDEDeviceControllerKey() >= 0);
        cdRom.setControllerKey(vmMo.getIDEDeviceControllerKey());
        if (deviceNumber < 0)
            deviceNumber = vmMo.getNextIDEDeviceNumber();
        cdRom.setUnitNumber(deviceNumber);
        cdRom.setKey(-contextNumber);
    }
    VirtualDeviceConnectInfo cInfo = new VirtualDeviceConnectInfo();
    cInfo.setConnected(connect);
    cInfo.setStartConnected(connectAtBoot);
    cdRom.setConnectable(cInfo);
    if (isoDatastorePath != null) {
        VirtualCdromIsoBackingInfo backingInfo = new VirtualCdromIsoBackingInfo();
        backingInfo.setFileName(isoDatastorePath);
        backingInfo.setDatastore(morDs);
        cdRom.setBacking(backingInfo);
    } else {
        VirtualCdromRemotePassthroughBackingInfo backingInfo = new VirtualCdromRemotePassthroughBackingInfo();
        backingInfo.setDeviceName("");
        cdRom.setBacking(backingInfo);
    }
    return new Pair<VirtualDevice, Boolean>(cdRom, newCdRom);
}
Also used : VirtualCdromIsoBackingInfo(com.vmware.vim25.VirtualCdromIsoBackingInfo) VirtualCdrom(com.vmware.vim25.VirtualCdrom) VirtualDeviceConnectInfo(com.vmware.vim25.VirtualDeviceConnectInfo) VirtualCdromRemotePassthroughBackingInfo(com.vmware.vim25.VirtualCdromRemotePassthroughBackingInfo) Pair(com.cloud.utils.Pair)

Aggregations

VirtualCdrom (com.vmware.vim25.VirtualCdrom)11 VirtualDeviceConnectInfo (com.vmware.vim25.VirtualDeviceConnectInfo)10 VirtualDeviceConfigSpec (com.vmware.vim25.VirtualDeviceConfigSpec)8 VirtualCdromIsoBackingInfo (com.vmware.vim25.VirtualCdromIsoBackingInfo)7 ManagedObjectReference (com.vmware.vim25.ManagedObjectReference)6 VirtualMachineConfigSpec (com.vmware.vim25.VirtualMachineConfigSpec)6 ArrayOfManagedObjectReference (com.vmware.vim25.ArrayOfManagedObjectReference)5 DiskService (com.vmware.photon.controller.model.resources.DiskService)4 DISK_CONTROLLER_NUMBER (com.vmware.photon.controller.model.adapters.vsphere.CustomProperties.DISK_CONTROLLER_NUMBER)3 VirtualDeviceConfigSpecOperation (com.vmware.vim25.VirtualDeviceConfigSpecOperation)3 Operation (com.vmware.xenon.common.Operation)3 Pair (com.cloud.utils.Pair)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 RESOURCE_GROUP_NAME (com.vmware.photon.controller.model.ComputeProperties.RESOURCE_GROUP_NAME)2 ComputeInstanceRequest (com.vmware.photon.controller.model.adapterapi.ComputeInstanceRequest)2 VM_PATH_FORMAT (com.vmware.photon.controller.model.adapters.vsphere.ClientUtils.VM_PATH_FORMAT)2 ClientUtils.createCdrom (com.vmware.photon.controller.model.adapters.vsphere.ClientUtils.createCdrom)2 ClientUtils.createFloppy (com.vmware.photon.controller.model.adapters.vsphere.ClientUtils.createFloppy)2 ClientUtils.createHdd (com.vmware.photon.controller.model.adapters.vsphere.ClientUtils.createHdd)2 ClientUtils.detachDisk (com.vmware.photon.controller.model.adapters.vsphere.ClientUtils.detachDisk)2