use of com.vmware.photon.controller.model.resources.DiskService.DiskState in project photon-model by vmware.
the class BaseVSphereAdapterTest method constructDiskState.
protected DiskState constructDiskState(String alias, DiskService.DiskType type, int bootOrder, URI sourceImageReference, long capacityMBytes, HashMap<String, String> customProperties) {
DiskState res = new DiskState();
res.capacityMBytes = capacityMBytes;
if (bootOrder > 0) {
res.bootOrder = bootOrder;
}
res.type = type;
res.id = res.name = "disk-" + alias;
res.sourceImageReference = sourceImageReference;
res.customProperties = customProperties;
return res;
}
use of com.vmware.photon.controller.model.resources.DiskService.DiskState in project photon-model by vmware.
the class BaseVSphereAdapterTest method createDiskWithStoragePolicy.
/**
* Create a new disk state to attach it to the virual machine.
*/
protected DiskState createDiskWithStoragePolicy(String alias, DiskService.DiskType type, int bootOrder, URI sourceImageReference, long capacityMBytes, HashMap<String, String> customProperties) throws Throwable {
DiskState diskState = constructDiskState(alias, type, bootOrder, sourceImageReference, capacityMBytes, customProperties);
diskState.groupLinks = new HashSet<>();
diskState.groupLinks.add(createResourceGroupState().documentSelfLink);
return doPost(this.host, diskState, DiskState.class, UriUtils.buildUri(this.host, DiskService.FACTORY_LINK));
}
use of com.vmware.photon.controller.model.resources.DiskService.DiskState in project photon-model by vmware.
the class TestVSphereProvisionFromImageLink method createBootDisk.
private DiskState createBootDisk(String imageLink) throws Throwable {
DiskService.DiskState res = new DiskService.DiskState();
res.name = nextName("disk");
res.id = res.name;
res.capacityMBytes = 1;
res.bootOrder = 1;
res.type = DiskType.HDD;
res.imageLink = imageLink;
return doPost(this.host, res, DiskService.DiskState.class, UriUtils.buildUri(this.host, DiskService.FACTORY_LINK));
}
use of com.vmware.photon.controller.model.resources.DiskService.DiskState in project photon-model by vmware.
the class TestVSphereDiskService method testDiskCreateAndDeleteWithDatastore.
@Test
public void testDiskCreateAndDeleteWithDatastore() throws Throwable {
prepareEnvironment();
DiskState diskState = createDiskWithDatastore("AdditionalDisk1", DiskService.DiskType.HDD, ADDITIONAL_DISK_SIZE, buildCustomProperties());
testDiskCreateAndDelete(diskState);
}
use of com.vmware.photon.controller.model.resources.DiskService.DiskState in project photon-model by vmware.
the class TestVSphereDiskService method testDiskAvailabilityInVSphereAndDeleteIfAbsent.
@Test
public void testDiskAvailabilityInVSphereAndDeleteIfAbsent() throws Throwable {
if (isMock()) {
return;
}
prepareEnvironment();
// Create a sample disk
DiskState diskState = createDiskWithDatastore("AdditionalDisk1", DiskService.DiskType.HDD, ADDITIONAL_DISK_SIZE, buildCustomProperties());
String documentSelfLink = performDiskRequest(diskState, SubStage.CREATING_DISK);
this.host.waitForFinishedTask(ProvisionDiskTaskService.ProvisionDiskTaskState.class, documentSelfLink);
ServiceDocumentQueryResult result = ProvisioningUtils.queryDiskInstances(this.host, 1);
diskState = Utils.fromJson(result.documents.get(diskState.documentSelfLink), DiskState.class);
// refresh enumeration before delete disk
this.enumerateComputes(this.computeHost, this.endpointState);
// delete disk in vSphere
deleteDiskFromVSphere(diskState);
// refresh enumeration after delete disk, this refresh will sync the deleted disk
this.enumerateComputes(this.computeHost, this.endpointState);
// disk state should be 0
ProvisioningUtils.queryDiskInstances(this.host, 0);
}
Aggregations