List of usage examples for com.amazonaws.services.ec2.model Instance getInstanceType
public String getInstanceType()
The instance type.
From source file:at.ac.tuwien.infosys.jcloudscale.vm.ec2.EC2Wrapper.java
License:Apache License
public String getInstanceSize(String id) { DescribeInstancesRequest req = new DescribeInstancesRequest().withInstanceIds(id); DescribeInstancesResult result = ec2Client.describeInstances(req); for (Reservation r : result.getReservations()) { for (Instance i : r.getInstances()) { if (i.getInstanceId().equals(id)) return i.getInstanceType(); }/* w w w. j a v a 2 s. co m*/ } return null; }
From source file:aws.example.ec2.DescribeInstances.java
License:Open Source License
public static void main(String[] args) { final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient(); boolean done = false; while (!done) { DescribeInstancesRequest request = new DescribeInstancesRequest(); DescribeInstancesResult response = ec2.describeInstances(request); for (Reservation reservation : response.getReservations()) { for (Instance instance : reservation.getInstances()) { System.out.printf( "Found reservation with id %s, " + "AMI %s, " + "type %s, " + "state %s " + "and monitoring state %s", instance.getInstanceId(), instance.getImageId(), instance.getInstanceType(), instance.getState().getName(), instance.getMonitoring().getState()); }/* ww w . java2s. com*/ } request.setNextToken(response.getNextToken()); if (response.getNextToken() == null) { done = true; } } }
From source file:com.appdynamics.connectors.AWSConnector.java
License:Apache License
public IMachine createMachine(IComputeCenter computeCenter, IImage image, IMachineDescriptor machineDescriptor) throws InvalidObjectException, ConnectorException { boolean succeeded = false; Exception createFailureRootCause = null; Instance instance = null; try {/* w w w . ja v a2s . c o m*/ IProperty[] macProps = machineDescriptor.getProperties(); AmazonEC2 connector = getConnector(image, computeCenter, controllerServices); String amiName = Utils.getAMIName(image.getProperties(), controllerServices); List<String> securityGroups = getSecurityGroup(macProps); validateAndConfigureSecurityGroups(securityGroups, connector); controllerServices.getStringPropertyByName(macProps, Utils.SECURITY_GROUP) .setValue(getSecurityGroupsAsString(securityGroups)); String keyPair = Utils.getKeyPair(macProps, controllerServices); InstanceType instanceType = getInstanceType(macProps); String zone = Utils.getZone(macProps, controllerServices); String kernel = Utils.getKernel(macProps, controllerServices); String ramdisk = Utils.getRamDisk(macProps, controllerServices); String controllerHost = System.getProperty(CONTROLLER_SERVICES_HOST_NAME_PROPERTY_KEY, InetAddress.getLocalHost().getHostName()); int controllerPort = Integer.getInteger(CONTROLLER_SERVICES_PORT_PROPERTY_KEY, DEFAULT_CONTROLLER_PORT_VALUE); IAccount account = computeCenter.getAccount(); String accountName = account.getName(); String accountAccessKey = account.getAccessKey(); AgentResolutionEncoder agentResolutionEncoder = new AgentResolutionEncoder(controllerHost, controllerPort, accountName, accountAccessKey); String userData = agentResolutionEncoder.encodeAgentResolutionInfo(); String instanceName = Utils.getInstanceName(macProps, controllerServices); logger.info("Starting EC2 machine of Image :" + amiName + " Name :" + instanceName + " security :" + securityGroups + " keypair :" + keyPair + " instance :" + instanceType + " zone :" + zone + " kernel :" + kernel + " ramdisk :" + ramdisk + " userData :" + userData); RunInstancesRequest runInstancesRequest = new RunInstancesRequest(amiName, 1, 1); runInstancesRequest.setSecurityGroups(securityGroups); runInstancesRequest.setUserData(Base64.encodeAsString(userData.getBytes())); runInstancesRequest.setKeyName(keyPair); runInstancesRequest.setInstanceType(instanceType); runInstancesRequest.setKernelId(kernel); runInstancesRequest.setRamdiskId(ramdisk); Reservation reservation = connector.runInstances(runInstancesRequest).getReservation(); List<Instance> instances = reservation.getInstances(); if (instances.size() == 0) throw new ConnectorException("Cannot create instance for image :" + image.getName()); instance = instances.get(0); //Set name for the instance if (!Strings.isNullOrEmpty(instanceName)) { CreateTagsRequest createTagsRequest = new CreateTagsRequest(); createTagsRequest.withResources(instance.getInstanceId()).withTags(new Tag("Name", instanceName)); connector.createTags(createTagsRequest); } logger.info("EC2 machine started; id:" + instance.getInstanceId()); IMachine machine; if (Strings.isNullOrEmpty(instance.getPublicDnsName())) { machine = controllerServices.createMachineInstance(instance.getInstanceId(), agentResolutionEncoder.getUniqueHostIdentifier(), computeCenter, machineDescriptor, image, getAgentPort()); } else { machine = controllerServices.createMachineInstance(instance.getInstanceId(), agentResolutionEncoder.getUniqueHostIdentifier(), instance.getPublicDnsName(), computeCenter, machineDescriptor, image, getAgentPort()); } if (kernel == null) { controllerServices.getStringPropertyByName(macProps, Utils.KERNEL).setValue(instance.getKernelId()); } if (zone == null) { DescribeAvailabilityZonesResult describeAvailabilityZonesResult = connector .describeAvailabilityZones(); List<AvailabilityZone> availabilityZones = describeAvailabilityZonesResult.getAvailabilityZones(); controllerServices.getStringPropertyByName(macProps, Utils.ZONE) .setValue(availabilityZones.get(0).getZoneName()); } controllerServices.getStringPropertyByName(macProps, Utils.INSTANCE_TYPE) .setValue(instance.getInstanceType()); succeeded = true; return machine; } catch (InvalidObjectException e) { createFailureRootCause = e; throw e; } catch (ConnectorException e) { createFailureRootCause = e; throw e; } catch (Exception e) { createFailureRootCause = e; throw new ConnectorException(e.getMessage(), e); } finally { // We have to make sure to terminate any orphan EC2 instances if // the machine create fails. if (!succeeded && instance != null) { try { ConnectorLocator.getInstance().getConnector(computeCenter, controllerServices) .terminateInstances( new TerminateInstancesRequest(Lists.newArrayList(instance.getInstanceId()))); } catch (Exception e) { throw new ConnectorException("Machine create failed, but terminate failed as well! " + "We have an orphan EC2 instance with id: " + instance.getInstanceId() + " that must be shut down manually. Root cause for machine " + "create failure is following: ", createFailureRootCause); } } } }
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; }//from w w w . j a v a2s . 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;// w w w . j a v a2 s . c o m }
From source file:com.cloudera.director.aws.ec2.EC2Provider.java
License:Apache License
/** * Performs a sequence of strict instance ownership checks to avoid any potential harmful * accidents.//from w w w .j a v a 2 s .co m * * @param instance the instance * @param template the template from which the instance was created, or <code>null</code> * if it is unknown (such as during a delete call) * @return the virtual instance ID * @throws IllegalStateException if the instance fails an ownership check */ private String checkInstanceIsManagedByDirector(Instance instance, EC2InstanceTemplate template) { String virtualInstanceId = getVirtualInstanceId(instance.getTags(), "instance"); String instanceIds = instance.getInstanceId() + " / " + virtualInstanceId; String instanceKeyName = instance.getKeyName(); if (template != null) { if (!template.getKeyName().equals(Optional.fromNullable(instanceKeyName))) { throw new IllegalStateException( "Found unexpected key name: " + instanceKeyName + " for instance: " + instanceIds); } String instanceType = instance.getInstanceType(); if (!template.getType().equals(instanceType)) { throw new IllegalStateException( "Found unexpected type: " + instanceType + " for instance: " + instanceIds); } String instanceImageId = instance.getImageId(); if (!template.getImage().equals(instanceImageId)) { throw new IllegalStateException( "Found unexpected image type: " + instanceImageId + " for instance: " + instanceIds); } } return virtualInstanceId; }
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 ww . j a v a 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.intuit.tank.vmManager.environment.amazon.AmazonDataConverter.java
License:Open Source License
/** * @param data// w w w. j av a 2 s.c o m * @param instance * @param region * @return */ public VMInformation instanceToVmInformation(Reservation data, Instance instance, VMRegion region) { VMInformation info = new VMInformation(); info.setProvider(VMProvider.Amazon); info.setRequestId(data.getRequesterId()); info.setImageId(instance.getImageId()); info.setInstanceId(instance.getInstanceId()); info.setKeyName(instance.getKeyName()); // info.setLaunchTime(); info.setRegion(region); info.setPlatform(instance.getPlatform()); info.setPrivateDNS(instance.getPrivateDnsName()); info.setPublicDNS(instance.getPublicDnsName()); info.setState(instance.getState().getName()); info.setSize(instance.getInstanceType()); return info; }
From source file:com.liferay.amazontools.AMIBuilder.java
License:Open Source License
protected void start() { RunInstancesRequest runInstancesRequest = new RunInstancesRequest(); String availabilityZone = properties.getProperty("availability.zone"); if (!isZoneAvailable(availabilityZone)) { throw new RuntimeException("Unavailable zone " + availabilityZone); }/*from w ww .j a va 2s .c om*/ String imageId = properties.getProperty("image.id"); if (imageId == null) { imageId = getImageId(properties.getProperty("image.name")); } runInstancesRequest.setImageId(imageId); runInstancesRequest.setInstanceType(properties.getProperty("instance.type")); runInstancesRequest.setKeyName(properties.getProperty("key.name")); runInstancesRequest.setMaxCount(1); runInstancesRequest.setMinCount(1); Placement placement = new Placement(); placement.setAvailabilityZone(availabilityZone); runInstancesRequest.setPlacement(placement); List<String> securityGroupsIds = new ArrayList<String>(); securityGroupsIds.add(properties.getProperty("security.group.id")); runInstancesRequest.setSecurityGroupIds(securityGroupsIds); RunInstancesResult runInstancesResult = amazonEC2Client.runInstances(runInstancesRequest); Reservation reservation = runInstancesResult.getReservation(); List<Instance> instances = reservation.getInstances(); if (instances.isEmpty()) { throw new RuntimeException("Unable to create instances"); } Instance instance = instances.get(0); _instanceId = instance.getInstanceId(); _publicIpAddress = instance.getPublicIpAddress(); StringBuilder sb = new StringBuilder(13); sb.append("{imageId="); sb.append(instance.getImageId()); sb.append(", instanceId="); sb.append(_instanceId); sb.append(", instanceType="); sb.append(instance.getInstanceType()); sb.append(", keyName="); sb.append(instance.getKeyName()); sb.append(", reservationId="); sb.append(reservation.getReservationId()); sb.append(", state="); InstanceState instanceState = instance.getState(); sb.append(instanceState.getName()); sb.append("}"); System.out.println("Starting instance " + sb.toString()); boolean running = false; for (int i = 0; i < 6; i++) { sleep(30); instance = getRunningInstance(_instanceId); if (instance != null) { _publicIpAddress = instance.getPublicIpAddress(); running = true; sb = new StringBuilder(7); sb.append("{instanceId="); sb.append(_instanceId); sb.append(", publicIpAddress="); sb.append(_publicIpAddress); sb.append(", stat="); instanceState = instance.getState(); sb.append(instanceState.getName()); sb.append("}"); System.out.println("Started instance " + sb.toString()); break; } } if (!running) { throw new RuntimeException("Unable to start instance " + _instanceId); } }
From source file:com.lunabeat.pooper.commands.AppCommand.java
License:Apache License
private void listClusters() { Map<String, Map<String, List<Instance>>> outMap = ClusterList.getClusterMap(_config); out.println("found running clusters:"); HashSet<String> emptyClusters = new HashSet<String>(); for (String clustername : outMap.keySet()) { //out.println(clustername); boolean empty = true; for (String group : outMap.get(clustername).keySet()) { if (outMap.get(clustername).get(group).size() < 1) { emptyClusters.add(group.replace(HadoopCluster.MASTER_SUFFIX, "")); } else { out.println(group + " (" + outMap.get(clustername).get(group).size() + ")"); empty = false;/*from w w w. j a v a 2 s . co m*/ } for (Instance i : outMap.get(clustername).get(group)) { StringBuilder sb = new StringBuilder("\t"); sb.append(i.getInstanceId()); sb.append("\t"); sb.append(i.getInstanceType()); sb.append("\t"); sb.append(i.getState().getName()); //sb.append("\t"); //sb.append(i.getPublicDnsName()); out.println(sb.toString()); } if (!empty) { out.println(); } } if (!empty) { out.println("-----------"); } } out.println("Found empty cluster security groups:"); for (String s : emptyClusters) { out.println("\t" + s); } }