Search in sources :

Example 1 with VolumeAttachment

use of org.openstack4j.model.storage.block.VolumeAttachment in project openstack4j by ContainX.

the class VolumeTests method getVolumeV2.

@SuppressWarnings("unchecked")
@Test
@SkipTest(connector = ".*", issue = 395, description = "Volume attribute not recognized when using cinder v2 api")
public void getVolumeV2() throws Exception {
    // Check get volume
    respondWith("/storage/v2/volume.json");
    Volume volume = osv3().blockStorage().volumes().get("8a9287b7-4f4d-4213-8d75-63470f19f27c");
    RecordedRequest getRequest = server.takeRequest();
    assertTrue(getRequest.getPath().matches("/v[12]/\\p{XDigit}*/volumes/8a9287b7-4f4d-4213-8d75-63470f19f27c"));
    assertEquals(volume.getId(), "8a9287b7-4f4d-4213-8d75-63470f19f27c");
    assertEquals(volume.getName(), "vol-test");
    assertEquals(volume.getDescription(), "a description");
    assertNotNull(volume.getCreated());
    assertEquals(volume.getZone(), "nova");
    assertEquals(volume.getSize(), 100);
    assertEquals(volume.getStatus(), Volume.Status.IN_USE);
    assertEquals(volume.getSnapshotId(), "22222222-2222-2222-2222-222222222222");
    assertEquals(volume.getSourceVolid(), "11111111-1111-1111-1111-111111111111");
    assertEquals(volume.getVolumeType(), "Gold");
    assertNotNull(volume.getMetaData());
    Map<String, String> metadata = volume.getMetaData();
    assertEquals(metadata.get("readonly"), "False");
    assertEquals(metadata.get("attached_mode"), "rw");
    assertNotNull(volume.getAttachments());
    List<VolumeAttachment> attachments = (List<VolumeAttachment>) volume.getAttachments();
    assertEquals(attachments.get(0).getDevice(), "/dev/vdd");
    assertEquals(attachments.get(0).getHostname(), "myhost");
    assertEquals(attachments.get(0).getId(), "8a9287b7-4f4d-4213-8d75-63470f19f27c");
    assertEquals(attachments.get(0).getServerId(), "eaa6a54d-35c1-40ce-831d-bb61f991e1a9");
    assertEquals(attachments.get(0).getVolumeId(), "8a9287b7-4f4d-4213-8d75-63470f19f27c");
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) VolumeAttachment(org.openstack4j.model.storage.block.VolumeAttachment) Volume(org.openstack4j.model.storage.block.Volume) List(java.util.List) AbstractTest(org.openstack4j.api.AbstractTest) SkipTest(org.openstack4j.api.SkipTest) Test(org.testng.annotations.Test) SkipTest(org.openstack4j.api.SkipTest)

Example 2 with VolumeAttachment

use of org.openstack4j.model.storage.block.VolumeAttachment in project openstack4j by ContainX.

the class VolumeTests method getVolumeV1.

@SuppressWarnings("unchecked")
@Test
public void getVolumeV1() throws Exception {
    // Check get volume
    respondWith("/storage/v1/volume.json");
    Volume volume = osv3().blockStorage().volumes().get("8a9287b7-4f4d-4213-8d75-63470f19f27c");
    RecordedRequest getRequest = server.takeRequest();
    assertTrue(getRequest.getPath().matches("/v[12]/\\p{XDigit}*/volumes/8a9287b7-4f4d-4213-8d75-63470f19f27c"));
    assertEquals(volume.getId(), "8a9287b7-4f4d-4213-8d75-63470f19f27c");
    assertEquals(volume.getName(), "vol-test");
    assertEquals(volume.getDescription(), "a description");
    assertNotNull(volume.getCreated());
    assertEquals(volume.getZone(), "nova");
    assertEquals(volume.getSize(), 100);
    assertEquals(volume.getStatus(), Volume.Status.IN_USE);
    assertEquals(volume.getSnapshotId(), "22222222-2222-2222-2222-222222222222");
    assertEquals(volume.getSourceVolid(), "11111111-1111-1111-1111-111111111111");
    assertEquals(volume.getVolumeType(), "Gold");
    assertNotNull(volume.getMetaData());
    Map<String, String> metadata = volume.getMetaData();
    assertEquals(metadata.get("readonly"), "False");
    assertEquals(metadata.get("attached_mode"), "rw");
    assertNotNull(volume.getAttachments());
    List<VolumeAttachment> attachments = (List<VolumeAttachment>) volume.getAttachments();
    assertEquals(attachments.get(0).getDevice(), "/dev/vdd");
    assertEquals(attachments.get(0).getHostname(), "myhost");
    assertEquals(attachments.get(0).getId(), "8a9287b7-4f4d-4213-8d75-63470f19f27c");
    assertEquals(attachments.get(0).getServerId(), "eaa6a54d-35c1-40ce-831d-bb61f991e1a9");
    assertEquals(attachments.get(0).getVolumeId(), "8a9287b7-4f4d-4213-8d75-63470f19f27c");
    assertEquals(volume.getTenantId(), "b0b5ed7ae06049688349fe43737796d4");
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) VolumeAttachment(org.openstack4j.model.storage.block.VolumeAttachment) Volume(org.openstack4j.model.storage.block.Volume) List(java.util.List) AbstractTest(org.openstack4j.api.AbstractTest) SkipTest(org.openstack4j.api.SkipTest) Test(org.testng.annotations.Test)

Aggregations

List (java.util.List)2 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)2 AbstractTest (org.openstack4j.api.AbstractTest)2 SkipTest (org.openstack4j.api.SkipTest)2 Volume (org.openstack4j.model.storage.block.Volume)2 VolumeAttachment (org.openstack4j.model.storage.block.VolumeAttachment)2 Test (org.testng.annotations.Test)2