Package com.amazonaws.services.ec2.model

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


    private void addTag(AmazonEC2Client ec2, String id, String key, String value) {
        Tag tag = new Tag(key, value);
        List<Tag> tags = Lists.newArrayList();
        tags.add(tag);

        CreateTagsRequest request = new CreateTagsRequest();
        request.setResources(Collections.singletonList(id));
        request.setTags(tags);

        ec2.createTags(request);

        log.info("Added tag: {}={} to {}", key, value, id);
    }
View Full Code Here


  }

  public void tagCreate(final String resourceId, final String key,
      final String value) {

    final CreateTagsRequest request = new CreateTagsRequest();

    final Collection<String> resourceList = new ArrayList<String>(1);
    resourceList.add(resourceId);

    final Collection<Tag> tagList = new ArrayList<Tag>(1);
    tagList.add(new Tag(key, value));

    request.setResources(resourceList);
    request.setTags(tagList);

    logger.info("tag create request=" + request);

    amazonClient.createTags(request);
View Full Code Here

       * 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(KEY_PAIR_NAME);
        ec2.deleteKeyPair(deleteKeyPairRequest);
        ImportKeyPairRequest importKeyPairRequest = new ImportKeyPairRequest(KEY_PAIR_NAME, encodedPublicKey);
        ec2.importKeyPair(importKeyPairRequest);
      }

View Full Code Here

            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);
                ec2.deleteKeyPair(deleteKeyPairRequest);
                ImportKeyPairRequest importKeyPairRequest = new ImportKeyPairRequest(keyPairName, encodedPublicKey);
                ec2.importKeyPair(importKeyPairRequest);
            }

View Full Code Here

            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);
                ec2.deleteKeyPair(deleteKeyPairRequest);
                ImportKeyPairRequest importKeyPairRequest = new ImportKeyPairRequest(keyPairName, encodedPublicKey);
                ec2.importKeyPair(importKeyPairRequest);
            }

View Full Code Here

  }

  public void tagDelete(final String resourceId, final String key,
      final String value) {

    final DeleteTagsRequest request = new DeleteTagsRequest();

    final Collection<String> resourceList = new ArrayList<String>(1);
    resourceList.add(resourceId);

    final Collection<Tag> tagList = new ArrayList<Tag>(1);
    tagList.add(new Tag(key, value));

    request.setResources(resourceList);
    request.setTags(tagList);

    logger.info("tag delete request=" + request);

    amazonClient.deleteTags(request);
View Full Code Here

             * computing capacity in AWS datacenters.
             *
             * In this sample, we use the EC2 client to list the availability zones
             * in a region, and then list the instances running in those zones.
             */
            DescribeAvailabilityZonesResult availabilityZonesResult = ec2.describeAvailabilityZones();
            List<AvailabilityZone> availabilityZones = availabilityZonesResult.getAvailabilityZones();
            System.out.println("You have access to " + availabilityZones.size() + " availability zones:");
            for (AvailabilityZone zone : availabilityZones) {
                System.out.println(" - " + zone.getZoneName() + " (" + zone.getRegionName() + ")");
            }

View Full Code Here

    final long timeStart = System.currentTimeMillis();

    final List<String> imageIds = new ArrayList<String>();
    imageIds.add(imageId);

    final DescribeImagesRequest request = new DescribeImagesRequest();
    request.setImageIds(imageIds);

    while (true) {

      final DescribeImagesResult result = amazonClient
          .describeImages(request);
View Full Code Here

    final DescribeImagesRequest request = new DescribeImagesRequest();
    request.setImageIds(imageIds);

    while (true) {

      final DescribeImagesResult result = amazonClient
          .describeImages(request);

      final List<Image> imageList = result.getImages();

      final Image image;

      if (isTimeoutPending(timeStart)) {
        image = newImageWithStatus(State.UNKNOWN.value, "timeout",
View Full Code Here

      if (ami_id != null)
        this.instance = startInstances(ec2client, ami_id, ins_type, invocationContext.getExecutionContext().getNotificationService()).get(0);
      else {

        // already running instance
        DescribeInstancesRequest describeInstancesRequest = new DescribeInstancesRequest();
        DescribeInstancesResult describeInstancesResult = ec2client.describeInstances(describeInstancesRequest.withInstanceIds(ins_id));

        if (describeInstancesResult.getReservations().size() == 0 || describeInstancesResult.getReservations().get(0).getInstances().size() == 0) {
          throw new GfacException("Instance not found:" + ins_id, FaultCode.InvalidRequest);
        }
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.