From cf82aab59469fbdbf8f49ff415346519ec3ed8b0 Mon Sep 17 00:00:00 2001 From: Dmitri Babaev <-> Date: Sun, 17 Apr 2011 04:25:07 +0400 Subject: [PATCH] URI is used to calculate the server image and hardware test fixes --- .../functions/ServerToNodeMetadata.java | 4 +-- .../jclouds/openstack/nova/_NovaClient.java | 2 ++ .../ParseAddressesFromJsonResponseTest.java | 10 +++++-- .../test/resources/test_list_addresses.json | 28 +++++++------------ 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/compute/functions/ServerToNodeMetadata.java b/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/compute/functions/ServerToNodeMetadata.java index 3b03764e46..2e131ad622 100644 --- a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/compute/functions/ServerToNodeMetadata.java +++ b/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/compute/functions/ServerToNodeMetadata.java @@ -76,7 +76,7 @@ public class ServerToNodeMetadata implements Function { @Override public boolean apply(Image input) { - return input.getProviderId().equals(instance.getImageRef() + ""); + return input.getUri().toString().equals(instance.getImageRef() + ""); } } @@ -89,7 +89,7 @@ public class ServerToNodeMetadata implements Function { @Override public boolean apply(Hardware input) { - return input.getProviderId().equals(instance.getFlavorRef() + ""); + return input.getUri().toString().equals(instance.getFlavorRef() + ""); } } diff --git a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/_NovaClient.java b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/_NovaClient.java index 3b1e5263a4..b43f6368da 100644 --- a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/_NovaClient.java +++ b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/_NovaClient.java @@ -47,6 +47,8 @@ public class _NovaClient { } catch (RunNodesException e) { e.printStackTrace(); }*/ + + //cs.destroyNode("64"); context.close(); } diff --git a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseAddressesFromJsonResponseTest.java b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseAddressesFromJsonResponseTest.java index b9e7ab8c49..98839a6e42 100644 --- a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseAddressesFromJsonResponseTest.java +++ b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseAddressesFromJsonResponseTest.java @@ -19,6 +19,7 @@ package org.jclouds.openstack.nova.functions; import com.google.common.collect.ImmutableList; +import com.google.common.collect.Iterables; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.Key; @@ -27,6 +28,7 @@ import org.jclouds.http.HttpResponse; import org.jclouds.http.functions.UnwrapOnlyJsonValue; import org.jclouds.io.Payloads; import org.jclouds.json.config.GsonModule; +import org.jclouds.openstack.nova.domain.Address; import org.jclouds.openstack.nova.domain.Addresses; import org.testng.annotations.Test; @@ -53,9 +55,13 @@ public class ParseAddressesFromJsonResponseTest { })); Addresses response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is))); - List publicAddresses = ImmutableList.of("67.23.10.132", "::babe:67.23.10.132", "67.23.10.131", "::babe:4317:0A83"); + List
publicAddresses = ImmutableList.copyOf( + Iterables.transform(ImmutableList.of("67.23.10.132", "::babe:67.23.10.132", "67.23.10.131", "::babe:4317:0A83"), + Address.newString2AddressFunction())); - List privateAddresses = ImmutableList.of("10.176.42.16", "::babe:10.176.42.16"); + List
privateAddresses = ImmutableList.copyOf( + Iterables.transform(ImmutableList.of("10.176.42.16", "::babe:10.176.42.16"), + Address.newString2AddressFunction())); assertEquals(response.getPublicAddresses(), publicAddresses); assertEquals(response.getPrivateAddresses(), privateAddresses); diff --git a/sandbox-apis/nova/src/test/resources/test_list_addresses.json b/sandbox-apis/nova/src/test/resources/test_list_addresses.json index 9f3a235f81..14dd5e898d 100644 --- a/sandbox-apis/nova/src/test/resources/test_list_addresses.json +++ b/sandbox-apis/nova/src/test/resources/test_list_addresses.json @@ -1,23 +1,15 @@ { "addresses" : { - "values" : [ - { - "id" : "public", - "values" : [ - {"version" : 4, "addr" : "67.23.10.132"}, - {"version" : 6, "addr" : "::babe:67.23.10.132"}, - {"version" : 4, "addr" : "67.23.10.131"}, - {"version" : 6, "addr" : "::babe:4317:0A83"} - ] - }, - { - "id" : "private", - "values" : [ - {"version" : 4, "addr" : "10.176.42.16"}, - {"version" : 6, "addr" : "::babe:10.176.42.16"} - ] - } + "public" : [ + {"version" : 4, "addr" : "67.23.10.132"}, + {"version" : 6, "addr" : "::babe:67.23.10.132"}, + {"version" : 4, "addr" : "67.23.10.131"}, + {"version" : 6, "addr" : "::babe:4317:0A83"} + ], + "private" : [ + {"version" : 4, "addr" : "10.176.42.16"}, + {"version" : 6, "addr" : "::babe:10.176.42.16"} ] - } + } }