/** {@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; }
computeService = ctxBuilder.buildView(ComputeServiceContext.class).getComputeService();
@Override public boolean supports(ComputeService computeService) { try { computeService.getContext().unwrapApi(NovaApi.class); return true; } catch (IllegalArgumentException e) { return false; } }
/** * Returns the template for the base node, override to test different templates. * * @return */ public Template getNodeTemplate() { return view.getComputeService().templateBuilder().build(); }
/** * Lists the images found in the {@link ComputeService}, subclasses may override to constrain * search. * * @return */ protected Iterable<? extends Image> listImages() { return view.getComputeService().listImages(); }
public void destroy() { if (computeService != null) { this.computeService.getContext().close(); } }
protected void checkHttpGet(NodeMetadata node) { ComputeTestUtils.checkHttpGet(view.utils().http(), node, 8080); }
/** * get all nodes including details such as image and ip addresses even if it incurs extra * requests to the service. * * @param filter how to select the nodes you are interested in details on. */ @Override public Set<? extends NodeMetadata> listNodesDetailsMatching(Predicate<ComputeMetadata> filter) { return computeService.listNodesDetailsMatching(filter); }
/** * The list locations command returns all the valid locations for nodes. A location has a scope, * which is typically region or zone. A region is a general area, like eu-west, where a zone is * similar to a datacenter. If a location has a parent, that implies it is within that location. * For example a location can be a rack, whose parent is likely to be a zone. */ @Override public Set<? extends Location> listAssignableLocations() { return computeService.listAssignableLocations(); }
/** * @see org.jclouds.compute.ComputeService#runScriptOnNodesMatching(com.google.common.base.Predicate, org.jclouds.scriptbuilder.domain.Statement, org.jclouds.compute.options.RunScriptOptions) */ @Override public Map<? extends NodeMetadata, ExecResponse> runScriptOnNodesMatching(Predicate<NodeMetadata> filter, String runScript) throws RunScriptOnNodesException { return computeService.runScriptOnNodesMatching(filter, runScript); }
/** * Images define the operating system and metadata related to a node. In some clouds, Images are * bound to a specific region, and their identifiers are different across these regions. For this * reason, you should consider matching image requirements like operating system family with * TemplateBuilder as opposed to choosing an image explicitly. The getImages() command returns a * map of images by id. */ @Override public Set<? extends Image> listImages() { return computeService.listImages(); }
/** * The list hardware profiles command shows you the options including virtual cpu count, memory, * and disks. cpu count is not a portable quantity across clouds, as they are measured * differently. However, it is a good indicator of relative speed within a cloud. memory is * measured in megabytes and disks in gigabytes. * * @return a map of hardware profiles by ID, conceding that in some clouds the "id" is not used. */ @Override public Set<? extends Hardware> listHardwareProfiles() { return computeService.listHardwareProfiles(); }
/** * @see #runScriptOnNode(String, String, org.jclouds.compute.options.RunScriptOptions) */ @Override public ExecResponse runScriptOnNode(String id, String runScript) { return computeService.runScriptOnNode(id, runScript); }
/** * Returns the {@link org.jclouds.compute.extensions.ImageExtension} for this provider if it implements it. * * @return an optional of the {@link org.jclouds.compute.extensions.ImageExtension} or {@link com.google.common.base.Optional#absent()} if not * implemented */ @Override public Optional<ImageExtension> getImageExtension() { return computeService.getImageExtension(); }
/** * resume the node from {@link org.jclouds.compute.domain.NodeState#SUSPENDED suspended} state, * given its id. * <p/> * <h4>note</h4> * <p/> * affected nodes may not resume with the same IP address(es) */ @Override public void resumeNode(String id) { computeService.resumeNode(id); }
/** * reboot the node, given its id. */ @Override public void rebootNode(String id) { computeService.rebootNode(id); }
/** * Lists the images found in the {@link ComputeService}, subclasses may override to constrain * search. * * @return */ protected Iterable<? extends Image> listImages() { return view.getComputeService().listImages(); }
protected void checkHttpGet(NodeMetadata node) { ComputeTestUtils.checkHttpGet(view.utils().http(), node, 8080); }