private void cleanupAutoGeneratedKeyPair(String keyPairName) { logger.debug(">> cleaning up auto-generated key pairs..."); try { novaApi.getKeyPairApi(region).get().delete(keyPairName); } catch (Exception ex) { logger.warn(">> could not delete key pair %s: %s", keyPairName, ex.getMessage()); } }
private void cleanupAutoGeneratedKeyPair(String keyPairName) { logger.debug(">> cleaning up auto-generated key pairs..."); try { novaApi.getKeyPairApi(region).get().delete(keyPairName); } catch (Exception ex) { logger.warn(">> could not delete key pair %s: %s", keyPairName, ex.getMessage()); } }
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); } keyPairCache.invalidate(ZoneAndName.fromZoneAndName(zoneId, namingConvention.create().sharedNameForGroup(group))); } } }
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); } keyPairCache.invalidate(ZoneAndName.fromZoneAndName(zoneId, namingConvention.create().sharedNameForGroup(group))); } } }
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); } keyPairCache.invalidate(ZoneAndName.fromZoneAndName(zoneId, namingConvention.create().sharedNameForGroup(group))); } } }
public void testCreateAndDeleteKeyPair() throws Exception { final String KEYPAIR_NAME = "testkp"; for (String zoneId : api.getConfiguredZones()) { KeyPairApi keyPairApi = api.getKeyPairExtensionForZone(zoneId).get(); KeyPair keyPair = null; try { keyPair = keyPairApi.create(KEYPAIR_NAME); assertNotNull(keyPair); } finally { if (keyPair != null) { keyPairApi.delete(KEYPAIR_NAME); } } } }
public void testCreateAndDeleteKeyPairWithPublicKey() throws Exception { final String KEYPAIR_NAME = "testkp"; final String PUBLIC_KEY = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCrrBREFxz3002l1HuXz0+UOdJQ/mOYD5DiJwwB/TOybwIKQJPOxJWA9gBoo4k9dthTKBTaEYbzrll7iZcp59E80S6mNiAr3mUgi+x5Y8uyXeJ2Ws+h6peVyFVUu9epkwpcTd1GVfdcVWsTajwDz9+lxCDhl0RZKDFoT0scTxbj/w== nova@nv-aw2az2-api0002"; for (String zoneId : api.getConfiguredZones()) { KeyPairApi keyPairApi = api.getKeyPairExtensionForZone(zoneId).get(); KeyPair keyPair = null; try { keyPair = keyPairApi.createWithPublicKey(KEYPAIR_NAME, PUBLIC_KEY); assertNotNull(keyPair); } finally { if (keyPair != null) { keyPairApi.delete(KEYPAIR_NAME); } } } } }
public void testCreateAndDeleteKeyPairWithPublicKey() throws Exception { for (String regionId : api.getConfiguredRegions()) { KeyPairApi keyPairApi = api.getKeyPairApi(regionId).get(); KeyPair createdKeyPair = null; try { createdKeyPair = keyPairApi.createWithPublicKey(KEYPAIR_NAME, PUBLIC_KEY); assertNotNull(createdKeyPair); KeyPair keyPair = keyPairApi.get(KEYPAIR_NAME); assertEquals(keyPair.getName(), createdKeyPair.getName()); assertEquals(keyPair.getFingerprint(), createdKeyPair.getFingerprint()); assertEquals(keyPair.getPublicKey(), createdKeyPair.getPublicKey()); } finally { if (createdKeyPair != null) { keyPairApi.delete(KEYPAIR_NAME); } } } } }
public void testCreateAndGetAndDeleteKeyPair() throws Exception { for (String regionId : api.getConfiguredRegions()) { KeyPairApi keyPairApi = api.getKeyPairApi(regionId).get(); KeyPair createdKeyPair = null; try { createdKeyPair = keyPairApi.create(KEYPAIR_NAME); assertNotNull(createdKeyPair); KeyPair keyPair = keyPairApi.get(KEYPAIR_NAME); assertEquals(keyPair.getName(), createdKeyPair.getName()); assertEquals(keyPair.getFingerprint(), createdKeyPair.getFingerprint()); assertEquals(keyPair.getPublicKey(), createdKeyPair.getPublicKey()); } finally { if (createdKeyPair != null) { keyPairApi.delete(KEYPAIR_NAME); } } } }
public void testDeleteKeyPair() throws Exception { HttpRequest delete = HttpRequest .builder() .method("DELETE") .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-keypairs/testkeypair") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken).build(); HttpResponse deleteResponse = HttpResponse.builder().statusCode(202).build(); NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, delete, deleteResponse); assertTrue(apiWhenServersExist.getKeyPairApi("az-1.region-a.geo-1").get().delete("testkeypair")); }
public void testDeleteKeyPair() throws Exception { HttpRequest delete = HttpRequest .builder() .method("DELETE") .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-keypairs/testkeypair") .addHeader("Accept", "*/*") .addHeader("X-Auth-Token", authToken).build(); HttpResponse deleteResponse = HttpResponse.builder().statusCode(202).build(); NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, delete, deleteResponse); assertTrue(apiWhenServersExist.getKeyPairExtensionForZone("az-1.region-a.geo-1").get().delete("testkeypair")); } }
RegionAndName regionAndName = RegionAndName.fromRegionAndName(regionAndId.getRegion(), server.getKeyName()); logger.debug(">> deleting keypair(%s)", regionAndName); novaApi.getKeyPairApi(regionAndId.getRegion()).get().delete(server.getKeyName());