Package com.amazonaws.services.ec2.model.transform

Examples of com.amazonaws.services.ec2.model.transform.CreateVolumeRequestMarshaller


        }

        /* 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

  @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

    final String imageId = result.getImageId();

    logger.info("register imageId=" + imageId);

    final Image image = waitForImage(imageId);

    return image;

  }
View Full Code Here

    final StateReason reason = new StateReason();
    reason.setCode(code);
    reason.setMessage(message);

    final Image image = new Image();
    image.setState(state);
    image.setStateReason(reason);

    return image;

  }
View Full Code Here

      final DescribeImagesResult result = amazonClient
          .describeImages(request);

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

      final Image image;

      if (isTimeoutPending(timeStart)) {
        image = newImageWithStatus(State.UNKNOWN.value, "timeout",
            "image create timeout while waiting");
      } else if (imageList == null || imageList.isEmpty()) {
        image = newImageWithStatus(State.UNKNOWN.value, "missing",
            "image create missing in descriptions");
      } else {
        image = imageList.get(0);
      }

      final String value = image.getState();

      final State state = State.fromValue(value);

      switch (state) {
View Full Code Here

       */

      if (newKey) {
        DeleteKeyPairRequest deleteKeyPairRequest = new DeleteKeyPairRequest(KEY_PAIR_NAME);
        ec2.deleteKeyPair(deleteKeyPairRequest);
        ImportKeyPairRequest importKeyPairRequest = new ImportKeyPairRequest(KEY_PAIR_NAME, encodedPublicKey);
        ec2.importKeyPair(importKeyPairRequest);
      }

    } catch (AmazonServiceException ase) {
      /*
       * Key doesn't exists, import new key.
       */
      if(ase.getErrorCode().equals("InvalidKeyPair.NotFound")){     
        ImportKeyPairRequest importKeyPairRequest = new ImportKeyPairRequest(KEY_PAIR_NAME, encodedPublicKey);
        ec2.importKeyPair(importKeyPairRequest);
      }else{
        throw ase;
      }
    }
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(keyPairName);
                ec2.deleteKeyPair(deleteKeyPairRequest);
                ImportKeyPairRequest importKeyPairRequest = new ImportKeyPairRequest(keyPairName, encodedPublicKey);
                ec2.importKeyPair(importKeyPairRequest);
            }

        } catch (AmazonServiceException ase) {
            /* Key doesn't exists, import new key. */
            if (ase.getErrorCode().equals("InvalidKeyPair.NotFound")) {
                ImportKeyPairRequest importKeyPairRequest = new ImportKeyPairRequest(keyPairName, encodedPublicKey);
                ec2.importKeyPair(importKeyPairRequest);
            } else {
                throw ase;
            }
        }
View Full Code Here

public class EC2RequestHandler extends AbstractRequestHandler {
    public void beforeRequest(Request<?> request) {
        AmazonWebServiceRequest originalRequest = request.getOriginalRequest();
        if (originalRequest instanceof ImportKeyPairRequest) {
            ImportKeyPairRequest importKeyPairRequest = (ImportKeyPairRequest)originalRequest;
            String publicKeyMaterial = importKeyPairRequest.getPublicKeyMaterial();
            String encodedKeyMaterial = new String(Base64.encodeBase64(publicKeyMaterial.getBytes()));
            importKeyPairRequest.setPublicKeyMaterial(encodedKeyMaterial);
        }
    }
View Full Code Here

TOP

Related Classes of com.amazonaws.services.ec2.model.transform.CreateVolumeRequestMarshaller

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.