diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/FloatingIP.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/FloatingIP.java index 203b2da02e..76e1c26ed0 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/FloatingIP.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/FloatingIP.java @@ -31,28 +31,26 @@ import com.google.common.base.Objects.ToStringHelper; * A Floating IP is an IP address that can be created and associated with a * Server instance. Floating IPs can also be disassociated and deleted from a * Server instance. - * - * @author Jeremy Daggett - * @author chamerling -*/ + */ public class FloatingIP implements Comparable { - public static Builder builder() { + public static Builder builder() { return new ConcreteBuilder(); } - + public Builder toBuilder() { return new ConcreteBuilder().fromFloatingIP(this); } - public abstract static class Builder> { + public abstract static class Builder> { protected abstract T self(); protected String id; protected String ip; protected String fixedIp; protected String instanceId; - + protected String pool; + /** * @see FloatingIP#getId() */ @@ -85,8 +83,16 @@ public class FloatingIP implements Comparable { return self(); } + /** + * @see FloatingIP#getPool() + */ + public T pool(String pool) { + this.pool = pool; + return self(); + } + public FloatingIP build() { - return new FloatingIP(id, ip, fixedIp, instanceId); + return new FloatingIP(id, ip, fixedIp, instanceId, pool); } public T fromFloatingIP(FloatingIP in) { @@ -94,7 +100,8 @@ public class FloatingIP implements Comparable { .id(in.getId()) .ip(in.getIp()) .fixedIp(in.getFixedIp()) - .instanceId(in.getInstanceId()); + .instanceId(in.getInstanceId()) + .pool(in.getPool()); } } @@ -111,15 +118,17 @@ public class FloatingIP implements Comparable { private final String fixedIp; @Named("instance_id") private final String instanceId; + private final String pool; @ConstructorProperties({ - "id", "ip", "fixed_ip", "instance_id" + "id", "ip", "fixed_ip", "instance_id", "pool" }) - protected FloatingIP(String id, String ip, @Nullable String fixedIp, @Nullable String instanceId) { + protected FloatingIP(String id, String ip, @Nullable String fixedIp, @Nullable String instanceId, @Nullable String pool) { this.id = checkNotNull(id, "id"); this.ip = checkNotNull(ip, "ip"); this.fixedIp = fixedIp; this.instanceId = instanceId; + this.pool = pool; } public String getId() { @@ -140,9 +149,14 @@ public class FloatingIP implements Comparable { return this.instanceId; } + @Nullable + public String getPool() { + return this.pool; + } + @Override public int hashCode() { - return Objects.hashCode(id, ip, fixedIp, instanceId); + return Objects.hashCode(id, ip, fixedIp, instanceId, pool); } @Override @@ -153,14 +167,15 @@ public class FloatingIP implements Comparable { return Objects.equal(this.id, that.id) && Objects.equal(this.ip, that.ip) && Objects.equal(this.fixedIp, that.fixedIp) - && Objects.equal(this.instanceId, that.instanceId); + && Objects.equal(this.instanceId, that.instanceId) + && Objects.equal(this.pool, that.pool); } - + protected ToStringHelper string() { return Objects.toStringHelper(this) - .add("id", id).add("ip", ip).add("fixedIp", fixedIp).add("instanceId", instanceId); + .add("id", id).add("ip", ip).add("fixedIp", fixedIp).add("instanceId", instanceId).add("pool", pool); } - + @Override public String toString() { return string().toString(); diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApiLiveTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApiLiveTest.java index d85604c2ef..f65914f0d2 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApiLiveTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApiLiveTest.java @@ -34,9 +34,7 @@ import com.google.common.base.Optional; import com.google.common.collect.Multimap; /** - * Tests behavior of {@code ServerApi} - * - * @author Adrian Cole + * Tests the behavior of the {@link FloatingIPApi} */ @Test(groups = "live", testName = "FloatingIPApiLiveTest") public class FloatingIPApiLiveTest extends BaseNovaApiLiveTest { @@ -60,7 +58,7 @@ public class FloatingIPApiLiveTest extends BaseNovaApiLiveTest { assertEquals(newDetails.getIp(), ip.getIp()); assertEquals(newDetails.getFixedIp(), ip.getFixedIp()); assertEquals(newDetails.getInstanceId(), ip.getInstanceId()); - + assertEquals(newDetails.getPool(), ip.getPool()); } } } diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFloatingIPListTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFloatingIPListTest.java index 705b6e6f40..80a85690fe 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFloatingIPListTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFloatingIPListTest.java @@ -33,8 +33,7 @@ import com.google.inject.Guice; import com.google.inject.Injector; /** - * - * @author Michael Arnold + * Tests parsing of {@link FloatingIP} JSON data. */ @Test(groups = "unit", testName = "ParseFloatingIPListTest") public class ParseFloatingIPListTest extends BaseSetParserTest { @@ -48,8 +47,11 @@ public class ParseFloatingIPListTest extends BaseSetParserTest { @SelectJson("floating_ips") @Consumes(MediaType.APPLICATION_JSON) public Set expected() { - return ImmutableSet.of(FloatingIP.builder().id("1").instanceId("12").ip("10.0.0.3").fixedIp("11.0.0.1").build(), - FloatingIP.builder().id("2").instanceId(null).ip("10.0.0.5").fixedIp(null).build()); + return ImmutableSet.of( + FloatingIP.builder().id("1").instanceId("12").ip("10.0.0.3").fixedIp("11.0.0.1").pool("nova").build(), + FloatingIP.builder().id("2").instanceId(null).ip("10.0.0.5").fixedIp(null).pool("nova").build(), + FloatingIP.builder().id("3").instanceId("13").ip("10.0.0.13").fixedIp("11.0.0.3").build(), + FloatingIP.builder().id("4").instanceId("14").ip("10.0.0.14").fixedIp("11.0.0.4").pool(null).build()); } protected Injector injector() { diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFloatingIPTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFloatingIPTest.java index a75167c5bd..fb1921a9bf 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFloatingIPTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFloatingIPTest.java @@ -30,7 +30,7 @@ import com.google.inject.Guice; import com.google.inject.Injector; /** - * @author Michael Arnold + * Test to parse a {@link FloatingIP} */ @Test(groups = "unit", testName = "ParseFloatingIPTest") public class ParseFloatingIPTest extends BaseItemParserTest { @@ -44,7 +44,7 @@ public class ParseFloatingIPTest extends BaseItemParserTest { @SelectJson("floating_ip") @Consumes(MediaType.APPLICATION_JSON) public FloatingIP expected() { - return FloatingIP.builder().id("1").instanceId("123").fixedIp("10.0.0.2").ip("10.0.0.3").build(); + return FloatingIP.builder().id("1").instanceId("123").fixedIp("10.0.0.2").ip("10.0.0.3").pool("nova").build(); } protected Injector injector() { diff --git a/apis/openstack-nova/src/test/resources/floatingip_details.json b/apis/openstack-nova/src/test/resources/floatingip_details.json index c2411fd65f..7773b8e705 100644 --- a/apis/openstack-nova/src/test/resources/floatingip_details.json +++ b/apis/openstack-nova/src/test/resources/floatingip_details.json @@ -1,9 +1,9 @@ { - "floating_ip" : - { - "id" : 1, - "ip" : "10.0.0.3", - "fixed_ip" : "10.0.0.2", - "instance_id" : 123 - } -} \ No newline at end of file + "floating_ip": { + "id": 1, + "ip": "10.0.0.3", + "fixed_ip": "10.0.0.2", + "instance_id": 123, + "pool": "nova" + } +} diff --git a/apis/openstack-nova/src/test/resources/floatingip_list.json b/apis/openstack-nova/src/test/resources/floatingip_list.json index 27d251926a..73f22fb4ac 100644 --- a/apis/openstack-nova/src/test/resources/floatingip_list.json +++ b/apis/openstack-nova/src/test/resources/floatingip_list.json @@ -4,13 +4,27 @@ "instance_id": 12, "ip" : "10.0.0.3", "fixed_ip": "11.0.0.1", - "id" : 1 + "id" : 1, + "pool": "nova" }, { "instance_id": null, "ip": "10.0.0.5", "fixed_ip": null, - "id": 2 + "id": 2, + "pool": "nova" + }, + { + "instance_id": 13, + "ip": "10.0.0.13", + "fixed_ip": "11.0.0.3", + "id": 3 + }, + { + "instance_id": 14, + "ip": "10.0.0.14", + "fixed_ip": "11.0.0.4", + "id": 4 } ] -} \ No newline at end of file +}