cleanupOrphanedKeysInZone(ImmutableSet.copyOf(entry.getValue()), entry.getKey());
}
}
private void cleanupOrphanedKeysInZone(Set<String> groups, String datacenterId) {
KeyApi keyApi = novaApi.getKeyApi();
for (String group : groups) {
for (Key key : Iterables.filter(keyApi.list(),
KeyPredicates.nameMatches(namingConvention.create().containsGroup(group)))) {
DatacenterAndName datacenterAndName = DatacenterAndName.fromDatacenterAndName(datacenterId, key.getName());
logger.debug(">> deleting key(%s)", datacenterAndName);
keyApi.delete(key.getName());
// TODO: test this clear happens
keyCache.invalidate(datacenterAndName);
logger.debug("<< deleted key(%s)", datacenterAndName);
}