Package org.jclouds.ec2.features

Examples of org.jclouds.ec2.features.AvailabilityZoneAndRegionApi


                                 iaasInfo;
            log.error(msg);
            throw new InvalidZoneException(msg);
        }
        ComputeServiceContext context = iaasInfo.getComputeService().getContext();
        AvailabilityZoneAndRegionApi zoneRegionApi = context.unwrapApi(AWSEC2Api.class).
            getAvailabilityZoneAndRegionApiForRegion(region).get();
       
        Set<AvailabilityZoneInfo> availabilityZones =
                                                      zoneRegionApi.describeAvailabilityZonesInRegion(region,
                                                              new DescribeAvailabilityZonesOptions[0]);
        for (AvailabilityZoneInfo zoneInfo : availabilityZones) {
            String configuredZone = zoneInfo.getZone();
            if (zone.equalsIgnoreCase(configuredZone)) {
                if (log.isDebugEnabled()) {
View Full Code Here


public class DescribeAvailabilityZonesInRegionTest {
   @Test
   public void testDescribeAvailabilityZonesInRegion_BestEffort() {
      IMocksControl control = createControl();
      EC2Api client = control.createMock(EC2Api.class);
      AvailabilityZoneAndRegionApi regionClient = control.createMock(AvailabilityZoneAndRegionApi.class);
      AvailabilityZoneInfo info1 = control.createMock(AvailabilityZoneInfo.class);
      AvailabilityZoneInfo info2 = control.createMock(AvailabilityZoneInfo.class);
      HttpCommand command = control.createMock(HttpCommand.class);
      HttpResponseException exception = new HttpResponseException("Error: Unable to tunnel through proxy: ...",
               command, null);

      expect(client.getAvailabilityZoneAndRegionApi()).andStubReturn((Optional) Optional.of(regionClient));
      expect(regionClient.describeAvailabilityZonesInRegion("accessibleRegion1")).andReturn(
               ImmutableSet.of(info1));
      expect(regionClient.describeAvailabilityZonesInRegion("inaccessibleRegion")).andThrow(exception);
      expect(regionClient.describeAvailabilityZonesInRegion("accessibleRegion2")).andReturn(
               ImmutableSet.of(info2));
      expect(info1.getZone()).andStubReturn("zone1");
      expect(info2.getZone()).andStubReturn("zone2");

      Set<String> regions = ImmutableSet.of("accessibleRegion1", "inaccessibleRegion", "accessibleRegion2");
View Full Code Here

   @Test
   public void testDescribeAvailabilityZonesInRegion_RethrowIfNoneFound() {
      IMocksControl control = createControl();
      EC2Api client = control.createMock(EC2Api.class);
      AvailabilityZoneAndRegionApi regionClient = control.createMock(AvailabilityZoneAndRegionApi.class);
      HttpCommand command = control.createMock(HttpCommand.class);
      HttpResponseException exception = new HttpResponseException("Error: Unable to tunnel through proxy: ...",
               command, null);

      expect(client.getAvailabilityZoneAndRegionApi()).andStubReturn((Optional) Optional.of(regionClient));
      expect(regionClient.describeAvailabilityZonesInRegion("inaccessibleRegion")).andThrow(exception);

      Set<String> regions = ImmutableSet.of("inaccessibleRegion");
      control.replay();

      DescribeAvailabilityZonesInRegion regionIdToZoneId = new DescribeAvailabilityZonesInRegion(client, Suppliers
View Full Code Here

   @Test
   public void testDescribeAvailabilityZonesInRegion_NoZones() {
      IMocksControl control = createControl();
      EC2Api client = control.createMock(EC2Api.class);
      AvailabilityZoneAndRegionApi regionClient = control.createMock(AvailabilityZoneAndRegionApi.class);

      expect(client.getAvailabilityZoneAndRegionApi()).andStubReturn((Optional) Optional.of(regionClient));
      expect(regionClient.describeAvailabilityZonesInRegion("emptyRegion")).andReturn(
               ImmutableSet.<AvailabilityZoneInfo> of());

      Set<String> regions = ImmutableSet.of("emptyRegion");
      control.replay();
View Full Code Here

public class DescribeAvailabilityZonesInRegionTest {
   @Test
   public void testDescribeAvailabilityZonesInRegion_BestEffort() {
      IMocksControl control = createControl();
      EC2Api client = control.createMock(EC2Api.class);
      AvailabilityZoneAndRegionApi regionClient = control.createMock(AvailabilityZoneAndRegionApi.class);
      AvailabilityZoneInfo info1 = control.createMock(AvailabilityZoneInfo.class);
      AvailabilityZoneInfo info2 = control.createMock(AvailabilityZoneInfo.class);
      HttpCommand command = control.createMock(HttpCommand.class);
      HttpResponseException exception = new HttpResponseException("Error: Unable to tunnel through proxy: ...",
               command, null);

      expect(client.getAvailabilityZoneAndRegionApi()).andStubReturn((Optional) Optional.of(regionClient));
      expect(regionClient.describeAvailabilityZonesInRegion("accessibleRegion1")).andReturn(
               ImmutableSet.of(info1));
      expect(regionClient.describeAvailabilityZonesInRegion("inaccessibleRegion")).andThrow(exception);
      expect(regionClient.describeAvailabilityZonesInRegion("accessibleRegion2")).andReturn(
               ImmutableSet.of(info2));
      expect(info1.getZone()).andStubReturn("zone1");
      expect(info2.getZone()).andStubReturn("zone2");

      Set<String> regions = ImmutableSet.of("accessibleRegion1", "inaccessibleRegion", "accessibleRegion2");
View Full Code Here

   @Test
   public void testDescribeAvailabilityZonesInRegion_RethrowIfNoneFound() {
      IMocksControl control = createControl();
      EC2Api client = control.createMock(EC2Api.class);
      AvailabilityZoneAndRegionApi regionClient = control.createMock(AvailabilityZoneAndRegionApi.class);
      HttpCommand command = control.createMock(HttpCommand.class);
      HttpResponseException exception = new HttpResponseException("Error: Unable to tunnel through proxy: ...",
               command, null);

      expect(client.getAvailabilityZoneAndRegionApi()).andStubReturn((Optional) Optional.of(regionClient));
      expect(regionClient.describeAvailabilityZonesInRegion("inaccessibleRegion")).andThrow(exception);

      Set<String> regions = ImmutableSet.of("inaccessibleRegion");
      control.replay();

      DescribeAvailabilityZonesInRegion regionIdToZoneId = new DescribeAvailabilityZonesInRegion(client, Suppliers
View Full Code Here

   @Test
   public void testDescribeAvailabilityZonesInRegion_NoZones() {
      IMocksControl control = createControl();
      EC2Api client = control.createMock(EC2Api.class);
      AvailabilityZoneAndRegionApi regionClient = control.createMock(AvailabilityZoneAndRegionApi.class);

      expect(client.getAvailabilityZoneAndRegionApi()).andStubReturn((Optional) Optional.of(regionClient));
      expect(regionClient.describeAvailabilityZonesInRegion("emptyRegion")).andReturn(
               ImmutableSet.<AvailabilityZoneInfo> of());

      Set<String> regions = ImmutableSet.of("emptyRegion");
      control.replay();
View Full Code Here

   @Override
   public LoginCredentials apply(final RunningInstance instance) {
      Optional<? extends WindowsApi> windowsOption = ec2Client.getWindowsApiForRegion(instance.getRegion());
      checkState(windowsOption.isPresent(), "windows feature not present in region %s", instance.getRegion());
     
      final WindowsApi windowsApi = windowsOption.get();
     
      LoginCredentials credentials = LoginCredentials.builder().user("Administrator").noPrivateKey().build();
      String privateKey = getPrivateKeyOrNull(instance);
      if (privateKey == null) {
         return credentials;
      }
      // The Administrator password will take some time before it is ready - Amazon says
      // sometimes
      // 15 minutes.
      // So we create a predicate that tests if the password is ready, and wrap it in a retryable
      // predicate.
      final AtomicReference<PasswordData> data = Atomics.newReference();
      Predicate<String> passwordReady = new Predicate<String>() {
         @Override
         public boolean apply(@Nullable String s) {
            if (Strings.isNullOrEmpty(s))
               return false;
            data.set(windowsApi.getPasswordDataForInstance(instance.getId()));
            if (data.get() == null)
               return false;
            return !Strings.isNullOrEmpty(data.get().getPasswordData());
         }
      };
View Full Code Here

                                               .addFormParam("NoReboot", "true").build();

   public void testCreateImageOptions() throws SecurityException, NoSuchMethodException, IOException {
      Invokable<?, ?> method = method(AWSAMIAsyncClient.class, "createImageInRegion", String.class, String.class, String.class,
               CreateImageOptions[].class);
      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "name", "instanceId", new CreateImageOptions()
               .withDescription("description").noReboot()));

      request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
     
      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
View Full Code Here

   public void testRegisterImageBackedByEBSOptions() throws SecurityException, NoSuchMethodException, IOException {
      Invokable<?, ?> method = method(AWSAMIAsyncClient.class, "registerUnixImageBackedByEbsInRegion", String.class,
               String.class, String.class, RegisterImageBackedByEbsOptions[].class);
      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "imageName", "snapshotId",
               new RegisterImageBackedByEbsOptions().withDescription("description").addBlockDeviceFromSnapshot(
                        "/dev/device", null, "snapshot").addNewBlockDevice("/dev/newdevice", "newblock", 100)));

      request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
     
      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
View Full Code Here

TOP

Related Classes of org.jclouds.ec2.features.AvailabilityZoneAndRegionApi

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.