Package org.jclouds.openstack.glance.v1_0.options

Examples of org.jclouds.openstack.glance.v1_0.options.CreateImageOptions


                        .put("X-Auth-Token", authToken).build())
            .build();

      HttpResponse updateResponse = HttpResponse.builder().statusCode(404).build();

      GlanceApi apiWhenExist = requestsSendResponses(keystoneAuthWithUsernameAndPassword,
            responseWithKeystoneAccess, versionNegotiationRequest, versionNegotiationResponse,
            get, updateResponse);

      assertEquals(apiWhenExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1"));

      apiWhenExist.getImageApiForZone("az-1.region-a.geo-1")
            .update("fcc451d0-f6e4-4824-ad8f-70ec12326d07",
                  UpdateImageOptions.Builder.name("newname"),
                  UpdateImageOptions.Builder.isPublic(true));
   }


      HttpResponse updateResponse = HttpResponse.builder().statusCode(200)
            .payload(payloadFromResource("/image.json")).build();


      GlanceApi apiWhenExist = requestsSendResponses(keystoneAuthWithUsernameAndPassword,
            responseWithKeystoneAccess, versionNegotiationRequest, versionNegotiationResponse,
            get, updateResponse);

      assertEquals(apiWhenExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1"));

      assertEquals(apiWhenExist.getImageApiForZone("az-1.region-a.geo-1").upload("fcc451d0-f6e4-4824-ad8f-70ec12326d07",
            new StringPayload("somenewdata")), new ParseImageDetailsTest().expected());
   }

      HttpResponse updateResponse = HttpResponse.builder().statusCode(200)
            .payload(payloadFromResource("/image.json")).build();


      GlanceApi apiWhenExist = requestsSendResponses(keystoneAuthWithUsernameAndPassword,
            responseWithKeystoneAccess, versionNegotiationRequest, versionNegotiationResponse,
            get, updateResponse);

      assertEquals(apiWhenExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1"));

      assertEquals(apiWhenExist.getImageApiForZone("az-1.region-a.geo-1").upload("fcc451d0-f6e4-4824-ad8f-70ec12326d07",
            new StringPayload("somenewdata"), UpdateImageOptions.Builder.name("anothernewname")), new ParseImageDetailsTest().expected());
   }

            .payload(payloadFromStringWithContentType("somenewdata", MediaType.APPLICATION_OCTET_STREAM))
            .build();

      HttpResponse updateResponse = HttpResponse.builder().statusCode(403).build();

      GlanceApi apiWhenExist = requestsSendResponses(keystoneAuthWithUsernameAndPassword,
            responseWithKeystoneAccess, versionNegotiationRequest, versionNegotiationResponse,
            get, updateResponse);

      assertEquals(apiWhenExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1"));

      apiWhenExist.getImageApiForZone("az-1.region-a.geo-1").upload("fcc451d0-f6e4-4824-ad8f-70ec12326d07",
            new StringPayload("somenewdata"), UpdateImageOptions.Builder.name("anothernewname"));
   }

            .addHeader("Accept", MediaType.APPLICATION_JSON)
            .addHeader("X-Auth-Token", authToken).build();

      HttpResponse getResponse = HttpResponse.builder().statusCode(200).build();

      GlanceApi apiWhenExist = requestsSendResponses(keystoneAuthWithUsernameAndPassword,
            responseWithKeystoneAccess, versionNegotiationRequest, versionNegotiationResponse,
            get, getResponse);

      assertEquals(apiWhenExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1"));

      assertTrue(apiWhenExist.getImageApiForZone("az-1.region-a.geo-1").delete("fcc451d0-f6e4-4824-ad8f-70ec12326d07"));
   }

            .addHeader("X-Auth-Token", authToken).build();


      HttpResponse getResponse = HttpResponse.builder().statusCode(404).build();

      GlanceApi apiWhenExist = requestsSendResponses(keystoneAuthWithUsernameAndPassword,
            responseWithKeystoneAccess, versionNegotiationRequest, versionNegotiationResponse,
            get, getResponse);

      assertEquals(apiWhenExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1"));

      assertFalse(apiWhenExist.getImageApiForZone("az-1.region-a.geo-1").delete("fcc451d0-f6e4-4824-ad8f-70ec12326d07"));
   }


      HttpResponse listResponse = HttpResponse.builder().statusCode(200)
            .payload(payloadFromResource("/images.json")).build();

      GlanceApi apiWhenExist = requestsSendResponses(keystoneAuthWithUsernameAndPassword,
            responseWithKeystoneAccess, versionNegotiationRequest, versionNegotiationResponse,
            list, listResponse);

      assertEquals(apiWhenExist.getImageApiForZone("az-1.region-a.geo-1").list().concat().toString(),
            new ParseImagesTest().expected().toString());
   }

   public void testNonExistentVersion() throws Exception {
      // The referenced resource only an endpoint for v999.999 of the GlanceApi
      HttpResponse localVersionNegotiationResponse = HttpResponse.builder().statusCode(300).message("HTTP/1.1 300 Multiple Choices").payload(
            payloadFromResourceWithContentType("/glanceVersionResponseVersionUnavailable.json", "application/json")).build();

      GlanceApi apiWhenExist = requestsSendResponses(keystoneAuthWithUsernameAndPassword,
            responseWithKeystoneAccess, versionNegotiationRequest, localVersionNegotiationResponse);

      apiWhenExist.getImageApiForZone("az-1.region-a.geo-1").list();
   }


      HttpResponse listResponse = HttpResponse.builder().statusCode(200)
            .payload(payloadFromResource("/images.json")).build();

      GlanceApi apiWhenExist = requestsSendResponses(keystoneAuthWithUsernameAndPassword,
            localResponseWithKeystoneAccess, versionNegotiationRequest, versionNegotiationResponse,
            list, listResponse);

      assertEquals(apiWhenExist.getImageApiForZone("az-1.region-a.geo-1").list().concat().toString(),
            new ParseImagesTest().expected().toString());
   }


      HttpResponse listResponse = HttpResponse.builder().statusCode(200)
            .payload(payloadFromResource("/images.json")).build();

      GlanceApi apiWhenExist = requestsSendResponses(keystoneAuthWithUsernameAndPassword,
            responseWithKeystoneAccess, list, listResponse);

      assertEquals(apiWhenExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1"));

      assertEquals(apiWhenExist.getImageApiForZone("az-1.region-a.geo-1").list().concat().toString(),
            new ParseImagesTest().expected().toString());
   }

TOP

Related Classes of org.jclouds.openstack.glance.v1_0.options.CreateImageOptions

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.