use of com.amazonaws.services.ec2.model.VolumeType in project photon-model by vmware.
the class AWSVolumeTypeDiscoveryService method handleGet.
@Override
public void handleGet(Operation get) {
Map<String, String> params = UriUtils.parseUriQueryParams(get.getUri());
String deviceType = params.get(DEVICE_TYPE);
if (deviceType == null || deviceType.isEmpty()) {
get.fail(new IllegalArgumentException("No deviceType provided."));
return;
}
if (!deviceType.equals(AWSConstants.AWSStorageType.EBS.name().toLowerCase())) {
get.fail(new IllegalArgumentException("Unsupported device Type"));
return;
}
VolumeTypeList volumeTypeList = new VolumeTypeList();
for (VolumeType volumeType : VolumeType.values()) {
volumeTypeList.volumeTypes.add(volumeType.toString());
}
get.setBody(volumeTypeList);
get.complete();
}
use of com.amazonaws.services.ec2.model.VolumeType in project photon-model by vmware.
the class TestProvisionAWSDisk method testDiskProvision.
/**
* This test verified the disk creation and deletion on aws.
*/
@Test
public void testDiskProvision() throws Throwable {
createEndpoint();
this.diskState = createAWSDiskState(this.host, this.endpointState, this.currentTestName.getMethodName() + "_disk1", Boolean.TRUE, null, regionId);
String taskLink = com.vmware.photon.controller.model.adapters.awsadapter.TestUtils.getProvisionDiskTask(this.diskState.documentSelfLink, ProvisionDiskTaskState.SubStage.CREATING_DISK, this.host, this.isMock, this.endpointState.tenantLinks);
this.host.waitForFinishedTask(ProvisionDiskTaskState.class, taskLink);
// check that the disk has been created
ProvisioningUtils.queryDiskInstances(this.host, 1);
DiskState disk = getDisk(this.host, this.diskState.documentSelfLink);
if (!this.isMock) {
String volumeId = disk.id;
assertTrue(volumeId.startsWith(VOLUMEID_PREFIX));
List<Volume> volumes = getAwsDisksByIds(this.client, this.host, Collections.singletonList(volumeId));
Volume volume = volumes.get(0);
// check disk size
assertEquals("Disk size is not matching with the volume size on aws", disk.capacityMBytes, volume.getSize() * 1024);
// check volume type
assertEquals("Disk type is not matching the volume type on aws", disk.customProperties.get("volumeType"), volume.getVolumeType());
// check iops of disk
String diskIops = disk.customProperties.get(DISK_IOPS);
if (diskIops != null) {
int requestedIops = Integer.parseInt(diskIops);
int MAX_SUPPORTED_IOPS = (int) (disk.capacityMBytes / 1024) * 50;
int provisionedIops = Math.min(requestedIops, MAX_SUPPORTED_IOPS);
assertEquals("Disk iops is not matching with the volume on aws", provisionedIops, volume.getIops().intValue());
}
assertEquals("availability zones are not matching", disk.zoneId, volume.getAvailabilityZone());
assertTrue("disk status is not matching", disk.status == DiskService.DiskStatus.AVAILABLE);
assertEquals("disk encryption status not matching", 0, disk.encrypted.compareTo(isEncrypted));
}
// delete the disk using the AWSDiskService.Delete
taskLink = com.vmware.photon.controller.model.adapters.awsadapter.TestUtils.getProvisionDiskTask(this.diskState.documentSelfLink, ProvisionDiskTaskState.SubStage.DELETING_DISK, this.host, this.isMock, this.endpointState.tenantLinks);
this.host.waitForFinishedTask(ProvisionDiskTaskState.class, taskLink);
// check that the disk has been deleted
ProvisioningUtils.queryDiskInstances(this.host, 0);
if (!this.isMock) {
String volumeId = disk.id;
List<Volume> volumes = getAwsDisksByIds(this.client, this.host, Collections.singletonList(volumeId));
// assert that the volume is deleted on aws.
assertNull(volumes);
}
}
use of com.amazonaws.services.ec2.model.VolumeType in project photon-model by vmware.
the class TestAWSProvisionTask method assertBootDiskConfiguration.
protected void assertBootDiskConfiguration(AmazonEC2AsyncClient client, Instance awsInstance, String diskLink) {
DiskState diskState = getDiskState(diskLink);
Volume bootVolume = getVolume(client, awsInstance, awsInstance.getRootDeviceName());
assertEquals("Boot Disk capacity in diskstate is not matching the boot disk size of the " + "vm launched in aws", diskState.capacityMBytes, bootVolume.getSize() * 1024);
assertNotNull("Boot disk creation time cannot be empty", diskState.creationTimeMicros);
assertEquals("Boot disk type in diskstate is not same as the type of the volume attached to the VM", diskState.customProperties.get("volumeType"), bootVolume.getVolumeType());
assertEquals("Boot disk iops in diskstate is the same as the iops of the volume attached to the VM", Integer.parseInt(diskState.customProperties.get("iops")), bootVolume.getIops().intValue());
assertEquals("Boot disk attach status is not matching", DiskService.DiskStatus.ATTACHED, diskState.status);
}
Aggregations