Package org.jclouds.ec2.compute.internal

Examples of org.jclouds.ec2.compute.internal.EC2TemplateBuilderImpl


      public void run() {
         try {
            Set<SecurityGroup> oneResult = client.describeSecurityGroupsInRegion(null, group);
            assertNotNull(oneResult);
            assertEquals(oneResult.size(), 1);
            SecurityGroup listPair = oneResult.iterator().next();
            assertEquals(listPair.size(), 0);
         } catch (Exception e) {
            throw new AssertionError(e);
         }
      }
View Full Code Here


               IpPermissions.permit(IpProtocol.TCP).port(80));
         assertEventually(new GroupHasPermission(client, group1Name, new TCPPort80AllIPs()));
         Set<SecurityGroup> oneResult = client.describeSecurityGroupsInRegion(null, group1Name);
         assertNotNull(oneResult);
         assertEquals(oneResult.size(), 1);
         final SecurityGroup group = oneResult.iterator().next();
         assertEquals(group.getName(), group1Name);
         IpPermissions group2CanHttpGroup1 = IpPermissions.permit(IpProtocol.TCP).port(80)
               .originatingFromSecurityGroupId(group1Id);
         AWSSecurityGroupClient.class.cast(client).authorizeSecurityGroupIngressInRegion(null, group2Id,
               group2CanHttpGroup1);
         assertEventually(new GroupHasPermission(client, group2Name, new Predicate<IpPermission>() {
            @Override
            public boolean apply(IpPermission arg0) {
               return arg0.getUserIdGroupPairs().equals(ImmutableMultimap.of(group.getOwnerId(), group1Name))
                     && arg0.getFromPort() == 80 && arg0.getToPort() == 80 && arg0.getIpProtocol() == IpProtocol.TCP;
            }
         }));

         AWSSecurityGroupClient.class.cast(client).revokeSecurityGroupIngressInRegion(null, group2Id,
View Full Code Here

         Set<SecurityGroup> oneResult = client.describeSecurityGroupsInRegion(null, group1Name);
         assertNotNull(oneResult);
         assertEquals(oneResult.size(), 1);
         final SecurityGroup group = oneResult.iterator().next();
         assertEquals(group.getName(), group1Name);
         final UserIdGroupPair to = new UserIdGroupPair(group.getOwnerId(), group1Name);
         client.authorizeSecurityGroupIngressInRegion(null, group2Name, to);
         assertEventually(new GroupHasPermission(client, group2Name, new Predicate<IpPermission>() {
            @Override
            public boolean apply(IpPermission arg0) {
               return arg0.getUserIdGroupPairs().equals(ImmutableMultimap.of(group.getOwnerId(), group1Name));
            }
         }));

         client.revokeSecurityGroupIngressInRegion(null, group2Name,
               new UserIdGroupPair(group.getOwnerId(), group1Name));
         assertEventually(new GroupHasNoPermissions(client, group2Name));
      } finally {
         client.deleteSecurityGroupInRegion(null, group2Name);
         client.deleteSecurityGroupInRegion(null, group1Name);
      }
View Full Code Here

   }

   protected void authorizeGroupToItself(String region, String name) {
      logger.debug(">> authorizing securityGroup region(%s) name(%s) permission to itself", region, name);
      String myOwnerId = Iterables.get(securityClient.describeSecurityGroupsInRegion(region, name), 0).getOwnerId();
      securityClient.authorizeSecurityGroupIngressInRegion(region, name, new UserIdGroupPair(myOwnerId, name));
      logger.debug("<< authorized securityGroup(%s)", name);
   }
View Full Code Here

      this.client = client;
   }

   public boolean apply(Attachment attachment) {
      logger.trace("looking for volume %s", attachment.getVolumeId());
      Volume volume = Iterables.getOnlyElement(client.describeVolumesInRegion(attachment
              .getRegion(), attachment.getVolumeId()));

      /*If attachment size is 0 volume is detached for sure.*/
      if (volume.getAttachments().size() == 0) {
         return true;
      }

      /* But if attachment size is > 0, then the attachment could be in any state.
         * So we need to check if the status is DETACHED (return true) or not (return false).
         */
      Attachment lastAttachment = getLast(volume.getAttachments());
      logger.trace("%s: looking for status %s: currently: %s", lastAttachment,
              Attachment.Status.DETACHED, lastAttachment.getStatus());
      return lastAttachment.getStatus() == Attachment.Status.DETACHED;
   }
View Full Code Here

      this.client = client;
   }

   public boolean apply(Attachment attachment) {
      logger.trace("looking for volume %s", attachment.getVolumeId());
      Volume volume = Iterables.getOnlyElement(client.describeVolumesInRegion(attachment
               .getRegion(), attachment.getVolumeId()));
      if (volume.getAttachments().size() == 0) {
         return false;
      }
      Attachment lastAttachment = Sets.newTreeSet(volume.getAttachments()).last();
      logger.trace("%s: looking for status %s: currently: %s", lastAttachment,
               Attachment.Status.ATTACHED, lastAttachment.getStatus());
      return lastAttachment.getStatus() == Attachment.Status.ATTACHED;
   }
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

                                                             .addFormParam("Name", "name").build();

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

      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.compute.internal.EC2TemplateBuilderImpl

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.