Examples of AmazonEC2Client


Examples of com.amazonaws.services.ec2.AmazonEC2Client

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

        /* Need to start EC2 instance before running it */
        AWSCredentials credential =
                new BasicAWSCredentials(amazonSecurityContext.getAccessKey(), amazonSecurityContext.getSecretKey());
        AmazonEC2Client ec2client = new AmazonEC2Client(credential);
        taskID = jobExecutionContext.getTaskData().getTaskID();
    GFacUtils.saveJobStatus(jobExecutionContext, details, JobState.SETUP);
        initEc2Environment(jobExecutionContext, ec2client);
        checkConnection(instance, ec2client);
    }
View Full Code Here

Examples of com.amazonaws.services.ec2.AmazonEC2Client

    private static AmazonEC2 getEC2Client() {
        // FIXME : Fix this properly after adding UI components.
        String accessKey = "";
        String secretKey = "";
        AmazonEC2 ec2 = new AmazonEC2Client(new BasicAWSCredentials(accessKey, secretKey));
        return ec2;
    }
View Full Code Here

Examples of com.amazonaws.services.ec2.AmazonEC2Client

                                    "Warning", "The file " + file.getAbsolutePath() + " exists.");

                        } else {
                            AWSCredentials credential =
                                    new BasicAWSCredentials(accessID, secretID);
                            AmazonEC2Client ec2client = new AmazonEC2Client(credential);

                            try {
                                EC2ProviderUtil.buildKeyPair(ec2client, EC2Provider.KEY_PAIR_NAME);
                            } catch (NoSuchAlgorithmException e1) {
                                ChangeCredentialWindow.this.engine.getGUI().getErrorWindow().
View Full Code Here

Examples of com.amazonaws.services.ec2.AmazonEC2Client

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

Examples of com.amazonaws.services.ec2.AmazonEC2Client

    {
    }

    public AmazonEC2 get()
    {
        AmazonEC2 ec2Client = new AmazonEC2Client();
        ec2Client.setEndpoint(endpoint.get());
        return ec2Client;
    }
View Full Code Here

Examples of com.amazonaws.services.ec2.AmazonEC2Client

     *
     * @param nodeSet
     */
    public INodeSet performQuery() {
        final NodeSetImpl nodeSet = new NodeSetImpl();
        final AmazonEC2Client ec2 = new AmazonEC2Client(credentials);
        if (null != getEndpoint()) {
            ec2.setEndpoint(getEndpoint());
        }
        final ArrayList<Filter> filters = buildFilters();
        final Set<Instance> instances = query(ec2, new DescribeInstancesRequest().withFilters(filters));


View Full Code Here

Examples of com.amazonaws.services.ec2.AmazonEC2Client

  @Provides
  @LazySingleton
  public AmazonEC2 getEc2Client(AWSCredentials credentials)
  {
    return new AmazonEC2Client(credentials);
  }
View Full Code Here

Examples of com.amazonaws.services.ec2.AmazonEC2Client

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

Examples of com.amazonaws.services.ec2.AmazonEC2Client

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

Examples of com.amazonaws.services.ec2.AmazonEC2Client

                    "Cannot load the credentials from the credential profiles file. " +
                    "Please make sure that your credentials file is at the correct " +
                    "location (~/.aws/credentials), and is in valid format.",
                    e);
        }
        ec2 = new AmazonEC2Client(credentials);
        s3  = new AmazonS3Client(credentials);
        sdb = new AmazonSimpleDBClient(credentials);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.