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);
}
}
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));
}
}
}
}
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));
}
}
}
}
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;
}
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;
}
Aggregations