add availability zone to server

This commit is contained in:
lbortman 2014-10-14 17:46:10 +03:00 committed by Jeremy Daggett
parent 8439c7238d
commit 3e8413335d
10 changed files with 381 additions and 262 deletions

View File

@ -157,28 +157,24 @@ public class NovaParserModule extends AbstractModule {
}
private static class ServerInternal extends Server {
@ConstructorProperties({
"id", "name", "links", "uuid", "tenant_id", "user_id", "updated", "created", "hostId", "accessIPv4", "accessIPv6", "status", "image", "flavor", "key_name", "config_drive", "addresses", "metadata", "extendedStatus", "extendedAttributes", "OS-DCF:diskConfig"
})
@ConstructorProperties({"id", "name", "links", "uuid", "tenant_id", "user_id", "updated", "created", "hostId", "accessIPv4", "accessIPv6", "status", "image", "flavor", "key_name", "config_drive", "addresses", "metadata", "extendedStatus", "extendedAttributes", "OS-DCF:diskConfig", "OS-EXT-AZ:availability_zone"})
protected ServerInternal(String id, @Nullable String name, java.util.Set<Link> links, @Nullable String uuid, String tenantId,
String userId, Date updated, Date created, @Nullable String hostId, @Nullable String accessIPv4,
@Nullable String accessIPv6, Server.Status status, Resource image, Resource flavor, @Nullable String keyName,
@Nullable String configDrive, Multimap<String, Address> addresses, Map<String, String> metadata,
@Nullable ServerExtendedStatus extendedStatus, @Nullable ServerExtendedAttributes extendedAttributes, @Nullable String diskConfig) {
super(id, name, links, uuid, tenantId, userId, updated, created, hostId, accessIPv4, accessIPv6, status, image, flavor, keyName, configDrive, addresses, metadata, extendedStatus, extendedAttributes, diskConfig);
@Nullable ServerExtendedStatus extendedStatus, @Nullable ServerExtendedAttributes extendedAttributes, @Nullable String diskConfig, @Nullable String availabilityZone) {
super(id, name, links, uuid, tenantId, userId, updated, created, hostId, accessIPv4, accessIPv6, status, image, flavor, keyName, configDrive, addresses, metadata, extendedStatus, extendedAttributes, diskConfig, availabilityZone);
}
}
private static class ServerInternalWithoutImage extends Server {
@ConstructorProperties({
"id", "name", "links", "uuid", "tenant_id", "user_id", "updated", "created", "hostId", "accessIPv4", "accessIPv6", "status", "flavor", "key_name", "config_drive", "addresses", "metadata", "extendedStatus", "extendedAttributes", "OS-DCF:diskConfig"
})
@ConstructorProperties({"id", "name", "links", "uuid", "tenant_id", "user_id", "updated", "created", "hostId", "accessIPv4", "accessIPv6", "status", "flavor", "key_name", "config_drive", "addresses", "metadata", "extendedStatus", "extendedAttributes", "OS-DCF:diskConfig", "OS-EXT-AZ:availability_zone"})
protected ServerInternalWithoutImage(String id, @Nullable String name, java.util.Set<Link> links, @Nullable String uuid, String tenantId,
String userId, Date updated, Date created, @Nullable String hostId, @Nullable String accessIPv4,
@Nullable String accessIPv6, Server.Status status, Resource flavor, @Nullable String keyName,
@Nullable String configDrive, Multimap<String, Address> addresses, Map<String, String> metadata,
@Nullable ServerExtendedStatus extendedStatus, @Nullable ServerExtendedAttributes extendedAttributes, @Nullable String diskConfig) {
super(id, name, links, uuid, tenantId, userId, updated, created, hostId, accessIPv4, accessIPv6, status, null, flavor, keyName, configDrive, addresses, metadata, extendedStatus, extendedAttributes, diskConfig);
@Nullable ServerExtendedStatus extendedStatus, @Nullable ServerExtendedAttributes extendedAttributes, @Nullable String diskConfig, @Nullable String availabilityZone) {
super(id, name, links, uuid, tenantId, userId, updated, created, hostId, accessIPv4, accessIPv6, status, null, flavor, keyName, configDrive, addresses, metadata, extendedStatus, extendedAttributes, diskConfig, availabilityZone);
}
}
}

View File

