Package com.amazonaws.services.ec2.model

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


    final long timeStart = System.currentTimeMillis();

    while (true) {

      final Instance instance = findInstance(instanceId);

      if (isTimeoutPending(timeStart)) {
        logger.error("instance state : timeout");
        throw new Exception("timeout");
      }
View Full Code Here


        instanceList.add(mkInstance("i-123456781"));
        return instanceList;
    }

    private Instance mkInstance(String instanceId) {
        return new Instance().withInstanceId(instanceId)
                .withState(new InstanceState().withName("running"));
    }
View Full Code Here

    @BeforeMethod
    public void setUp() throws Exception {
        MockitoAnnotations.initMocks(this);
        List<Instance> instanceList = Lists.newArrayList();
        Instance instance = new Instance().withInstanceId(VPC_INSTANCE_ID).withVpcId("12345");
        instanceList.add(instance);
        doReturn(instanceList).when(instanceInVPC).getAWSInstances(REGION, VPC_INSTANCE_ID);
        List<Instance> instanceList2 = Lists.newArrayList();
        Instance instance2 = new Instance().withInstanceId(INSTANCE_ID);
        instanceList2.add(instance2);
        doReturn(instanceList2).when(instanceInVPC).getAWSInstances(REGION, INSTANCE_ID);

    }
View Full Code Here

     *
     * @param instanceId id of instance to find
     * @return the instance info, or null if instance not found
     */
    public Instance describeInstance(String instanceId) {
        Instance instance = null;
        for (Instance i : describeInstances(instanceId)) {
            if (instance != null) {
                throw new IllegalStateException("Duplicate instance: " + instanceId);
            }
            instance = i;
View Full Code Here

     * @param instanceId
     *            instance we're checking
     * @return vpc id, or null if not a vpc instance
     */
    String getVpcId(String instanceId) {
        Instance awsInstance = describeInstance(instanceId);

        String vpcId = awsInstance.getVpcId();
        if (Strings.isNullOrEmpty(vpcId)) {
            return null;
        }

        return vpcId;
View Full Code Here

    checkState(isConfigured(), "attempt to use unconfigured ScalingGroup");

    List<Machine> startedMachines = Lists.newArrayList();
    try {
      for (int i = 0; i < count; i++) {
        Instance newInstance = launchInstance(scaleUpConfig);
        startedMachines.add(InstanceToMachine.convert(newInstance));

        newInstance = awaitIpAddress(newInstance);
        startedMachines.set(i, InstanceToMachine.convert(newInstance));
View Full Code Here

  }

  private Instance launchInstance(ScaleUpConfig scaleUpConfig)
      throws ScalingGroupException {
    try {
      Instance launchedInstance = this.client
          .launchInstance(scaleUpConfig);
      // refresh meta data
      return this.client.getInstanceMetadata(launchedInstance
          .getInstanceId());
    } catch (Exception e) {
      throw new ScalingGroupException(format(
          "failed to launch instance: %s", e.getMessage()), e);
    }
View Full Code Here

      this.instanceId = instanceId;
    }

    @Override
    public String call() throws Exception {
      Instance instance = this.client
          .getInstanceMetadata(this.instanceId);
      checkState(instance.getPublicIpAddress() != null,
          "instance has not been assigned a public IP address");
      return instance.getPublicIpAddress();
    }
View Full Code Here

    // no particular availability zone
    String availabilityZone = null;
    String bootscript = Joiner.on("\n").join(
        provisioningDetails.getBootScript());

    Instance startedInstance = new CreateInstance(awsCredentials(),
        region(), availabilityZone,
        provisioningDetails.getSecurityGroups(),
        provisioningDetails.getKeyPair(),
        provisioningDetails.getSize(), provisioningDetails.getImage(),
        bootscript).call();
View Full Code Here

      this.instanceId = instanceId;
    }

    @Override
    public String call() throws Exception {
      Instance instance = this.client
          .getInstanceMetadata(this.instanceId);
      checkState(instance.getPublicIpAddress() != null,
          "instance has not been assigned a public IP address");
      return instance.getPublicIpAddress();
    }
View Full Code Here

TOP

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

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.