Repo repo = repoEntry.getKey();
String repoName = repo.getName();
for (Distribution distribution : repoEntry.getValue().values()) {
Distro existingCobblerDistro = cobblerDistros.get(distribution.getLabel());
Distro desiredCobblerDistro = instantiateCobblerDistro(conn, distribution, repoName, rootUrl);
if (existingCobblerDistro != null) {
// cobbler already has a distro with the name we are looking for.
// let's make sure its data is the same, otherwise, we need to upgrade it.
// but first, we need to take it out of our map, because whatever is left in this map will be removed from Cobbler later.
cobblerDistros.remove(existingCobblerDistro.getName());
if (!compareCobblerDistros(existingCobblerDistro, desiredCobblerDistro)) {
// the one Cobbler has is old and needs to be updated with the latest data.
updateCobblerDistro(existingCobblerDistro, desiredCobblerDistro);
existingCobblerDistro.commit();
log.info("Updated existing Cobbler distro [" + distribution.getLabel() + "]");
} else {
log.debug("Cobbler already has distro [" + distribution.getLabel() + "]; keeping it");
}
} else {
desiredCobblerDistro.commit();
log.info("Added new distro to Cobbler: [" + distribution.getLabel() + "]");
}
}
}