Example usage for com.amazonaws.services.ec2.model InstanceState setName

List of usage examples for com.amazonaws.services.ec2.model InstanceState setName

Introduction

In this page you can find the example usage for com.amazonaws.services.ec2.model InstanceState setName.

Prototype


public void setName(InstanceStateName name) 

Source Link

Document

The current state of the instance.

Usage

From source file:jp.primecloud.auto.aws.typica.converter.InstanceConverter.java

License:Open Source License

@Override
protected Instance convertObject(com.xerox.amazonws.ec2.ReservationDescription.Instance from) {
    Instance to = new Instance();

    to.setInstanceId(from.getInstanceId());
    to.setImageId(from.getImageId());//from   ww  w . j  av a 2 s .  c o  m

    InstanceState state = new InstanceState();
    state.setCode(from.getStateCode());
    state.setName(from.getState());
    to.setState(state);

    to.setPrivateDnsName(from.getPrivateDnsName());
    to.setPublicDnsName(from.getDnsName());
    to.setStateTransitionReason(from.getReason());
    to.setKeyName(from.getKeyName());
    to.setAmiLaunchIndex(null);
    to.setProductCodes(null);
    to.setInstanceType(from.getInstanceType().name());
    to.setLaunchTime(from.getLaunchTime().getTime());

    Placement placement = new Placement();
    placement.setAvailabilityZone(from.getAvailabilityZone());
    placement.setGroupName(null); // 
    to.setPlacement(placement);

    to.setKernelId(from.getKernelId());
    to.setRamdiskId(from.getRamdiskId());
    to.setPlatform(from.getPlatform());

    Monitoring monitoring = new Monitoring();
    monitoring.setState(Boolean.toString(from.isMonitoring()));
    to.setMonitoring(monitoring);

    // 
    to.setSubnetId(null);
    to.setVpcId(null);
    to.setPrivateIpAddress(null);
    to.setPublicIpAddress(null);
    to.setStateReason(null);
    //to.setArchitecture(null);
    to.setRootDeviceName(null);
    to.setRootDeviceName(null);
    to.setBlockDeviceMappings(null);
    //to.setVirtualizationType(null);
    //to.setInstanceLifecycle(null);
    to.setSpotInstanceRequestId(null);
    //to.setLicense(null);
    to.setClientToken(null);
    to.setTags(null);

    return to;
}

From source file:jp.primecloud.auto.aws.typica.converter.InstanceStateChangeTerminateConverter.java

License:Open Source License

@Override
protected InstanceStateChange convertObject(TerminatingInstanceDescription from) {
    InstanceStateChange to = new InstanceStateChange();

    to.setInstanceId(from.getInstanceId());

    InstanceState previousState = new InstanceState();
    previousState.setCode(from.getPreviousStateCode());
    previousState.setName(from.getPreviousState());
    to.setPreviousState(previousState);/* ww w. j  av a  2  s. com*/

    InstanceState currentState = new InstanceState();
    currentState.setCode(from.getShutdownStateCode());
    currentState.setName(from.getShutdownState());
    to.setCurrentState(currentState);

    return to;
}

From source file:org.jenkinsci.plugins.ec2harness.MockAmazonEC2.java

License:Open Source License

@Override
public RunInstancesResult runInstances(RunInstancesRequest runInstancesRequest)
        throws AmazonServiceException, AmazonClientException {
    printcall();/*from   w  w w  . j av  a  2 s  .  c  o m*/

    Instance instance = new Instance();
    Random random = new Random();
    instance.setInstanceId("" + random.nextInt(10000));
    InstanceState instanceState = new InstanceState();
    instanceState.setName(InstanceStateName.Running);
    instance.setState(instanceState);

    ArrayList<Instance> instances = new ArrayList<Instance>();
    instances.add(instance);
    this.instances.add(instance);

    Reservation reservation = new Reservation();
    reservation.setInstances(instances);

    RunInstancesResult runInstancesResult = new RunInstancesResult();
    runInstancesResult.setReservation(reservation);

    return runInstancesResult;
}