Example usage for com.amazonaws.services.ec2.model Instance getSubnetId

List of usage examples for com.amazonaws.services.ec2.model Instance getSubnetId

Introduction

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

Prototype


public String getSubnetId() 

Source Link

Document

[EC2-VPC] The ID of the subnet in which the instance is running.

Usage

From source file:com.automata.cloudcore.xmlbindings.RunningInstancesItemType.java

License:Open Source License

public RunningInstancesItemType(Instance instance) {
    this.instanceId = instance.getInstanceId();
    InstanceStateType instanceStateType = new InstanceStateType();
    instanceStateType.setName(instance.getInstanceLifecycle());
    //instanceStateType.setCode();
    this.instanceState = instanceStateType;
    this.privateDnsName = instance.getPrivateDnsName();
    this.imageId = instance.getImageId();
    this.dnsName = instance.getPublicDnsName();
    //this.reason   = instance.get
    this.keyName = instance.getKeyName();
    if (instance.getStateTransitionReason() != null)
        this.reason = instance.getStateTransitionReason().toString();
    this.amiLaunchIndex = instance.getAmiLaunchIndex().toString();
    //this.productCodes = instance.getProductCodes();
    this.instanceType = instance.getInstanceType();
    //this.launchTime = instance.getLaunchTime();
    //this.placement = instance.getPlacement();
    this.kernelId = instance.getKernelId();
    this.ramdiskId = instance.getRamdiskId();
    this.platform = instance.getPlatform();

    InstanceMonitoringStateType instanceMonitoringStateType;
    instanceMonitoringStateType = new InstanceMonitoringStateType();
    instanceMonitoringStateType.setState(instance.getMonitoring().toString());
    this.monitoring = instanceMonitoringStateType;

    this.subnetId = instance.getSubnetId();
    this.vpcId = instance.getVpcId();
    this.privateIpAddress = instance.getPrivateIpAddress();
    this.ipAddress = instance.getPublicIpAddress();
    this.sourceDestCheck = instance.getSourceDestCheck();
    //this.groupSet = 

    if (instance.getStateReason() != null) {
        StateReasonType stateReasonType = new StateReasonType();
        stateReasonType.setMessage(instance.getStateReason().getMessage());
        this.stateReason = stateReasonType;
    }// w  w w  .  j  av a2 s.c o  m
    this.architecture = instance.getArchitecture();
    this.rootDeviceType = instance.getRootDeviceType();
    this.rootDeviceName = instance.getRootDeviceName();

    /*BlockDeviceMappingsType blockDeviceMappingsType = new BlockDeviceMappingsType();
    List<BlockDeviceMapping> blockDeviceMappingList = new ArrayList<BlockDeviceMapping>();
    BlockDeviceMapping blockDeviceMapping = new BlockDeviceMapping();
    for (){
               
    }
            
    blockDeviceMappingsType = 
    this.blockDeviceMapping = instance.getBlockDeviceMappings();*/
    this.instanceLifecycle = instance.getInstanceLifecycle();
    this.spotInstanceRequestId = instance.getSpotInstanceRequestId();

    if (instance.getLicense() != null) {
        InstanceLicenseResponseType instanceLicenseResponseType;
        instanceLicenseResponseType = new InstanceLicenseResponseType();
        instanceLicenseResponseType.setPool(instance.getLicense().getPool());
        this.license = instanceLicenseResponseType;
    }

    this.virtualizationType = instance.getVirtualizationType();
    this.clientToken = instance.getClientToken();

    /*ResourceTagSetType resourceTagSetType;
    ResourceTagSetItemType resourceTagSetItemType;
    List<ResourceTagSetItemType> resourceTagSetItemTypeList;
            
    resourceTagSetItemTypeList = new ArrayList<ResourceTagSetItemType>();
            
    resourceTagSetType = new ResourceTagSetType();
    resourceTagSetType.getItem()
    this.tagSet = instance.getTags();
    this.hypervisor = instance.get*/
}

From source file:com.clouck.model.aws.ec2.Ec2Instance.java

