@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getAssociation() == null) ? 0 : getAssociation().hashCode()); hashCode = prime * hashCode + ((getAttachment() == null) ? 0 : getAttachment().hashCode()); hashCode = prime * hashCode + ((getDescription() == null) ? 0 : getDescription().hashCode()); hashCode = prime * hashCode + ((getGroups() == null) ? 0 : getGroups().hashCode()); hashCode = prime * hashCode + ((getIpv6Addresses() == null) ? 0 : getIpv6Addresses().hashCode()); hashCode = prime * hashCode + ((getMacAddress() == null) ? 0 : getMacAddress().hashCode()); hashCode = prime * hashCode + ((getNetworkInterfaceId() == null) ? 0 : getNetworkInterfaceId().hashCode()); hashCode = prime * hashCode + ((getOwnerId() == null) ? 0 : getOwnerId().hashCode()); hashCode = prime * hashCode + ((getPrivateDnsName() == null) ? 0 : getPrivateDnsName().hashCode()); hashCode = prime * hashCode + ((getPrivateIpAddress() == null) ? 0 : getPrivateIpAddress().hashCode()); hashCode = prime * hashCode + ((getPrivateIpAddresses() == null) ? 0 : getPrivateIpAddresses().hashCode()); hashCode = prime * hashCode + ((getSourceDestCheck() == null) ? 0 : getSourceDestCheck().hashCode()); hashCode = prime * hashCode + ((getStatus() == null) ? 0 : getStatus().hashCode()); hashCode = prime * hashCode + ((getSubnetId() == null) ? 0 : getSubnetId().hashCode()); hashCode = prime * hashCode + ((getVpcId() == null) ? 0 : getVpcId().hashCode()); return hashCode; }
public InstanceNetworkInterface unmarshall(StaxUnmarshallerContext context) throws Exception { InstanceNetworkInterface instanceNetworkInterface = new InstanceNetworkInterface(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; instanceNetworkInterface.setAssociation(InstanceNetworkInterfaceAssociationStaxUnmarshaller.getInstance().unmarshall(context)); continue; instanceNetworkInterface.setAttachment(InstanceNetworkInterfaceAttachmentStaxUnmarshaller.getInstance().unmarshall(context)); continue; instanceNetworkInterface.setDescription(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; instanceNetworkInterface.withGroups(new ArrayList<GroupIdentifier>()); continue; instanceNetworkInterface.withGroups(GroupIdentifierStaxUnmarshaller.getInstance().unmarshall(context)); continue; instanceNetworkInterface.withIpv6Addresses(new ArrayList<InstanceIpv6Address>()); continue; instanceNetworkInterface.withIpv6Addresses(InstanceIpv6AddressStaxUnmarshaller.getInstance().unmarshall(context)); continue; instanceNetworkInterface.setMacAddress(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; instanceNetworkInterface.setNetworkInterfaceId(StringStaxUnmarshaller.getInstance().unmarshall(context));
/** * Unbind the IP that this instance is associated with. */ public void unbind() throws Exception { InstanceInfo myInfo = applicationInfoManager.getInfo(); String myInstanceId = ((AmazonInfo) myInfo.getDataCenterInfo()).get(AmazonInfo.MetaDataKey.instanceId); AmazonEC2 ec2 = getEC2Service(); List<InstanceNetworkInterface> result = instanceData(myInstanceId, ec2).getNetworkInterfaces(); List<String> ips = getCandidateIps(); for(InstanceNetworkInterface networkInterface: result){ if (ips.contains(networkInterface.getPrivateIpAddress())) { String attachmentId = networkInterface.getAttachment().getAttachmentId(); ec2.detachNetworkInterface(new DetachNetworkInterfaceRequest().withAttachmentId(attachmentId)); break; } } }
public InstanceNetworkInterface unmarshall(StaxUnmarshallerContext context) throws Exception { InstanceNetworkInterface instanceNetworkInterface = new InstanceNetworkInterface(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; instanceNetworkInterface.setNetworkInterfaceId(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; instanceNetworkInterface.setSubnetId(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; instanceNetworkInterface.setVpcId(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; instanceNetworkInterface.setDescription(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; instanceNetworkInterface.setOwnerId(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; instanceNetworkInterface.setStatus(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; instanceNetworkInterface.setMacAddress(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; instanceNetworkInterface.setPrivateIpAddress(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; instanceNetworkInterface.setPrivateDnsName(StringStaxUnmarshaller.getInstance().unmarshall(context));
public boolean alreadyBound() throws MalformedURLException { InstanceInfo myInfo = applicationInfoManager.getInfo(); String myInstanceId = ((AmazonInfo) myInfo.getDataCenterInfo()).get(AmazonInfo.MetaDataKey.instanceId); AmazonEC2 ec2Service = getEC2Service(); List<InstanceNetworkInterface> instanceNetworkInterfaces = instanceData(myInstanceId, ec2Service).getNetworkInterfaces(); List<String> candidateIPs = getCandidateIps(); for (String ip : candidateIPs) { for(InstanceNetworkInterface ini: instanceNetworkInterfaces) { if (ip.equals(ini.getPrivateIpAddress())) { logger.info("My instance {} seems to be already associated with the ip {}", myInstanceId, ip); return true; } } } return false; }
/** * One or more security groups. * <p> * Returns a reference to this object so that method calls can be chained together. * * @param groups One or more security groups. * * @return A reference to this updated object so that method calls can be chained * together. */ public InstanceNetworkInterface withGroups(GroupIdentifier... groups) { if (getGroups() == null) setGroups(new java.util.ArrayList<GroupIdentifier>(groups.length)); for (GroupIdentifier value : groups) { getGroups().add(value); } return this; }
// get network interface of instance and from that get mac address List<InstanceNetworkInterface> networkInterfaces = inst.getNetworkInterfaces(); for (InstanceNetworkInterface instanceNetworkInterface : networkInterfaces) { System.out.println("=-------------"+instanceNetworkInterface.getNetworkInterfaceId()); DescribeNetworkInterfacesRequest describeNetworkInterfacesRequest = new DescribeNetworkInterfacesRequest(); describeNetworkInterfacesRequest.withNetworkInterfaceIds(instanceNetworkInterface.getNetworkInterfaceId()); DescribeNetworkInterfacesResult describeNetworkInterfacesResult = amazonEc2.describeNetworkInterfaces(describeNetworkInterfacesRequest); List<NetworkInterface> networkInterfaces1 = describeNetworkInterfacesResult.getNetworkInterfaces(); for (NetworkInterface networkInterface : networkInterfaces1) { System.out.println(networkInterface.getMacAddress()); } } //-------------------------
/** * Unbind the IP that this instance is associated with. */ public void unbind() throws Exception { InstanceInfo myInfo = applicationInfoManager.getInfo(); String myInstanceId = ((AmazonInfo) myInfo.getDataCenterInfo()).get(AmazonInfo.MetaDataKey.instanceId); AmazonEC2 ec2 = getEC2Service(); List<InstanceNetworkInterface> result = instanceData(myInstanceId, ec2).getNetworkInterfaces(); List<String> ips = getCandidateIps(); for(InstanceNetworkInterface networkInterface: result){ if (ips.contains(networkInterface.getPrivateIpAddress())) { String attachmentId = networkInterface.getAttachment().getAttachmentId(); ec2.detachNetworkInterface(new DetachNetworkInterfaceRequest().withAttachmentId(attachmentId)); break; } } }
public boolean alreadyBound() throws MalformedURLException { InstanceInfo myInfo = applicationInfoManager.getInfo(); String myInstanceId = ((AmazonInfo) myInfo.getDataCenterInfo()).get(AmazonInfo.MetaDataKey.instanceId); AmazonEC2 ec2Service = getEC2Service(); List<InstanceNetworkInterface> instanceNetworkInterfaces = instanceData(myInstanceId, ec2Service).getNetworkInterfaces(); List<String> candidateIPs = getCandidateIps(); for (String ip : candidateIPs) { for(InstanceNetworkInterface ini: instanceNetworkInterfaces) { if (ip.equals(ini.getPrivateIpAddress())) { logger.info("My instance {} seems to be already associated with the ip {}", myInstanceId, ip); return true; } } } return false; }
return false; InstanceNetworkInterface other = (InstanceNetworkInterface) obj; if (other.getAssociation() == null ^ this.getAssociation() == null) return false; if (other.getAssociation() != null && other.getAssociation().equals(this.getAssociation()) == false) return false; if (other.getAttachment() == null ^ this.getAttachment() == null) return false; if (other.getAttachment() != null && other.getAttachment().equals(this.getAttachment()) == false) return false; if (other.getDescription() == null ^ this.getDescription() == null) return false; if (other.getDescription() != null && other.getDescription().equals(this.getDescription()) == false) return false; if (other.getGroups() == null ^ this.getGroups() == null) return false; if (other.getGroups() != null && other.getGroups().equals(this.getGroups()) == false) return false; if (other.getIpv6Addresses() == null ^ this.getIpv6Addresses() == null) return false; if (other.getIpv6Addresses() != null && other.getIpv6Addresses().equals(this.getIpv6Addresses()) == false) return false; if (other.getMacAddress() == null ^ this.getMacAddress() == null) return false; if (other.getMacAddress() != null && other.getMacAddress().equals(this.getMacAddress()) == false) return false; if (other.getNetworkInterfaceId() == null ^ this.getNetworkInterfaceId() == null) return false; if (other.getNetworkInterfaceId() != null && other.getNetworkInterfaceId().equals(this.getNetworkInterfaceId()) == false)
public InstanceNetworkInterface unmarshall(StaxUnmarshallerContext context) throws Exception { InstanceNetworkInterface instanceNetworkInterface = new InstanceNetworkInterface(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; instanceNetworkInterface.setAssociation(InstanceNetworkInterfaceAssociationStaxUnmarshaller.getInstance().unmarshall(context)); continue; instanceNetworkInterface.setAttachment(InstanceNetworkInterfaceAttachmentStaxUnmarshaller.getInstance().unmarshall(context)); continue; instanceNetworkInterface.setDescription(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; instanceNetworkInterface.withGroups(new ArrayList<GroupIdentifier>()); continue; instanceNetworkInterface.withGroups(GroupIdentifierStaxUnmarshaller.getInstance().unmarshall(context)); continue; instanceNetworkInterface.withIpv6Addresses(new ArrayList<InstanceIpv6Address>()); continue; instanceNetworkInterface.withIpv6Addresses(InstanceIpv6AddressStaxUnmarshaller.getInstance().unmarshall(context)); continue; instanceNetworkInterface.setMacAddress(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; instanceNetworkInterface.setNetworkInterfaceId(StringStaxUnmarshaller.getInstance().unmarshall(context));
StringBuilder sb = new StringBuilder(); sb.append("{"); if (getAssociation() != null) sb.append("Association: ").append(getAssociation()).append(","); if (getAttachment() != null) sb.append("Attachment: ").append(getAttachment()).append(","); if (getDescription() != null) sb.append("Description: ").append(getDescription()).append(","); if (getGroups() != null) sb.append("Groups: ").append(getGroups()).append(","); if (getIpv6Addresses() != null) sb.append("Ipv6Addresses: ").append(getIpv6Addresses()).append(","); if (getMacAddress() != null) sb.append("MacAddress: ").append(getMacAddress()).append(","); if (getNetworkInterfaceId() != null) sb.append("NetworkInterfaceId: ").append(getNetworkInterfaceId()).append(","); if (getOwnerId() != null) sb.append("OwnerId: ").append(getOwnerId()).append(","); if (getPrivateDnsName() != null) sb.append("PrivateDnsName: ").append(getPrivateDnsName()).append(","); if (getPrivateIpAddress() != null) sb.append("PrivateIpAddress: ").append(getPrivateIpAddress()).append(","); if (getPrivateIpAddresses() != null) sb.append("PrivateIpAddresses: ").append(getPrivateIpAddresses()).append(","); if (getSourceDestCheck() != null) sb.append("SourceDestCheck: ").append(getSourceDestCheck()).append(","); if (getStatus() != null) sb.append("Status: ").append(getStatus()).append(","); if (getSubnetId() != null)
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getNetworkInterfaceId() == null) ? 0 : getNetworkInterfaceId().hashCode()); hashCode = prime * hashCode + ((getSubnetId() == null) ? 0 : getSubnetId().hashCode()); hashCode = prime * hashCode + ((getVpcId() == null) ? 0 : getVpcId().hashCode()); hashCode = prime * hashCode + ((getDescription() == null) ? 0 : getDescription().hashCode()); hashCode = prime * hashCode + ((getOwnerId() == null) ? 0 : getOwnerId().hashCode()); hashCode = prime * hashCode + ((getStatus() == null) ? 0 : getStatus().hashCode()); hashCode = prime * hashCode + ((getMacAddress() == null) ? 0 : getMacAddress().hashCode()); hashCode = prime * hashCode + ((getPrivateIpAddress() == null) ? 0 : getPrivateIpAddress().hashCode()); hashCode = prime * hashCode + ((getPrivateDnsName() == null) ? 0 : getPrivateDnsName().hashCode()); hashCode = prime * hashCode + ((isSourceDestCheck() == null) ? 0 : isSourceDestCheck().hashCode()); hashCode = prime * hashCode + ((getGroups() == null) ? 0 : getGroups().hashCode()); hashCode = prime * hashCode + ((getAttachment() == null) ? 0 : getAttachment().hashCode()); hashCode = prime * hashCode + ((getAssociation() == null) ? 0 : getAssociation().hashCode()); hashCode = prime * hashCode + ((getPrivateIpAddresses() == null) ? 0 : getPrivateIpAddresses().hashCode()); return hashCode; }
/** * Returns a string representation of this object; useful for testing and * debugging. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getNetworkInterfaceId() != null) sb.append("NetworkInterfaceId: " + getNetworkInterfaceId() + ","); if (getSubnetId() != null) sb.append("SubnetId: " + getSubnetId() + ","); if (getVpcId() != null) sb.append("VpcId: " + getVpcId() + ","); if (getDescription() != null) sb.append("Description: " + getDescription() + ","); if (getOwnerId() != null) sb.append("OwnerId: " + getOwnerId() + ","); if (getStatus() != null) sb.append("Status: " + getStatus() + ","); if (getMacAddress() != null) sb.append("MacAddress: " + getMacAddress() + ","); if (getPrivateIpAddress() != null) sb.append("PrivateIpAddress: " + getPrivateIpAddress() + ","); if (getPrivateDnsName() != null) sb.append("PrivateDnsName: " + getPrivateDnsName() + ","); if (isSourceDestCheck() != null) sb.append("SourceDestCheck: " + isSourceDestCheck() + ","); if (getGroups() != null) sb.append("Groups: " + getGroups() + ","); if (getAttachment() != null) sb.append("Attachment: " + getAttachment() + ","); if (getAssociation() != null) sb.append("Association: " + getAssociation() + ","); if (getPrivateIpAddresses() != null) sb.append("PrivateIpAddresses: " + getPrivateIpAddresses() ); sb.append("}"); return sb.toString(); }
if (other.getNetworkInterfaceId() == null ^ this.getNetworkInterfaceId() == null) return false; if (other.getNetworkInterfaceId() != null && other.getNetworkInterfaceId().equals(this.getNetworkInterfaceId()) == false) return false; if (other.getSubnetId() == null ^ this.getSubnetId() == null) return false; if (other.getSubnetId() != null && other.getSubnetId().equals(this.getSubnetId()) == false) return false; if (other.getVpcId() == null ^ this.getVpcId() == null) return false; if (other.getVpcId() != null && other.getVpcId().equals(this.getVpcId()) == false) return false; if (other.getDescription() == null ^ this.getDescription() == null) return false; if (other.getDescription() != null && other.getDescription().equals(this.getDescription()) == false) return false; if (other.getOwnerId() == null ^ this.getOwnerId() == null) return false; if (other.getOwnerId() != null && other.getOwnerId().equals(this.getOwnerId()) == false) return false; if (other.getStatus() == null ^ this.getStatus() == null) return false; if (other.getStatus() != null && other.getStatus().equals(this.getStatus()) == false) return false; if (other.getMacAddress() == null ^ this.getMacAddress() == null) return false; if (other.getMacAddress() != null && other.getMacAddress().equals(this.getMacAddress()) == false) return false; if (other.getPrivateIpAddress() == null ^ this.getPrivateIpAddress() == null) return false; if (other.getPrivateIpAddress() != null && other.getPrivateIpAddress().equals(this.getPrivateIpAddress()) == false) return false; if (other.getPrivateDnsName() == null ^ this.getPrivateDnsName() == null) return false; if (other.getPrivateDnsName() != null && other.getPrivateDnsName().equals(this.getPrivateDnsName()) == false) return false; if (other.isSourceDestCheck() == null ^ this.isSourceDestCheck() == null) return false; if (other.isSourceDestCheck() != null && other.isSourceDestCheck().equals(this.isSourceDestCheck()) == false) return false; if (other.getGroups() == null ^ this.getGroups() == null) return false; if (other.getGroups() != null && other.getGroups().equals(this.getGroups()) == false) return false; if (other.getAttachment() == null ^ this.getAttachment() == null) return false; if (other.getAttachment() != null && other.getAttachment().equals(this.getAttachment()) == false) return false; if (other.getAssociation() == null ^ this.getAssociation() == null) return false; if (other.getAssociation() != null && other.getAssociation().equals(this.getAssociation()) == false) return false; if (other.getPrivateIpAddresses() == null ^ this.getPrivateIpAddresses() == null) return false; if (other.getPrivateIpAddresses() != null && other.getPrivateIpAddresses().equals(this.getPrivateIpAddresses()) == false) return false; return true;
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getAssociation() == null) ? 0 : getAssociation().hashCode()); hashCode = prime * hashCode + ((getAttachment() == null) ? 0 : getAttachment().hashCode()); hashCode = prime * hashCode + ((getDescription() == null) ? 0 : getDescription().hashCode()); hashCode = prime * hashCode + ((getGroups() == null) ? 0 : getGroups().hashCode()); hashCode = prime * hashCode + ((getIpv6Addresses() == null) ? 0 : getIpv6Addresses().hashCode()); hashCode = prime * hashCode + ((getMacAddress() == null) ? 0 : getMacAddress().hashCode()); hashCode = prime * hashCode + ((getNetworkInterfaceId() == null) ? 0 : getNetworkInterfaceId().hashCode()); hashCode = prime * hashCode + ((getOwnerId() == null) ? 0 : getOwnerId().hashCode()); hashCode = prime * hashCode + ((getPrivateDnsName() == null) ? 0 : getPrivateDnsName().hashCode()); hashCode = prime * hashCode + ((getPrivateIpAddress() == null) ? 0 : getPrivateIpAddress().hashCode()); hashCode = prime * hashCode + ((getPrivateIpAddresses() == null) ? 0 : getPrivateIpAddresses().hashCode()); hashCode = prime * hashCode + ((getSourceDestCheck() == null) ? 0 : getSourceDestCheck().hashCode()); hashCode = prime * hashCode + ((getStatus() == null) ? 0 : getStatus().hashCode()); hashCode = prime * hashCode + ((getSubnetId() == null) ? 0 : getSubnetId().hashCode()); hashCode = prime * hashCode + ((getVpcId() == null) ? 0 : getVpcId().hashCode()); return hashCode; }
return false; InstanceNetworkInterface other = (InstanceNetworkInterface) obj; if (other.getAssociation() == null ^ this.getAssociation() == null) return false; if (other.getAssociation() != null && other.getAssociation().equals(this.getAssociation()) == false) return false; if (other.getAttachment() == null ^ this.getAttachment() == null) return false; if (other.getAttachment() != null && other.getAttachment().equals(this.getAttachment()) == false) return false; if (other.getDescription() == null ^ this.getDescription() == null) return false; if (other.getDescription() != null && other.getDescription().equals(this.getDescription()) == false) return false; if (other.getGroups() == null ^ this.getGroups() == null) return false; if (other.getGroups() != null && other.getGroups().equals(this.getGroups()) == false) return false; if (other.getIpv6Addresses() == null ^ this.getIpv6Addresses() == null) return false; if (other.getIpv6Addresses() != null && other.getIpv6Addresses().equals(this.getIpv6Addresses()) == false) return false; if (other.getMacAddress() == null ^ this.getMacAddress() == null) return false; if (other.getMacAddress() != null && other.getMacAddress().equals(this.getMacAddress()) == false) return false; if (other.getNetworkInterfaceId() == null ^ this.getNetworkInterfaceId() == null) return false; if (other.getNetworkInterfaceId() != null && other.getNetworkInterfaceId().equals(this.getNetworkInterfaceId()) == false)
StringBuilder sb = new StringBuilder(); sb.append("{"); if (getAssociation() != null) sb.append("Association: ").append(getAssociation()).append(","); if (getAttachment() != null) sb.append("Attachment: ").append(getAttachment()).append(","); if (getDescription() != null) sb.append("Description: ").append(getDescription()).append(","); if (getGroups() != null) sb.append("Groups: ").append(getGroups()).append(","); if (getIpv6Addresses() != null) sb.append("Ipv6Addresses: ").append(getIpv6Addresses()).append(","); if (getMacAddress() != null) sb.append("MacAddress: ").append(getMacAddress()).append(","); if (getNetworkInterfaceId() != null) sb.append("NetworkInterfaceId: ").append(getNetworkInterfaceId()).append(","); if (getOwnerId() != null) sb.append("OwnerId: ").append(getOwnerId()).append(","); if (getPrivateDnsName() != null) sb.append("PrivateDnsName: ").append(getPrivateDnsName()).append(","); if (getPrivateIpAddress() != null) sb.append("PrivateIpAddress: ").append(getPrivateIpAddress()).append(","); if (getPrivateIpAddresses() != null) sb.append("PrivateIpAddresses: ").append(getPrivateIpAddresses()).append(","); if (getSourceDestCheck() != null) sb.append("SourceDestCheck: ").append(getSourceDestCheck()).append(","); if (getStatus() != null) sb.append("Status: ").append(getStatus()).append(","); if (getSubnetId() != null)