@ -107,6 +107,7 @@ public class Server extends Resource {
protected ServerExtendedStatus extendedStatus;
protected ServerExtendedAttributes extendedAttributes;
protected String diskConfig;
protected String availabilityZone;
/**
* @see Server#getUuid()
@ -252,10 +253,18 @@ public class Server extends Resource {
return self();
}
/**
* @see Server#getAvailabilityZone()
*/
public T availabilityZone(String availabilityZone) {
this.availabilityZone = availabilityZone;
return self();
}
public Server build() {
return new Server(id, name, links, uuid, tenantId, userId, updated, created, hostId, accessIPv4, accessIPv6,
status, image, flavor, keyName, configDrive, addresses, metadata, extendedStatus,
extendedAttributes, diskConfig);
extendedAttributes, diskConfig, availabilityZone);
}
public T fromServer(Server in) {
@ -277,7 +286,8 @@ public class Server extends Resource {
.metadata(in.getMetadata())
.extendedStatus(in.getExtendedStatus().orNull())
.extendedAttributes(in.getExtendedAttributes().orNull())
.diskConfig(in.getDiskConfig().orNull());
.diskConfig(in.getDiskConfig().orNull())
.availabilityZone(in.getAvailabilityZone().orNull());
}
}
@ -311,16 +321,16 @@ public class Server extends Resource {
private final Optional<ServerExtendedAttributes> extendedAttributes;
@Named("OS-DCF:diskConfig")
private final Optional<String> diskConfig;
@Named("OS-EXT-AZ:availability_zone")
private final Optional<String> availabilityZone;
@ConstructorProperties({
"id", "name", "links", "uuid", "tenant_id", "user_id", "updated", "created", "hostId", "accessIPv4", "accessIPv6", "status", "image", "flavor", "key_name", "config_drive", "addresses", "metadata", "extendedStatus", "extendedAttributes", "OS-DCF:diskConfig"
})
@ConstructorProperties({"id", "name", "links", "uuid", "tenant_id", "user_id", "updated", "created", "hostId", "accessIPv4", "accessIPv6", "status", "image", "flavor", "key_name", "config_drive", "addresses", "metadata", "extendedStatus", "extendedAttributes", "OS-DCF:diskConfig", "OS-EXT-AZ:availability_zone"})
protected Server(String id, @Nullable String name, java.util.Set<Link> links, @Nullable String uuid, String tenantId,
String userId, @Nullable Date updated, Date created, @Nullable String hostId, @Nullable String accessIPv4,
@Nullable String accessIPv6, Server.Status status, @Nullable Resource image, Resource flavor, @Nullable String keyName,
@Nullable String configDrive, Multimap<String, Address> addresses, Map<String, String> metadata,
@Nullable ServerExtendedStatus extendedStatus, @Nullable ServerExtendedAttributes extendedAttributes,
@Nullable String diskConfig) {
@Nullable String diskConfig, @Nullable String availabilityZone) {
super(id, name, links);
this.uuid = uuid;
this.tenantId = checkNotNull(tenantId, "tenantId");
@ -340,6 +350,7 @@ public class Server extends Resource {
this.extendedStatus = Optional.fromNullable(extendedStatus);
this.extendedAttributes = Optional.fromNullable(extendedAttributes);
this.diskConfig = Optional.fromNullable(diskConfig);
this.availabilityZone = Optional.fromNullable(availabilityZone);
}
/**
@ -466,6 +477,14 @@ public class Server extends Resource {
return this.diskConfig;
}
/**
* return the Availability Zone of a server
* @see org.jclouds.openstack.nova.v2_0.extensions.ExtensionNamespaces#AVAILABILITY_ZONE
*/
@Nullable
public Optional<String> getAvailabilityZone() {
return this.availabilityZone;
}
// hashCode/equals from super is ok
@ -476,7 +495,8 @@ public class Server extends Resource {
.add("hostId", hostId).add("accessIPv4", accessIPv4).add("accessIPv6", accessIPv6).add("status", status).add("image", image)
.add("flavor", flavor).add("keyName", keyName).add("configDrive", configDrive).add("addresses", addresses)
.add("metadata", metadata).add("extendedStatus", extendedStatus).add("extendedAttributes", extendedAttributes)
.add("diskConfig", diskConfig);
.add("diskConfig", diskConfig)
.add("availabilityZone", availabilityZone);
}
}

View File

@ -36,18 +36,15 @@ import com.google.common.base.Objects.ToStringHelper;
*/
public class ServerExtendedAttributes {
public static String PREFIX;
public static Builder<?> builder() {
public static Builder builder() {
return new ConcreteBuilder();
}
public Builder<?> toBuilder() {
public Builder toBuilder() {
return new ConcreteBuilder().fromServerExtendedAttributes(this);
}
public abstract static class Builder<T extends Builder<T>> {
protected abstract T self();
public static class Builder {
protected String instanceName;
protected String hostName;
@ -56,7 +53,7 @@ public class ServerExtendedAttributes {
/**
* @see ServerExtendedAttributes#getInstanceName()
*/
public T instanceName(String instanceName) {
public Builder instanceName(String instanceName) {
this.instanceName = instanceName;
return self();
}
@ -64,7 +61,7 @@ public class ServerExtendedAttributes {
/**
* @see ServerExtendedAttributes#getHostName()
*/
public T hostName(String hostName) {
public Builder hostName(String hostName) {
this.hostName = hostName;
return self();
}
@ -72,7 +69,7 @@ public class ServerExtendedAttributes {
/**
* @see ServerExtendedAttributes#getHypervisorHostName()
*/
public T hypervisorHostName(String hypervisorHostName) {
public Builder hypervisorHostName(String hypervisorHostName) {
this.hypervisorHostName = hypervisorHostName;
return self();
}
@ -81,15 +78,19 @@ public class ServerExtendedAttributes {
return new ServerExtendedAttributes(instanceName, hostName, hypervisorHostName);
}
public T fromServerExtendedAttributes(ServerExtendedAttributes in) {
public Builder fromServerExtendedAttributes(ServerExtendedAttributes in) {
return this
.instanceName(in.getInstanceName())
.hostName(in.getHostName())
.hypervisorHostName(in.getHypervisorHostName());
}
protected Builder self(){
return this;
}
}
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
private static class ConcreteBuilder extends Builder {
@Override
protected ConcreteBuilder self() {
return this;
@ -103,9 +104,7 @@ public class ServerExtendedAttributes {
@Named("OS-EXT-SRV-ATTR:hypervisor_hostname")
private final String hypervisorHostName;
@ConstructorProperties({
"OS-EXT-SRV-ATTR:instance_name", "OS-EXT-SRV-ATTR:host", "OS-EXT-SRV-ATTR:hypervisor_hostname"
})
@ConstructorProperties({"OS-EXT-SRV-ATTR:instance_name", "OS-EXT-SRV-ATTR:host", "OS-EXT-SRV-ATTR:hypervisor_hostname"})
protected ServerExtendedAttributes(@Nullable String instanceName, @Nullable String hostName, @Nullable String hypervisorHostName) {
this.instanceName = instanceName;
this.hostName = hostName;

View File

@ -69,7 +69,7 @@ public class ServerWithSecurityGroups extends Server {
public ServerWithSecurityGroups build() {
return new ServerWithSecurityGroups(id, name, links, uuid, tenantId, userId, updated, created, hostId,
accessIPv4, accessIPv6, status, image, flavor, keyName, configDrive, addresses,
metadata, extendedStatus, extendedAttributes, diskConfig, securityGroupNames);
metadata, extendedStatus, extendedAttributes, diskConfig, securityGroupNames, availabilityZone);
}
public T fromServerWithSecurityGroups(ServerWithSecurityGroups in) {
@ -88,17 +88,15 @@ public class ServerWithSecurityGroups extends Server {
@Named("security_groups")
private final Set<String> securityGroupNames;
@ConstructorProperties({
"id", "name", "links", "uuid", "tenant_id", "user_id", "updated", "created", "hostId", "accessIPv4", "accessIPv6", "status", "image", "flavor", "key_name", "config_drive", "addresses", "metadata", "extendedStatus", "extendedAttributes", "OS-DCF:diskConfig", "security_groups"
})
@ConstructorProperties({"id", "name", "links", "uuid", "tenant_id", "user_id", "updated", "created", "hostId", "accessIPv4", "accessIPv6", "status", "image", "flavor", "key_name", "config_drive", "addresses", "metadata", "extendedStatus", "extendedAttributes", "OS-DCF:diskConfig", "security_groups", "OS-EXT-AZ:availability_zone"})
protected ServerWithSecurityGroups(String id, @Nullable String name, Set<Link> links, @Nullable String uuid,
String tenantId, String userId, Date updated, Date created, @Nullable String hostId,
@Nullable String accessIPv4, @Nullable String accessIPv6, Server.Status status, Resource image,
Resource flavor, @Nullable String keyName, @Nullable String configDrive,
Multimap<String, Address> addresses, Map<String, String> metadata,
@Nullable ServerExtendedStatus extendedStatus, @Nullable ServerExtendedAttributes extendedAttributes,
@Nullable String diskConfig, Set<String> securityGroupNames) {
super(id, name, links, uuid, tenantId, userId, updated, created, hostId, accessIPv4, accessIPv6, status, image, flavor, keyName, configDrive, addresses, metadata, extendedStatus, extendedAttributes, diskConfig);
@Nullable String diskConfig, Set<String> securityGroupNames, @Nullable String availabilityZone) {
super(id, name, links, uuid, tenantId, userId, updated, created, hostId, accessIPv4, accessIPv6, status, image, flavor, keyName, configDrive, addresses, metadata, extendedStatus, extendedAttributes, diskConfig, availabilityZone);
this.securityGroupNames = ImmutableSet.copyOf(checkNotNull(securityGroupNames, "securityGroupNames"));
}

View File

@ -0,0 +1,50 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.openstack.nova.v2_0.extensions;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
import org.jclouds.openstack.nova.v2_0.NovaApi;
import org.jclouds.openstack.nova.v2_0.domain.Server;
import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiExpectTest;
import org.testng.annotations.Test;
import static org.testng.Assert.assertNotNull;
@Test(groups = "unit", testName = "ExtendedAvailabilityZoneExpectTest")
public class ExtendedAvailabilityZoneExpectTest extends BaseNovaApiExpectTest{
public void testAvailabilityZoneInServerDetails() throws Exception {
String serverId = "71752";
HttpRequest serverDetail = HttpRequest
.builder()
.method("GET")
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/" + serverId)
.addHeader("Accept", "application/json")
.addHeader("X-Auth-Token", authToken).build();
HttpResponse serverDetailResponse = HttpResponse.builder().statusCode(200)
.payload(payloadFromResource("/server_details.json")).build();
NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
responseWithKeystoneAccess, serverDetail, serverDetailResponse);
Server server = apiWhenServerExists.getServerApi("az-1.region-a.geo-1").get(serverId);
assertNotNull(server.getAvailabilityZone());
}
}

View File

@ -0,0 +1,41 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.openstack.nova.v2_0.extensions;
import org.jclouds.openstack.nova.v2_0.domain.Server;
import org.jclouds.openstack.nova.v2_0.features.ServerApi;
import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest;
import org.testng.annotations.Test;
import static org.testng.Assert.assertNotNull;
@Test(groups = "live", testName = "ExtendedAvailabilityZoneLiveTest")
public class ExtendedAvailabilityZoneLiveTest extends BaseNovaApiLiveTest {
public void testListServersInDetailsReturnAvalibiltyZone() throws Exception {
for (String regionId : regions) {
ServerApi serverApi = api.getServerApi(regionId);
for (Server server : serverApi.listInDetail().concat()) {
if (server.getAvailabilityZone().isPresent()) {
assertNotNull(server.getAvailabilityZone().get());
}
}
}
}
}

View File

@ -16,12 +16,9 @@
*/
package org.jclouds.openstack.nova.v2_0.features;
import static org.jclouds.openstack.nova.v2_0.domain.Server.Status.ACTIVE;
import static org.jclouds.openstack.nova.v2_0.predicates.ServerPredicates.awaitActive;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import org.jclouds.http.HttpResponseException;
import org.jclouds.openstack.nova.v2_0.domain.BlockDeviceMapping;
import org.jclouds.openstack.nova.v2_0.domain.Network;
@ -37,9 +34,11 @@ import org.jclouds.openstack.v2_0.features.ExtensionApi;
import org.jclouds.openstack.v2_0.predicates.LinkPredicates;
import org.testng.annotations.Test;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import static org.jclouds.openstack.nova.v2_0.domain.Server.Status.ACTIVE;
import static org.jclouds.openstack.nova.v2_0.predicates.ServerPredicates.awaitActive;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
/**
* Tests behavior of {@link ServerApi}
@ -135,9 +134,9 @@ public class ServerApiLiveTest extends BaseNovaApiLiveTest {
/**
* This test creates a new server with a boot device from an image.
*
* <p/>
* This needs to be supported by the provider, and is usually not supported.
*
* <p/>
* TODO: Configurable system properties for flavor/image refs.
*/
@Test

View File

@ -59,7 +59,8 @@ public class ParseServerDetailsStatesTest extends BaseSetParserTest<Server> {
URI.create("http://openstack:8774/v2/4e1900cf21924a098709c23480e157c0/servers/56d51a88-0066-4976-91b6-d1b453be603f")),
Link.create(
Relation.BOOKMARK,
URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/servers/56d51a88-0066-4976-91b6-d1b453be603f")))
URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/servers/56d51a88-0066-4976-91b6-d1b453be603f"))
)
.image(Resource.builder()
.id("e3f84189-964e-4dc3-8ac6-832c2b7553d4")
.links(Link.create(
@ -83,6 +84,7 @@ public class ParseServerDetailsStatesTest extends BaseSetParserTest<Server> {
.extendedStatus(ServerExtendedStatus.builder().vmState("building").powerState(0).taskState("spawning")
.build())
.diskConfig("MANUAL")
.availabilityZone("nova")
.extendedAttributes(
ServerExtendedAttributes.builder()
.instanceName("instance-0000000b")
@ -96,7 +98,8 @@ public class ParseServerDetailsStatesTest extends BaseSetParserTest<Server> {
URI.create("http://openstack:8774/v2/4e1900cf21924a098709c23480e157c0/servers/3bc8ab03-52e7-4d2b-ba88-73f9ecadf003")),
Link.create(
Relation.BOOKMARK,
URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/servers/3bc8ab03-52e7-4d2b-ba88-73f9ecadf003")))
URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/servers/3bc8ab03-52e7-4d2b-ba88-73f9ecadf003"))
)
.image(Resource.builder()
.id("e3f84189-964e-4dc3-8ac6-832c2b7553d4")
.links(Link.create(
@ -119,6 +122,7 @@ public class ParseServerDetailsStatesTest extends BaseSetParserTest<Server> {
.tenantId("4e1900cf21924a098709c23480e157c0")
.extendedStatus(ServerExtendedStatus.builder().vmState("active").powerState(1).build())
.diskConfig("MANUAL")
.availabilityZone("nova")
.extendedAttributes(
ServerExtendedAttributes.builder()
.instanceName("instance-00000009")
@ -135,7 +139,8 @@ public class ParseServerDetailsStatesTest extends BaseSetParserTest<Server> {
URI.create("http://openstack:8774/v2/4e1900cf21924a098709c23480e157c0/servers/cad76945-8851-489a-99e1-f1049e02c769")),
Link.create(
Relation.BOOKMARK,
URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/servers/cad76945-8851-489a-99e1-f1049e02c769")))
URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/servers/cad76945-8851-489a-99e1-f1049e02c769"))
)
.image(Resource.builder()
.id("e3f84189-964e-4dc3-8ac6-832c2b7553d4")
.links(Link.create(
@ -157,6 +162,7 @@ public class ParseServerDetailsStatesTest extends BaseSetParserTest<Server> {
.tenantId("4e1900cf21924a098709c23480e157c0")
.extendedStatus(ServerExtendedStatus.builder().vmState("shelved_offloaded").powerState(4).build())
.diskConfig("MANUAL")
.availabilityZone("nova")
.extendedAttributes(
ServerExtendedAttributes.builder()
.instanceName("instance-00000006").build()
@ -171,7 +177,8 @@ public class ParseServerDetailsStatesTest extends BaseSetParserTest<Server> {
URI.create("http://openstack:8774/v2/4e1900cf21924a098709c23480e157c0/servers/89142a4f-f58c-4205-8571-65f4a2be2bc9")),
Link.create(
Relation.BOOKMARK,
URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/servers/89142a4f-f58c-4205-8571-65f4a2be2bc9")))
URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/servers/89142a4f-f58c-4205-8571-65f4a2be2bc9"))
)
.image(Resource.builder()
.id("e3f84189-964e-4dc3-8ac6-832c2b7553d4")
.links(Link.create(
@ -194,6 +201,7 @@ public class ParseServerDetailsStatesTest extends BaseSetParserTest<Server> {
.tenantId("4e1900cf21924a098709c23480e157c0")
.extendedStatus(ServerExtendedStatus.builder().vmState("rescued").powerState(1).build())
.diskConfig("MANUAL")
.availabilityZone("nova")
.extendedAttributes(
ServerExtendedAttributes.builder()
.instanceName("instance-00000005")
@ -210,7 +218,8 @@ public class ParseServerDetailsStatesTest extends BaseSetParserTest<Server> {
URI.create("http://openstack:8774/v2/4e1900cf21924a098709c23480e157c0/servers/fac50d26-bb38-455f-ad92-eba790187c00")),
Link.create(
Relation.BOOKMARK,
URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/servers/fac50d26-bb38-455f-ad92-eba790187c00")))
URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/servers/fac50d26-bb38-455f-ad92-eba790187c00"))
)
.image(Resource.builder()
.id("e3f84189-964e-4dc3-8ac6-832c2b7553d4")
.links(Link.create(
@ -233,6 +242,7 @@ public class ParseServerDetailsStatesTest extends BaseSetParserTest<Server> {
.tenantId("4e1900cf21924a098709c23480e157c0")
.extendedStatus(ServerExtendedStatus.builder().vmState("stopped").powerState(4).build())
.diskConfig("MANUAL")
.availabilityZone("nova")
.extendedAttributes(
ServerExtendedAttributes.builder()
.instanceName("instance-00000004")

View File

@ -16,11 +16,10 @@
*/
package org.jclouds.openstack.nova.v2_0.parse;
import java.net.URI;
import javax.ws.rs.Consumes;
import javax.ws.rs.core.MediaType;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.inject.Guice;
import com.google.inject.Injector;
import org.jclouds.date.internal.SimpleDateFormatDateService;
import org.jclouds.json.BaseItemParserTest;
import org.jclouds.json.config.GsonModule;
@ -34,10 +33,9 @@ import org.jclouds.openstack.v2_0.domain.Resource;
import org.jclouds.rest.annotations.SelectJson;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.inject.Guice;
import com.google.inject.Injector;
import javax.ws.rs.Consumes;
import javax.ws.rs.core.MediaType;
import java.net.URI;
import static org.jclouds.openstack.nova.v2_0.domain.Address.createV4;
import static org.jclouds.openstack.nova.v2_0.domain.Address.createV6;
@ -67,6 +65,7 @@ public class ParseServerTest extends BaseItemParserTest<Server> {
.accessIPv6("::babe:67.23.10.132")
.status(Status.BUILD)
.diskConfig(Server.DISK_CONFIG_AUTO)
.availabilityZone("nova")
.image(
Resource
.builder()
@ -78,8 +77,10 @@ public class ParseServerTest extends BaseItemParserTest<Server> {
URI.create("http://servers.api.openstack.org/v2/1234/images/52415800-8b69-11e0-9b19-734f6f006e54")),
Link.create(
Relation.BOOKMARK,
URI.create("http://servers.api.openstack.org/1234/images/52415800-8b69-11e0-9b19-734f6f006e54")))
.build())
URI.create("http://servers.api.openstack.org/1234/images/52415800-8b69-11e0-9b19-734f6f006e54"))
)
.build()
)
.flavor(
Resource
.builder()
@ -91,11 +92,14 @@ public class ParseServerTest extends BaseItemParserTest<Server> {
URI.create("http://servers.api.openstack.org/v2/1234/flavors/52415800-8b69-11e0-9b19-734f216543fd")),
Link.create(
Relation.BOOKMARK,
URI.create("http://servers.api.openstack.org/1234/flavors/52415800-8b69-11e0-9b19-734f216543fd")))
.build())
URI.create("http://servers.api.openstack.org/1234/flavors/52415800-8b69-11e0-9b19-734f216543fd"))
)
.build()
)
.metadata(
new ImmutableMap.Builder<String, String>().put("Server Label", "Web Head 1")
.put("Image Version", "2.1").build())
.put("Image Version", "2.1").build()
)
.addresses(ImmutableMultimap.<String, Address>builder()
.putAll("public", createV4("67.23.10.132"), createV6("::babe:67.23.10.132"), createV4("67.23.10.131"), createV6("::babe:4317:0A83"))
.putAll("private", createV4("10.176.42.16"), createV6("::babe:10.176.42.16"))
@ -104,7 +108,8 @@ public class ParseServerTest extends BaseItemParserTest<Server> {
Relation.SELF, URI.create("http://servers.api.openstack.org/v2/1234/servers/71752")),
Link.create(
Relation.BOOKMARK,
URI.create("http://servers.api.openstack.org/1234/servers/71752")))
URI.create("http://servers.api.openstack.org/1234/servers/71752"))
)
.build();
}

View File

@ -12,6 +12,7 @@
"status": "BUILD(scheduling)",
"progress": 60,
"OS-DCF:diskConfig": "AUTO",
"OS-EXT-AZ:availability_zone": "nova",
"image": {
"id": "52415800-8b69-11e0-9b19-734f6f006e54",
"links": [