@Override
@SuppressWarnings("rawtypes")
protected boolean isEqual(AbstractResource newResource) {
    Instance oldInstance = this.getResource();
    Ec2Instance newEc2Instance = (Ec2Instance) newResource;
    Instance newInstance = newEc2Instance.getResource();

    if (notEqual(oldInstance.getInstanceId(), newInstance.getInstanceId()))
        return false;
    if (notEqual(oldInstance.getImageId(), newInstance.getImageId()))
        return false;
    if (notEqual(oldInstance.getState(), newInstance.getState()))
        return false;
    if (notEqual(oldInstance.getPrivateDnsName(), newInstance.getPrivateDnsName()))
        return false;
    if (notEqual(oldInstance.getPublicDnsName(), newInstance.getPublicDnsName()))
        return false;
    if (notEqual(oldInstance.getStateTransitionReason(), newInstance.getStateTransitionReason()))
        return false;
    if (notEqual(oldInstance.getKeyName(), newInstance.getKeyName()))
        return false;
    if (notEqual(oldInstance.getAmiLaunchIndex(), newInstance.getAmiLaunchIndex()))
        return false;
    if (notEqualCollection(oldInstance.getProductCodes(), newInstance.getProductCodes()))
        return false;
    if (notEqual(oldInstance.getInstanceType(), newInstance.getInstanceType()))
        return false;
    if (notEqual(oldInstance.getLaunchTime(), newInstance.getLaunchTime()))
        return false;
    if (notEqual(oldInstance.getPlacement(), newInstance.getPlacement()))
        return false;
    if (notEqual(oldInstance.getKernelId(), newInstance.getKernelId()))
        return false;
    if (notEqual(oldInstance.getRamdiskId(), newInstance.getRamdiskId()))
        return false;
    if (notEqual(oldInstance.getPlatform(), newInstance.getPlatform()))
        return false;
    if (notEqual(oldInstance.getMonitoring(), newInstance.getMonitoring()))
        return false;
    if (notEqual(oldInstance.getSubnetId(), newInstance.getSubnetId()))
        return false;
    if (notEqual(oldInstance.getVpcId(), newInstance.getVpcId()))
        return false;
    if (notEqual(oldInstance.getPrivateIpAddress(), newInstance.getPrivateIpAddress()))
        return false;
    if (notEqual(oldInstance.getPublicIpAddress(), newInstance.getPublicIpAddress()))
        return false;
    if (notEqual(oldInstance.getStateReason(), newInstance.getStateReason()))
        return false;
    if (notEqual(oldInstance.getArchitecture(), newInstance.getArchitecture()))
        return false;
    if (notEqual(oldInstance.getRootDeviceType(), newInstance.getRootDeviceType()))
        return false;
    if (notEqual(oldInstance.getRootDeviceName(), newInstance.getRootDeviceName()))
        return false;
    if (notEqualCollection(oldInstance.getBlockDeviceMappings(), newInstance.getBlockDeviceMappings()))
        return false;
    if (notEqual(oldInstance.getVirtualizationType(), newInstance.getVirtualizationType()))
        return false;
    if (notEqual(oldInstance.getInstanceLifecycle(), newInstance.getInstanceLifecycle()))
        return false;
    if (notEqual(oldInstance.getSpotInstanceRequestId(), newInstance.getSpotInstanceRequestId()))
        return false;
    if (notEqual(oldInstance.getLicense(), newInstance.getLicense()))
        return false;
    if (notEqual(oldInstance.getClientToken(), newInstance.getClientToken()))
        return false;
    if (notEqualCollection(oldInstance.getTags(), newInstance.getTags()))
        return false;
    if (notEqualCollection(oldInstance.getSecurityGroups(), newInstance.getSecurityGroups()))
        return false;
    if (notEqual(oldInstance.getSourceDestCheck(), newInstance.getSourceDestCheck()))
        return false;
    if (notEqual(oldInstance.getHypervisor(), newInstance.getHypervisor()))
        return false;
    if (notEqualNetworkInterfaces(oldInstance.getNetworkInterfaces(), newInstance.getNetworkInterfaces()))
        return false;
    if (notEqual(oldInstance.getIamInstanceProfile(), newInstance.getIamInstanceProfile()))
        return false;
    if (notEqual(oldInstance.getEbsOptimized(), newInstance.getEbsOptimized()))
        return false;
    if (notEqual(this.getTerminationProtection(), newEc2Instance.getTerminationProtection()))
        return false;
    if (notEqual(this.getShutdownBehavior(), newEc2Instance.getShutdownBehavior()))
        return false;
    if (notEqual(this.getUserData(), newEc2Instance.getUserData()))
        return false;

    return true;/*from w ww.j av  a 2  s  .c  om*/
}

