@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(toPortableNodeStatus.get(from.getStatus()));
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));
for (Link link: from.getLinks()) {
if (link.getRelation().equals(Link.Relation.SELF)) {
builder.uri(link.getHref());
}
}