Search in sources :

Example 1 with VolumeBackupCreate

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

the class VolumeBackupTests method createVolumeBackupFromSnapshotV1.

@Test
public void createVolumeBackupFromSnapshotV1() throws Exception {
    respondWith("/storage/v1/volumebackup_create_response.json");
    final String name = "backup1122";
    VolumeBackupCreate create = Builders.volumeBackupCreate().volumeId("999b49ff-a813-45cc-aef3-3ec82f089490").container("container123").description("description123").name(name).incremental(false).snapshotId("b4b3258d-555a-4fce-8f53-69cc2ae96d3c").build();
    VolumeBackup backup = osv3().blockStorage().backups().create(create);
    RecordedRequest request = server.takeRequest();
    assertNotNull(request.getHeader("X-Auth-Token"));
    assertTrue(request.getPath().matches("/v[123]/\\p{XDigit}*/backups"));
    assertEquals(request.getMethod(), "POST");
    String requestBody = request.getBody().readUtf8();
    assertTrue(requestBody.contains("\"volume_id\" : \"999b49ff-a813-45cc-aef3-3ec82f089490\""));
    assertTrue(requestBody.contains("\"snapshot_id\" : \"b4b3258d-555a-4fce-8f53-69cc2ae96d3c\""));
    assertEquals(backup.getName(), name);
    assertNotNull(backup.getId());
    assertEquals(backup.getId(), "7069c687-c85c-45ca-befa-aa78a971fdfe");
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) VolumeBackupCreate(org.openstack4j.model.storage.block.VolumeBackupCreate) VolumeBackup(org.openstack4j.model.storage.block.VolumeBackup) Test(org.testng.annotations.Test) AbstractTest(org.openstack4j.api.AbstractTest)

Example 2 with VolumeBackupCreate

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

the class VolumeBackupTests method createVolumeBackupV1.

@Test
public void createVolumeBackupV1() throws Exception {
    respondWith("/storage/v1/volumebackup_create_response.json");
    final String name = "backup1122";
    VolumeBackupCreate create = Builders.volumeBackupCreate().volumeId("999b49ff-a813-45cc-aef3-3ec82f089490").container("container123").description("description123").name(name).incremental(false).build();
    VolumeBackup backup = osv3().blockStorage().backups().create(create);
    RecordedRequest request = server.takeRequest();
    assertNotNull(request.getHeader("X-Auth-Token"));
    assertTrue(request.getPath().matches("/v[123]/\\p{XDigit}*/backups"));
    assertEquals(request.getMethod(), "POST");
    String requestBody = request.getBody().readUtf8();
    assertTrue(requestBody.contains("\"volume_id\" : \"999b49ff-a813-45cc-aef3-3ec82f089490\""));
    assertEquals(backup.getName(), name);
    assertNotNull(backup.getId());
    assertEquals(backup.getId(), "7069c687-c85c-45ca-befa-aa78a971fdfe");
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) VolumeBackupCreate(org.openstack4j.model.storage.block.VolumeBackupCreate) VolumeBackup(org.openstack4j.model.storage.block.VolumeBackup) Test(org.testng.annotations.Test) AbstractTest(org.openstack4j.api.AbstractTest)

Aggregations

RecordedRequest (okhttp3.mockwebserver.RecordedRequest)2 AbstractTest (org.openstack4j.api.AbstractTest)2 VolumeBackup (org.openstack4j.model.storage.block.VolumeBackup)2 VolumeBackupCreate (org.openstack4j.model.storage.block.VolumeBackupCreate)2 Test (org.testng.annotations.Test)2