private String getPublicHostnameGeneric(NodeMetadata node, @Nullable ConfigBag setup) { //prefer the public address to the hostname because hostname is sometimes wrong/abbreviated //(see that javadoc; also e.g. on rackspace, the hostname lacks the domain) //TODO would it be better to prefer hostname, but first check that it is resolvable? if (truth(node.getPublicAddresses())) { return node.getPublicAddresses().iterator().next(); } else if (truth(node.getHostname())) { return node.getHostname(); } else if (truth(node.getPrivateAddresses())) { return node.getPrivateAddresses().iterator().next(); } else { return null; } }
private void fetchMemberMetaData(NodeMetadata metadata) { Location location = metadata.getLocation(); while (location != null) { String id = location.getId(); if (location.getScope().equals(LocationScope.ZONE)) { if (id != null) { memberMetaData.put(PARTITION_GROUP_ZONE, id); } } location = location.getParent(); } memberMetaData.put(PARTITION_GROUP_HOST, metadata.getHostname()); }
protected void checkResponseEqualsHostname(ExecResponse execResponse, NodeMetadata node1) { assert execResponse.getOutput().trim().equals(node1.getHostname()) : node1 + ": " + execResponse; }
protected void checkResponseEqualsHostname(ExecResponse execResponse, NodeMetadata node1) { assert execResponse.getOutput().trim().equals(node1.getHostname()) : node1 + ": " + execResponse; }
private void checkSoftlayer(String spec) { FixedListMachineProvisioningLocation<JcloudsSshMachineLocation> loc = resolve(spec); Set<JcloudsSshMachineLocation> machines = loc.getAllMachines(); JcloudsSshMachineLocation machine = Iterables.getOnlyElement(machines); assertEquals(machine.getParent().getProvider(), "softlayer"); assertEquals(machine.getNode().getId(), slVmInstanceId); assertEquals(machine.getAddress().getHostAddress(), slVmIp); assertTrue(slVmHostname.equals(machine.getAddress().getHostName()) || slVmIp.equals(machine.getAddress().getHostName()), "address hostname is: "+machine.getAddress().getHostName()); assertTrue(slVmHostname.equals(machine.getNode().getHostname()) || slVmIp.equals(machine.getNode().getHostname()), "node hostname is: "+machine.getNode().getHostname()); // could also assert this, given a user credential, but not currently set up // assertTrue(machine.isSshable()); }
if (null != slave) { final NodeMetadata nmd = slave.getNodeMetaData(); if (null != nmd && nmd.getHostname().equals(hostName)) { slave.setWaitPhoneHome(false); return;
private static void assertNodeEquals(NodeMetadata actual, NodeMetadata expected) { assertEquals(actual, expected); // NodeMetadata equals method does not use all fields in equals. It assumes that same ids in same locations // determine the equivalence assertEquals(actual.getStatus(), expected.getStatus()); assertEquals(actual.getBackendStatus(), expected.getBackendStatus()); assertEquals(actual.getLoginPort(), expected.getLoginPort()); assertEquals(actual.getPublicAddresses(), expected.getPublicAddresses()); assertEquals(actual.getPrivateAddresses(), expected.getPrivateAddresses()); assertEquals(actual.getCredentials(), expected.getCredentials()); assertEquals(actual.getGroup(), expected.getGroup()); assertEquals(actual.getImageId(), expected.getImageId()); assertEquals(actual.getHardware(), expected.getHardware()); assertEquals(actual.getOperatingSystem(), expected.getOperatingSystem()); assertEquals(actual.getHostname(), expected.getHostname()); }
private void assertNodeMetadata(NodeMetadata result, org.jclouds.compute.domain.OperatingSystem os, String imageId, NodeMetadata.Status status, ImmutableSet<String> privateIpAddresses, ImmutableSet<String> publicIpAddresses) { assertNotNull(result); assertEquals(result.getId(), serverWithExternalIp.server().id()); assertEquals(result.getName(), serverWithExternalIp.server().name()); assertEquals(result.getHostname(), serverWithExternalIp.server().description()); assertEquals(result.getGroup(), "[" + serverName + "]"); assertEquals(result.getHardware(), hardware); assertEquals(result.getOperatingSystem(), os); assertEquals(result.getLocation(), location); assertEquals(result.getImageId(), imageId); assertEquals(result.getStatus(), status); assertEquals(result.getPrivateAddresses(), privateIpAddresses); assertEquals(result.getPublicAddresses(), publicIpAddresses); } }
@Test public void testVirtualGuestToNodeMetadata() { VirtualGuest virtualGuest = createVirtualGuest(); NodeMetadata nodeMetadata = new VirtualGuestToNodeMetadata(locationSupplier, namingConvention, virtualGuestToImage, virtualGuestToHardware).apply(virtualGuest); assertNotNull(nodeMetadata); assertEquals(nodeMetadata.getName(), virtualGuest.getHostname()); assertNotNull(nodeMetadata.getLocation()); assertEquals(nodeMetadata.getLocation().getId(), location.getId()); assertEquals(nodeMetadata.getHostname(), virtualGuest.getFullyQualifiedDomainName()); assertEquals(nodeMetadata.getHardware().getRam(), virtualGuest.getMaxMemory()); assertTrue(nodeMetadata.getHardware().getProcessors().size() == 1); assertEquals(Iterables.get(nodeMetadata.getHardware().getProcessors(), 0).getCores(), (double) virtualGuest.getStartCpus()); assertEquals(nodeMetadata.getOperatingSystem().getFamily(), OsFamily.UBUNTU); assertEquals(nodeMetadata.getOperatingSystem().getVersion(), "12.04"); assertEquals(nodeMetadata.getOperatingSystem().is64Bit(), true); }
@BeforeClass(groups="Live") public void setUpClass() throws Exception { classManagementContext = newManagementContext(); classLoc = (JcloudsLocation) classManagementContext.getLocationRegistry().getLocationManaged(SOFTLAYER_LOCATION_SPEC); classVm = (JcloudsSshMachineLocation)classLoc.obtain(MutableMap.<String,Object>builder() .put("inboundPorts", ImmutableList.of(22)) .build()); slVmUser = classVm.getUser(); slVmInstanceId = classVm.getJcloudsId(); slVmIp = classVm.getAddress().getHostAddress(); slVmHostname = classVm.getNode().getHostname(); }
jCloudsContainerMetadata.setContainerName(containerName); jCloudsContainerMetadata.setPublicAddresses(copyOfPublicAddresses); jCloudsContainerMetadata.setHostname(nodeMetadata.getHostname());
a.setHostname(nodeInstance.getHostname()); a.setCore((int) nodeInstance.getHardware().getProcessors().iterator().next().getCores()); state = ComponentInstance.State.RUNNING;
@Override public NodeMetadata apply(@Nullable org.jclouds.compute.domain.NodeMetadata input) { if (input == null) { return null; } return NodeMetadata.builder().id(input.getId()).name(input.getName()).status(input.getStatus().name()) .hostname(input.getHostname()) .loginPort(input.getLoginPort()).group(input.getGroup()) .tags(input.getTags()).metadata(input.getUserMetadata()) .locationId(input.getLocation() != null ? input.getLocation().getId() : null) .imageId(input.getImageId()) .defaultCredentials(ToLoginCredentials.INSTANCE.apply(input.getCredentials())).build(); } }
public static NodeMetadataBuilder fromNodeMetadata(NodeMetadata node) { return new NodeMetadataBuilder().providerId(node.getProviderId()).name(node.getName()).id(node.getId()).location( node.getLocation()).uri(node.getUri()).userMetadata(node.getUserMetadata()).tags(node.getTags()).group( node.getGroup()).hardware(node.getHardware()).imageId(node.getImageId()).operatingSystem( node.getOperatingSystem()).status(node.getStatus()).backendStatus(node.getBackendStatus()).loginPort( node.getLoginPort()).publicAddresses(node.getPublicAddresses()).privateAddresses( node.getPrivateAddresses()).credentials(node.getCredentials()).hostname(node.getHostname()); }
public static NodeMetadataBuilder fromNodeMetadata(NodeMetadata node) { return new NodeMetadataBuilder().providerId(node.getProviderId()).name(node.getName()).id(node.getId()).location( node.getLocation()).uri(node.getUri()).userMetadata(node.getUserMetadata()).tags(node.getTags()).group( node.getGroup()).hardware(node.getHardware()).imageId(node.getImageId()).operatingSystem( node.getOperatingSystem()).status(node.getStatus()).backendStatus(node.getBackendStatus()).loginPort( node.getLoginPort()).publicAddresses(node.getPublicAddresses()).privateAddresses( node.getPrivateAddresses()).credentials(node.getCredentials()).hostname(node.getHostname()); }
public static NodeMetadataBuilder fromNodeMetadata(NodeMetadata node) { return new NodeMetadataBuilder().providerId(node.getProviderId()).name(node.getName()).id(node.getId()).location( node.getLocation()).uri(node.getUri()).userMetadata(node.getUserMetadata()).tags(node.getTags()).group( node.getGroup()).hardware(node.getHardware()).imageId(node.getImageId()).operatingSystem( node.getOperatingSystem()).status(node.getStatus()).backendStatus(node.getBackendStatus()).loginPort( node.getLoginPort()).publicAddresses(node.getPublicAddresses()).privateAddresses( node.getPrivateAddresses()).credentials(node.getCredentials()).hostname(node.getHostname()); }
public static NodeMetadataBuilder fromNodeMetadata(NodeMetadata node) { return new NodeMetadataBuilder().providerId(node.getProviderId()).name(node.getName()).id(node.getId()).location( node.getLocation()).uri(node.getUri()).userMetadata(node.getUserMetadata()).tags(node.getTags()).group( node.getGroup()).hardware(node.getHardware()).imageId(node.getImageId()).operatingSystem( node.getOperatingSystem()).status(node.getStatus()).backendStatus(node.getBackendStatus()).loginPort( node.getLoginPort()).publicAddresses(node.getPublicAddresses()).privateAddresses( node.getPrivateAddresses()).credentials(node.getCredentials()).hostname(node.getHostname()); }