/** {@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; }
@Override public boolean apply(ComputeMetadata computeMetadata) { String region = null; String zone = null; Location location = computeMetadata.getLocation(); while (location != null) { switch (location.getScope()) { case ZONE: zone = location.getId(); break; case REGION: region = location.getId(); break; } location = location.getParent(); } if (regions != null && region != null && !regions.contains(region)) return false; if (zones != null && zone != null && !zones.contains(zone)) return false; return true; } };
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 ImageBuilder fromImage(Image image) { return new ImageBuilder().providerId(image.getProviderId()).name(image.getName()).id(image.getId()).location( image.getLocation()).uri(image.getUri()).userMetadata(image.getUserMetadata()).tags(image.getTags()) .version(image.getVersion()).description(image.getDescription()).operatingSystem( image.getOperatingSystem()).status(image.getStatus()).backendStatus(image.getBackendStatus()) .defaultCredentials(image.getDefaultCredentials()); }
public Builder fromOperatingSystem(OperatingSystem in) { return family(in.getFamily()).name(in.getName()).version(in.getVersion()).arch(in.getArch()).description( in.getDescription()).is64Bit(in.is64Bit()); } }
@Override public Image getImage(VirtualGuest guest) { return new ImageBuilder().ids("123").description("mocked image") .operatingSystem(OperatingSystem.builder().description("foo os").build()) .status(Image.Status.AVAILABLE).build(); } }
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()); }
public static SecurityGroupBuilder fromSecurityGroup(SecurityGroup group) { return new SecurityGroupBuilder().providerId(group.getProviderId()) .name(group.getName()) .id(group.getId()) .location(group.getLocation()) .uri(group.getUri()) .userMetadata(group.getUserMetadata()) .tags(group.getTags()) .ipPermissions(group.getIpPermissions()) .ownerId(group.getOwnerId()); }
public static ComputeMetadataBuilder fromComputeMetadata(ComputeMetadata in) { return new ComputeMetadataBuilder(in.getType()).id(in.getId()).location(in.getLocation()).name(in.getName()) .uri(in.getUri()).userMetadata(in.getUserMetadata()).tags(in.getTags()); } }
public static double getCoresAndSpeed(Hardware input) { double total = 0; for (Processor processor : input.getProcessors()) total += processor.getCores() * processor.getSpeed(); return total; }
public static double getCores(Hardware input) { double cores = 0; for (Processor processor : input.getProcessors()) cores += processor.getCores(); return cores; }
public static double getSpace(Hardware input) { double total = 0; for (Volume volume : input.getVolumes()) { Float size = volume.getSize(); if (size != null) { total += size; } } return total; }
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 Builder fromOperatingSystem(OperatingSystem in) { return family(in.getFamily()).name(in.getName()).version(in.getVersion()).arch(in.getArch()).description( in.getDescription()).is64Bit(in.is64Bit()); } }
public static ComputeMetadataBuilder fromComputeMetadata(ComputeMetadata in) { return new ComputeMetadataBuilder(in.getType()).id(in.getId()).location(in.getLocation()).name(in.getName()) .uri(in.getUri()).userMetadata(in.getUserMetadata()).tags(in.getTags()); } }
public static double getCoresAndSpeed(Hardware input) { double total = 0; for (Processor processor : input.getProcessors()) total += processor.getCores() * processor.getSpeed(); return total; }
public static double getCores(Hardware input) { double cores = 0; for (Processor processor : input.getProcessors()) cores += processor.getCores(); return cores; }