private void saveHostMetadata(Cluster cluster, Map<String, List<String>> hostGroupMappings) {
Set<HostMetadata> hostMetadata = new HashSet<>();
for (Entry<String, List<String>> hostGroupMapping : hostGroupMappings.entrySet()) {
for (String hostName : hostGroupMapping.getValue()) {
HostMetadata hostMetadataEntry = new HostMetadata();
hostMetadataEntry.setHostName(hostName);
hostMetadataEntry.setHostGroup(hostGroupMapping.getKey());
hostMetadataEntry.setCluster(cluster);
hostMetadata.add(hostMetadataEntry);
}
}
cluster.setHostMetadata(hostMetadata);
clusterRepository.save(cluster);