use of com.vmware.vim25.VslmCreateSpec in project cloudstack by apache.
the class VirtualStorageObjectManagerMO method createDisk.
public VStorageObject createDisk(ManagedObjectReference morDS, Storage.ProvisioningType diskProvisioningType, long currentSizeInBytes, String datastoreFilepath, String filename) throws Exception {
long currentSizeInMB = currentSizeInBytes / (1024 * 1024);
VslmCreateSpecDiskFileBackingSpec diskFileBackingSpec = new VslmCreateSpecDiskFileBackingSpec();
diskFileBackingSpec.setDatastore(morDS);
if (diskProvisioningType != null) {
if (diskProvisioningType == Storage.ProvisioningType.FAT) {
diskFileBackingSpec.setProvisioningType(BaseConfigInfoDiskFileBackingInfoProvisioningType.EAGER_ZEROED_THICK.value());
} else if (diskProvisioningType == Storage.ProvisioningType.THIN) {
diskFileBackingSpec.setProvisioningType(BaseConfigInfoDiskFileBackingInfoProvisioningType.THIN.value());
} else if (diskProvisioningType == Storage.ProvisioningType.SPARSE) {
diskFileBackingSpec.setProvisioningType(BaseConfigInfoDiskFileBackingInfoProvisioningType.LAZY_ZEROED_THICK.value());
}
}
// path should be just the folder name. For example, instead of '[datastore1] folder1/filename.vmdk' you would just do 'folder1'.
// path is introduced from 6.7. In 6.5 disk will be created in the default folder "fcd"
diskFileBackingSpec.setPath(null);
VslmCreateSpec vslmCreateSpec = new VslmCreateSpec();
vslmCreateSpec.setBackingSpec(diskFileBackingSpec);
vslmCreateSpec.setCapacityInMB(currentSizeInMB);
vslmCreateSpec.setName(filename);
ManagedObjectReference morTask = _context.getService().createDiskTask(_mor, vslmCreateSpec);
boolean result = _context.getVimClient().waitForTask(morTask);
VStorageObject vStorageObject = null;
if (result) {
_context.waitForTaskProgressDone(morTask);
// _context.getService().reconcileDatastoreInventoryTask(_mor, morDS);
TaskInfo taskInfo = TaskMO.getTaskInfo(_context, morTask);
vStorageObject = (VStorageObject) taskInfo.getResult();
} else {
LOGGER.error("VMware CreateDisk_Task failed due to " + TaskMO.getTaskFailureInfo(_context, morTask));
}
return vStorageObject;
}
Aggregations