@Test public void testAttachVolume() throws TimeoutException { VolumeAttachment volumeAttachment = volumeAttachmentApi .attachVolumeToServerAsDevice(volume.getId(), server.getId(), deviceId); // Wait for the volume to become Attached (aka In Use) before moving on if (!VolumePredicates.awaitInUse(volumeApi).apply(volume)) { throw new TimeoutException("Timeout on volume: " + volume); } assertEquals(volumeAttachment.getVolumeId(), volume.getId()); assertEquals(volumeAttachment.getServerId(), server.getId()); // we can't assert the device because, depending on the implementation, the passed in device may be ignored // and the implementation just picks a device itself }
@Test(expectedExceptions = ResourceNotFoundException.class) public void testAttachVolumeFail() { URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/instance-1/os-volume_attachments"); VolumeAttachmentApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, authenticatedGET().endpoint(endpoint).method("POST") .payload(payloadFromStringWithContentType("{\"volumeAttachment\":{\"volumeId\":\"1\",\"device\":\"/dev/vdc\"}}", MediaType.APPLICATION_JSON)).endpoint(endpoint).build(), HttpResponse.builder().statusCode(404).build() ).getVolumeAttachmentExtensionForZone("az-1.region-a.geo-1").get(); api.attachVolumeToServerAsDevice("1", "instance-1","/dev/vdc"); }
final int before = attachments.size(); VolumeAttachment testAttachment = volumeAttachmentApi.get().attachVolumeToServerAsDevice( testVolume.getId(), serverId, "/dev/vdf"); assertNotNull(testAttachment.getId());
public void testAttachVolume() { URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/instance-1/os-volume_attachments"); VolumeAttachmentApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, authenticatedGET().endpoint(endpoint).method("POST") .payload(payloadFromStringWithContentType("{\"volumeAttachment\":{\"volumeId\":\"1\",\"device\":\"/dev/vdc\"}}", MediaType.APPLICATION_JSON)).endpoint(endpoint).build(), HttpResponse.builder().statusCode(200).payload(payloadFromResource("/attachment_details.json")).build() ).getVolumeAttachmentExtensionForZone("az-1.region-a.geo-1").get(); VolumeAttachment result = api.attachVolumeToServerAsDevice("1", "instance-1", "/dev/vdc"); assertEquals(result, testAttachment()); }
public void testAttachVolume() { URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/instance-1/os-volume_attachments"); VolumeAttachmentApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, authenticatedGET().endpoint(endpoint).method("POST") .payload(payloadFromStringWithContentType("{\"volumeAttachment\":{\"volumeId\":\"1\",\"device\":\"/dev/vdc\"}}", MediaType.APPLICATION_JSON)).endpoint(endpoint).build(), HttpResponse.builder().statusCode(200).payload(payloadFromResource("/attachment_details.json")).build() ).getVolumeAttachmentApi("az-1.region-a.geo-1").get(); VolumeAttachment result = api.attachVolumeToServerAsDevice("1", "instance-1", "/dev/vdc"); assertEquals(result, testAttachment()); }