diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Host.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Host.java index 72df77d5e6..2c690f48e8 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Host.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Host.java @@ -43,6 +43,7 @@ public class Host { protected String name; protected String service; + protected String zone; /** * @see Host#getName() @@ -60,14 +61,23 @@ public class Host { return self(); } + /** + * @see Host#getZone() + */ + public T zone(String zone) { + this.zone = zone; + return self(); + } + public Host build() { - return new Host(name, service); + return new Host(name, service, zone); } public T fromHost(Host in) { return this .name(in.getName()) - .service(in.getService()); + .service(in.getService()) + .zone(in.getZone()); } } @@ -81,13 +91,15 @@ public class Host { @Named("host_name") private final String name; private final String service; + private final String zone; @ConstructorProperties({ - "host_name", "service" + "host_name", "service", "zone" }) - protected Host(@Nullable String name, @Nullable String service) { + protected Host(@Nullable String name, @Nullable String service, @Nullable String zone) { this.name = name; this.service = service; + this.zone = zone; } @Nullable @@ -100,9 +112,13 @@ public class Host { return this.service; } + @Nullable + public String getZone() { + return this.zone; + } @Override public int hashCode() { - return Objects.hashCode(name, service); + return Objects.hashCode(name, service, zone); } @Override @@ -111,12 +127,13 @@ public class Host { if (obj == null || getClass() != obj.getClass()) return false; Host that = Host.class.cast(obj); return Objects.equal(this.name, that.name) - && Objects.equal(this.service, that.service); + && Objects.equal(this.service, that.service) + && Objects.equal(this.zone, that.zone); } protected ToStringHelper string() { return Objects.toStringHelper(this) - .add("name", name).add("service", service); + .add("name", name).add("service", service).add("zone", zone); } @Override diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationApiExpectTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationApiExpectTest.java index 3b3f01f81c..0414bda368 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationApiExpectTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationApiExpectTest.java @@ -53,12 +53,13 @@ public class HostAdministrationApiExpectTest extends BaseNovaApiExpectTest { .endpoint(endpoint).build(), HttpResponse.builder().statusCode(200).payload(payloadFromResource("/hosts_list.json")).build()).getHostAdministrationExtensionForZone("az-1.region-a.geo-1").get(); - Host expected = Host.builder().name("ubuntu").service("compute").build(); + Host expected = Host.builder().name("ubuntu").service("compute").zone("nova").build(); Set result = api.list().toSet(); Host host = Iterables.getOnlyElement(result); assertEquals(host.getName(), "ubuntu"); assertEquals(host.getService(), "compute"); + assertEquals(host.getZone(), "nova"); assertEquals(host, expected); } diff --git a/apis/openstack-nova/src/test/resources/hosts_list.json b/apis/openstack-nova/src/test/resources/hosts_list.json index 6eb136179c..ab06b0d240 100644 --- a/apis/openstack-nova/src/test/resources/hosts_list.json +++ b/apis/openstack-nova/src/test/resources/hosts_list.json @@ -1,6 +1,7 @@ { "hosts": [ { + "zone": "nova", "host_name": "ubuntu", "service": "compute" }