Package com.amazonaws.services.ec2.model

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


   * Amazon EC2 instance type
   */
  public final static String[] INSTANCE_TYPE = { "t1.micro", "m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "c1.medium", "c1.xlarge" };
 
  private static AmazonEC2 getEC2Client() {
    AmazonEC2 ec2 = new AmazonEC2Client(new BasicAWSCredentials(AmazonCredential.getInstance().getAwsAccessKeyId(), AmazonCredential.getInstance().getAwsSecretAccessKey()));
    return ec2;
  }
View Full Code Here


  private AmazonEC2 newClient() {

    final AWSCredentials credentials = new BasicAWSCredentials(
        this.awsAccessKey, this.awsSecretKey);

    final AmazonEC2 amazonClient = new AmazonEC2Client(credentials);

    amazonClient.setEndpoint(endpoint);

    return amazonClient;

  }
View Full Code Here

  private CloudWatchMonitor monitor;
  private List<Map<String, Integer>> instancesIdsAndStates;

  public Provisioner()
  {
    this.ec2Client = new AmazonEC2Client(new ClasspathPropertiesFileCredentialsProvider());
    this.monitor = new CloudWatchMonitor();
    ec2Client.setEndpoint("ec2.us-west-2.amazonaws.com");
    this.instancesIdsAndStates = new ArrayList<Map<String, Integer>>();
    initInstancesIdsAndStates();
  }
View Full Code Here

  public Worker()
  {
    this.client = new DefaultHttpClient();
    BasicAWSCredentials credentials = new BasicAWSCredentials("", "");
    this.amazonEC2Client = new AmazonEC2Client(credentials);
    amazonEC2Client.setEndpoint("ec2.us-west-2.amazonaws.com");
  }
View Full Code Here

            credentials = new AWSCredentialsProviderChain(
                    new StaticCredentialsProvider(new BasicAWSCredentials(account, key))
            );
        }

        this.client = new AmazonEC2Client(credentials, clientConfiguration);

        if (componentSettings.get("ec2.endpoint") != null) {
            String endpoint = componentSettings.get("ec2.endpoint");
            logger.debug("using explicit ec2 endpoint [{}]", endpoint);
            client.setEndpoint(endpoint);
View Full Code Here

            throw new GFacProviderException("EC2 Username is empty", jobExecutionContext);

        /* Need to start EC2 instance before running it */
        AWSCredentials credential =
                new BasicAWSCredentials(amazonSecurityContext.getAccessKey(), amazonSecurityContext.getSecretKey());
        AmazonEC2Client ec2client = new AmazonEC2Client(credential);

        initEc2Environment(jobExecutionContext, ec2client);
        checkConnection(instance, ec2client);
    }
View Full Code Here

   * Amazon EC2 instance type
   */
  public final static String[] INSTANCE_TYPE = { "t1.micro", "m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "c1.medium", "c1.xlarge" };
 
  private static AmazonEC2 getEC2Client() {
    AmazonEC2 ec2 = new AmazonEC2Client(new BasicAWSCredentials(AmazonCredential.getInstance().getAwsAccessKeyId(), AmazonCredential.getInstance().getAwsSecretAccessKey()));
    return ec2;
  }
View Full Code Here

   
    /*
     * Need to start EC2 instance before running it
     */
    AWSCredentials credential = new BasicAWSCredentials(access_key, secret_key);
    AmazonEC2Client ec2client = new AmazonEC2Client(credential);
       
    try {
      /*
       * Build key pair before start instance
       */
      buildKeyPair(ec2client);

      // right now, we can run it on one host
      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);
        }

        this.instance = describeInstancesResult.getReservations().get(0).getInstances().get(0);

        // check instance keypair
        if (this.instance.getKeyName() == null || !this.instance.getKeyName().equals(KEY_PAIR_NAME))
          throw new GfacException("Keypair for instance:" + ins_id + " is not valid", FaultCode.InvalidRequest);
      }
     
      //send out instance id
      invocationContext.getExecutionContext().getNotificationService().sendResourceMappingNotifications(this.instance.getPublicDnsName(), "EC2 Instance " + this.instance.getInstanceId() + " is running with public name " + this.instance.getPublicDnsName(), this.instance.getInstanceId());
     

      /*
       * Make sure port 22 is connectable
       */
      for (GroupIdentifier g : this.instance.getSecurityGroups()) {
        IpPermission ip = new IpPermission();
        ip.setIpProtocol("tcp");
        ip.setFromPort(22);
        ip.setToPort(22);
        AuthorizeSecurityGroupIngressRequest r = new AuthorizeSecurityGroupIngressRequest();
        r = r.withIpPermissions(ip.withIpRanges("0.0.0.0/0"));
        r.setGroupId(g.getGroupId());
        try {
          ec2client.authorizeSecurityGroupIngress(r);
        } catch (AmazonServiceException as) {
          /*
           * If exception is from duplicate room, ignore it.
           */
          if (!as.getErrorCode().equals("InvalidPermission.Duplicate"))
View Full Code Here

                throw new ElasticSearchIllegalArgumentException("The configured proxy port value [" + portString + "] is invalid", ex);
            }
            clientConfiguration.withProxyHost(proxyHost).setProxyPort(proxyPort);
        }

        this.client = new AmazonEC2Client(new BasicAWSCredentials(account, key), clientConfiguration);

        if (componentSettings.get("ec2.endpoint") != null) {
            client.setEndpoint(componentSettings.get("ec2.endpoint"));
        } else if (componentSettings.get("region") != null) {
            String endpoint;
View Full Code Here

        /*
         * Need to start EC2 instance before running it
         */
        AWSCredentials credential = new BasicAWSCredentials(access_key, secret_key);
        AmazonEC2Client ec2client = new AmazonEC2Client(credential);

        try {
            /*
             * Build key pair before start instance
             */
            buildKeyPair(ec2client);

            // right now, we can run it on one host
            if (ami_id != null)
                this.instance = startInstances(ec2client, ami_id, ins_type, execContext).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);
                }

                this.instance = describeInstancesResult.getReservations().get(0).getInstances().get(0);

                // check instance keypair
                if (this.instance.getKeyName() == null || !this.instance.getKeyName().equals(KEY_PAIR_NAME))
                    throw new GfacException("Keypair for instance:" + ins_id + " is not valid");
            }

            //TODO send out instance id
            //execContext.getNotificationService().sendResourceMappingNotifications(this.instance.getPublicDnsName(), "EC2 Instance " + this.instance.getInstanceId() + " is running with public name " + this.instance.getPublicDnsName(), this.instance.getInstanceId());


            /*
             * Make sure port 22 is connectable
             */
            for (GroupIdentifier g : this.instance.getSecurityGroups()) {
                IpPermission ip = new IpPermission();
                ip.setIpProtocol("tcp");
                ip.setFromPort(22);
                ip.setToPort(22);
                AuthorizeSecurityGroupIngressRequest r = new AuthorizeSecurityGroupIngressRequest();
                r = r.withIpPermissions(ip.withIpRanges("0.0.0.0/0"));
                r.setGroupId(g.getGroupId());
                try {
                    ec2client.authorizeSecurityGroupIngress(r);
                } catch (AmazonServiceException as) {
                    /*
                     * If exception is from duplicate room, ignore it.
                     */
                    if (!as.getErrorCode().equals("InvalidPermission.Duplicate"))
View Full Code Here

TOP

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

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.