@Override
  public NodeMetadata apply(ServerInZone serverInZone) {
    Location zone = locationIndex.get().get(serverInZone.getZone());
    checkState(
        zone != null,
        "location %s not in locationIndex: %s",
        serverInZone.getZone(),
        locationIndex.get());
    Server from = serverInZone.getServer();

    NodeMetadataBuilder builder = new NodeMetadataBuilder();
    builder.id(serverInZone.slashEncode());
    builder.providerId(from.getId());
    builder.name(from.getName());
    builder.hostname(from.getName());
    builder.location(
        from.getHostId() != null
            ? new LocationBuilder()
                .scope(LocationScope.HOST)
                .id(from.getHostId())
                .description(from.getHostId())
                .parent(zone)
                .build()
            : zone);
    addMetadataAndParseTagsFromCommaDelimitedValue(builder, from.getMetadata());
    builder.group(nodeNamingConvention.groupInUniqueNameOrNull(from.getName()));
    builder.imageId(
        ZoneAndId.fromZoneAndId(serverInZone.getZone(), from.getImage().getId()).slashEncode());
    builder.operatingSystem(findOperatingSystemForServerOrNull(serverInZone));
    builder.hardware(findHardwareForServerOrNull(serverInZone));
    builder.status(from.getStatus().getNodeStatus());
    builder.publicAddresses(
        filter(
            transform(
                filter(from.getAddresses().values(), Predicates.not(isPrivateAddress)),
                AddressToStringTransformationFunction.INSTANCE),
            isInet4Address));
    builder.privateAddresses(
        filter(
            transform(
                filter(from.getAddresses().values(), isPrivateAddress),
                AddressToStringTransformationFunction.INSTANCE),
            isInet4Address));

    return builder.build();
  }
 protected OperatingSystem findOperatingSystemForServerOrNull(ServerInZone serverInZone) {
   Image image =
       findObjectOfTypeForServerOrNull(
           images.get(), "image", serverInZone.getServer().getImage().getId(), serverInZone);
   return (image != null) ? image.getOperatingSystem() : null;
 }
 protected Hardware findHardwareForServerOrNull(ServerInZone serverInZone) {
   return findObjectOfTypeForServerOrNull(
       hardwares.get(), "hardware", serverInZone.getServer().getFlavor().getId(), serverInZone);
 }