@Test public void imageUrl() { NodeMetadata nodeMetadata = groupNullNodeParser.apply(instance); assertEquals(nodeMetadata.getImageId(), imageUrl.toString()); }
@Override public NodeMetadata apply(Instance input) { String group = groupFromMapOrName(input.metadata().asMap(), input.name(), nodeNamingConvention); NodeMetadataBuilder builder = new NodeMetadataBuilder(); Location zone = locationsByUri.get().get(input.zone()); if (zone == null) { throw new IllegalStateException( String.format("zone %s not present in %s", input.zone(), locationsByUri.get().keySet())); } URI diskSource = input.disks().get(0).source(); Optional<Image> image = diskURIToImage.getUnchecked(diskSource); Hardware hardware; if (isCustomMachineTypeURI(input.machineType())) { hardware = machineTypeURIToCustomHardware(input.machineType()); } else { hardware = hardwares.get().get(input.machineType()); } builder.id(input.selfLink().toString()) .name(input.name()) .providerId(input.id()) .hostname(input.name()) .location(zone) .imageId(image.isPresent() ? image.get().selfLink().toString() : null) .hardware(hardware) .status(input.status() != null ? toPortableNodeStatus.get(input.status()) : Status.UNRECOGNIZED) .tags(input.tags().items()) .uri(input.selfLink()) .userMetadata(input.metadata().asMap()) .group(group) .privateAddresses(collectPrivateAddresses(input)) .publicAddresses(collectPublicAddresses(input)); return builder.build(); }
InstanceToNodeMetadata implements Function<Instance, NodeMetadata> { @Override public NodeMetadata apply(Instance input) { String group = groupFromMapOrName(input.metadata().asMap(), input.name(), nodeNamingConvention); NodeMetadataBuilder builder = new NodeMetadataBuilder(); Location zone = locationsByUri.get().get(input.zone()); if (zone == null) { throw new IllegalStateException( String.format("zone %s not present in %s", input.zone(), locationsByUri.get().keySet())); } URI diskSource = input.disks().get(0).source(); Optional<Image> image = diskURIToImage.getUnchecked(diskSource); Hardware hardware; if (isCustomMachineTypeURI(input.machineType())) { hardware = machineTypeURIToCustomHardware(input.machineType()); } else { hardware = hardwares.get().get(input.machineType()); } builder.id(input.selfLink().toString()) .name(input.name()) .providerId(input.id()) .hostname(input.name()) .location(zone) .imageId(image.isPresent() ? image.get().selfLink().toString() : null) .hardware(hardware) .status(input.status() != null ? toPortableNodeStatus.get(input.status()) : Status.UNRECOGNIZED) .tags(input.tags().items()) .uri(input.selfLink()) .userMetadata(input.metadata().asMap()) .group(group) .privateAddresses(collectPrivateAddresses(input)) .publicAddresses(collectPublicAddresses(input)); return builder.build(); } }
InstanceToNodeMetadata implements Function<Instance, NodeMetadata> { @Override public NodeMetadata apply(Instance input) { String group = groupFromMapOrName(input.metadata().asMap(), input.name(), nodeNamingConvention); NodeMetadataBuilder builder = new NodeMetadataBuilder(); Location zone = locationsByUri.get().get(input.zone()); if (zone == null) { throw new IllegalStateException( String.format("zone %s not present in %s", input.zone(), locationsByUri.get().keySet())); } URI diskSource = input.disks().get(0).source(); Optional<Image> image = diskURIToImage.getUnchecked(diskSource); Hardware hardware; if (isCustomMachineTypeURI(input.machineType())) { hardware = machineTypeURIToCustomHardware(input.machineType()); } else { hardware = hardwares.get().get(input.machineType()); } builder.id(input.selfLink().toString()) .name(input.name()) .providerId(input.id()) .hostname(input.name()) .location(zone) .imageId(image.isPresent() ? image.get().selfLink().toString() : null) .hardware(hardware) .status(input.status() != null ? toPortableNodeStatus.get(input.status()) : Status.UNRECOGNIZED) .tags(input.tags().items()) .uri(input.selfLink()) .userMetadata(input.metadata().asMap()) .group(group) .privateAddresses(collectPrivateAddresses(input)) .publicAddresses(collectPublicAddresses(input)); return builder.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> { @Override public NodeMetadata apply(Instance input) { String group = groupFromMapOrName(input.metadata().asMap(), input.name(), nodeNamingConvention); NodeMetadataBuilder builder = new NodeMetadataBuilder(); Location zone = locationsByUri.get().get(input.zone()); if (zone == null) { throw new IllegalStateException( String.format("zone %s not present in %s", input.zone(), locationsByUri.get().keySet())); } URI diskSource = input.disks().get(0).source(); Optional<Image> image = diskURIToImage.getUnchecked(diskSource); Hardware hardware; if (isCustomMachineTypeURI(input.machineType())) { hardware = machineTypeURIToCustomHardware(input.machineType()); } else { hardware = hardwares.get().get(input.machineType()); } builder.id(input.selfLink().toString()) .name(input.name()) .providerId(input.id()) .hostname(input.name()) .location(zone) .imageId(image.isPresent() ? image.get().selfLink().toString() : null) .hardware(hardware) .status(input.status() != null ? toPortableNodeStatus.get(input.status()) : Status.UNRECOGNIZED) .tags(input.tags().items()) .uri(input.selfLink()) .userMetadata(input.metadata().asMap()) .group(group) .privateAddresses(collectPrivateAddresses(input)) .publicAddresses(collectPublicAddresses(input)); return builder.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> { @Override public NodeMetadata apply(Instance input) { String group = groupFromMapOrName(input.metadata().asMap(), input.name(), nodeNamingConvention); NodeMetadataBuilder builder = new NodeMetadataBuilder(); Location zone = locationsByUri.get().get(input.zone()); if (zone == null) { throw new IllegalStateException( String.format("zone %s not present in %s", input.zone(), locationsByUri.get().keySet())); } URI diskSource = input.disks().get(0).source(); Optional<Image> image = diskURIToImage.getUnchecked(diskSource); Hardware hardware; if (isCustomMachineTypeURI(input.machineType())) { hardware = machineTypeURIToCustomHardware(input.machineType()); } else { hardware = hardwares.get().get(input.machineType()); } builder.id(input.selfLink().toString()) .name(input.name()) .providerId(input.id()) .hostname(input.name()) .location(zone) .imageId(image.isPresent() ? image.get().selfLink().toString() : null) .hardware(hardware) .status(input.status() != null ? toPortableNodeStatus.get(input.status()) : Status.UNRECOGNIZED) .tags(input.tags().items()) .uri(input.selfLink()) .userMetadata(input.metadata().asMap()) .group(group) .privateAddresses(collectPrivateAddresses(input)) .publicAddresses(collectPublicAddresses(input)); return builder.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);  }