use of cz.metacentrum.perun.audit.events.FacilityManagerEvents.HostAddedToFacility in project perun by CESNET.
the class FacilitiesManagerBlImpl method addHosts.
@Override
public List<Host> addHosts(PerunSession sess, List<Host> hosts, Facility facility) throws HostExistsException {
// check if hosts not exist in cluster
List<Host> alreadyAssignedHosts = getHosts(sess, facility);
Set<String> alreadyAssignedHostnames = new HashSet<>();
Set<String> newHostnames = new HashSet<>();
for (Host h : alreadyAssignedHosts) alreadyAssignedHostnames.add(h.getHostname());
for (Host h : hosts) newHostnames.add(h.getHostname());
newHostnames.retainAll(alreadyAssignedHostnames);
if (!newHostnames.isEmpty())
throw new HostExistsException(newHostnames.toString());
for (Host host : hosts) {
getFacilitiesManagerImpl().addHost(sess, host, facility);
getPerunBl().getAuditer().log(sess, new HostAddedToFacility(host, facility));
}
return hosts;
}
Aggregations