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);
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, @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,27 +36,24 @@ 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;
protected String hypervisorHostName;
/**
* @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());
.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}
@ -67,7 +66,7 @@ public class ServerApiLiveTest extends BaseNovaApiLiveTest {
}
}
@Test(description = "GET /v${apiVersion}/{tenantId}/servers/{id}", dependsOnMethods = { "testListServersInDetail" })
@Test(description = "GET /v${apiVersion}/{tenantId}/servers/{id}", dependsOnMethods = {"testListServersInDetail"})
public void testGetServerById() throws Exception {
for (String regionId : regions) {
ServerApi serverApi = api.getServerApi(regionId);
@ -117,7 +116,7 @@ public class ServerApiLiveTest extends BaseNovaApiLiveTest {
CreateServerOptions options = CreateServerOptions.Builder.novaNetworks(
// This network UUID must match an existing network.
ImmutableSet.of(Network.builder().networkUuid("bc4cfa2b-2b27-4671-8e8f-73009623def0").fixedIp("192.168.55.56").build())
);
);
ServerCreated server = serverApi.create(hostName, imageIdForRegion(regionId), "1", options);
serverId = server.getId();
@ -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
@ -183,7 +182,7 @@ public class ServerApiLiveTest extends BaseNovaApiLiveTest {
for (String regionId : regions) {
ServerApi serverApi = api.getServerApi(regionId);
try {
serverId = createServer(regionId, "err").getId();
serverId = createServer(regionId, "err").getId();
} catch (HttpResponseException e) {
// Here is an implementation detail difference between OpenStack and some providers.
// Some providers accept a bad availability zone and create the server in the zoneId.
@ -237,7 +236,7 @@ public class ServerApiLiveTest extends BaseNovaApiLiveTest {
CreateServerOptions options = new CreateServerOptions();
if (availabilityZoneId != null) {
options = options.availabilityZone(availabilityZoneId);
options = options.availabilityZone(availabilityZoneId);
}
ServerCreated server = serverApi.create(hostName, imageIdForRegion(regionId), flavorRefForRegion(regionId), options);

View File

@ -52,196 +52,206 @@ public class ParseServerDetailsStatesTest extends BaseSetParserTest<Server> {
@Consumes(MediaType.APPLICATION_JSON)
public Set<Server> expected() {
return ImmutableSet.<Server>of(
Server.builder()
.links(
Link.create(
Relation.SELF,
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")))
.image(Resource.builder()
.id("e3f84189-964e-4dc3-8ac6-832c2b7553d4")
.links(Link.create(
Relation.BOOKMARK,
URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/images/e3f84189-964e-4dc3-8ac6-832c2b7553d4")))
.build())
.flavor(Resource.builder()
.id("6")
.links(Link.create(
Relation.BOOKMARK,
URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/flavors/6")))
.build())
.id("56d51a88-0066-4976-91b6-d1b453be603f")
.userId("08ba127f0d6842279f9db8e8bc6977e9")
.status(Status.BUILD)
.updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2014-03-19T11:54:59Z"))
.hostId("0bc453b1c10348e9dc398fed7a5b06f996964ae1643fe460a85a23d8")
.name("machine_5")
.created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2014-03-19T11:54:57Z"))
.tenantId("4e1900cf21924a098709c23480e157c0")
.extendedStatus(ServerExtendedStatus.builder().vmState("building").powerState(0).taskState("spawning")
.build())
.diskConfig("MANUAL")
.extendedAttributes(
ServerExtendedAttributes.builder()
.instanceName("instance-0000000b")
.hostName("rdohavana.localdomain")
.hypervisorHostName("rdohavana.localdomain").build()
).build(),
Server.builder()
.links(
Link.create(
Relation.SELF,
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")))
.image(Resource.builder()
.id("e3f84189-964e-4dc3-8ac6-832c2b7553d4")
.links(Link.create(
Relation.BOOKMARK,
URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/images/e3f84189-964e-4dc3-8ac6-832c2b7553d4")))
.build())
.flavor(Resource.builder()
.id("6")
.links(Link.create(
Relation.BOOKMARK,
URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/flavors/6")))
.build())
.id("3bc8ab03-52e7-4d2b-ba88-73f9ecadf003")
.userId("08ba127f0d6842279f9db8e8bc6977e9")
.status(Status.ACTIVE)
.updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2014-03-19T11:52:21Z"))
.hostId("0bc453b1c10348e9dc398fed7a5b06f996964ae1643fe460a85a23d8")
.name("machine_4")
.created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2014-03-19T11:51:53Z"))
.tenantId("4e1900cf21924a098709c23480e157c0")
.extendedStatus(ServerExtendedStatus.builder().vmState("active").powerState(1).build())
.diskConfig("MANUAL")
.extendedAttributes(
ServerExtendedAttributes.builder()
.instanceName("instance-00000009")
.hostName("rdohavana.localdomain")
.hypervisorHostName("rdohavana.localdomain").build()
)
.addresses(ImmutableMultimap.<String, Address>builder()
Server.builder()
.links(
Link.create(
Relation.SELF,
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"))
)
.image(Resource.builder()
.id("e3f84189-964e-4dc3-8ac6-832c2b7553d4")
.links(Link.create(
Relation.BOOKMARK,
URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/images/e3f84189-964e-4dc3-8ac6-832c2b7553d4")))
.build())
.flavor(Resource.builder()
.id("6")
.links(Link.create(
Relation.BOOKMARK,
URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/flavors/6")))
.build())
.id("56d51a88-0066-4976-91b6-d1b453be603f")
.userId("08ba127f0d6842279f9db8e8bc6977e9")
.status(Status.BUILD)
.updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2014-03-19T11:54:59Z"))
.hostId("0bc453b1c10348e9dc398fed7a5b06f996964ae1643fe460a85a23d8")
.name("machine_5")
.created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2014-03-19T11:54:57Z"))
.tenantId("4e1900cf21924a098709c23480e157c0")
.extendedStatus(ServerExtendedStatus.builder().vmState("building").powerState(0).taskState("spawning")
.build())
.diskConfig("MANUAL")
.availabilityZone("nova")
.extendedAttributes(
ServerExtendedAttributes.builder()
.instanceName("instance-0000000b")
.hostName("rdohavana.localdomain")
.hypervisorHostName("rdohavana.localdomain").build()
).build(),
Server.builder()
.links(
Link.create(
Relation.SELF,
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"))
)
.image(Resource.builder()
.id("e3f84189-964e-4dc3-8ac6-832c2b7553d4")
.links(Link.create(
Relation.BOOKMARK,
URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/images/e3f84189-964e-4dc3-8ac6-832c2b7553d4")))
.build())
.flavor(Resource.builder()
.id("6")
.links(Link.create(
Relation.BOOKMARK,
URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/flavors/6")))
.build())
.id("3bc8ab03-52e7-4d2b-ba88-73f9ecadf003")
.userId("08ba127f0d6842279f9db8e8bc6977e9")
.status(Status.ACTIVE)
.updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2014-03-19T11:52:21Z"))
.hostId("0bc453b1c10348e9dc398fed7a5b06f996964ae1643fe460a85a23d8")
.name("machine_4")
.created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2014-03-19T11:51:53Z"))
.tenantId("4e1900cf21924a098709c23480e157c0")
.extendedStatus(ServerExtendedStatus.builder().vmState("active").powerState(1).build())
.diskConfig("MANUAL")
.availabilityZone("nova")
.extendedAttributes(
ServerExtendedAttributes.builder()
.instanceName("instance-00000009")
.hostName("rdohavana.localdomain")
.hypervisorHostName("rdohavana.localdomain").build()
)
.addresses(ImmutableMultimap.<String, Address>builder()
.putAll("public", Address.createV4("172.24.4.232")).build()
).build(),
Server.builder()
.links(
Link.create(
Relation.SELF,
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")))
.image(Resource.builder()
.id("e3f84189-964e-4dc3-8ac6-832c2b7553d4")
.links(Link.create(
Relation.BOOKMARK,
URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/images/e3f84189-964e-4dc3-8ac6-832c2b7553d4")))
.build())
.flavor(Resource.builder()
.id("6")
.links(Link.create(
Relation.BOOKMARK,
URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/flavors/6")))
.build())
.id("cad76945-8851-489a-99e1-f1049e02c769")
.userId("08ba127f0d6842279f9db8e8bc6977e9")
.status(Status.SHELVED_OFFLOADED)
.updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2014-03-19T11:38:05Z"))
.name("machine_3")
.created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2014-03-19T11:33:27Z"))
.tenantId("4e1900cf21924a098709c23480e157c0")
.extendedStatus(ServerExtendedStatus.builder().vmState("shelved_offloaded").powerState(4).build())
.diskConfig("MANUAL")
.extendedAttributes(
ServerExtendedAttributes.builder()
.instanceName("instance-00000006").build()
)
.addresses(ImmutableMultimap.<String, Address>builder()
).build(),
Server.builder()
.links(
Link.create(
Relation.SELF,
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"))
)
.image(Resource.builder()
.id("e3f84189-964e-4dc3-8ac6-832c2b7553d4")
.links(Link.create(
Relation.BOOKMARK,
URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/images/e3f84189-964e-4dc3-8ac6-832c2b7553d4")))
.build())
.flavor(Resource.builder()
.id("6")
.links(Link.create(
Relation.BOOKMARK,
URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/flavors/6")))
.build())
.id("cad76945-8851-489a-99e1-f1049e02c769")
.userId("08ba127f0d6842279f9db8e8bc6977e9")
.status(Status.SHELVED_OFFLOADED)
.updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2014-03-19T11:38:05Z"))
.name("machine_3")
.created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2014-03-19T11:33:27Z"))
.tenantId("4e1900cf21924a098709c23480e157c0")
.extendedStatus(ServerExtendedStatus.builder().vmState("shelved_offloaded").powerState(4).build())
.diskConfig("MANUAL")
.availabilityZone("nova")
.extendedAttributes(
ServerExtendedAttributes.builder()
.instanceName("instance-00000006").build()
)
.addresses(ImmutableMultimap.<String, Address>builder()
.putAll("public", Address.createV4("172.24.4.229")).build()
).build(),
Server.builder()
.links(
Link.create(
Relation.SELF,
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")))
.image(Resource.builder()
.id("e3f84189-964e-4dc3-8ac6-832c2b7553d4")
.links(Link.create(
Relation.BOOKMARK,
URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/images/e3f84189-964e-4dc3-8ac6-832c2b7553d4")))
.build())
.flavor(Resource.builder()
.id("6")
.links(Link.create(
Relation.BOOKMARK,
URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/flavors/6")))
.build())
.id("89142a4f-f58c-4205-8571-65f4a2be2bc9")
.userId("08ba127f0d6842279f9db8e8bc6977e9")
.status(Status.RESCUE)
.updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2014-03-19T11:36:05Z"))
.hostId("0bc453b1c10348e9dc398fed7a5b06f996964ae1643fe460a85a23d8")
.name("machine_2")
.created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2014-03-19T11:31:19Z"))
.tenantId("4e1900cf21924a098709c23480e157c0")
.extendedStatus(ServerExtendedStatus.builder().vmState("rescued").powerState(1).build())
.diskConfig("MANUAL")
.extendedAttributes(
ServerExtendedAttributes.builder()
.instanceName("instance-00000005")
.hostName("rdohavana.localdomain")
.hypervisorHostName("rdohavana.localdomain").build()
)
.addresses(ImmutableMultimap.<String, Address>builder()
).build(),
Server.builder()
.links(
Link.create(
Relation.SELF,
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"))
)
.image(Resource.builder()
.id("e3f84189-964e-4dc3-8ac6-832c2b7553d4")
.links(Link.create(
Relation.BOOKMARK,
URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/images/e3f84189-964e-4dc3-8ac6-832c2b7553d4")))
.build())
.flavor(Resource.builder()
.id("6")
.links(Link.create(
Relation.BOOKMARK,
URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/flavors/6")))
.build())
.id("89142a4f-f58c-4205-8571-65f4a2be2bc9")
.userId("08ba127f0d6842279f9db8e8bc6977e9")
.status(Status.RESCUE)
.updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2014-03-19T11:36:05Z"))
.hostId("0bc453b1c10348e9dc398fed7a5b06f996964ae1643fe460a85a23d8")
.name("machine_2")
.created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2014-03-19T11:31:19Z"))
.tenantId("4e1900cf21924a098709c23480e157c0")
.extendedStatus(ServerExtendedStatus.builder().vmState("rescued").powerState(1).build())
.diskConfig("MANUAL")
.availabilityZone("nova")
.extendedAttributes(
ServerExtendedAttributes.builder()
.instanceName("instance-00000005")
.hostName("rdohavana.localdomain")
.hypervisorHostName("rdohavana.localdomain").build()
)
.addresses(ImmutableMultimap.<String, Address>builder()
.putAll("public", Address.createV4("172.24.4.227")).build()
).build(),
Server.builder()
.links(
Link.create(
Relation.SELF,
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")))
.image(Resource.builder()
.id("e3f84189-964e-4dc3-8ac6-832c2b7553d4")
.links(Link.create(
Relation.BOOKMARK,
URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/images/e3f84189-964e-4dc3-8ac6-832c2b7553d4")))
.build())
.flavor(Resource.builder()
.id("6")
.links(Link.create(
Relation.BOOKMARK,
URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/flavors/6")))
.build())
.id("fac50d26-bb38-455f-ad92-eba790187c00")
.userId("08ba127f0d6842279f9db8e8bc6977e9")
.status(Status.SHUTOFF)
.updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2014-03-19T11:35:26Z"))
.hostId("0bc453b1c10348e9dc398fed7a5b06f996964ae1643fe460a85a23d8")
.name("machine_1")
.created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2014-03-19T11:28:56Z"))
.tenantId("4e1900cf21924a098709c23480e157c0")
.extendedStatus(ServerExtendedStatus.builder().vmState("stopped").powerState(4).build())
.diskConfig("MANUAL")
.extendedAttributes(
ServerExtendedAttributes.builder()
.instanceName("instance-00000004")
.hostName("rdohavana.localdomain")
.hypervisorHostName("rdohavana.localdomain").build()
)
.addresses(ImmutableMultimap.<String, Address>builder()
).build(),
Server.builder()
.links(
Link.create(
Relation.SELF,
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"))
)
.image(Resource.builder()
.id("e3f84189-964e-4dc3-8ac6-832c2b7553d4")
.links(Link.create(
Relation.BOOKMARK,
URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/images/e3f84189-964e-4dc3-8ac6-832c2b7553d4")))
.build())
.flavor(Resource.builder()
.id("6")
.links(Link.create(
Relation.BOOKMARK,
URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/flavors/6")))
.build())
.id("fac50d26-bb38-455f-ad92-eba790187c00")
.userId("08ba127f0d6842279f9db8e8bc6977e9")
.status(Status.SHUTOFF)
.updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2014-03-19T11:35:26Z"))
.hostId("0bc453b1c10348e9dc398fed7a5b06f996964ae1643fe460a85a23d8")
.name("machine_1")
.created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2014-03-19T11:28:56Z"))
.tenantId("4e1900cf21924a098709c23480e157c0")
.extendedStatus(ServerExtendedStatus.builder().vmState("stopped").powerState(4).build())
.diskConfig("MANUAL")
.availabilityZone("nova")
.extendedAttributes(
ServerExtendedAttributes.builder()
.instanceName("instance-00000004")
.hostName("rdohavana.localdomain")
.hypervisorHostName("rdohavana.localdomain").build()
)
.addresses(ImmutableMultimap.<String, Address>builder()
.putAll("public", Address.createV4("172.24.4.228")).build()
).build()
).build()
);
}

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,20 +92,24 @@ 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"))
.build())
.links(Link.create(
Relation.SELF, URI.create("http://servers.api.openstack.org/v2/1234/servers/71752")),
Link.create(
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": [