Package com.amazonaws.services.ec2.model

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


   * @return list of newly launched instances
   */
  public static List<Instance> launchInstance(String AMI_ID, String type, Integer number) {
    List<Instance> resultList = new ArrayList<Instance>();

    RunInstancesRequest request = new RunInstancesRequest(AMI_ID, number, number);
    request.setInstanceType(type);

    RunInstancesResult result = getEC2Client().runInstances(request);
    resultList.addAll(result.getReservation().getInstances());
    return resultList;
  }
View Full Code Here


   * @return list of newly launched instances
   */
  public static List<Instance> launchInstance(String AMI_ID, String type, Integer number, String keyname) {
    List<Instance> resultList = new ArrayList<Instance>();

    RunInstancesRequest request = new RunInstancesRequest(AMI_ID, number, number);
    request.setInstanceType(type);
    request.setKeyName(keyname);

    RunInstancesResult result = getEC2Client().runInstances(request);
    resultList.addAll(result.getReservation().getInstances());
    return resultList;
  }
View Full Code Here

  }
 

  private List<Instance> startInstances(AmazonEC2Client ec2, String AMI_ID, String INS_TYPE, NotificationService notifier) throws AmazonServiceException {
    // start only 1 instance
    RunInstancesRequest request = new RunInstancesRequest(AMI_ID, 1, 1);
    request.setKeyName(KEY_PAIR_NAME);
    request.setInstanceType(INS_TYPE);

    RunInstancesResult result = ec2.runInstances(request);

    List<Instance> instances = result.getReservation().getInstances();
View Full Code Here

    List<Instance> resultList = new ArrayList<Instance>();

    RunInstancesRequest request = new RunInstancesRequest(AMI_ID, number, number);
    request.setInstanceType(type);

    RunInstancesResult result = getEC2Client().runInstances(request);
    resultList.addAll(result.getReservation().getInstances());
    return resultList;
  }
View Full Code Here

    RunInstancesRequest request = new RunInstancesRequest(AMI_ID, number, number);
    request.setInstanceType(type);
    request.setKeyName(keyname);

    RunInstancesResult result = getEC2Client().runInstances(request);
    resultList.addAll(result.getReservation().getInstances());
    return resultList;
  }
View Full Code Here

    // start only 1 instance
    RunInstancesRequest request = new RunInstancesRequest(AMI_ID, 1, 1);
    request.setKeyName(KEY_PAIR_NAME);
    request.setInstanceType(INS_TYPE);

    RunInstancesResult result = ec2.runInstances(request);

    List<Instance> instances = result.getReservation().getInstances();

    while (!allInstancesStateEqual(instances, InstanceStateName.Running)) {

      // instance status should not be Terminated
      if (anyInstancesStateEqual(instances, InstanceStateName.Terminated)) {
View Full Code Here

        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

    public void assertSecurityGroupExistsWithRules(String groupName, final Set<Rule> ingressRules) {
        DescribeSecurityGroupsResult result = client.describeSecurityGroups(
            new DescribeSecurityGroupsRequest().withGroupNames(groupName));

        assertThat(result.getSecurityGroups()).hasSize(1);
        SecurityGroup group = getOnlyElement(result.getSecurityGroups());

        assertThat(group.getIpPermissions()).hasSize(ingressRules.size());
        assertThat(ingressRules).containsAll(transform(group.getIpPermissions(),
            ConvertIpPermissionToRule.FUNCTION));
    }
View Full Code Here

    /** {@inheritDoc} */
    @Override
    public String findSecurityGroup(String instanceId, String groupName) {
        String vpcId = getVpcId(instanceId);

        SecurityGroup found = null;
        List<SecurityGroup> securityGroups = describeSecurityGroups(vpcId, groupName);
        for (SecurityGroup sg : securityGroups) {
            if (Objects.equal(vpcId, sg.getVpcId())) {
                if (found != null) {
                    throw new IllegalStateException("Duplicate security groups found");
                }
                found = sg;
            }
        }
        if (found == null) {
            return null;
        }
        return found.getGroupId();
    }
View Full Code Here

    public void assertSecurityGroupExistsWithRules(String groupName, final Set<Rule> ingressRules) {
        DescribeSecurityGroupsResult result = client.describeSecurityGroups(
            new DescribeSecurityGroupsRequest().withGroupNames(groupName));

        assertThat(result.getSecurityGroups()).hasSize(1);
        SecurityGroup group = getOnlyElement(result.getSecurityGroups());

        assertThat(group.getIpPermissions()).hasSize(ingressRules.size());
        assertThat(ingressRules).containsAll(transform(group.getIpPermissions(),
            ConvertIpPermissionToRule.FUNCTION));
    }
View Full Code Here

TOP

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

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.