From b93c039507d50ee1045b8b7d3c9ae11a3c333391 Mon Sep 17 00:00:00 2001 From: Adam Lowe Date: Fri, 16 Dec 2011 15:29:01 +0000 Subject: [PATCH] Eliminating hyphens from KeyPair 'name' fields for Terremark VcloudExpress and ECloud providers --- .../vcloud_0_8/compute/functions/CreateUniqueKeyPair.java | 2 +- .../trmk/vcloud_0_8/compute/strategy/DeleteKeyPair.java | 2 +- .../trmk/vcloud_0_8/compute/strategy/DeleteKeyPairTest.java | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/functions/CreateUniqueKeyPair.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/functions/CreateUniqueKeyPair.java index 41ab971d6e..1a09094276 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/functions/CreateUniqueKeyPair.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/functions/CreateUniqueKeyPair.java @@ -81,6 +81,6 @@ public class CreateUniqueKeyPair implements Function { } private String getNextName(String keyPairName) { - return "jclouds#" + keyPairName + "#" + randomSuffix.get(); + return "jclouds_" + keyPairName.replaceAll("-", "_") + "_" + randomSuffix.get(); } } diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/strategy/DeleteKeyPair.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/strategy/DeleteKeyPair.java index e34c4782e0..c6c9e710cf 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/strategy/DeleteKeyPair.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/strategy/DeleteKeyPair.java @@ -54,7 +54,7 @@ public class DeleteKeyPair { public void execute(OrgAndName orgTag) { for (KeyPair keyPair : terremarkClient.listKeyPairsInOrg(orgTag.getOrg())) { - if (keyPair.getName().matches("jclouds#" + orgTag.getName() + "#[0-9a-f]+")) { + if (keyPair.getName().matches("jclouds_" + orgTag.getName().replaceAll("-", "_") + "_[0-9a-f]+")) { logger.debug(">> deleting keyPair(%s)", keyPair.getName()); terremarkClient.deleteKeyPair(keyPair.getId()); // TODO: test this clear happens diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/strategy/DeleteKeyPairTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/strategy/DeleteKeyPairTest.java index 05a21e7190..dbe5836072 100644 --- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/strategy/DeleteKeyPairTest.java +++ b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/strategy/DeleteKeyPairTest.java @@ -75,7 +75,7 @@ public class DeleteKeyPairTest { // setup expectations expect(strategy.terremarkClient.listKeyPairsInOrg(orgTag.getOrg())).andReturn(ImmutableSet. of(keyPair)); - expect(keyPair.getName()).andReturn("jclouds#" + orgTag.getName() + "#123").atLeastOnce(); + expect(keyPair.getName()).andReturn("jclouds_" + orgTag.getName() + "_123").atLeastOnce(); expect(keyPair.getId()).andReturn(URI.create("1245")); strategy.terremarkClient.deleteKeyPair(URI.create("1245")); expect(strategy.credentialsMap.remove(orgTag)).andReturn(null); @@ -104,7 +104,7 @@ public class DeleteKeyPairTest { // setup expectations expect(strategy.terremarkClient.listKeyPairsInOrg(orgTag.getOrg())).andReturn(ImmutableSet. of(keyPair)); - expect(keyPair.getName()).andReturn("kclouds#" + orgTag.getName() + "-123"); + expect(keyPair.getName()).andReturn("kclouds_" + orgTag.getName() + "_123"); // replay mocks replay(keyPair);