@Override public OsDetails getOsDetails() { if (node.getOperatingSystem() != null) { return new BasicOsDetails( node.getOperatingSystem().getName() != null ? node.getOperatingSystem().getName() : "linux", node.getOperatingSystem().getArch() != null ? node.getOperatingSystem().getArch() : BasicOsDetails.OsArchs.I386, node.getOperatingSystem().getVersion() != null ? node.getOperatingSystem().getVersion() : "unknown", node.getOperatingSystem().is64Bit()); } return super.getOsDetails(); }
/** * Returns a String that displays the {@link org.jclouds.compute.domain.OperatingSystem} details. * * @param node * @return */ protected String getOperatingSystemDetails(NodeMetadata node) { if (node != null) { OperatingSystem os = node.getOperatingSystem(); if (os != null) { return node.getOperatingSystem().getFamily().value() + " " + node.getOperatingSystem().getArch() + " " + node.getOperatingSystem().getVersion(); } } return ""; }
protected void checkOsMatchesTemplate(NodeMetadata node) { if (node.getOperatingSystem() != null) assert node.getOperatingSystem().getFamily().equals(template.getImage().getOperatingSystem().getFamily()) : String .format("expecting family %s but got %s", template.getImage().getOperatingSystem().getFamily(), node.getOperatingSystem()); }
protected void checkOsMatchesTemplate(NodeMetadata node) { if (node.getOperatingSystem() != null) assert node.getOperatingSystem().getFamily().equals(template.getImage().getOperatingSystem().getFamily()) : String .format("expecting family %s but got %s", template.getImage().getOperatingSystem().getFamily(), node.getOperatingSystem()); }
if (m.getOperatingSystem().is64Bit() != template.getIs64bit()) return false; if (m.getOperatingSystem() == null || !template.getOsFamily().equals(m.getOperatingSystem().getFamily())) return false; if (m.getOperatingSystem() == null || m.getOperatingSystem().getName()==null || !m.getOperatingSystem().getName().matches(template.getOsNameMatchesRegex())) return false;
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); }
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()); }
assertEquals(convertedNodeMetadata.getOperatingSystem(), expectedOs);
protected void createAndRunAServiceInGroup(String group) throws RunNodesException { // note that some cloud providers do not support mixed case tag names ImmutableMap<String, String> userMetadata = ImmutableMap.of("test", group); ImmutableSet<String> tags = ImmutableSet.of(group); Stopwatch watch = Stopwatch.createStarted(); template = buildTemplate(client.templateBuilder()); template.getOptions().inboundPorts(22, 8080).blockOnPort(22, 300).userMetadata(userMetadata).tags(tags); NodeMetadata node = getOnlyElement(client.createNodesInGroup(group, 1, template)); long createSeconds = watch.elapsed(TimeUnit.SECONDS); final String nodeId = node.getId(); //checkUserMetadataContains(node, userMetadata); //checkTagsInNodeEquals(node, tags); getAnonymousLogger().info( format("<< available node(%s) os(%s) in %ss", node.getId(), node.getOperatingSystem(), createSeconds)); watch.reset().start(); client.runScriptOnNode(nodeId, JettyStatements.install(), nameTask("configure-jetty")); long configureSeconds = watch.elapsed(TimeUnit.SECONDS); getAnonymousLogger().info( format( "<< configured node(%s) with %s and jetty %s in %ss", nodeId, exec(nodeId, "java -fullversion"), exec(nodeId, JettyStatements.version()), configureSeconds)); trackProcessOnNode(JettyStatements.start(), "start jetty", node); client.runScriptOnNode(nodeId, JettyStatements.stop(), runAsRoot(false).wrapInInitScript(false)); trackProcessOnNode(JettyStatements.start(), "start jetty", node); }
protected void createAndRunAServiceInGroup(String group) throws RunNodesException { // note that some cloud providers do not support mixed case tag names ImmutableMap<String, String> userMetadata = ImmutableMap.<String, String> of("test", group); ImmutableSet<String> tags = ImmutableSet. of(group); Stopwatch watch = new Stopwatch().start(); NodeMetadata node = getOnlyElement(client.createNodesInGroup(group, 1, inboundPorts(22, 8080).blockOnPort(22, 300).userMetadata(userMetadata).tags(tags))); long createSeconds = watch.elapsedTime(TimeUnit.SECONDS); final String nodeId = node.getId(); checkUserMetadataContains(node, userMetadata); checkTagsInNodeEquals(node, tags); getAnonymousLogger().info( format("<< available node(%s) os(%s) in %ss", node.getId(), node.getOperatingSystem(), createSeconds)); watch.reset().start(); client.runScriptOnNode(nodeId, JettyStatements.install(), nameTask("configure-jetty")); long configureSeconds = watch.elapsedTime(TimeUnit.SECONDS); getAnonymousLogger().info( format( "<< configured node(%s) with %s and jetty %s in %ss", nodeId, exec(nodeId, "java -fullversion"), exec(nodeId, JettyStatements.version()), configureSeconds)); trackAvailabilityOfProcessOnNode(JettyStatements.start(), "start jetty", node); client.runScriptOnNode(nodeId, JettyStatements.stop(), runAsRoot(false).wrapInInitScript(false)); trackAvailabilityOfProcessOnNode(JettyStatements.start(), "start jetty", node); }
protected void createAndRunAServiceInGroup(String group) throws RunNodesException { // note that some cloud providers do not support mixed case tag names ImmutableMap<String, String> userMetadata = ImmutableMap.<String, String> of("test", group); ImmutableSet<String> tags = ImmutableSet.of(group); Stopwatch watch = Stopwatch.createStarted(); template = buildTemplate(templateBuilder()); template.getOptions().inboundPorts(22, 8080).blockOnPort(22, 300).userMetadata(userMetadata).tags(tags); NodeMetadata node = getOnlyElement(client.createNodesInGroup(group, 1, template)); long createSeconds = watch.elapsed(TimeUnit.SECONDS); final String nodeId = node.getId(); checkUserMetadataContains(node, userMetadata); checkTagsInNodeEquals(node, tags); getAnonymousLogger().info( format("<< available node(%s) os(%s) in %ss", node.getId(), node.getOperatingSystem(), createSeconds)); watch.reset().start(); client.runScriptOnNode(nodeId, JettyStatements.install(), nameTask("configure-jetty")); long configureSeconds = watch.elapsed(TimeUnit.SECONDS); getAnonymousLogger().info( format( "<< configured node(%s) with %s and jetty %s in %ss", nodeId, exec(nodeId, "java -fullversion"), exec(nodeId, JettyStatements.version()), configureSeconds)); trackAvailabilityOfProcessOnNode(JettyStatements.start(), "start jetty", node); client.runScriptOnNode(nodeId, JettyStatements.stop(), runAsRoot(false).wrapInInitScript(false)); trackAvailabilityOfProcessOnNode(JettyStatements.start(), "start jetty", node); }
public NodeMetadata createNodeWithAdminUserAndJDKInGroupOpeningPortAndMinRam(String group, int port, int minRam) { ImmutableMap<String, String> userMetadata = ImmutableMap.<String, String> of("Name", group); // we want everything as defaults except ram Template defaultTemplate = compute.templateBuilder().build(); Template minecraft = compute.templateBuilder().fromTemplate(defaultTemplate).minRam(minRam).build(); // setup the template to customize the node with jdk, etc. also opening ports. Statement bootstrap = newStatementList(AdminAccess.standard(), InstallJDK.fromOpenJDK()); minecraft.getOptions().inboundPorts(22, port).userMetadata(userMetadata).runScript(bootstrap); // example of using a cloud-specific hook if (minecraft.getOptions() instanceof AWSEC2TemplateOptions) minecraft.getOptions().as(AWSEC2TemplateOptions.class).enableMonitoring(); logger.info(">> creating node type(%s) in group %s, opening ports 22, %s with admin user and jdk", minecraft .getHardware().getId(), group, port); try { NodeMetadata node = getOnlyElement(compute.createNodesInGroup(group, 1, minecraft)); logger.info("<< available node(%s) os(%s) publicAddresses%s", node.getId(), node.getOperatingSystem(), node.getPublicAddresses()); return node; } catch (RunNodesException e) { throw destroyBadNodesAndPropagate(e); } }
runScriptWithCreds(group, first.getOperatingSystem(), LoginCredentials.builder().user(first.getCredentials().identity).privateKey(result.getKeyMaterial()) .build());
wrapInInitScript(false).runAsRoot(false)); checkResponseEqualsHostname(response, node); OperatingSystem os = node.getOperatingSystem();
wrapInInitScript(false).runAsRoot(false)); checkResponseEqualsHostname(response, node); OperatingSystem os = node.getOperatingSystem();
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()); }