Package io.fathom.cloud.compute.api.aws.ec2.model

Examples of io.fathom.cloud.compute.api.aws.ec2.model.Instance


  }

  @Override
  public String call() throws Exception {
    LOG.debug("requesting details for instance '{}'", this.instanceId);
    Instance instance = new GetEc2Instance(getAwsCredentials(),
        getRegion(), this.instanceId).call();
    LOG.debug("got details for instance '{}'", instance);
    String ipAddress = instance.getPublicIpAddress();

    checkState(ipAddress != null,
        "instance has not been assigned a public IP address");
    return ipAddress;
  }
View Full Code Here


        .withInstanceType(this.instanceType)
        .withUserData(AmazonApiUtils.base64Encode(this.bootScript))
        .withSecurityGroupIds(this.securityGroups)
        .withKeyName(this.keyPair).withPlacement(placement);
    RunInstancesResult result = getClient().getApi().runInstances(request);
    Instance launchedInstance = Iterables.getLast(result.getReservation()
        .getInstances());
    // await running and await reachable checks are disabled for now, since
    // they take quite long to finish (especially the reachability check).
    // These checks are also somewhat superfluous if we have boot-time
    // liveness checking enabled.
View Full Code Here

    private List<Reservation> generateReservationsWithInstances() {
        List<Reservation> reservations = Lists.newArrayList();
        for (int i = 0; i < 5; i++) {
            Reservation r = new Reservation();
            List<Instance> instances = Lists.newArrayList();
            instances.add(new Instance().withInstanceId(String.valueOf(new Random().nextInt(100))));
            r.setInstances(instances);
            reservations.add(r);
        }
        return reservations;
    }
View Full Code Here

    }

  }

  private InstanceStateName stateFrom(final String instanceId) {
    final Instance instance = findInstance(instanceId);
    return InstanceStateName.fromValue(instance.getState().getName());
  }
View Full Code Here

  /**
   * http://shlomoswidler.com/2009/07/ec2-instance-life-cycle.html
   */
  public void instanceStart(final String instanceId) throws Exception {

    final Instance instance = findInstance(instanceId);

    final InstanceStateName state = stateFrom(instance);

    logger.info("start: current state=" + state);

View Full Code Here

  /**
   * http://shlomoswidler.com/2009/07/ec2-instance-life-cycle.html
   */
  public void instanceStop(final String instanceId) throws Exception {

    final Instance instance = findInstance(instanceId);

    final InstanceStateName state = stateFrom(instance);

    logger.info("stop: current state=" + state);

View Full Code Here

    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

TOP

Related Classes of io.fathom.cloud.compute.api.aws.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.