mirror of https://github.com/apache/jclouds.git
Add metadata to nova compute service
This commit is contained in:
parent
0f0209e3c4
commit
4054eaee4f
|
@ -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<Server, NodeMetadata>
|
|||
.publicAddresses(Iterables.transform(server.getPublicAddresses(), new AddressToStringTransformationFunction()))
|
||||
.privateAddresses(Iterables.transform(server.getPrivateAddresses(), new AddressToStringTransformationFunction()))
|
||||
.state(server.getStatus().getNodeState())
|
||||
.userMetadata(ImmutableMap.copyOf(server.getMetadata()))
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue