use of com.vmware.photon.controller.model.resources.DiskService.DiskState in project photon-model by vmware.
the class TestAWSEnumerationTask method removeS3BucketRegionFromDiskState.
private void removeS3BucketRegionFromDiskState() {
Query query = Query.Builder.create().addKindFieldClause(DiskState.class).addFieldClause(DiskState.FIELD_NAME_ID, TEST_BUCKET_NAME).build();
QueryTask queryTask = QueryTask.Builder.createDirectTask().setQuery(query).addOption(QueryOption.EXPAND_CONTENT).build();
Operation getTestBucketState = QueryUtils.createQueryTaskOperation(this.host, queryTask, ServiceTypeCluster.INVENTORY_SERVICE).setReferer(this.host.getUri());
Operation response = this.host.waitForResponse(getTestBucketState);
QueryTask queryTaskResponse = response.getBody(QueryTask.class);
DiskState testBucketDiskState = Utils.fromJson(queryTaskResponse.results.documents.get(queryTaskResponse.results.documentLinks.get(0)), DiskState.class);
testBucketDiskState.regionId = null;
Operation setNullRegionOp = Operation.createPatch(this.host, testBucketDiskState.documentSelfLink).setBody(testBucketDiskState).setReferer(this.host.getUri());
response = this.host.waitForResponse(setNullRegionOp);
// TODO : This test is broken - Setting the regionId to null does not do anything to the underlying state
if (response.hasPragmaDirective(Operation.PRAGMA_DIRECTIVE_STATE_NOT_MODIFIED)) {
this.isTestBucketPatched = false;
} else {
this.isTestBucketPatched = true;
}
}
use of com.vmware.photon.controller.model.resources.DiskService.DiskState in project photon-model by vmware.
the class TestAWSSetupUtils method getAdditionalDiskConfiguration.
/**
* Returns 2 Test diskStates. first disk is marked for encryption and to persistent on vm delete.
*/
private static List<DiskState> getAdditionalDiskConfiguration(VerificationHost host, EndpointState endpointState, ComputeState computeHost, Boolean persistent) throws Throwable {
List<String[]> additionalDiskConfigs = new ArrayList<>();
String[] disk1properties = { "ebs", "gp2" };
String[] disk2properties = { "ebs", "io1", "900" };
additionalDiskConfigs.add(disk1properties);
additionalDiskConfigs.add(disk2properties);
List<DiskState> disks = new ArrayList<>();
for (int i = 0; i < additionalDiskConfigs.size(); i++) {
DiskState disk = new DiskState();
disk.id = UUID.randomUUID().toString();
disk.documentSelfLink = disk.id;
disk.bootOrder = null;
disk.name = "Test_Volume_" + i;
disk.sourceImageReference = URI.create(imageId);
disk.capacityMBytes = ADDITIONAL_DISK_SIZE_IN_MEBI_BYTES;
// add custom properties to root disk from profile
disk.customProperties = new HashMap<>();
disk.customProperties.put(DEVICE_TYPE, additionalDiskConfigs.get(i)[0]);
disk.customProperties.put(VOLUME_TYPE, additionalDiskConfigs.get(i)[1]);
if (additionalDiskConfigs.get(i).length > 2) {
disk.customProperties.put(DISK_IOPS, additionalDiskConfigs.get(i)[2]);
}
disk.regionId = regionId;
disk.endpointLink = endpointState.documentSelfLink;
disk.endpointLinks = new HashSet<>();
disk.endpointLinks.add(endpointState.documentSelfLink);
disk.authCredentialsLink = endpointState.authCredentialsLink;
disk.tenantLinks = endpointState.tenantLinks;
disk.computeHostLink = endpointState.computeHostLink;
disk.diskAdapterReference = UriUtils.buildUri(host, AWSDiskService.SELF_LINK);
disk.persistent = (i == 0) ? persistent : null;
disk.encrypted = (i == 0) ? true : null;
disk = TestUtils.doPost(host, disk, DiskService.DiskState.class, UriUtils.buildUri(host, DiskService.FACTORY_LINK));
disks.add(disk);
}
return disks;
}
use of com.vmware.photon.controller.model.resources.DiskService.DiskState in project photon-model by vmware.
the class BaseVSphereAdapterTest method createDiskWithDatastore.
/**
* Create a new disk state to attach it to the virtual machine.
*/
protected DiskState createDiskWithDatastore(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.storageDescriptionLink = createStorageDescriptionState().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 BaseVSphereAdapterTest method createCDromWithIso.
/**
* Create a new CD ROM disk state with ISO Image data.
*/
protected DiskState createCDromWithIso(String alias, DiskService.DiskType type, int bootOrder, URI sourceImageReference, long capacityMBytes, HashMap<String, String> customProperties, boolean insertCDRom, boolean withStorageDescription) throws Throwable {
DiskState diskState = constructDiskState(alias, type, bootOrder, sourceImageReference, capacityMBytes, customProperties);
// 150KB
byte[] iso = new byte[150 * 1024];
// of zeroes
Arrays.fill(iso, (byte) 0);
ContentService.ContentState state = new ContentService.ContentState();
state.binaryData = iso;
state = doPost(this.host, state, ContentService.ContentState.class, UriUtils.buildUri(this.host, ContentService.FACTORY_LINK));
CustomProperties.of(diskState).put(PhotonModelConstants.DISK_CONTENT_LINK, state.documentSelfLink);
if (insertCDRom) {
CustomProperties.of(diskState).put(INSERT_CDROM, true);
}
if (withStorageDescription) {
diskState.storageDescriptionLink = createStorageDescriptionState().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 AWSComputeDiskDay2ServiceTest method verifyPersistedDisks.
private void verifyPersistedDisks(boolean isMock, List<DiskState> persistedDisks) throws Throwable {
for (DiskState diskState : persistedDisks) {
assertNotNull(diskState);
assertNotNull(diskState.persistent);
assertTrue(diskState.persistent);
assertNotNull(diskState.id);
if (!isMock) {
assertTrue(diskState.id.startsWith("vol-"));
List<Volume> volumes = getAwsDisksByIds(this.client, this.host, Collections.singletonList(diskState.id));
Volume volume = volumes.get(0);
assertNotNull(volume);
}
}
}
Aggregations