Package com.amazonaws.services.ec2.model

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


    }

    private InstanceNetworkInterface findNetworkInterface(Instance ec2Instance, int deviceIndex) {
        InstanceNetworkInterface networkInterface = null;
        for (InstanceNetworkInterface i : ec2Instance.getNetworkInterfaces()) {
            InstanceNetworkInterfaceAttachment attachment = i.getAttachment();
            if (attachment == null) {
                log.error("EC2 network attachment on instance was null");
                continue;
            }

            Integer attachmentDeviceIndex = attachment.getDeviceIndex();
            if (attachmentDeviceIndex == null) {
                log.error("EC2 device index was null");
                continue;
            }
View Full Code Here


             * "Did not find network interface after attaching: " +
             * created.getNetworkInterfaceId()); }
             */
        }

        InstancePrivateIpAddress privateIp = findUnusedIp(networkInterface);

        if (privateIp == null) {
            // TODO: Prune private ip addresses from NICs?
            // TODO: Need to tag??

            {
                AssignPrivateIpAddressesRequest request = new AssignPrivateIpAddressesRequest();
                request.setNetworkInterfaceId(networkInterface.getNetworkInterfaceId());
                request.setSecondaryPrivateIpAddressCount(1);
                ec2.assignPrivateIpAddresses(request);
            }

            ec2Instance = describeInstance(ec2, ec2InstanceId);
            networkInterface = findNetworkInterface(ec2Instance, networkInterfaceIndex);
            privateIp = findUnusedIp(networkInterface);

            if (privateIp == null) {
                throw new IllegalStateException("Unable to find private IP address");
            }
        }

        String privateIpAddress = privateIp.getPrivateIpAddress();

        {
            AssociateAddressRequest request = new AssociateAddressRequest();
            request.setPublicIp(vip.getData().getIp());
            request.setPrivateIpAddress(privateIpAddress);
View Full Code Here

                if (filterByTag) {
                    logger.trace("filtering out instance {} based tags {}, not part of {}", instance.getInstanceId(), tags, instance.getTags());
                    continue;
                }

                InstanceState state = instance.getState();
                if (state.getName().equalsIgnoreCase("pending") || state.getName().equalsIgnoreCase("running")) {
                    String address = null;
                    switch (hostType) {
                        case PRIVATE_DNS:
                            address = instance.getPrivateDnsName();
                            break;
View Full Code Here

      /*
       * 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) {
          /*
 
View Full Code Here

  public static List<Instance> loadInstances() {
    List<Instance> resultList = new ArrayList<Instance>();
    DescribeInstancesResult describeInstancesResult = getEC2Client().describeInstances();
    List<Reservation> reservations = describeInstancesResult.getReservations();
    for (Iterator<Reservation> iterator = reservations.iterator(); iterator.hasNext();) {
      Reservation reservation = iterator.next();
      for (Instance instance : reservation.getInstances()) {
        resultList.add(instance);
      }
    }
    return resultList;
  }
View Full Code Here

    public static List<Instance> loadInstances() {
        List<Instance> resultList = new ArrayList<Instance>();
        DescribeInstancesResult describeInstancesResult = getEC2Client().describeInstances();
        List<Reservation> reservations = describeInstancesResult.getReservations();
        for (Iterator<Reservation> iterator = reservations.iterator(); iterator.hasNext();) {
            Reservation reservation = iterator.next();
            for (Instance instance : reservation.getInstances()) {
                resultList.add(instance);
            }
        }
        return resultList;
    }
View Full Code Here

    public static List<Instance> loadInstances() {
        List<Instance> resultList = new ArrayList<Instance>();
        DescribeInstancesResult describeInstancesResult = getEC2Client().describeInstances();
        List<Reservation> reservations = describeInstancesResult.getReservations();
        for (Iterator<Reservation> iterator = reservations.iterator(); iterator.hasNext();) {
            Reservation reservation = iterator.next();
            for (Instance instance : reservation.getInstances()) {
                resultList.add(instance);
            }
        }
        return resultList;
    }
View Full Code Here

        List<String> instanceIds = Lists.newArrayList("i-123", "i-456");
        when(execution.getVariable(ProcessVariables.INSTANCE_IDS)).thenReturn(instanceIds);

        when(client.describeInstances(Matchers.<DescribeInstancesRequest>any()))
            .thenReturn(new DescribeInstancesResult()
                .withReservations(new Reservation().withInstances(
                    new Instance().withInstanceId("i-123").withPublicDnsName("i1.amazonaws.com")
                        .withPublicIpAddress("1.2.3.4").withPrivateDnsName("i1.internal").withPrivateIpAddress("10.1.2.3"),
                    new Instance().withInstanceId("i-456").withPublicDnsName("i2.amazonaws.com")
                        .withPublicIpAddress("5.6.7.8").withPrivateDnsName("i2.internal").withPrivateIpAddress("10.4.5.6")
                )));
View Full Code Here

    DescribeInstancesRequest request = new DescribeInstancesRequest()
    .withInstanceIds(this.instanceId);
    DescribeInstancesResult result = this.ec2Client
        .describeInstances(request);
    if (!result.getReservations().isEmpty()) {
      Reservation reservation = getOnlyElement(result.getReservations());
      return getOnlyElement(reservation.getInstances()).getState();
    } else {
      throw new NotFoundException(
          "No reservation received for describe instance call");
    }
  }
View Full Code Here

    if (result.getReservations().isEmpty()) {
      throw new IllegalArgumentException(format(
          "no result was received on DescribeInstances for %s",
          this.instanceId));
    }
    Reservation reservation = getOnlyElement(result.getReservations());
    Instance instance = getOnlyElement(reservation.getInstances());
    return instance;
  }
View Full Code Here

TOP

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

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.