From source file:com.haskins.cloudtrailviewer.dialog.resourcedetail.detailpanels.EC2InstanceDetail.java

License:Open Source License

private void buildUI(DescribeInstancesResult detail) {

    JTabbedPane tabs = new JTabbedPane();
    tabs.add("Instance", primaryScrollPane);
    tabs.add("Tags", tagsScrollPane);

    this.add(tabs, BorderLayout.CENTER);

    List<Reservation> reservations = detail.getReservations();
    if (!reservations.isEmpty()) {

        Reservation reservation = reservations.get(0);
        List<Instance> instances = reservation.getInstances();
        if (!instances.isEmpty()) {

            Instance instance = instances.get(0);

            if (instance.getAmiLaunchIndex() != null) {
                primaryTableModel.addRow(new Object[] { "AMI Launch Index", instance.getAmiLaunchIndex() });
            }/*w  w  w  .j a va  2 s  .  c  o m*/
            if (instance.getArchitecture() != null) {
                primaryTableModel.addRow(new Object[] { "Architecture", instance.getArchitecture() });
            }
            if (instance.getAmiLaunchIndex() != null) {
                primaryTableModel.addRow(new Object[] { "Block Mapping Device", "" });
            }
            if (instance.getClientToken() != null) {
                primaryTableModel.addRow(new Object[] { "Client Token", instance.getClientToken() });
            }
            primaryTableModel.addRow(new Object[] { "EBS Optimised", instance.isEbsOptimized() });
            if (instance.getHypervisor() != null) {
                primaryTableModel.addRow(new Object[] { "Hypervisor", instance.getHypervisor() });
            }
            if (instance.getIamInstanceProfile() != null) {
                primaryTableModel.addRow(
                        new Object[] { "Instance Profile", instance.getIamInstanceProfile().toString() });
            }
            if (instance.getImageId() != null) {
                primaryTableModel.addRow(new Object[] { "Image Id", instance.getImageId() });
            }
            if (instance.getInstanceId() != null) {
                primaryTableModel.addRow(new Object[] { "Instance Id", instance.getInstanceId() });
            }
            if (instance.getInstanceLifecycle() != null) {
                primaryTableModel.addRow(new Object[] { "Instance Lifecyle", instance.getInstanceLifecycle() });
            }
            if (instance.getInstanceType() != null) {
                primaryTableModel.addRow(new Object[] { "Instance Type", instance.getInstanceType() });
            }
            if (instance.getKernelId() != null) {
                primaryTableModel.addRow(new Object[] { "Kernel Id", instance.getKernelId() });
            }
            if (instance.getKeyName() != null) {
                primaryTableModel.addRow(new Object[] { "Key Name", instance.getKeyName() });
            }
            if (instance.getLaunchTime() != null) {
                primaryTableModel.addRow(new Object[] { "Launch Time", instance.getLaunchTime() });
            }
            if (instance.getMonitoring() != null) {
                primaryTableModel.addRow(new Object[] { "Monitoring", instance.getMonitoring().toString() });
            }
            if (instance.getPlacement() != null) {
                primaryTableModel
                        .addRow(new Object[] { "Placement", instance.getPlacement().getAvailabilityZone() });
            }
            if (instance.getPlatform() != null) {
                primaryTableModel.addRow(new Object[] { "Platform", instance.getPlatform() });
            }
            if (instance.getPrivateDnsName() != null) {
                primaryTableModel.addRow(new Object[] { "Private DNS Name", instance.getPrivateDnsName() });
            }
            if (instance.getPrivateIpAddress() != null) {
                primaryTableModel.addRow(new Object[] { "Private IP Address", instance.getPrivateIpAddress() });
            }
            if (instance.getAmiLaunchIndex() != null) {
                primaryTableModel.addRow(new Object[] { "Product Codes", "" });
            }
            if (instance.getPublicDnsName() != null) {
                primaryTableModel.addRow(new Object[] { "Public DNS Name", instance.getPublicDnsName() });
            }
            if (instance.getPublicIpAddress() != null) {
                primaryTableModel.addRow(new Object[] { "Public IP Address", instance.getPublicIpAddress() });
            }
            if (instance.getRamdiskId() != null) {
                primaryTableModel.addRow(new Object[] { "Ram Disk Id", instance.getRamdiskId() });
            }
            if (instance.getRootDeviceName() != null) {
                primaryTableModel.addRow(new Object[] { "Root Device Name", instance.getRootDeviceName() });
            }
            if (instance.getRootDeviceType() != null) {
                primaryTableModel.addRow(new Object[] { "Root Device Type", instance.getRootDeviceType() });
            }
            if (instance.getAmiLaunchIndex() != null) {
                primaryTableModel.addRow(new Object[] { "Security Groups", "" });
            }
            if (instance.getSourceDestCheck() != null) {
                primaryTableModel
                        .addRow(new Object[] { "Source Destination Check", instance.getSourceDestCheck() });
            }
            if (instance.getSpotInstanceRequestId() != null) {
                primaryTableModel.addRow(
                        new Object[] { "Spot Instance Request Id", instance.getSpotInstanceRequestId() });
            }
            if (instance.getSriovNetSupport() != null) {
                primaryTableModel
                        .addRow(new Object[] { "Sriov network Support", instance.getSriovNetSupport() });
            }
            if (instance.getState() != null) {
                primaryTableModel.addRow(new Object[] { "State", instance.getState().getName() });
            }
            if (instance.getStateReason() != null) {
                primaryTableModel
                        .addRow(new Object[] { "State Reason", instance.getStateReason().getMessage() });
            }
            if (instance.getSubnetId() != null) {
                primaryTableModel.addRow(new Object[] { "Subnet Id", instance.getSubnetId() });
            }
            if (instance.getVirtualizationType() != null) {
                primaryTableModel
                        .addRow(new Object[] { "Virtualisation Type", instance.getVirtualizationType() });
            }
            if (instance.getVpcId() != null) {
                primaryTableModel.addRow(new Object[] { "Vpc Id", instance.getVpcId() });
            }

            List<Tag> tags = instance.getTags();
            for (Tag tag : tags) {
                tagsTableModel.addRow(new Object[] { tag.getKey(), tag.getValue() });
            }
        }
    }
}

