Search in sources :

Example 1 with VirtualDiskSpec

use of com.vmware.vim25.VirtualDiskSpec in project CloudStack-archive by CloudStack-extras.

the class VirtualDiskManagerMO method copyVirtualDisk.

public void copyVirtualDisk(String srcName, ManagedObjectReference morSrcDc, String destName, ManagedObjectReference morDestDc, VirtualDiskSpec diskSpec, boolean force) throws Exception {
    ManagedObjectReference morTask = _context.getService().copyVirtualDisk_Task(_mor, srcName, morSrcDc, destName, morDestDc, diskSpec, force);
    String result = _context.getServiceUtil().waitForTask(morTask);
    if (!result.equals("sucess"))
        throw new Exception("Unable to copy virtual disk " + srcName + " to " + destName + " due to " + TaskMO.getTaskFailureInfo(_context, morTask));
    _context.waitForTaskProgressDone(morTask);
}
Also used : ManagedObjectReference(com.vmware.vim25.ManagedObjectReference)

Example 2 with VirtualDiskSpec

use of com.vmware.vim25.VirtualDiskSpec in project CloudStack-archive by CloudStack-extras.

the class VirtualDiskManagerMO method createVirtualDisk.

public void createVirtualDisk(String name, ManagedObjectReference morDc, VirtualDiskSpec diskSpec) throws Exception {
    ManagedObjectReference morTask = _context.getService().createVirtualDisk_Task(_mor, name, morDc, diskSpec);
    String result = _context.getServiceUtil().waitForTask(morTask);
    if (!result.equals("sucess"))
        throw new Exception("Unable to create virtual disk " + name + " due to " + TaskMO.getTaskFailureInfo(_context, morTask));
    _context.waitForTaskProgressDone(morTask);
}
Also used : ManagedObjectReference(com.vmware.vim25.ManagedObjectReference)

Example 3 with VirtualDiskSpec

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

the class VirtualDiskManagerMO method copyVirtualDisk.

public void copyVirtualDisk(String srcName, ManagedObjectReference morSrcDc, String destName, ManagedObjectReference morDestDc, VirtualDiskSpec diskSpec, boolean force) throws Exception {
    ManagedObjectReference morTask = _context.getService().copyVirtualDiskTask(_mor, srcName, morSrcDc, destName, morDestDc, diskSpec, force);
    boolean result = _context.getVimClient().waitForTask(morTask);
    if (!result)
        throw new Exception("Unable to copy virtual disk " + srcName + " to " + destName + " due to " + TaskMO.getTaskFailureInfo(_context, morTask));
    _context.waitForTaskProgressDone(morTask);
}
Also used : ManagedObjectReference(com.vmware.vim25.ManagedObjectReference)

Example 4 with VirtualDiskSpec

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

the class VirtualDiskManagerMO method createVirtualDisk.

public void createVirtualDisk(String name, ManagedObjectReference morDc, VirtualDiskSpec diskSpec) throws Exception {
    ManagedObjectReference morTask = _context.getService().createVirtualDiskTask(_mor, name, morDc, diskSpec);
    boolean result = _context.getVimClient().waitForTask(morTask);
    if (!result)
        throw new Exception("Unable to create virtual disk " + name + " due to " + TaskMO.getTaskFailureInfo(_context, morTask));
    _context.waitForTaskProgressDone(morTask);
}
Also used : ManagedObjectReference(com.vmware.vim25.ManagedObjectReference)

Example 5 with VirtualDiskSpec

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

the class InstanceClient method createFullCloneAndAttach.

