@Test public void machineTypeParserTest() { URI uri = URI.create("https: Hardware hardware = machineTypeURIToCustomHardware(uri); assertThat(hardware.getRam()).isEqualTo(1024); assertThat(hardware.getProcessors().get(0).getCores()).isEqualTo(1); assertThat(hardware.getUri()) .isEqualTo(URI.create("https: assertThat(hardware.getId()) .isEqualTo("https: }
public static Hardware machineTypeURIToCustomHardware(URI machineType) { String uri = machineType.toString(); String values = uri.substring(uri.lastIndexOf('/') + 8); List<String> hardwareValues = Splitter.on('-') .trimResults() .splitToList(values); return new HardwareBuilder() .id(uri) .providerId(uri) .processor(new Processor(Double.parseDouble(hardwareValues.get(0)), 1.0)) .ram(Integer.parseInt(hardwareValues.get(1))) .uri(machineType) .build(); }
InstanceToNodeMetadata implements Function<Instance, NodeMetadata> { public static Hardware machineTypeURIToCustomHardware(URI machineType) { String uri = machineType.toString(); String values = uri.substring(uri.lastIndexOf('/') + 8); List<String> hardwareValues = Splitter.on('-') .trimResults() .splitToList(values); return new HardwareBuilder() .id(uri) .providerId(uri) .processor(new Processor(Double.parseDouble(hardwareValues.get(0)), 1.0)) .ram(Integer.parseInt(hardwareValues.get(1))) .uri(machineType) .build(); } }
InstanceToNodeMetadata implements Function<Instance, NodeMetadata> { public static Hardware machineTypeURIToCustomHardware(URI machineType) { String uri = machineType.toString(); String values = uri.substring(uri.lastIndexOf('/') + 8); List<String> hardwareValues = Splitter.on('-') .trimResults() .splitToList(values); return new HardwareBuilder() .id(uri) .providerId(uri) .processor(new Processor(Double.parseDouble(hardwareValues.get(0)), 1.0)) .ram(Integer.parseInt(hardwareValues.get(1))) .uri(machineType) .build(); } @Inject  InstanceToNodeMetadata(Map<Instance.Status, NodeMetadata.Status> toPortableNodeStatus,
                                  GroupNamingConvention.Factory namingConvention,
                                  LoadingCache<URI, Optional<Image>> diskURIToImage,
                                  @Memoized Supplier<Map<URI, Hardware>> hardwares,
                                  @Memoized Supplier<Map<URI, Location>> locationsByUri); }
InstanceToNodeMetadata implements Function<Instance, NodeMetadata> { public static Hardware machineTypeURIToCustomHardware(URI machineType) { String uri = machineType.toString(); String values = uri.substring(uri.lastIndexOf('/') + 8); List<String> hardwareValues = Splitter.on('-') .trimResults() .splitToList(values); return new HardwareBuilder() .id(uri) .providerId(uri) .processor(new Processor(Double.parseDouble(hardwareValues.get(0)), 1.0)) .ram(Integer.parseInt(hardwareValues.get(1))) .uri(machineType) .build(); } @Inject  InstanceToNodeMetadata(Map<Instance.Status, NodeMetadata.Status> toPortableNodeStatus,
                                  GroupNamingConvention.Factory namingConvention,
                                  LoadingCache<URI, Optional<Image>> diskURIToImage,
                                  @Memoized Supplier<Map<URI, Hardware>> hardwares,
                                  @Memoized Supplier<Map<URI, Location>> locationsByUri); @Override NodeMetadata apply(Instance input); static boolean isCustomMachineTypeURI(URI machineType); static Hardware machineTypeURIToCustomHardware(URI machineType); }
InstanceToNodeMetadata implements Function<Instance, NodeMetadata> { public static Hardware machineTypeURIToCustomHardware(URI machineType) { String uri = machineType.toString(); String values = uri.substring(uri.lastIndexOf('/') + 8); List<String> hardwareValues = Splitter.on('-') .trimResults() .splitToList(values); return new HardwareBuilder() .id(uri) .providerId(uri) .processor(new Processor(Double.parseDouble(hardwareValues.get(0)), 1.0)) .ram(Integer.parseInt(hardwareValues.get(1))) .uri(machineType) .build(); } @Inject  InstanceToNodeMetadata(Map<Instance.Status, NodeMetadata.Status> toPortableNodeStatus,
                                  GroupNamingConvention.Factory namingConvention,
                                  LoadingCache<URI, Optional<Image>> diskURIToImage,
                                  @Memoized Supplier<Map<URI, Hardware>> hardwares,
                                  @Memoized Supplier<Map<URI, Location>> locationsByUri); @Override NodeMetadata apply(Instance input); static boolean isCustomMachineTypeURI(URI machineType); static Hardware machineTypeURIToCustomHardware(URI machineType);  }