From source file:com.sequenceiq.samples.web.transformers.ReservationTransformer.java

public AWSReservation transform(Reservation reservation) {
    AWSReservation awsInstance = new AWSReservation(reservation.getOwnerId(), reservation.getReservationId(),
            reservation.getRequesterId());
    awsInstance.setGroupNames(reservation.getGroupNames());
    awsInstance.setGroups(reservation.getGroups());
    List<AwsSimpleInstance> awsSimpleInstanceList = new ArrayList<>();
    for (Instance item : reservation.getInstances()) {
        AwsSimpleInstance instance = new AwsSimpleInstance();
        instance.setAmiLaunchIndex(item.getAmiLaunchIndex());
        instance.setArchitecture(item.getArchitecture());
        instance.setClientToken(item.getClientToken());
        instance.setImageId(item.getImageId());
        instance.setInstanceId(item.getInstanceId());
        instance.setState(item.getState());
        instance.setPrivateDnsName(item.getPrivateDnsName());
        instance.setPublicDnsName(item.getPublicDnsName());
        instance.setStateTransitionReason(item.getStateTransitionReason());
        instance.setKeyName(item.getKeyName());
        instance.setAmiLaunchIndex(item.getAmiLaunchIndex());
        instance.setInstanceType(item.getInstanceType());
        instance.setLaunchTime(item.getLaunchTime());
        instance.setPlacement(item.getPlacement());
        instance.setKernelId(item.getKernelId());
        instance.setRamdiskId(item.getRamdiskId());
        instance.setPlatform(item.getPlatform());
        instance.setMonitoring(item.getMonitoring());
        instance.setSubnetId(item.getSubnetId());
        instance.setVpcId(item.getVpcId());
        instance.setPrivateIpAddress(item.getPrivateIpAddress());
        instance.setPublicIpAddress(item.getPublicIpAddress());
        instance.setStateReason(item.getStateReason());
        instance.setArchitecture(item.getArchitecture());
        instance.setRootDeviceType(item.getRootDeviceType());
        instance.setRootDeviceName(item.getRootDeviceName());
        instance.setVirtualizationType(item.getVirtualizationType());
        instance.setInstanceLifecycle(item.getInstanceLifecycle());
        instance.setSpotInstanceRequestId(item.getSpotInstanceRequestId());
        instance.setLicense(item.getLicense());
        instance.setClientToken(item.getClientToken());
        awsSimpleInstanceList.add(instance);
    }/*w  w w  . j av  a 2  s  .c  o m*/
    awsInstance.setInstances(awsSimpleInstanceList);
    return awsInstance;
}

