mirror of https://github.com/apache/jclouds.git
Issue 487:Add hostname property to nodemetadata
This commit is contained in:
parent
acd4b4a628
commit
6928082674
|
@ -79,6 +79,7 @@ public class NodeToNodeMetadata implements Function<Node, NodeMetadata> {
|
||||||
NodeMetadataBuilder builder = new NodeMetadataBuilder();
|
NodeMetadataBuilder builder = new NodeMetadataBuilder();
|
||||||
builder.ids(from.getId());
|
builder.ids(from.getId());
|
||||||
builder.name(from.getName());
|
builder.name(from.getName());
|
||||||
|
builder.hostname(from.getHostname());
|
||||||
builder.location(findLocationWithId(from.getLocationId()));
|
builder.location(findLocationWithId(from.getLocationId()));
|
||||||
builder.group(from.getGroup());
|
builder.group(from.getGroup());
|
||||||
builder.tags(from.getTags());
|
builder.tags(from.getTags());
|
||||||
|
|
|
@ -73,12 +73,17 @@ public class NodeToNodeMetadataTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static NodeMetadata expectedNodeMetadataFromResource(int id, String resource, Location location) {
|
public static NodeMetadata expectedNodeMetadataFromResource(int id, String resource, Location location) {
|
||||||
return new NodeMetadataBuilder().ids("cluster-" + id).group("hadoop").name("cluster-" + id).location(location)
|
return new NodeMetadataBuilder()
|
||||||
.state(NodeState.RUNNING).operatingSystem(
|
.ids("cluster-" + id)
|
||||||
OperatingSystem.builder().description("redhat").family(OsFamily.RHEL).arch("x86")
|
.group("hadoop")
|
||||||
.version("5.3").build()).publicAddresses(
|
.name("cluster-" + id)
|
||||||
ImmutableSet.of("cluster-" + id + ".mydomain.com")).credentials(
|
.hostname("cluster-" + id + ".mydomain.com")
|
||||||
new Credentials("myUser", NodesFromYamlTest.key)).adminPassword("happy bear").build();
|
.location(location)
|
||||||
|
.state(NodeState.RUNNING)
|
||||||
|
.operatingSystem(
|
||||||
|
OperatingSystem.builder().description("redhat").family(OsFamily.RHEL).arch("x86").version("5.3")
|
||||||
|
.build()).publicAddresses(ImmutableSet.of("cluster-" + id + ".mydomain.com"))
|
||||||
|
.credentials(new Credentials("myUser", NodesFromYamlTest.key)).adminPassword("happy bear").build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -108,6 +108,7 @@ public class ServerToNodeMetadata implements Function<Server, NodeMetadata> {
|
||||||
NodeMetadataBuilder builder = new NodeMetadataBuilder();
|
NodeMetadataBuilder builder = new NodeMetadataBuilder();
|
||||||
builder.ids(from.getId() + "");
|
builder.ids(from.getId() + "");
|
||||||
builder.name(from.getName());
|
builder.name(from.getName());
|
||||||
|
builder.hostname(from.getName());
|
||||||
builder.location(new LocationBuilder().scope(LocationScope.HOST).id(from.getHostId()).description(
|
builder.location(new LocationBuilder().scope(LocationScope.HOST).id(from.getHostId()).description(
|
||||||
from.getHostId()).parent(location.get()).build());
|
from.getHostId()).parent(location.get()).build());
|
||||||
builder.userMetadata(from.getMetadata());
|
builder.userMetadata(from.getMetadata());
|
||||||
|
|
|
@ -72,9 +72,19 @@ public class ServerToNodeMetadataTest {
|
||||||
|
|
||||||
NodeMetadata metadata = parser.apply(server);
|
NodeMetadata metadata = parser.apply(server);
|
||||||
|
|
||||||
assertEquals(metadata, new NodeMetadataBuilder().state(NodeState.PENDING).publicAddresses(
|
assertEquals(
|
||||||
ImmutableSet.of("67.23.10.132", "67.23.10.131")).privateAddresses(ImmutableSet.of("10.176.42.16"))
|
metadata,
|
||||||
.imageId("2").id("1234").providerId("1234").name("sample-server").credentials(creds).location(
|
new NodeMetadataBuilder()
|
||||||
|
.state(NodeState.PENDING)
|
||||||
|
.publicAddresses(ImmutableSet.of("67.23.10.132", "67.23.10.131"))
|
||||||
|
.privateAddresses(ImmutableSet.of("10.176.42.16"))
|
||||||
|
.imageId("2")
|
||||||
|
.id("1234")
|
||||||
|
.providerId("1234")
|
||||||
|
.name("sample-server")
|
||||||
|
.hostname("sample-server")
|
||||||
|
.credentials(creds)
|
||||||
|
.location(
|
||||||
new LocationBuilder().scope(LocationScope.HOST).id("e4d909c290d0fb1ca068ffaddf22cbd0")
|
new LocationBuilder().scope(LocationScope.HOST).id("e4d909c290d0fb1ca068ffaddf22cbd0")
|
||||||
.description("e4d909c290d0fb1ca068ffaddf22cbd0").parent(provider).build())
|
.description("e4d909c290d0fb1ca068ffaddf22cbd0").parent(provider).build())
|
||||||
.userMetadata(ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build());
|
.userMetadata(ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build());
|
||||||
|
@ -93,9 +103,18 @@ public class ServerToNodeMetadataTest {
|
||||||
|
|
||||||
NodeMetadata metadata = parser.apply(server);
|
NodeMetadata metadata = parser.apply(server);
|
||||||
|
|
||||||
assertEquals(metadata, new NodeMetadataBuilder().state(NodeState.PENDING).publicAddresses(
|
assertEquals(
|
||||||
ImmutableSet.of("67.23.10.132", "67.23.10.131")).privateAddresses(ImmutableSet.of("10.176.42.16"))
|
metadata,
|
||||||
.imageId("2").id("1234").providerId("1234").name("sample-server").location(
|
new NodeMetadataBuilder()
|
||||||
|
.state(NodeState.PENDING)
|
||||||
|
.publicAddresses(ImmutableSet.of("67.23.10.132", "67.23.10.131"))
|
||||||
|
.privateAddresses(ImmutableSet.of("10.176.42.16"))
|
||||||
|
.imageId("2")
|
||||||
|
.id("1234")
|
||||||
|
.providerId("1234")
|
||||||
|
.name("sample-server")
|
||||||
|
.hostname("sample-server")
|
||||||
|
.location(
|
||||||
new LocationBuilder().scope(LocationScope.HOST).id("e4d909c290d0fb1ca068ffaddf22cbd0")
|
new LocationBuilder().scope(LocationScope.HOST).id("e4d909c290d0fb1ca068ffaddf22cbd0")
|
||||||
.description("e4d909c290d0fb1ca068ffaddf22cbd0").parent(provider).build())
|
.description("e4d909c290d0fb1ca068ffaddf22cbd0").parent(provider).build())
|
||||||
.userMetadata(ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build());
|
.userMetadata(ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build());
|
||||||
|
@ -116,11 +135,21 @@ public class ServerToNodeMetadataTest {
|
||||||
|
|
||||||
NodeMetadata metadata = parser.apply(server);
|
NodeMetadata metadata = parser.apply(server);
|
||||||
|
|
||||||
assertEquals(metadata, new NodeMetadataBuilder().state(NodeState.PENDING).publicAddresses(
|
assertEquals(
|
||||||
ImmutableSet.of("67.23.10.132", "67.23.10.131")).privateAddresses(ImmutableSet.of("10.176.42.16"))
|
metadata,
|
||||||
.imageId("2").operatingSystem(
|
new NodeMetadataBuilder()
|
||||||
|
.state(NodeState.PENDING)
|
||||||
|
.publicAddresses(ImmutableSet.of("67.23.10.132", "67.23.10.131"))
|
||||||
|
.privateAddresses(ImmutableSet.of("10.176.42.16"))
|
||||||
|
.imageId("2")
|
||||||
|
.operatingSystem(
|
||||||
new OperatingSystem.Builder().family(OsFamily.CENTOS).description("CentOS 5.2").version("5.2")
|
new OperatingSystem.Builder().family(OsFamily.CENTOS).description("CentOS 5.2").version("5.2")
|
||||||
.is64Bit(true).build()).id("1234").providerId("1234").name("sample-server").location(
|
.is64Bit(true).build())
|
||||||
|
.id("1234")
|
||||||
|
.providerId("1234")
|
||||||
|
.name("sample-server")
|
||||||
|
.hostname("sample-server")
|
||||||
|
.location(
|
||||||
new LocationBuilder().scope(LocationScope.HOST).id("e4d909c290d0fb1ca068ffaddf22cbd0")
|
new LocationBuilder().scope(LocationScope.HOST).id("e4d909c290d0fb1ca068ffaddf22cbd0")
|
||||||
.description("e4d909c290d0fb1ca068ffaddf22cbd0").parent(provider).build())
|
.description("e4d909c290d0fb1ca068ffaddf22cbd0").parent(provider).build())
|
||||||
.userMetadata(ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build());
|
.userMetadata(ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build());
|
||||||
|
@ -140,15 +169,30 @@ public class ServerToNodeMetadataTest {
|
||||||
|
|
||||||
NodeMetadata metadata = parser.apply(server);
|
NodeMetadata metadata = parser.apply(server);
|
||||||
|
|
||||||
assertEquals(metadata, new NodeMetadataBuilder().state(NodeState.PENDING).publicAddresses(
|
assertEquals(
|
||||||
ImmutableSet.of("67.23.10.132", "67.23.10.131")).privateAddresses(ImmutableSet.of("10.176.42.16"))
|
metadata,
|
||||||
.imageId("2").hardware(
|
new NodeMetadataBuilder()
|
||||||
new HardwareBuilder().ids("1").name("256 MB Server").processors(
|
.state(NodeState.PENDING)
|
||||||
ImmutableList.of(new Processor(1.0, 1.0))).ram(256).volumes(
|
.publicAddresses(ImmutableSet.of("67.23.10.132", "67.23.10.131"))
|
||||||
ImmutableList.of(new VolumeBuilder().type(Volume.Type.LOCAL).size(10.0f).durable(true)
|
.privateAddresses(ImmutableSet.of("10.176.42.16"))
|
||||||
.bootDevice(true).build())).build()).operatingSystem(
|
.imageId("2")
|
||||||
|
.hardware(
|
||||||
|
new HardwareBuilder()
|
||||||
|
.ids("1")
|
||||||
|
.name("256 MB Server")
|
||||||
|
.processors(ImmutableList.of(new Processor(1.0, 1.0)))
|
||||||
|
.ram(256)
|
||||||
|
.volumes(
|
||||||
|
ImmutableList.of(new VolumeBuilder().type(Volume.Type.LOCAL).size(10.0f)
|
||||||
|
.durable(true).bootDevice(true).build())).build())
|
||||||
|
.operatingSystem(
|
||||||
new OperatingSystem.Builder().family(OsFamily.CENTOS).description("CentOS 5.2").version("5.2")
|
new OperatingSystem.Builder().family(OsFamily.CENTOS).description("CentOS 5.2").version("5.2")
|
||||||
.is64Bit(true).build()).id("1234").providerId("1234").name("sample-server").location(
|
.is64Bit(true).build())
|
||||||
|
.id("1234")
|
||||||
|
.providerId("1234")
|
||||||
|
.name("sample-server")
|
||||||
|
.hostname("sample-server")
|
||||||
|
.location(
|
||||||
new LocationBuilder().scope(LocationScope.HOST).id("e4d909c290d0fb1ca068ffaddf22cbd0")
|
new LocationBuilder().scope(LocationScope.HOST).id("e4d909c290d0fb1ca068ffaddf22cbd0")
|
||||||
.description("e4d909c290d0fb1ca068ffaddf22cbd0").parent(provider).build())
|
.description("e4d909c290d0fb1ca068ffaddf22cbd0").parent(provider).build())
|
||||||
.userMetadata(ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build());
|
.userMetadata(ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build());
|
||||||
|
|
|
@ -91,6 +91,9 @@ public class RunningInstanceToNodeMetadata implements Function<RunningInstance,
|
||||||
builder.id(instance.getRegion() + "/" + instance.getId());
|
builder.id(instance.getRegion() + "/" + instance.getId());
|
||||||
String group = getGroupForInstance(instance);
|
String group = getGroupForInstance(instance);
|
||||||
builder.group(group);
|
builder.group(group);
|
||||||
|
// standard convention from aws-ec2, which might not be re-used outside.
|
||||||
|
if (instance.getPrivateDnsName() != null)
|
||||||
|
builder.hostname(instance.getPrivateDnsName().replaceAll("\\..*", ""));
|
||||||
addCredentialsForInstance(builder, instance);
|
addCredentialsForInstance(builder, instance);
|
||||||
builder.state(instanceToNodeState.get(instance.getInstanceState()));
|
builder.state(instanceToNodeState.get(instance.getInstanceState()));
|
||||||
builder.publicAddresses(NullSafeCollections.nullSafeSet(instance.getIpAddress()));
|
builder.publicAddresses(NullSafeCollections.nullSafeSet(instance.getIpAddress()));
|
||||||
|
|
|
@ -80,10 +80,12 @@ public class RunningInstanceToNodeMetadataTest {
|
||||||
|
|
||||||
RunningInstance server = firstInstanceFromResource("/describe_instances_running.xml");
|
RunningInstance server = firstInstanceFromResource("/describe_instances_running.xml");
|
||||||
|
|
||||||
assertEquals(parser.apply(server), new NodeMetadataBuilder().state(NodeState.RUNNING).publicAddresses(
|
assertEquals(
|
||||||
ImmutableSet.<String> of()).privateAddresses(ImmutableSet.of("10.243.42.70")).publicAddresses(
|
parser.apply(server),
|
||||||
ImmutableSet.of("174.129.81.68")).credentials(creds).imageId("us-east-1/ami-82e4b5c7").id(
|
new NodeMetadataBuilder().state(NodeState.RUNNING).hostname("ip-10-243-42-70")
|
||||||
"us-east-1/i-0799056f").providerId("i-0799056f").build());
|
.publicAddresses(ImmutableSet.<String> of()).privateAddresses(ImmutableSet.of("10.243.42.70"))
|
||||||
|
.publicAddresses(ImmutableSet.of("174.129.81.68")).credentials(creds)
|
||||||
|
.imageId("us-east-1/ami-82e4b5c7").id("us-east-1/i-0799056f").providerId("i-0799056f").build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -93,10 +95,11 @@ public class RunningInstanceToNodeMetadataTest {
|
||||||
|
|
||||||
RunningInstance server = firstInstanceFromResource("/describe_instances_running.xml");
|
RunningInstance server = firstInstanceFromResource("/describe_instances_running.xml");
|
||||||
|
|
||||||
assertEquals(parser.apply(server), new NodeMetadataBuilder().state(NodeState.RUNNING).publicAddresses(
|
assertEquals(parser.apply(server),
|
||||||
ImmutableSet.<String> of()).privateAddresses(ImmutableSet.of("10.243.42.70")).publicAddresses(
|
new NodeMetadataBuilder().hostname("ip-10-243-42-70").state(NodeState.RUNNING)
|
||||||
ImmutableSet.of("174.129.81.68")).imageId("us-east-1/ami-82e4b5c7").id("us-east-1/i-0799056f")
|
.publicAddresses(ImmutableSet.<String> of()).privateAddresses(ImmutableSet.of("10.243.42.70"))
|
||||||
.providerId("i-0799056f").build());
|
.publicAddresses(ImmutableSet.of("174.129.81.68")).imageId("us-east-1/ami-82e4b5c7")
|
||||||
|
.id("us-east-1/i-0799056f").providerId("i-0799056f").build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -106,9 +109,10 @@ public class RunningInstanceToNodeMetadataTest {
|
||||||
|
|
||||||
RunningInstance server = firstInstanceFromResource("/describe_instances_running.xml");
|
RunningInstance server = firstInstanceFromResource("/describe_instances_running.xml");
|
||||||
|
|
||||||
assertEquals(parser.apply(server), new NodeMetadataBuilder().state(NodeState.RUNNING).privateAddresses(
|
assertEquals(parser.apply(server), new NodeMetadataBuilder().hostname("ip-10-243-42-70").state(NodeState.RUNNING)
|
||||||
ImmutableSet.of("10.243.42.70")).publicAddresses(ImmutableSet.of("174.129.81.68")).imageId(
|
.privateAddresses(ImmutableSet.of("10.243.42.70")).publicAddresses(ImmutableSet.of("174.129.81.68"))
|
||||||
"us-east-1/ami-82e4b5c7").id("us-east-1/i-0799056f").providerId("i-0799056f").location(provider).build());
|
.imageId("us-east-1/ami-82e4b5c7").id("us-east-1/i-0799056f").providerId("i-0799056f").location(provider)
|
||||||
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -118,12 +122,18 @@ public class RunningInstanceToNodeMetadataTest {
|
||||||
|
|
||||||
RunningInstance server = firstInstanceFromResource("/describe_instances_running.xml");
|
RunningInstance server = firstInstanceFromResource("/describe_instances_running.xml");
|
||||||
|
|
||||||
assertEquals(parser.apply(server), new NodeMetadataBuilder().state(NodeState.RUNNING).privateAddresses(
|
assertEquals(
|
||||||
ImmutableSet.of("10.243.42.70")).publicAddresses(ImmutableSet.of("174.129.81.68")).imageId(
|
parser.apply(server),
|
||||||
"us-east-1/ami-82e4b5c7").operatingSystem(
|
new NodeMetadataBuilder()
|
||||||
new OperatingSystem.Builder().family(OsFamily.UNRECOGNIZED).version("").arch("paravirtual").description(
|
.state(NodeState.RUNNING)
|
||||||
"137112412989/amzn-ami-0.9.7-beta.i386-ebs").is64Bit(false).build()).id("us-east-1/i-0799056f")
|
.hostname("ip-10-243-42-70")
|
||||||
.providerId("i-0799056f").location(provider).build());
|
.privateAddresses(ImmutableSet.of("10.243.42.70"))
|
||||||
|
.publicAddresses(ImmutableSet.of("174.129.81.68"))
|
||||||
|
.imageId("us-east-1/ami-82e4b5c7")
|
||||||
|
.operatingSystem(
|
||||||
|
new OperatingSystem.Builder().family(OsFamily.UNRECOGNIZED).version("").arch("paravirtual")
|
||||||
|
.description("137112412989/amzn-ami-0.9.7-beta.i386-ebs").is64Bit(false).build())
|
||||||
|
.id("us-east-1/i-0799056f").providerId("i-0799056f").location(provider).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -134,12 +144,19 @@ public class RunningInstanceToNodeMetadataTest {
|
||||||
|
|
||||||
RunningInstance server = firstInstanceFromResource("/describe_instances_running.xml");
|
RunningInstance server = firstInstanceFromResource("/describe_instances_running.xml");
|
||||||
|
|
||||||
assertEquals(parser.apply(server), new NodeMetadataBuilder().state(NodeState.RUNNING).privateAddresses(
|
assertEquals(
|
||||||
ImmutableSet.of("10.243.42.70")).publicAddresses(ImmutableSet.of("174.129.81.68")).imageId(
|
parser.apply(server),
|
||||||
"us-east-1/ami-82e4b5c7").hardware(m1_small32().build()).operatingSystem(
|
new NodeMetadataBuilder()
|
||||||
new OperatingSystem.Builder().family(OsFamily.UNRECOGNIZED).version("").arch("paravirtual").description(
|
.hostname("ip-10-243-42-70")
|
||||||
"137112412989/amzn-ami-0.9.7-beta.i386-ebs").is64Bit(false).build()).id("us-east-1/i-0799056f")
|
.state(NodeState.RUNNING)
|
||||||
.providerId("i-0799056f").location(provider).build());
|
.privateAddresses(ImmutableSet.of("10.243.42.70"))
|
||||||
|
.publicAddresses(ImmutableSet.of("174.129.81.68"))
|
||||||
|
.imageId("us-east-1/ami-82e4b5c7")
|
||||||
|
.hardware(m1_small32().build())
|
||||||
|
.operatingSystem(
|
||||||
|
new OperatingSystem.Builder().family(OsFamily.UNRECOGNIZED).version("").arch("paravirtual")
|
||||||
|
.description("137112412989/amzn-ami-0.9.7-beta.i386-ebs").is64Bit(false).build())
|
||||||
|
.id("us-east-1/i-0799056f").providerId("i-0799056f").location(provider).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -163,10 +180,12 @@ public class RunningInstanceToNodeMetadataTest {
|
||||||
|
|
||||||
RunningInstance server = firstInstanceFromResource("/describe_instances_running.xml");
|
RunningInstance server = firstInstanceFromResource("/describe_instances_running.xml");
|
||||||
|
|
||||||
assertEquals(parser.apply(server), new NodeMetadataBuilder().state(NodeState.RUNNING).privateAddresses(
|
assertEquals(
|
||||||
ImmutableSet.of("10.243.42.70")).publicAddresses(ImmutableSet.of("174.129.81.68")).imageId(
|
parser.apply(server),
|
||||||
"us-east-1/ami-82e4b5c7").id("us-east-1/i-0799056f").providerId("i-0799056f").hardware(
|
new NodeMetadataBuilder().hostname("ip-10-243-42-70").state(NodeState.RUNNING)
|
||||||
m1_small32().build()).location(provider).build());
|
.privateAddresses(ImmutableSet.of("10.243.42.70")).publicAddresses(ImmutableSet.of("174.129.81.68"))
|
||||||
|
.imageId("us-east-1/ami-82e4b5c7").id("us-east-1/i-0799056f").providerId("i-0799056f")
|
||||||
|
.hardware(m1_small32().build()).location(provider).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected RunningInstance firstInstanceFromResource(String resource) {
|
protected RunningInstance firstInstanceFromResource(String resource) {
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
package org.jclouds.elasticstack.compute;
|
package org.jclouds.elasticstack.compute;
|
||||||
|
|
||||||
import org.jclouds.compute.BaseComputeServiceLiveTest;
|
import org.jclouds.compute.BaseComputeServiceLiveTest;
|
||||||
|
import org.jclouds.compute.domain.ExecResponse;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -40,4 +42,11 @@ public class ElasticStackComputeServiceLiveTest extends BaseComputeServiceLiveTe
|
||||||
public void testOptionToNotBlock() {
|
public void testOptionToNotBlock() {
|
||||||
// start call is blocking anyway.
|
// start call is blocking anyway.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void checkResponseEqualsHostname(ExecResponse execResponse, NodeMetadata node1) {
|
||||||
|
assert execResponse.getOutput().trim().equals("ubuntu");// hostname is not
|
||||||
|
// predicatble
|
||||||
|
// based on node
|
||||||
|
// metadata
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import static com.google.common.collect.Iterables.filter;
|
||||||
import static org.jclouds.compute.util.ComputeServiceUtils.parseGroupFromName;
|
import static org.jclouds.compute.util.ComputeServiceUtils.parseGroupFromName;
|
||||||
import static org.jclouds.vcloud.compute.util.VCloudComputeUtils.getCredentialsFrom;
|
import static org.jclouds.vcloud.compute.util.VCloudComputeUtils.getCredentialsFrom;
|
||||||
import static org.jclouds.vcloud.compute.util.VCloudComputeUtils.getIpsFromVApp;
|
import static org.jclouds.vcloud.compute.util.VCloudComputeUtils.getIpsFromVApp;
|
||||||
|
import static org.jclouds.vcloud.compute.util.VCloudComputeUtils.getVirtualSystemIdentifierOfFirstVMIn;
|
||||||
import static org.jclouds.vcloud.compute.util.VCloudComputeUtils.toComputeOs;
|
import static org.jclouds.vcloud.compute.util.VCloudComputeUtils.toComputeOs;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -72,6 +73,8 @@ public class VAppToNodeMetadata implements Function<VApp, NodeMetadata> {
|
||||||
builder.ids(from.getHref().toASCIIString());
|
builder.ids(from.getHref().toASCIIString());
|
||||||
builder.uri(from.getHref());
|
builder.uri(from.getHref());
|
||||||
builder.name(from.getName());
|
builder.name(from.getName());
|
||||||
|
// not guaranteed to be correct, but good chance
|
||||||
|
builder.hostname(getVirtualSystemIdentifierOfFirstVMIn(from));
|
||||||
builder.location(findLocationForResourceInVDC.apply(from.getVDC()));
|
builder.location(findLocationForResourceInVDC.apply(from.getVDC()));
|
||||||
builder.group(parseGroupFromName(from.getName()));
|
builder.group(parseGroupFromName(from.getName()));
|
||||||
builder.operatingSystem(toComputeOs(from, null));
|
builder.operatingSystem(toComputeOs(from, null));
|
||||||
|
|
|
@ -57,6 +57,16 @@ public class VCloudComputeUtils {
|
||||||
return CIMOperatingSystem.toComputeOs(vm.getOperatingSystemSection());
|
return CIMOperatingSystem.toComputeOs(vm.getOperatingSystemSection());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getVirtualSystemIdentifierOfFirstVMIn(VApp vApp) {
|
||||||
|
return vApp.getChildren().size() > 0 ? getVirtualSystemIdentifierOf(Iterables.get(vApp.getChildren(), 0)) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getVirtualSystemIdentifierOf(Vm vm) {
|
||||||
|
if (vm.getVirtualHardwareSection() != null && vm.getVirtualHardwareSection().getSystem() != null)
|
||||||
|
return vm.getVirtualHardwareSection().getSystem().getVirtualSystemIdentifier();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public static Credentials getCredentialsFrom(VApp vApp) {
|
public static Credentials getCredentialsFrom(VApp vApp) {
|
||||||
return vApp.getChildren().size() > 0 ? getCredentialsFrom(Iterables.get(vApp.getChildren(), 0)) : null;
|
return vApp.getChildren().size() > 0 ? getCredentialsFrom(Iterables.get(vApp.getChildren(), 0)) : null;
|
||||||
}
|
}
|
||||||
|
@ -83,8 +93,10 @@ public class VCloudComputeUtils {
|
||||||
Builder<String> ips = ImmutableSet.<String> builder();
|
Builder<String> ips = ImmutableSet.<String> builder();
|
||||||
Vm vm = Iterables.get(vApp.getChildren(), 0);
|
Vm vm = Iterables.get(vApp.getChildren(), 0);
|
||||||
// TODO: figure out how to differentiate public from private ip addresses
|
// TODO: figure out how to differentiate public from private ip addresses
|
||||||
// assumption is that we'll do this from the network object, which may have
|
// assumption is that we'll do this from the network object, which may
|
||||||
// enough data to tell whether or not it is a public network without string
|
// have
|
||||||
|
// enough data to tell whether or not it is a public network without
|
||||||
|
// string
|
||||||
// parsing. At worst, we could have properties set per cloud provider to
|
// parsing. At worst, we could have properties set per cloud provider to
|
||||||
// declare the networks which are public, then check against these in
|
// declare the networks which are public, then check against these in
|
||||||
// networkconnection.getNetwork
|
// networkconnection.getNetwork
|
||||||
|
|
|
@ -121,6 +121,7 @@ public class VAppToNodeMetadataTest {
|
||||||
VAppToNodeMetadata converter = injector.getInstance(VAppToNodeMetadata.class);
|
VAppToNodeMetadata converter = injector.getInstance(VAppToNodeMetadata.class);
|
||||||
NodeMetadata node = converter.apply(result);
|
NodeMetadata node = converter.apply(result);
|
||||||
assertEquals(node.getLocation(), location);
|
assertEquals(node.getLocation(), location);
|
||||||
|
assertEquals(node.getHostname(), "my-app");
|
||||||
assertEquals(node.getPrivateAddresses(), ImmutableSet.of("172.16.7.230"));
|
assertEquals(node.getPrivateAddresses(), ImmutableSet.of("172.16.7.230"));
|
||||||
assertEquals(node.getPublicAddresses(), ImmutableSet.of());
|
assertEquals(node.getPublicAddresses(), ImmutableSet.of());
|
||||||
}
|
}
|
||||||
|
@ -135,6 +136,7 @@ public class VAppToNodeMetadataTest {
|
||||||
VAppToNodeMetadata converter = injector.getInstance(VAppToNodeMetadata.class);
|
VAppToNodeMetadata converter = injector.getInstance(VAppToNodeMetadata.class);
|
||||||
NodeMetadata node = converter.apply(result);
|
NodeMetadata node = converter.apply(result);
|
||||||
assertEquals(node.getLocation(), location);
|
assertEquals(node.getLocation(), location);
|
||||||
|
assertEquals(node.getHostname(), "Centos-5.5_x64");
|
||||||
assertEquals(node.getPrivateAddresses(), ImmutableSet.of());
|
assertEquals(node.getPrivateAddresses(), ImmutableSet.of());
|
||||||
assertEquals(node.getPublicAddresses(), ImmutableSet.of());
|
assertEquals(node.getPublicAddresses(), ImmutableSet.of());
|
||||||
}
|
}
|
||||||
|
@ -149,6 +151,7 @@ public class VAppToNodeMetadataTest {
|
||||||
VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is);
|
VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is);
|
||||||
VAppToNodeMetadata converter = injector.getInstance(VAppToNodeMetadata.class);
|
VAppToNodeMetadata converter = injector.getInstance(VAppToNodeMetadata.class);
|
||||||
NodeMetadata node = converter.apply(result);
|
NodeMetadata node = converter.apply(result);
|
||||||
|
assertEquals(node.getHostname(), "");
|
||||||
assertEquals(node.getLocation(), location);
|
assertEquals(node.getLocation(), location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,8 @@ public class VCloudExpressVAppToNodeMetadata implements Function<VCloudExpressVA
|
||||||
builder.ids(from.getHref().toASCIIString());
|
builder.ids(from.getHref().toASCIIString());
|
||||||
builder.uri(from.getHref());
|
builder.uri(from.getHref());
|
||||||
builder.name(from.getName());
|
builder.name(from.getName());
|
||||||
|
//terremark
|
||||||
|
builder.hostname(from.getName());
|
||||||
builder.location(findLocationForResourceInVDC.apply(from.getVDC()));
|
builder.location(findLocationForResourceInVDC.apply(from.getVDC()));
|
||||||
builder.group(parseGroupFromName(from.getName()));
|
builder.group(parseGroupFromName(from.getName()));
|
||||||
if (from.getOsType() != null && OSType.fromValue(from.getOsType()) != OSType.UNRECOGNIZED) {
|
if (from.getOsType() != null && OSType.fromValue(from.getOsType()) != OSType.UNRECOGNIZED) {
|
||||||
|
|
|
@ -33,6 +33,16 @@ import com.google.inject.ImplementedBy;
|
||||||
*/
|
*/
|
||||||
@ImplementedBy(NodeMetadataImpl.class)
|
@ImplementedBy(NodeMetadataImpl.class)
|
||||||
public interface NodeMetadata extends ComputeMetadata {
|
public interface NodeMetadata extends ComputeMetadata {
|
||||||
|
/**
|
||||||
|
* <h4>note</h4> hostname is something that is set in the operating system
|
||||||
|
* image, so this value, if present, cannot be guaranteed on images not
|
||||||
|
* directly controlled by the cloud provider.
|
||||||
|
*
|
||||||
|
* @return hostname of the node, or null if unknown
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
String getHostname();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tag used for all resources that belong to the same logical group. run, destroy commands are
|
* Tag used for all resources that belong to the same logical group. run, destroy commands are
|
||||||
|
@ -41,6 +51,7 @@ public interface NodeMetadata extends ComputeMetadata {
|
||||||
* @return group for this node, or null, if not a part of a group
|
* @return group for this node, or null, if not a part of a group
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
String getGroup();
|
String getGroup();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -53,6 +53,8 @@ public class NodeMetadataBuilder extends ComputeMetadataBuilder {
|
||||||
private Hardware hardware;
|
private Hardware hardware;
|
||||||
@Nullable
|
@Nullable
|
||||||
private OperatingSystem os;
|
private OperatingSystem os;
|
||||||
|
@Nullable
|
||||||
|
private String hostname;
|
||||||
|
|
||||||
public NodeMetadataBuilder() {
|
public NodeMetadataBuilder() {
|
||||||
super(ComputeType.NODE);
|
super(ComputeType.NODE);
|
||||||
|
@ -108,6 +110,11 @@ public class NodeMetadataBuilder extends ComputeMetadataBuilder {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public NodeMetadataBuilder hostname(String hostname) {
|
||||||
|
this.hostname = hostname;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NodeMetadataBuilder id(String id) {
|
public NodeMetadataBuilder id(String id) {
|
||||||
return NodeMetadataBuilder.class.cast(super.id(id));
|
return NodeMetadataBuilder.class.cast(super.id(id));
|
||||||
|
@ -151,7 +158,7 @@ public class NodeMetadataBuilder extends ComputeMetadataBuilder {
|
||||||
@Override
|
@Override
|
||||||
public NodeMetadata build() {
|
public NodeMetadata build() {
|
||||||
return new NodeMetadataImpl(providerId, name, id, location, uri, userMetadata, tags, group, hardware, imageId,
|
return new NodeMetadataImpl(providerId, name, id, location, uri, userMetadata, tags, group, hardware, imageId,
|
||||||
os, state, loginPort, publicAddresses, privateAddresses, adminPassword, credentials);
|
os, state, loginPort, publicAddresses, privateAddresses, adminPassword, credentials, hostname);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static NodeMetadataBuilder fromNodeMetadata(NodeMetadata node) {
|
public static NodeMetadataBuilder fromNodeMetadata(NodeMetadata node) {
|
||||||
|
@ -160,7 +167,7 @@ public class NodeMetadataBuilder extends ComputeMetadataBuilder {
|
||||||
node.getGroup()).hardware(node.getHardware()).imageId(node.getImageId()).operatingSystem(
|
node.getGroup()).hardware(node.getHardware()).imageId(node.getImageId()).operatingSystem(
|
||||||
node.getOperatingSystem()).state(node.getState()).loginPort(node.getLoginPort()).publicAddresses(
|
node.getOperatingSystem()).state(node.getState()).loginPort(node.getLoginPort()).publicAddresses(
|
||||||
node.getPublicAddresses()).privateAddresses(node.getPrivateAddresses()).adminPassword(
|
node.getPublicAddresses()).privateAddresses(node.getPrivateAddresses()).adminPassword(
|
||||||
node.getAdminPassword()).credentials(node.getCredentials());
|
node.getAdminPassword()).credentials(node.getCredentials()).hostname(node.getHostname());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -197,6 +197,7 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements NodeMetadat
|
||||||
result = prime * result + ((privateAddresses == null) ? 0 : privateAddresses.hashCode());
|
result = prime * result + ((privateAddresses == null) ? 0 : privateAddresses.hashCode());
|
||||||
result = prime * result + ((publicAddresses == null) ? 0 : publicAddresses.hashCode());
|
result = prime * result + ((publicAddresses == null) ? 0 : publicAddresses.hashCode());
|
||||||
result = prime * result + ((group == null) ? 0 : group.hashCode());
|
result = prime * result + ((group == null) ? 0 : group.hashCode());
|
||||||
|
result = prime * result + ((hostname == null) ? 0 : hostname.hashCode());
|
||||||
result = prime * result + ((imageId == null) ? 0 : imageId.hashCode());
|
result = prime * result + ((imageId == null) ? 0 : imageId.hashCode());
|
||||||
result = prime * result + ((hardware == null) ? 0 : hardware.hashCode());
|
result = prime * result + ((hardware == null) ? 0 : hardware.hashCode());
|
||||||
result = prime * result + ((os == null) ? 0 : os.hashCode());
|
result = prime * result + ((os == null) ? 0 : os.hashCode());
|
||||||
|
@ -226,6 +227,11 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements NodeMetadat
|
||||||
return false;
|
return false;
|
||||||
} else if (!publicAddresses.equals(other.publicAddresses))
|
} else if (!publicAddresses.equals(other.publicAddresses))
|
||||||
return false;
|
return false;
|
||||||
|
if (hostname == null) {
|
||||||
|
if (other.hostname != null)
|
||||||
|
return false;
|
||||||
|
} else if (!hostname.equals(other.hostname))
|
||||||
|
return false;
|
||||||
if (group == null) {
|
if (group == null) {
|
||||||
if (other.group != null)
|
if (other.group != null)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -89,6 +89,8 @@ public class StubComputeServiceAdapter implements JCloudsNativeComputeServiceAda
|
||||||
String id = idProvider.get() + "";
|
String id = idProvider.get() + "";
|
||||||
builder.ids(id);
|
builder.ids(id);
|
||||||
builder.name(name);
|
builder.name(name);
|
||||||
|
// using a predictable name so tests will pass
|
||||||
|
builder.hostname(group);
|
||||||
builder.tags(template.getOptions().getTags());
|
builder.tags(template.getOptions().getTags());
|
||||||
builder.group(group);
|
builder.group(group);
|
||||||
builder.location(location.get());
|
builder.location(location.get());
|
||||||
|
|
|
@ -51,11 +51,11 @@ import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
@ -243,11 +243,12 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
TemplateOptions options = client.templateOptions().blockOnPort(22, 120);
|
TemplateOptions options = client.templateOptions().blockOnPort(22, 120);
|
||||||
try {
|
try {
|
||||||
Set<? extends NodeMetadata> nodes = client.createNodesInGroup(group, 1, options);
|
Set<? extends NodeMetadata> nodes = client.createNodesInGroup(group, 1, options);
|
||||||
Credentials good = nodes.iterator().next().getCredentials();
|
NodeMetadata node = get(nodes, 0);
|
||||||
|
Credentials good = node.getCredentials();
|
||||||
assert good.identity != null : nodes;
|
assert good.identity != null : nodes;
|
||||||
assert good.credential != null : nodes;
|
assert good.credential != null : nodes;
|
||||||
|
|
||||||
OperatingSystem os = get(nodes, 0).getOperatingSystem();
|
OperatingSystem os = node.getOperatingSystem();
|
||||||
try {
|
try {
|
||||||
Map<? extends NodeMetadata, ExecResponse> responses = runScriptWithCreds(group, os, new Credentials(
|
Map<? extends NodeMetadata, ExecResponse> responses = runScriptWithCreds(group, os, new Credentials(
|
||||||
good.identity, "romeo"));
|
good.identity, "romeo"));
|
||||||
|
@ -257,33 +258,37 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Entry<? extends NodeMetadata, ExecResponse> response : client.runScriptOnNodesMatching(
|
for (Entry<? extends NodeMetadata, ExecResponse> response : client.runScriptOnNodesMatching(
|
||||||
runningInGroup(group), Statements.exec("echo hello"),
|
runningInGroup(group), Statements.exec("hostname"),
|
||||||
overrideCredentialsWith(good).wrapInInitScript(false).runAsRoot(false)).entrySet())
|
overrideCredentialsWith(good).wrapInInitScript(false).runAsRoot(false)).entrySet()){
|
||||||
assert response.getValue().getOutput().trim().equals("hello") : response.getKey() + ": "
|
checkResponseEqualsHostname(response.getValue(), response.getKey());
|
||||||
+ response.getValue();
|
}
|
||||||
|
|
||||||
// test single-node execution
|
// test single-node execution
|
||||||
ExecResponse response = client.runScriptOnNode(get(nodes, 0).getId(), "echo hello", wrapInInitScript(false)
|
ExecResponse response = client.runScriptOnNode(node.getId(), "hostname", wrapInInitScript(false)
|
||||||
.runAsRoot(false));
|
.runAsRoot(false));
|
||||||
assert response.getOutput().trim().equals("hello") : get(nodes, 0).getId() + ": " + response;
|
checkResponseEqualsHostname(response, node);
|
||||||
|
|
||||||
runScriptWithCreds(group, os, good);
|
runScriptWithCreds(group, os, good);
|
||||||
|
|
||||||
checkNodes(nodes, group);
|
checkNodes(nodes, group);
|
||||||
|
|
||||||
// test adding AdminAccess later changes the default boot user, in this case to foo
|
// test adding AdminAccess later changes the default boot user, in this case to foo
|
||||||
response = client.runScriptOnNode(get(nodes, 0).getId(), AdminAccess.builder().adminUsername("foo").build(), nameTask("adminUpdate"));
|
response = client.runScriptOnNode(node.getId(), AdminAccess.builder().adminUsername("foo").build(), nameTask("adminUpdate"));
|
||||||
|
|
||||||
response = client.runScriptOnNode(get(nodes, 0).getId(), "echo $USER", wrapInInitScript(false)
|
response = client.runScriptOnNode(node.getId(), "echo $USER", wrapInInitScript(false)
|
||||||
.runAsRoot(false));
|
.runAsRoot(false));
|
||||||
|
|
||||||
assert response.getOutput().trim().equals("foo") : get(nodes, 0).getId() + ": " + response;
|
assert response.getOutput().trim().equals("foo") : node.getId() + ": " + response;
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
client.destroyNodesMatching(inGroup(group));
|
client.destroyNodesMatching(inGroup(group));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void checkResponseEqualsHostname(ExecResponse execResponse, NodeMetadata node1) {
|
||||||
|
assert execResponse.getOutput().trim().equals(node1.getHostname()) : node1 + ": " + execResponse;
|
||||||
|
}
|
||||||
|
|
||||||
@Test(enabled = true, dependsOnMethods = { "testImagesCache" })
|
@Test(enabled = true, dependsOnMethods = { "testImagesCache" })
|
||||||
public void testTemplateMatch() throws Exception {
|
public void testTemplateMatch() throws Exception {
|
||||||
template = buildTemplate(client.templateBuilder());
|
template = buildTemplate(client.templateBuilder());
|
||||||
|
|
|
@ -158,12 +158,12 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes
|
||||||
|
|
||||||
// run script without backgrounding (via predicate)
|
// run script without backgrounding (via predicate)
|
||||||
client2.connect();
|
client2.connect();
|
||||||
expect(client2.exec("echo hello\n")).andReturn(new ExecResponse("hello\n", "", 0));
|
expect(client2.exec("hostname\n")).andReturn(new ExecResponse("stub-r\n", "", 0));
|
||||||
client2.disconnect();
|
client2.disconnect();
|
||||||
|
|
||||||
// run script without backgrounding (via id)
|
// run script without backgrounding (via id)
|
||||||
client2.connect();
|
client2.connect();
|
||||||
expect(client2.exec("echo hello\n")).andReturn(new ExecResponse("hello\n", "", 0));
|
expect(client2.exec("hostname\n")).andReturn(new ExecResponse("stub-r\n", "", 0));
|
||||||
client2.disconnect();
|
client2.disconnect();
|
||||||
|
|
||||||
client2.connect();
|
client2.connect();
|
||||||
|
|
|
@ -102,6 +102,7 @@ public class SliceToNodeMetadata implements Function<Slice, NodeMetadata> {
|
||||||
NodeMetadataBuilder builder = new NodeMetadataBuilder();
|
NodeMetadataBuilder builder = new NodeMetadataBuilder();
|
||||||
builder.ids(from.getId() + "");
|
builder.ids(from.getId() + "");
|
||||||
builder.name(from.getName());
|
builder.name(from.getName());
|
||||||
|
builder.hostname(from.getName());
|
||||||
builder.location(location.get());
|
builder.location(location.get());
|
||||||
builder.group(parseGroupFromName(from.getName()));
|
builder.group(parseGroupFromName(from.getName()));
|
||||||
builder.imageId(from.getImageId() + "");
|
builder.imageId(from.getImageId() + "");
|
||||||
|
|
|
@ -70,9 +70,11 @@ public class SliceToNodeMetadataTest {
|
||||||
|
|
||||||
NodeMetadata metadata = parser.apply(slice);
|
NodeMetadata metadata = parser.apply(slice);
|
||||||
|
|
||||||
assertEquals(metadata, new NodeMetadataBuilder().state(NodeState.PENDING).publicAddresses(
|
assertEquals(
|
||||||
ImmutableSet.of("174.143.212.229")).privateAddresses(ImmutableSet.of("10.176.164.199")).group("jclouds")
|
metadata,
|
||||||
.imageId("2").id("1").providerId("1").name("jclouds-foo").location(provider).credentials(creds)
|
new NodeMetadataBuilder().state(NodeState.PENDING).publicAddresses(ImmutableSet.of("174.143.212.229"))
|
||||||
|
.privateAddresses(ImmutableSet.of("10.176.164.199")).group("jclouds").imageId("2").id("1")
|
||||||
|
.providerId("1").name("jclouds-foo").hostname("jclouds-foo").location(provider).credentials(creds)
|
||||||
.userMetadata(ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build());
|
.userMetadata(ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,10 +91,12 @@ public class SliceToNodeMetadataTest {
|
||||||
|
|
||||||
NodeMetadata metadata = parser.apply(slice);
|
NodeMetadata metadata = parser.apply(slice);
|
||||||
|
|
||||||
assertEquals(metadata, new NodeMetadataBuilder().state(NodeState.PENDING).publicAddresses(
|
assertEquals(
|
||||||
ImmutableSet.of("174.143.212.229")).privateAddresses(ImmutableSet.of("10.176.164.199")).group("jclouds")
|
metadata,
|
||||||
.imageId("2").id("1").providerId("1").name("jclouds-foo").location(provider).userMetadata(
|
new NodeMetadataBuilder().state(NodeState.PENDING).publicAddresses(ImmutableSet.of("174.143.212.229"))
|
||||||
ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build());
|
.privateAddresses(ImmutableSet.of("10.176.164.199")).group("jclouds").imageId("2").id("1")
|
||||||
|
.providerId("1").name("jclouds-foo").hostname("jclouds-foo").location(provider)
|
||||||
|
.userMetadata(ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -108,11 +112,18 @@ public class SliceToNodeMetadataTest {
|
||||||
.ofInstance(provider), Suppliers.<Set<? extends Hardware>> ofInstance(hardwares));
|
.ofInstance(provider), Suppliers.<Set<? extends Hardware>> ofInstance(hardwares));
|
||||||
|
|
||||||
NodeMetadata metadata = parser.apply(slice);
|
NodeMetadata metadata = parser.apply(slice);
|
||||||
assertEquals(metadata, new NodeMetadataBuilder().state(NodeState.PENDING).publicAddresses(
|
assertEquals(
|
||||||
ImmutableSet.of("174.143.212.229")).privateAddresses(ImmutableSet.of("10.176.164.199")).group("jclouds")
|
metadata,
|
||||||
.imageId("2").operatingSystem(
|
new NodeMetadataBuilder()
|
||||||
|
.state(NodeState.PENDING)
|
||||||
|
.publicAddresses(ImmutableSet.of("174.143.212.229"))
|
||||||
|
.privateAddresses(ImmutableSet.of("10.176.164.199"))
|
||||||
|
.group("jclouds")
|
||||||
|
.imageId("2")
|
||||||
|
.operatingSystem(
|
||||||
new OperatingSystem.Builder().family(OsFamily.CENTOS).description("CentOS 5.2").version("5.2")
|
new OperatingSystem.Builder().family(OsFamily.CENTOS).description("CentOS 5.2").version("5.2")
|
||||||
.is64Bit(true).build()).id("1").providerId("1").name("jclouds-foo").location(provider)
|
.is64Bit(true).build()).id("1").providerId("1").name("jclouds-foo")
|
||||||
|
.hostname("jclouds-foo").location(provider)
|
||||||
.userMetadata(ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build());
|
.userMetadata(ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,15 +139,27 @@ public class SliceToNodeMetadataTest {
|
||||||
.ofInstance(provider), Suppliers.<Set<? extends Hardware>> ofInstance(hardwares));
|
.ofInstance(provider), Suppliers.<Set<? extends Hardware>> ofInstance(hardwares));
|
||||||
|
|
||||||
NodeMetadata metadata = parser.apply(slice);
|
NodeMetadata metadata = parser.apply(slice);
|
||||||
assertEquals(metadata, new NodeMetadataBuilder().state(NodeState.PENDING).publicAddresses(
|
assertEquals(
|
||||||
ImmutableSet.of("174.143.212.229")).privateAddresses(ImmutableSet.of("10.176.164.199")).group("jclouds")
|
metadata,
|
||||||
.imageId("2").hardware(
|
new NodeMetadataBuilder()
|
||||||
new HardwareBuilder().ids("1").name("256 slice").processors(
|
.state(NodeState.PENDING)
|
||||||
ImmutableList.of(new Processor(0.25, 1.0))).ram(256).volumes(
|
.publicAddresses(ImmutableSet.of("174.143.212.229"))
|
||||||
ImmutableList.of(new VolumeBuilder().type(Volume.Type.LOCAL).size(1.0f).durable(true)
|
.privateAddresses(ImmutableSet.of("10.176.164.199"))
|
||||||
.bootDevice(true).build())).build()).operatingSystem(
|
.group("jclouds")
|
||||||
|
.imageId("2")
|
||||||
|
.hardware(
|
||||||
|
new HardwareBuilder()
|
||||||
|
.ids("1")
|
||||||
|
.name("256 slice")
|
||||||
|
.processors(ImmutableList.of(new Processor(0.25, 1.0)))
|
||||||
|
.ram(256)
|
||||||
|
.volumes(
|
||||||
|
ImmutableList.of(new VolumeBuilder().type(Volume.Type.LOCAL).size(1.0f)
|
||||||
|
.durable(true).bootDevice(true).build())).build())
|
||||||
|
.operatingSystem(
|
||||||
new OperatingSystem.Builder().family(OsFamily.CENTOS).description("CentOS 5.2").version("5.2")
|
new OperatingSystem.Builder().family(OsFamily.CENTOS).description("CentOS 5.2").version("5.2")
|
||||||
.is64Bit(true).build()).id("1").providerId("1").name("jclouds-foo").location(provider)
|
.is64Bit(true).build()).id("1").providerId("1").name("jclouds-foo")
|
||||||
|
.hostname("jclouds-foo").location(provider)
|
||||||
.userMetadata(ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build());
|
.userMetadata(ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue