From 0f0209e3c440b56e71604bfa1524c40bd50cc760 Mon Sep 17 00:00:00 2001 From: Matt Stephenson Date: Mon, 12 Mar 2012 11:01:58 -0700 Subject: [PATCH 1/2] Removing vestigial code --- .../functions/ServerToNodeMetadata.java | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/functions/ServerToNodeMetadata.java b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/functions/ServerToNodeMetadata.java index d5c2f57080..2870cf06af 100644 --- a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/functions/ServerToNodeMetadata.java +++ b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/functions/ServerToNodeMetadata.java @@ -22,14 +22,10 @@ import java.util.Map; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadataBuilder; -import org.jclouds.compute.domain.NodeState; import org.jclouds.openstack.nova.v1_1.domain.Address; import org.jclouds.openstack.nova.v1_1.domain.Server; -import org.jclouds.openstack.nova.v1_1.domain.ServerStatus; -import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Function; -import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; /** @@ -40,21 +36,6 @@ import com.google.common.collect.Iterables; public class ServerToNodeMetadata implements Function { - @VisibleForTesting - public static final Map serverToNodeState = ImmutableMap.builder() - .put(ServerStatus.ACTIVE, NodeState.RUNNING) - .put(ServerStatus.SUSPENDED, NodeState.SUSPENDED) - .put(ServerStatus.DELETED, NodeState.TERMINATED) - .put(ServerStatus.RESIZE, NodeState.PENDING) - .put(ServerStatus.VERIFY_RESIZE, NodeState.PENDING) - .put(ServerStatus.BUILD, NodeState.PENDING) - .put(ServerStatus.PASSWORD, NodeState.PENDING) - .put(ServerStatus.REBUILD, NodeState.PENDING) - .put(ServerStatus.REBOOT, NodeState.PENDING) - .put(ServerStatus.HARD_REBOOT, NodeState.PENDING) - .put(ServerStatus.UNKNOWN, NodeState.UNRECOGNIZED) - .put(ServerStatus.UNRECOGNIZED, NodeState.UNRECOGNIZED).build(); - @Override public NodeMetadata apply(Server server) { From 4054eaee4f6d31f6f3c5a71b5cdb1301c698d19b Mon Sep 17 00:00:00 2001 From: Matt Stephenson Date: Tue, 13 Mar 2012 14:50:46 -0700 Subject: [PATCH 2/2] Add metadata to nova compute service --- .../nova/v1_1/compute/functions/ServerToNodeMetadata.java | 2 ++ .../v1_1/compute/functions/ServerToNodeMetadataTest.java | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/functions/ServerToNodeMetadata.java b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/functions/ServerToNodeMetadata.java index 2870cf06af..a1fb477dd0 100644 --- a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/functions/ServerToNodeMetadata.java +++ b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/functions/ServerToNodeMetadata.java @@ -26,6 +26,7 @@ import org.jclouds.openstack.nova.v1_1.domain.Address; import org.jclouds.openstack.nova.v1_1.domain.Server; import com.google.common.base.Function; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; /** @@ -47,6 +48,7 @@ public class ServerToNodeMetadata implements Function .publicAddresses(Iterables.transform(server.getPublicAddresses(), new AddressToStringTransformationFunction())) .privateAddresses(Iterables.transform(server.getPrivateAddresses(), new AddressToStringTransformationFunction())) .state(server.getStatus().getNodeState()) + .userMetadata(ImmutableMap.copyOf(server.getMetadata())) .build(); } diff --git a/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/functions/ServerToNodeMetadataTest.java b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/functions/ServerToNodeMetadataTest.java index fb7f96be33..ed2104157d 100644 --- a/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/functions/ServerToNodeMetadataTest.java +++ b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/functions/ServerToNodeMetadataTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.openstack.nova.v1_1.compute.functions; +import com.google.common.collect.ImmutableMap; + import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; @@ -47,6 +49,7 @@ public class ServerToNodeMetadataTest .privateAddresses(Address.createV4("10.0.0.1")) .publicAddresses(Address.createV4("1.0.1.1")) .status(ServerStatus.ACTIVE) + .metadata(ImmutableMap.of("test", "testing")) .build(); ServerToNodeMetadata converter = new ServerToNodeMetadata(); @@ -65,5 +68,9 @@ public class ServerToNodeMetadataTest assertNotNull(convertedNodeMetadata.getPublicAddresses()); assertEquals(convertedNodeMetadata.getPublicAddresses().size(), 1); assertEquals(convertedNodeMetadata.getPublicAddresses().iterator().next(), "1.0.1.1"); + + assertNotNull(convertedNodeMetadata.getUserMetadata()); + assertEquals(convertedNodeMetadata.getUserMetadata().size(), 1); + assertEquals(convertedNodeMetadata.getUserMetadata().get("test"),"testing"); } }