From source file:com.urbancode.terraform.tasks.aws.InstanceTask.java

License:Apache License

public boolean verify() {
    // will return false if the id is null
    boolean result = false;
    if (instanceId != null) {
        if (ec2Client == null) {
            ec2Client = context.fetchEC2Client();
        }//www  .  ja va2  s.c om

        List<String> id = new ArrayList<String>();
        id.add(instanceId);

        List<Instance> instances = helper.getInstances(id, ec2Client);
        if (instances != null && !instances.isEmpty()) {
            for (Instance instance : instances) {
                if (instance.getImageId().equals(amiId)) {
                    String subId = ((EnvironmentTaskAWS) context.getEnvironment()).getVpc()
                            .findSubnetForName(subnetName).getId();
                    if (instance.getSubnetId() != null && instance.getSubnetId().equals(subId)
                            && verifyElasticIp(instance) && verifyKeyPair(instance) && verifySize(instance)
                            && verifySecurityGroups(instance)) {

                        result = true;
                    }
                }
            }
        }
    }

    return result;
}

From source file:com.vmware.photon.controller.model.adapters.awsadapter.util.AWSNetworkUtils.java

License:Open Source License

public static NetworkState mapVPCToNetworkState(Instance instance, String regionId, String resourcePoolLink,
        String authCredentialsLink, List<String> tenantLinks) {
    if (instance == null) {
        throw new IllegalArgumentException("Cannot map VPC to network state for null instance");
    }/*from   w  w  w.ja va 2 s  . c o  m*/
    NetworkState networkState = new NetworkState();
    networkState.id = instance.getVpcId();
    networkState.name = instance.getVpcId();
    networkState.regionID = regionId;
    networkState.resourcePoolLink = resourcePoolLink;
    networkState.authCredentialsLink = authCredentialsLink;
    networkState.instanceAdapterReference = UriUtils.buildUri(AWSUriPaths.AWS_INSTANCE_ADAPTER);
    networkState.tenantLinks = tenantLinks;
    networkState.customProperties = new HashMap<String, String>();
    networkState.customProperties.put(AWS_VPC_ID, instance.getVpcId());
    networkState.customProperties.put(AWS_SUBNET_ID, instance.getSubnetId());
    return networkState;
}

From source file:dsmwatcher.DSMWatcher.java

License:Open Source License

