Search in sources :

Example 76 with ActionResponse

use of org.openstack4j.model.common.ActionResponse in project openstack4j by ContainX.

the class KeystoneUserServiceTests method changeUserPassword_fail_Test.

/**
     * tries to change the password for an non existent user fails
     *
     * @throws Exception
     */
public void changeUserPassword_fail_Test() throws Exception {
    respondWithCodeAndResource(404, JSON_USER_CHANGE_PASSWORD_FAIL);
    ActionResponse response_changePassword_fail = osv3().identity().users().changePassword("invalidUser", "OriginalPassword", "password");
    assertFalse(response_changePassword_fail.isSuccess());
}
Also used : ActionResponse(org.openstack4j.model.common.ActionResponse)

Example 77 with ActionResponse

use of org.openstack4j.model.common.ActionResponse in project openstack4j by ContainX.

the class ServerTagTests method deleteAllTags.

@Test
public void deleteAllTags() {
    respondWith(204);
    ActionResponse delete = osv3().compute().serverTags().deleteAll("1");
    System.out.println(delete.getCode());
    assertTrue(delete.isSuccess());
}
Also used : ActionResponse(org.openstack4j.model.common.ActionResponse) AbstractTest(org.openstack4j.api.AbstractTest) Test(org.testng.annotations.Test)

Example 78 with ActionResponse

use of org.openstack4j.model.common.ActionResponse in project openstack4j by ContainX.

the class FloatingIPTests method addFloatingIP.

@Test(dataProvider = "floatingIPs")
public void addFloatingIP(String ip) {
    String serverId = "255b83fd-1193-44a8-aba5-9887b347a41d";
    // Test add floatingIP success
    respondWith(202);
    ActionResponse successResponse = osv3().compute().floatingIps().addFloatingIP(serverId, ip);
    assertNotNull(successResponse);
    assertTrue(successResponse.isSuccess());
    // Test add floatingIP fail -- server instance not existed
    String jsonResponse = String.format("{\"itemNotFound\": {" + "\"message\": \"Instance %s could not be found.\", " + "\"code\": 404}}", serverId);
    respondWith(404, jsonResponse);
    ActionResponse failureResponse = osv3().compute().floatingIps().addFloatingIP(serverId, ip);
    assertNotNull(failureResponse);
    assertFalse(failureResponse.isSuccess());
    assertEquals(failureResponse.getCode(), 404);
    // Test add floatingIP fail -- floatingIP not existed
    String jsonResponse2 = String.format("{\"itemNotFound\": {" + "\"message\": \"floating ip not found\", " + "\"code\": 404}}");
    respondWith(404, jsonResponse2);
    ActionResponse failureResponse2 = osv3().compute().floatingIps().addFloatingIP(serverId, ip);
    assertNotNull(failureResponse2);
    assertFalse(failureResponse2.isSuccess());
    assertEquals(failureResponse2.getCode(), 404);
}
Also used : ActionResponse(org.openstack4j.model.common.ActionResponse) Test(org.testng.annotations.Test) AbstractTest(org.openstack4j.api.AbstractTest)

Example 79 with ActionResponse

use of org.openstack4j.model.common.ActionResponse in project camel by apache.

the class SnapshotProducer method doDelete.

private void doDelete(Exchange exchange) {
    final Message msg = exchange.getIn();
    final String id = msg.getHeader(OpenstackConstants.ID, msg.getHeader(CinderConstants.SNAPSHOT_ID, String.class), String.class);
    ObjectHelper.notEmpty(id, "Cinder Snapshot ID");
    final ActionResponse out = os.blockStorage().snapshots().delete(id);
    checkFailure(out, msg, "Delete snapshot " + id);
}
Also used : Message(org.apache.camel.Message) ActionResponse(org.openstack4j.model.common.ActionResponse)

Example 80 with ActionResponse

use of org.openstack4j.model.common.ActionResponse in project camel by apache.

the class SnapshotProducer method doUpdate.

private void doUpdate(Exchange exchange) {
    final Message msg = exchange.getIn();
    final String id = msg.getHeader(OpenstackConstants.ID, msg.getHeader(CinderConstants.SNAPSHOT_ID, String.class), String.class);
    final VolumeSnapshot vs = messageToSnapshot(msg);
    ObjectHelper.notEmpty(id, "Cinder Snapshot ID");
    final ActionResponse out = os.blockStorage().snapshots().update(id, vs.getName(), vs.getDescription());
    checkFailure(out, msg, "Update volume snapshot " + id);
}
Also used : Message(org.apache.camel.Message) VolumeSnapshot(org.openstack4j.model.storage.block.VolumeSnapshot) ActionResponse(org.openstack4j.model.common.ActionResponse)

Aggregations

ActionResponse (org.openstack4j.model.common.ActionResponse)123 AbstractTest (org.openstack4j.api.AbstractTest)54 Test (org.testng.annotations.Test)54 Message (org.apache.camel.Message)25 ArrayList (java.util.ArrayList)2 CreateUpdateContainerOptions (org.openstack4j.model.storage.object.options.CreateUpdateContainerOptions)2 TroveBuilders (org.openstack4j.openstack.trove.builder.TroveBuilders)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 InputStream (java.io.InputStream)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)1 ResponseToActionResponse (org.openstack4j.core.transport.functions.ResponseToActionResponse)1 Action (org.openstack4j.model.compute.Action)1 User (org.openstack4j.model.identity.v3.User)1 Volume (org.openstack4j.model.storage.block.Volume)1 VolumeSnapshot (org.openstack4j.model.storage.block.VolumeSnapshot)1 KeystoneUser (org.openstack4j.openstack.identity.v3.domain.KeystoneUser)1 TroveDatabase (org.openstack4j.openstack.trove.domain.TroveDatabase)1