Issue 487: rimu returns consistent hostname, but vcloud does not

This commit is contained in:
Adrian Cole 2011-07-23 23:20:13 +10:00
parent 0a73d5a22a
commit 81bf7268be
4 changed files with 9 additions and 7 deletions

View File

@ -24,7 +24,6 @@ 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;
@ -73,8 +72,6 @@ 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));

View File

@ -121,7 +121,6 @@ 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());
} }
@ -136,7 +135,6 @@ 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());
} }
@ -151,7 +149,6 @@ 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);
} }
} }

View File

@ -94,6 +94,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());
Location location = findLocationWithId(from.getLocation().getId()); Location location = findLocationWithId(from.getLocation().getId());
builder.location(location); builder.location(location);
builder.group(parseGroupFromName(from.getName())); builder.group(parseGroupFromName(from.getName()));

View File

@ -21,7 +21,9 @@ package org.jclouds.stratogen.vcloud.mycloud.compute;
import static org.jclouds.compute.util.ComputeServiceUtils.getCores; import static org.jclouds.compute.util.ComputeServiceUtils.getCores;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.domain.Template; import org.jclouds.compute.domain.Template;
import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.compute.domain.TemplateBuilder;
@ -38,7 +40,8 @@ import org.testng.annotations.Test;
public class StratoGenVCloudMyCloudComputeServiceLiveTest extends VCloudComputeServiceLiveTest { public class StratoGenVCloudMyCloudComputeServiceLiveTest extends VCloudComputeServiceLiveTest {
public StratoGenVCloudMyCloudComputeServiceLiveTest() { public StratoGenVCloudMyCloudComputeServiceLiveTest() {
provider = "stratogen-vcloud-mycloud"; provider = "stratogen-vcloud-mycloud";
// vcloud requires instantiate before deploy, which takes longer than 30 seconds // vcloud requires instantiate before deploy, which takes longer than 30
// seconds
nonBlockDurationSeconds = 300; nonBlockDurationSeconds = 300;
} }
@ -67,4 +70,8 @@ public class StratoGenVCloudMyCloudComputeServiceLiveTest extends VCloudComputeS
return template; return template;
} }
protected void checkResponseEqualsHostname(ExecResponse execResponse, NodeMetadata node1) {
// hostname is not predictable based on node metadata
assert execResponse.getOutput().trim().equals("(none)");
}
} }