Search in sources :

Example 31 with NodeMetadata

use of org.jclouds.compute.domain.NodeMetadata in project legacy-jclouds-examples by jclouds.

the class ListServersWithFiltering method listServersByNameStartsWith.

private void listServersByNameStartsWith() {
    System.out.println("List Servers By Name Starts With");
    Set<? extends NodeMetadata> servers = compute.listNodesDetailsMatching(nameStartsWith("jclouds-ex"));
    for (NodeMetadata nodeMetadata : servers) {
        System.out.println("  " + nodeMetadata);
    }
}
Also used : NodeMetadata(org.jclouds.compute.domain.NodeMetadata)

Example 32 with NodeMetadata

use of org.jclouds.compute.domain.NodeMetadata in project camel by apache.

the class JcloudsSpringComputeTest method testCreateSuspendAndResumeNode.

@Test
public void testCreateSuspendAndResumeNode() throws InterruptedException {
    result.expectedMessageCount(1);
    template.sendBodyAndHeaders("direct:start", null, createHeaders("1", "default"));
    result.assertIsSatisfied();
    List<Exchange> exchanges = result.getExchanges();
    if (exchanges != null && !exchanges.isEmpty()) {
        for (Exchange exchange : exchanges) {
            Set<?> nodeMetadatas = exchange.getIn().getBody(Set.class);
            assertEquals("There should be one node running", 1, nodeMetadatas.size());
            for (Object obj : nodeMetadatas) {
                NodeMetadata nodeMetadata = (NodeMetadata) obj;
                template.sendBodyAndHeaders("direct:start", null, resumeHeaders(nodeMetadata.getId(), null));
            }
        }
    }
}
Also used : Exchange(org.apache.camel.Exchange) NodeMetadata(org.jclouds.compute.domain.NodeMetadata) Test(org.junit.Test)

Example 33 with NodeMetadata

use of org.jclouds.compute.domain.NodeMetadata in project camel by apache.

the class JcloudsSpringComputeTest method testCreateAndRebootNode.

@Test
public void testCreateAndRebootNode() throws InterruptedException {
    result.expectedMessageCount(1);
    template.sendBodyAndHeaders("direct:start", null, createHeaders("1", "default"));
    result.assertIsSatisfied();
    List<Exchange> exchanges = result.getExchanges();
    if (exchanges != null && !exchanges.isEmpty()) {
        for (Exchange exchange : exchanges) {
            Set<?> nodeMetadatas = exchange.getIn().getBody(Set.class);
            assertEquals("There should be one node running", 1, nodeMetadatas.size());
            for (Object obj : nodeMetadatas) {
                NodeMetadata nodeMetadata = (NodeMetadata) obj;
                template.sendBodyAndHeaders("direct:start", null, rebootHeaders(nodeMetadata.getId(), null));
            }
        }
    }
}
Also used : Exchange(org.apache.camel.Exchange) NodeMetadata(org.jclouds.compute.domain.NodeMetadata) Test(org.junit.Test)

Example 34 with NodeMetadata

use of org.jclouds.compute.domain.NodeMetadata in project SimianArmy by Netflix.

the class AWSClient method getJcloudsNode.

private NodeMetadata getJcloudsNode(ComputeService computeService, String jcloudsId) {
    // Work around a jclouds bug / documentation issue...
    // TODO: Figure out what's broken, and eliminate this function
    // This should work (?):
    // Set<NodeMetadata> nodes = computeService.listNodesByIds(Collections.singletonList(jcloudsId));
    Set<NodeMetadata> nodes = Sets.newHashSet();
    for (ComputeMetadata n : computeService.listNodes()) {
        if (jcloudsId.equals(n.getId())) {
            nodes.add((NodeMetadata) n);
        }
    }
    if (nodes.isEmpty()) {
        LOGGER.warn("Unable to find jclouds node: {}", jcloudsId);
        for (ComputeMetadata n : computeService.listNodes()) {
            LOGGER.info("Did find node: {}", n);
        }
        throw new IllegalStateException("Unable to find node using jclouds: " + jcloudsId);
    }
    NodeMetadata node = Iterables.getOnlyElement(nodes);
    return node;
}
Also used : NodeMetadata(org.jclouds.compute.domain.NodeMetadata) ComputeMetadata(org.jclouds.compute.domain.ComputeMetadata)

Example 35 with NodeMetadata

use of org.jclouds.compute.domain.NodeMetadata in project ignite by apache.

the class TcpDiscoveryCloudIpFinder method getRegisteredAddresses.

/** {@inheritDoc} */
@Override
public Collection<InetSocketAddress> getRegisteredAddresses() throws IgniteSpiException {
    initComputeService();
    Collection<InetSocketAddress> addresses = new LinkedList<>();
    try {
        Set<NodeMetadata> nodes;
        if (nodesFilter != null)
            nodes = (Set<NodeMetadata>) computeService.listNodesDetailsMatching(nodesFilter);
        else {
            nodes = new HashSet<>();
            for (ComputeMetadata metadata : computeService.listNodes()) nodes.add(computeService.getNodeMetadata(metadata.getId()));
        }
        for (NodeMetadata metadata : nodes) {
            if (metadata.getStatus() != NodeMetadata.Status.RUNNING)
                continue;
            for (String addr : metadata.getPrivateAddresses()) addresses.add(new InetSocketAddress(addr, 0));
            for (String addr : metadata.getPublicAddresses()) addresses.add(new InetSocketAddress(addr, 0));
        }
    } catch (Exception e) {
        throw new IgniteSpiException("Failed to get registered addresses for the provider: " + provider, e);
    }
    return addresses;
}
Also used : NodeMetadata(org.jclouds.compute.domain.NodeMetadata) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) Set(java.util.Set) InetSocketAddress(java.net.InetSocketAddress) ComputeMetadata(org.jclouds.compute.domain.ComputeMetadata) IgniteSpiException(org.apache.ignite.spi.IgniteSpiException) LinkedList(java.util.LinkedList) IgniteSpiException(org.apache.ignite.spi.IgniteSpiException) IgniteInterruptedCheckedException(org.apache.ignite.internal.IgniteInterruptedCheckedException) IOException(java.io.IOException)

Aggregations

NodeMetadata (org.jclouds.compute.domain.NodeMetadata)35 RunNodesException (org.jclouds.compute.RunNodesException)11 Template (org.jclouds.compute.domain.Template)9 ComputeService (org.jclouds.compute.ComputeService)7 IOException (java.io.IOException)6 TemplateBuilder (org.jclouds.compute.domain.TemplateBuilder)6 Test (org.junit.Test)5 Exchange (org.apache.camel.Exchange)4 ComputeServiceContext (org.jclouds.compute.ComputeServiceContext)4 RunScriptOnNodesException (org.jclouds.compute.RunScriptOnNodesException)4 Statement (org.jclouds.scriptbuilder.domain.Statement)4 File (java.io.File)3 Set (java.util.Set)3 InstanceTemplate (org.apache.whirr.service.ClusterSpec.InstanceTemplate)3 ComputeMetadata (org.jclouds.compute.domain.ComputeMetadata)3 LoginCredentials (org.jclouds.domain.LoginCredentials)3 Predicate (com.google.common.base.Predicate)2 Properties (java.util.Properties)2 Host (org.apache.hive.ptest.execution.conf.Host)2 RunListBuilder (org.jclouds.chef.util.RunListBuilder)2