private void cleanupOrphanedKeyPairsInZone(Set<String> groups, String zoneId) {
Optional<? extends KeyPairApi> keyPairApi = novaApi.getKeyPairExtensionForZone(zoneId);
if (keyPairApi.isPresent()) {
for (String group : groups) {
for (KeyPair pair : keyPairApi.get().list().filter(nameMatches(namingConvention.create().containsGroup(group)))) {
ZoneAndName zoneAndName = ZoneAndName.fromZoneAndName(zoneId, pair.getName());
logger.debug(">> deleting keypair(%s)", zoneAndName);
keyPairApi.get().delete(pair.getName());
// TODO: test this clear happens
keyPairCache.invalidate(zoneAndName);
logger.debug("<< deleted keypair(%s)", zoneAndName);