private VirtualDeviceConfigSpec createFullCloneAndAttach(String sourcePath, DiskStateExpanded ds, String dir, VirtualDevice scsiController, int unitNumber, List<VirtualMachineDefinedProfileSpec> pbmSpec) throws Exception {
    ManagedObjectReference diskManager = this.connection.getServiceContent().getVirtualDiskManager();
    String dsDirForDisk = getDatastorePathForDisk(ds, dir);
    // put full clone in the vm folder
    String destName = makePathToVmdkFile(ds.name, dsDirForDisk);
    // all ops are within a datacenter
    ManagedObjectReference sourceDc = this.ctx.datacenterMoRef;
    ManagedObjectReference destDc = sourceDc;
    Boolean force = true;
    // spec is not supported, should use null for now
    VirtualDiskSpec spec = null;
    ManagedObjectReference task = getVimPort().copyVirtualDiskTask(diskManager, sourcePath, sourceDc, destName, destDc, spec, force);
    // wait for the disk to be copied
    TaskInfo taskInfo = waitTaskEnd(task);
    if (taskInfo.getState() == TaskInfoState.ERROR) {
        return VimUtils.rethrow(taskInfo.getError());
    }
    VirtualDiskFlatVer2BackingInfo backing = new VirtualDiskFlatVer2BackingInfo();
    backing.setDiskMode(getDiskMode(ds));
    VirtualDiskType provisionType = getDiskProvisioningType(ds);
    if (provisionType != null) {
        backing.setThinProvisioned(provisionType == VirtualDiskType.THIN);
        backing.setEagerlyScrub(provisionType == VirtualDiskType.EAGER_ZEROED_THICK);
    }
    backing.setFileName(destName);
    backing.setDatastore(getDataStoreForDisk(ds, pbmSpec));
    VirtualDisk disk = new VirtualDisk();
    disk.setBacking(backing);
    disk.setStorageIOAllocation(getStorageIOAllocationInfo(ds));
    disk.setControllerKey(scsiController.getKey());
    disk.setUnitNumber(unitNumber);
    fillInControllerUnitNumber(ds, unitNumber);
    disk.setKey(-1);
    VirtualDeviceConfigSpec change = new VirtualDeviceConfigSpec();
    change.setDevice(disk);
    // Add storage policy spec
    if (pbmSpec != null) {
        pbmSpec.stream().forEach(sp -> {
            change.getProfile().add(sp);
        });
    }
    change.setOperation(VirtualDeviceConfigSpecOperation.ADD);
    return change;
}
Also used : TaskInfo(com.vmware.vim25.TaskInfo) VirtualDiskFlatVer2BackingInfo(com.vmware.vim25.VirtualDiskFlatVer2BackingInfo) VirtualDeviceConfigSpec(com.vmware.vim25.VirtualDeviceConfigSpec) VirtualDiskType(com.vmware.vim25.VirtualDiskType) VirtualDiskSpec(com.vmware.vim25.VirtualDiskSpec) VirtualDisk(com.vmware.vim25.VirtualDisk) ClientUtils.getListOfVirtualDisk(com.vmware.photon.controller.model.adapters.vsphere.ClientUtils.getListOfVirtualDisk) ArrayOfManagedObjectReference(com.vmware.vim25.ArrayOfManagedObjectReference) ManagedObjectReference(com.vmware.vim25.ManagedObjectReference)

Aggregations

ManagedObjectReference (com.vmware.vim25.ManagedObjectReference)5 ClientUtils.getListOfVirtualDisk (com.vmware.photon.controller.model.adapters.vsphere.ClientUtils.getListOfVirtualDisk)1 ArrayOfManagedObjectReference (com.vmware.vim25.ArrayOfManagedObjectReference)1 TaskInfo (com.vmware.vim25.TaskInfo)1 VirtualDeviceConfigSpec (com.vmware.vim25.VirtualDeviceConfigSpec)1 VirtualDisk (com.vmware.vim25.VirtualDisk)1 VirtualDiskFlatVer2BackingInfo (com.vmware.vim25.VirtualDiskFlatVer2BackingInfo)1 VirtualDiskSpec (com.vmware.vim25.VirtualDiskSpec)1 VirtualDiskType (com.vmware.vim25.VirtualDiskType)1