Package com.amazonaws.services.ec2.model

Examples of com.amazonaws.services.ec2.model.CreateSecurityGroupResult


    }

    @Override public List<DiscoveryNode> buildDynamicNodes() {
        List<DiscoveryNode> discoNodes = Lists.newArrayList();

        DescribeInstancesResult descInstances = client.describeInstances(new DescribeInstancesRequest());

        logger.trace("building dynamic unicast discovery nodes...");
        for (Reservation reservation : descInstances.getReservations()) {
            if (!groups.isEmpty()) {
                // lets see if we can filter based on groups
                List<String> groupNames = reservation.getGroupNames();
                if (bindAnyGroup) {
                    if (Collections.disjoint(groups, groupNames)) {
View Full Code Here


    private Instance describeInstance(AmazonEC2Client ec2, String ec2InstanceId) {
        Instance ec2Instance = null;
        {
            DescribeInstancesRequest request = new DescribeInstancesRequest();
            request.setInstanceIds(Collections.singletonList(ec2InstanceId));
            DescribeInstancesResult response = ec2.describeInstances(request);

            List<Reservation> reservations = response.getReservations();
            for (Reservation reservation : reservations) {
                for (Instance i : reservation.getInstances()) {
                    if (ec2Instance != null) {
                        throw new IllegalStateException();
                    }
View Full Code Here

            System.out.println("You have access to " + availabilityZones.size() + " availability zones:");
            for (AvailabilityZone zone : availabilityZones) {
                System.out.println(" - " + zone.getZoneName() + " (" + zone.getRegionName() + ")");
            }

            DescribeInstancesResult describeInstancesResult = ec2.describeInstances();
            Set<Instance> instances = new HashSet<Instance>();
            for (Reservation reservation : describeInstancesResult.getReservations()) {
                instances.addAll(reservation.getInstances());
            }

            System.out.println("You have " + instances.size() + " Amazon EC2 instance(s) running.");
View Full Code Here

        for (SpotInstanceRequest spotInstanceRequest : result.getSpotInstanceRequests()) {
          LaunchSpecification launchSpecification = spotInstanceRequest.getLaunchSpecification();
          populateLaunchSpecificationSecurityGroupNames(launchSpecification);
        }
      } else if (response instanceof DescribeInstancesResult) {
        DescribeInstancesResult result = (DescribeInstancesResult)response;
        for (Reservation reservation : result.getReservations()) {
          populateReservationSecurityGroupNames(reservation);
        }
      } else if (response instanceof RunInstancesResult) {
        RunInstancesResult result = (RunInstancesResult)response;
        populateReservationSecurityGroupNames(result.getReservation());
      }
  }
View Full Code Here

     */
    try {
      /*
       * Get current key pair in Amazon
       */
      DescribeKeyPairsRequest describeKeyPairsRequest = new DescribeKeyPairsRequest();
      ec2.describeKeyPairs(describeKeyPairsRequest.withKeyNames(KEY_PAIR_NAME));

      /*
       * If key exists and new key is created, delete old key and replace
       * with new one. Else, do nothing
       */
 
View Full Code Here

        }

        /* Generate key pair in Amazon if necessary */
        try {
            /* Get current key pair in Amazon */
            DescribeKeyPairsRequest describeKeyPairsRequest = new DescribeKeyPairsRequest();
            ec2.describeKeyPairs(describeKeyPairsRequest.withKeyNames(keyPairName));

            /* If key exists and new key is created, delete old key and replace
             * with new one. Else, do nothing */
            if (newKey) {
                DeleteKeyPairRequest deleteKeyPairRequest = new DeleteKeyPairRequest(keyPairName);
View Full Code Here

   *
   * @return list of keypairs
   */
  public static List<String> loadKeypairs(){
    List<String> resultList = new ArrayList<String>();
    DescribeKeyPairsResult results = getEC2Client().describeKeyPairs();
    for (KeyPairInfo key : results.getKeyPairs()) {
      resultList.add(key.getKeyName());
    }
    return resultList;
  }
View Full Code Here

     * For backwards compatibility, we preserve the existing List<String> of
     * security group names by explicitly populating it from the full list
     * of security group info.
     */
      if (response instanceof DescribeSpotInstanceRequestsResult) {
        DescribeSpotInstanceRequestsResult result = (DescribeSpotInstanceRequestsResult)response;
        for (SpotInstanceRequest spotInstanceRequest : result.getSpotInstanceRequests()) {
          LaunchSpecification launchSpecification = spotInstanceRequest.getLaunchSpecification();
          populateLaunchSpecificationSecurityGroupNames(launchSpecification);
        }
      } else if (response instanceof RequestSpotInstancesResult) {
        RequestSpotInstancesResult result = (RequestSpotInstancesResult)response;
        for (SpotInstanceRequest spotInstanceRequest : result.getSpotInstanceRequests()) {
          LaunchSpecification launchSpecification = spotInstanceRequest.getLaunchSpecification();
          populateLaunchSpecificationSecurityGroupNames(launchSpecification);
        }
      } else if (response instanceof DescribeInstancesResult) {
        DescribeInstancesResult result = (DescribeInstancesResult)response;
        for (Reservation reservation : result.getReservations()) {
          populateReservationSecurityGroupNames(reservation);
        }
      } else if (response instanceof RunInstancesResult) {
        RunInstancesResult result = (RunInstancesResult)response;
        populateReservationSecurityGroupNames(result.getReservation());
      }
  }
View Full Code Here

  @Named("beanstalk.env.id")
  public String getEnvId(@Named("aws.instance.id") String instanceId, AmazonEC2 ec2) {
    DescribeInstancesRequest request = new DescribeInstancesRequest()
        .withInstanceIds(instanceId)
        .withFilters(
            new Filter("instance-state-name").withValues("running"));

    for (Reservation r : ec2.describeInstances(request).getReservations()) {
      for (Instance i : r.getInstances()) {
        for (Tag t : i.getTags()) {
          if ("elasticbeanstalk:environment-id".equals(t.getKey())) {
View Full Code Here

  @Named("beanstalk.env.name")
  public String getEnvName(@Named("aws.instance.id") String instanceId, AmazonEC2 ec2) {
    DescribeInstancesRequest request = new DescribeInstancesRequest()
        .withInstanceIds(instanceId)
        .withFilters(
            new Filter("instance-state-name").withValues("running"));

    for (Reservation r : ec2.describeInstances(request).getReservations()) {
      for (Instance i : r.getInstances()) {
        for (Tag t : i.getTags()) {
          if ("elasticbeanstalk:environment-name".equals(t.getKey())) {
View Full Code Here

TOP

Related Classes of com.amazonaws.services.ec2.model.CreateSecurityGroupResult

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.