public void isolateInstance(Instance instance, AmazonEC2Client ec2) throws Exception {
    Subnet targetIRSubnet = null;//  w  w w  . j a  va2s.co  m
    handleAutoScaledInstance(instance); //check for autoscaling, if autoscaled instance detach first 
                                        // to prevent heathcheck failure and termination
    DescribeSubnetsRequest subnetRequest = new DescribeSubnetsRequest().withSubnetIds(instance.getSubnetId());
    List<Subnet> sourceSubnet = ec2.describeSubnets(subnetRequest).getSubnets();
    String targetAZStr = sourceSubnet.get(0).getAvailabilityZone();
    for (String IRSubnet : IRSubnets) {
        subnetRequest = new DescribeSubnetsRequest().withSubnetIds(IRSubnet);
        if (targetAZStr
                .compareTo(ec2.describeSubnets(subnetRequest).getSubnets().get(0).getAvailabilityZone()) == 0) {
            targetIRSubnet = ec2.describeSubnets(subnetRequest).getSubnets().get(0);
        }
    }
    if (targetIRSubnet == null) {
        error("Unable to find an isolation subnet for instance " + instance.getInstanceId());
        return;
    }
    List<InstanceNetworkInterface> ienis = instance.getNetworkInterfaces();
    for (InstanceNetworkInterface ieni : ienis) {
        String eniTag = "";
        List<GroupIdentifier> inititalSecGroups = ieni.getGroups();
        for (GroupIdentifier secGroup : inititalSecGroups) {
            eniTag += secGroup.getGroupId() + ",";
        }
        eniTag = eniTag.substring(0, eniTag.length() - 1);
        DescribeNetworkInterfacesRequest netReq = new DescribeNetworkInterfacesRequest()
                .withNetworkInterfaceIds(ieni.getNetworkInterfaceId());
        DescribeNetworkInterfacesResult netResult = ec2.describeNetworkInterfaces(netReq);
        List<com.amazonaws.services.ec2.model.NetworkInterface> enis = netResult.getNetworkInterfaces();
        for (com.amazonaws.services.ec2.model.NetworkInterface eni : enis) {
            List<Tag> tagSet = eni.getTagSet();
            Tag saveSGTag = new Tag().withKey("PreIsolationSG").withValue(eniTag);
            Tag isolationTag = new Tag().withKey("InIsolation").withValue("True");
            tagSet.add(saveSGTag);
            tagSet.add(isolationTag);
            CreateTagsRequest ctr = new CreateTagsRequest().withResources(eni.getNetworkInterfaceId())
                    .withTags(tagSet);
            ec2.createTags(ctr);
            ModifyNetworkInterfaceAttributeRequest netReqest = new ModifyNetworkInterfaceAttributeRequest()
                    .withNetworkInterfaceId(eni.getNetworkInterfaceId()).withGroups(denyAllSG);
            ec2.modifyNetworkInterfaceAttribute(netReqest);
        }
    }
    CreateNetworkInterfaceRequest newENIReq = new CreateNetworkInterfaceRequest()
            .withSubnetId(targetIRSubnet.getSubnetId()).withGroups(IRSecGrp);
    CreateNetworkInterfaceResult newENIResult = ec2.createNetworkInterface(newENIReq);
    AttachNetworkInterfaceRequest attachReq = new AttachNetworkInterfaceRequest()
            .withNetworkInterfaceId(newENIResult.getNetworkInterface().getNetworkInterfaceId())
            .withInstanceId(instance.getInstanceId())
            .withDeviceIndex(instance.getNetworkInterfaces().size() + 1);
    AttachNetworkInterfaceResult attachResults = ec2.attachNetworkInterface(attachReq);
    NetworkInterfaceAttachmentChanges attachTerm = new NetworkInterfaceAttachmentChanges()
            .withAttachmentId(attachResults.getAttachmentId()).withDeleteOnTermination(true);
    ModifyNetworkInterfaceAttributeRequest setDeleteOnTerm = new ModifyNetworkInterfaceAttributeRequest()
            .withAttachment(attachTerm)
            .withNetworkInterfaceId(newENIResult.getNetworkInterface().getNetworkInterfaceId());
    ec2.modifyNetworkInterfaceAttribute(setDeleteOnTerm);
    CreateTagsRequest tagNewENIReq = new CreateTagsRequest();
    List<Tag> isolationENITags = newENIResult.getNetworkInterface().getTagSet();
    Tag newENITag = new Tag().withKey("IRENI").withValue("True");
    isolationENITags.add(newENITag);
    tagNewENIReq.setTags(isolationENITags);
    tagNewENIReq.withResources(newENIResult.getNetworkInterface().getNetworkInterfaceId());
    ec2.createTags(tagNewENIReq);
}

From source file:org.occiware.clouddriver.util.InstanceDataFactory.java

License:Apache License

/**
 *
 * @param instance//  w w w. j a v  a2 s  .  c  o m
 * @param instanceDO
 */
