Location zone = locationIndex.get().get(machineInDatacenter.getDatacenter());
checkState(zone != null, "location %s not in locationIndex: %s", machineInDatacenter.getDatacenter(),
locationIndex.get());
Machine from = machineInDatacenter.get();
NodeMetadataBuilder builder = new NodeMetadataBuilder();
builder.id(machineInDatacenter.slashEncode());
builder.providerId(from.getId());
builder.name(from.getName());
builder.hostname(from.getId());
builder.location(zone);
addMetadataAndParseTagsFromCommaDelimitedValue(builder, filterKeys(from.getMetadata(), new Predicate<String>() {
@Override
public boolean apply(String input) {
// TODO make this more efficient
for (Metadata key : Metadata.values())
if (key.key().equals(input))
return false;
return true;
}
}));
builder.group(nodeNamingConvention.groupInUniqueNameOrNull(from.getName()));
builder.imageId(DatacenterAndName.fromDatacenterAndName(machineInDatacenter.getDatacenter(), from.getDatasetURN())
.slashEncode());
builder.operatingSystem(findOperatingSystemForMachineOrNull(machineInDatacenter));
builder.hardware(findHardwareForMachineOrNull(machineInDatacenter));
builder.status(toPortableNodeStatus.get(from.getState()));
builder.publicAddresses(filter(from.getIps(), not(InetAddresses2.IsPrivateIPAddress.INSTANCE)));
builder.privateAddresses(filter(from.getIps(), InetAddresses2.IsPrivateIPAddress.INSTANCE));
return builder.build();
}