mirror of https://github.com/apache/jclouds.git
Introduced the "allocationId" to EC2's notion of an IP Address so that the describeAddresssesInRegion method of the IP Client will contain this information.
This commit is contained in:
parent
bc43572d65
commit
a706e9308e
|
@ -34,13 +34,15 @@ public class PublicIpInstanceIdPair implements Comparable<PublicIpInstanceIdPair
|
||||||
private final String region;
|
private final String region;
|
||||||
@Nullable
|
@Nullable
|
||||||
private final String instanceId;
|
private final String instanceId;
|
||||||
|
private final String allocationId;
|
||||||
private final String publicIp;
|
private final String publicIp;
|
||||||
private final Map<String, String> tags;
|
private final Map<String, String> tags;
|
||||||
|
|
||||||
public PublicIpInstanceIdPair(final String region, final String publicIp, @Nullable final String instanceId,
|
public PublicIpInstanceIdPair(final String region, final String publicIp, @Nullable final String instanceId,
|
||||||
@Nullable final Map<String, String> tags) {
|
@Nullable final String allocationId, @Nullable final Map<String, String> tags) {
|
||||||
this.region = checkNotNull(region, "region");
|
this.region = checkNotNull(region, "region");
|
||||||
this.instanceId = instanceId;
|
this.instanceId = instanceId;
|
||||||
|
this.allocationId = allocationId;
|
||||||
this.publicIp = checkNotNull(publicIp, "publicIp");
|
this.publicIp = checkNotNull(publicIp, "publicIp");
|
||||||
this.tags = tags == null ? ImmutableMap.<String, String> of() : ImmutableMap.copyOf(tags);
|
this.tags = tags == null ? ImmutableMap.<String, String> of() : ImmutableMap.copyOf(tags);
|
||||||
}
|
}
|
||||||
|
@ -71,6 +73,13 @@ public class PublicIpInstanceIdPair implements Comparable<PublicIpInstanceIdPair
|
||||||
return instanceId;
|
return instanceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The ID of the IP allocation (e.g., eipalloc-0ca038968f2a2c986).
|
||||||
|
*/
|
||||||
|
public String getAllocationId() {
|
||||||
|
return allocationId;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The public IP address.
|
* The public IP address.
|
||||||
*/
|
*/
|
||||||
|
@ -87,6 +96,7 @@ public class PublicIpInstanceIdPair implements Comparable<PublicIpInstanceIdPair
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = 1;
|
int result = 1;
|
||||||
result = prime * result + ((instanceId == null) ? 0 : instanceId.hashCode());
|
result = prime * result + ((instanceId == null) ? 0 : instanceId.hashCode());
|
||||||
|
result = prime * result + ((allocationId == null) ? 0 : allocationId.hashCode());
|
||||||
result = prime * result + ((publicIp == null) ? 0 : publicIp.hashCode());
|
result = prime * result + ((publicIp == null) ? 0 : publicIp.hashCode());
|
||||||
result = prime * result + ((region == null) ? 0 : region.hashCode());
|
result = prime * result + ((region == null) ? 0 : region.hashCode());
|
||||||
result = prime * result + ((tags == null) ? 0 : tags.hashCode());
|
result = prime * result + ((tags == null) ? 0 : tags.hashCode());
|
||||||
|
@ -107,6 +117,11 @@ public class PublicIpInstanceIdPair implements Comparable<PublicIpInstanceIdPair
|
||||||
return false;
|
return false;
|
||||||
} else if (!instanceId.equals(other.instanceId))
|
} else if (!instanceId.equals(other.instanceId))
|
||||||
return false;
|
return false;
|
||||||
|
if (allocationId == null) {
|
||||||
|
if (other.allocationId != null)
|
||||||
|
return false;
|
||||||
|
} else if (!allocationId.equals(other.allocationId))
|
||||||
|
return false;
|
||||||
if (publicIp == null) {
|
if (publicIp == null) {
|
||||||
if (other.publicIp != null)
|
if (other.publicIp != null)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -144,6 +144,28 @@ public interface ElasticIPAddressApi {
|
||||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
|
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
|
||||||
@FormParam("PublicIp") String publicIp);
|
@FormParam("PublicIp") String publicIp);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Releases an elastic IP address associated with your identity.
|
||||||
|
*
|
||||||
|
* @param region
|
||||||
|
* Elastic IP addresses are tied to a Region and cannot be mapped across Regions.
|
||||||
|
* @param allocationId
|
||||||
|
* The Allocation ID (e.g., eipalloc-0ca038968f2a2c986) of the IP address that you are releasing from your identity.
|
||||||
|
*
|
||||||
|
* @see #allocateAddress
|
||||||
|
* @see #describeAddresses
|
||||||
|
* @see #associateAddress
|
||||||
|
* @see #disassociateAddress
|
||||||
|
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-ReleaseAddress.html"
|
||||||
|
*/
|
||||||
|
@Named("ReleaseAddress")
|
||||||
|
@POST
|
||||||
|
@Path("/")
|
||||||
|
@FormParams(keys = ACTION, values = "ReleaseAddress")
|
||||||
|
void releaseAddressInRegionByAllocationId(
|
||||||
|
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
|
||||||
|
@FormParam("AllocationId") String allocationId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lists elastic IP addresses assigned to your identity or provides information about a specific
|
* Lists elastic IP addresses assigned to your identity or provides information about a specific
|
||||||
* address.
|
* address.
|
||||||
|
|
|
@ -44,6 +44,7 @@ public class DescribeAddressesResponseHandler extends HandlerForGeneratedRequest
|
||||||
@Inject
|
@Inject
|
||||||
@Region
|
@Region
|
||||||
Supplier<String> defaultRegion;
|
Supplier<String> defaultRegion;
|
||||||
|
private String allocationId;
|
||||||
private String instanceId;
|
private String instanceId;
|
||||||
private final TagSetHandler tagSetHandler;
|
private final TagSetHandler tagSetHandler;
|
||||||
private boolean inTagSet;
|
private boolean inTagSet;
|
||||||
|
@ -80,14 +81,17 @@ public class DescribeAddressesResponseHandler extends HandlerForGeneratedRequest
|
||||||
ipAddress = currentOrNull();
|
ipAddress = currentOrNull();
|
||||||
} else if (qName.equals("instanceId")) {
|
} else if (qName.equals("instanceId")) {
|
||||||
instanceId = currentOrNull();
|
instanceId = currentOrNull();
|
||||||
|
} else if (qName.equals("allocationId")) {
|
||||||
|
allocationId = currentOrNull();
|
||||||
} else if (qName.equals("item")) {
|
} else if (qName.equals("item")) {
|
||||||
String region = AWSUtils.findRegionInArgsOrNull(getRequest());
|
String region = AWSUtils.findRegionInArgsOrNull(getRequest());
|
||||||
if (region == null)
|
if (region == null)
|
||||||
region = defaultRegion.get();
|
region = defaultRegion.get();
|
||||||
|
|
||||||
pairs.add(new PublicIpInstanceIdPair(region, ipAddress, instanceId, tagResults));
|
pairs.add(new PublicIpInstanceIdPair(region, ipAddress, instanceId, allocationId, tagResults));
|
||||||
ipAddress = null;
|
ipAddress = null;
|
||||||
instanceId = null;
|
instanceId = null;
|
||||||
|
allocationId = null;
|
||||||
tagResults = null;
|
tagResults = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class LoadPublicIpForInstanceOrNullTest {
|
||||||
|
|
||||||
expect(client.getElasticIPAddressApi()).andReturn((Optional) Optional.of(ipClient)).atLeastOnce();
|
expect(client.getElasticIPAddressApi()).andReturn((Optional) Optional.of(ipClient)).atLeastOnce();
|
||||||
expect(ipClient.describeAddressesInRegion("region")).andReturn(
|
expect(ipClient.describeAddressesInRegion("region")).andReturn(
|
||||||
ImmutableSet.<PublicIpInstanceIdPair> of(new PublicIpInstanceIdPair("region", "1.1.1.1", "i-blah", null)))
|
ImmutableSet.<PublicIpInstanceIdPair> of(new PublicIpInstanceIdPair("region", "1.1.1.1", "i-blah", null, null)))
|
||||||
.atLeastOnce();
|
.atLeastOnce();
|
||||||
|
|
||||||
replay(client);
|
replay(client);
|
||||||
|
@ -85,7 +85,7 @@ public class LoadPublicIpForInstanceOrNullTest {
|
||||||
expect(client.getElasticIPAddressApi()).andReturn((Optional) Optional.of(ipClient)).atLeastOnce();
|
expect(client.getElasticIPAddressApi()).andReturn((Optional) Optional.of(ipClient)).atLeastOnce();
|
||||||
|
|
||||||
expect(ipClient.describeAddressesInRegion("region")).andReturn(
|
expect(ipClient.describeAddressesInRegion("region")).andReturn(
|
||||||
ImmutableSet.<PublicIpInstanceIdPair> of(new PublicIpInstanceIdPair("region", "1.1.1.1", null, null)))
|
ImmutableSet.<PublicIpInstanceIdPair> of(new PublicIpInstanceIdPair("region", "1.1.1.1", null, null, null)))
|
||||||
.atLeastOnce();
|
.atLeastOnce();
|
||||||
|
|
||||||
replay(client);
|
replay(client);
|
||||||
|
|
Loading…
Reference in New Issue