private static void buildBasicInstanceData(Instance instance, InstanceDO instanceDO) {
    instanceDO.setInstanceId(instance.getInstanceId());
    instanceDO.setImageId(instance.getImageId());
    instanceDO.setAmiLaunchIndex(instance.getAmiLaunchIndex());
    instanceDO.setArchitecture(instance.getArchitecture());
    instanceDO.setOptimizedEbsIO(instance.getEbsOptimized());
    instanceDO.setEnaSupport(instance.getEnaSupport());
    instanceDO.setHypervisor(instance.getHypervisor());
    instanceDO.setInstanceType(instance.getInstanceType());
    instanceDO.setKernelId(instance.getKernelId());
    instanceDO.setInstanceLifeCycle(instance.getInstanceLifecycle());
    instanceDO.setPlatform(instance.getPlatform());
    instanceDO.setPrivateDnsName(instance.getPrivateDnsName());
    instanceDO.setPrivateIpAddress(instance.getPrivateIpAddress());
    instanceDO.setPublicDnsName(instance.getPublicDnsName());
    instanceDO.setPublicIpAddress(instance.getPublicIpAddress());
    instanceDO.setSourceDestCheck(instance.getSourceDestCheck());
    instanceDO.setKeyPairName(instance.getKeyName());
    instanceDO.setLaunchTime(instance.getLaunchTime());
    instanceDO.setRamDiskId(instance.getRamdiskId());
    instanceDO.setRootDeviceName(instance.getRootDeviceName());
    instanceDO.setRootDeviceType(instance.getRootDeviceType());
    instanceDO.setSpotInstanceRequestId(instance.getSpotInstanceRequestId());
    instanceDO.setSriovNetSuppport(instance.getSriovNetSupport());
    instanceDO.setStateTransitionReason(instance.getStateTransitionReason());
    instanceDO.setSubnetId(instance.getSubnetId());
    instanceDO.setVirtualizationType(instance.getVirtualizationType());
    instanceDO.setVpcId(instance.getVpcId());
}

From source file:org.xmlsh.aws.util.AWSEC2Command.java

License:BSD License

protected void writeReservation(Reservation res) throws XMLStreamException {
    startElement("reservation");
    attribute("id", res.getReservationId());
    attribute("requester-id", res.getRequesterId());

    for (Instance inst : res.getInstances()) {
        startElement("instance");
        attribute("instance-id", inst.getInstanceId());
        attribute("image", inst.getImageId());
        attribute("key-name", inst.getKeyName());
        attribute("architecture", inst.getArchitecture());
        attribute("client-token", inst.getClientToken());
        attribute("lifecycle", Util.notNull(inst.getInstanceLifecycle()));
        attribute("instance-type", inst.getInstanceType());
        attribute("kernel-id", inst.getKernelId());
        attribute("platform", inst.getPlatform());
        attribute("private-dns", inst.getPrivateDnsName());
        attribute("private-ip", inst.getPrivateIpAddress());
        attribute("public-dns", inst.getPublicDnsName());
        attribute("public-ip", inst.getPublicIpAddress());
        attribute("ramdisk-id", inst.getRamdiskId());
        attribute("root-device-name", inst.getRootDeviceName());

        attribute("spot-request-id", inst.getSpotInstanceRequestId());
        attribute("state-transistion-reason", inst.getStateTransitionReason());
        attribute("subnet-id", inst.getSubnetId());
        attribute("state", inst.getState().getName());
        attribute("virtualization-type", inst.getVirtualizationType());
        attribute("vpcid", inst.getVpcId());
        attribute("ami-launch-index", inst.getAmiLaunchIndex().toString());
        attribute("launch-date", Util.formatXSDateTime(inst.getLaunchTime()));
        attribute("monitoring", inst.getMonitoring().getState());
        attribute("source-dest-check", getSourceCheck(inst));
        attribute("state-reason", getStateReason(inst));

        writeProductCodes(inst.getProductCodes());
        writeTags(inst.getTags());/*www. j  a v  a  2  s  .c o  m*/

        writePlacement(inst.getPlacement());

        writeInstanceBlockDeviceMappings(inst.getBlockDeviceMappings());

        endElement();

    }

    endElement();
}