From 781aa88e30e27e3a14e2f68d1d76d9d09998e2c9 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Sun, 16 Oct 2011 03:00:57 -0700 Subject: [PATCH] fixed issue where admin user wasn't applying on terremark instances --- .../compute/functions/VAppToNodeMetadata.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/functions/VAppToNodeMetadata.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/functions/VAppToNodeMetadata.java index da68753882..e4a862b9c6 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/functions/VAppToNodeMetadata.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/functions/VAppToNodeMetadata.java @@ -64,11 +64,10 @@ public class VAppToNodeMetadata implements Function { protected final ConcurrentMap credentialsMap; @Inject - protected VAppToNodeMetadata(TerremarkVCloudComputeClient computeClient, - Map credentialStore, Map vAppStatusToNodeState, - HardwareForVCloudExpressVApp hardwareForVCloudExpressVApp, - FindLocationForResource findLocationForResourceInVDC, @Memoized Supplier> images, - ConcurrentMap credentialsMap) { + protected VAppToNodeMetadata(TerremarkVCloudComputeClient computeClient, Map credentialStore, + Map vAppStatusToNodeState, HardwareForVCloudExpressVApp hardwareForVCloudExpressVApp, + FindLocationForResource findLocationForResourceInVDC, @Memoized Supplier> images, + ConcurrentMap credentialsMap) { this.images = checkNotNull(images, "images"); this.hardwareForVCloudExpressVApp = checkNotNull(hardwareForVCloudExpressVApp, "hardwareForVCloudExpressVApp"); this.findLocationForResourceInVDC = checkNotNull(findLocationForResourceInVDC, "findLocationForResourceInVDC"); @@ -89,7 +88,7 @@ public class VAppToNodeMetadata implements Function { builder.location(vdcLocation); if (from.getOsType() != null && OSType.fromValue(from.getOsType()) != OSType.UNRECOGNIZED) { builder.operatingSystem(new CIMOperatingSystem(OSType.fromValue(from.getOsType()), "", null, from - .getOperatingSystemDescription())); + .getOperatingSystemDescription())); } else if (from.getOperatingSystemDescription() != null) { OperatingSystem.Builder osBuilder = new OperatingSystem.Builder(); if (from.getOsType() != null) @@ -105,8 +104,9 @@ public class VAppToNodeMetadata implements Function { builder.publicAddresses(computeClient.getPublicAddresses(from.getHref())); builder.privateAddresses(computeClient.getPrivateAddresses(from.getHref())); String group = parseGroupFromName(from.getName()); - if (group != null) { - builder.group(group); + builder.group(group); + // node-specific credentials override those from cache based on group + if (group != null && !credentialStore.containsKey("node#" + from.getHref().toASCIIString())) { installCredentialsFromCache(from.getHref(), URI.create(vdcLocation.getParent().getId()), group, builder); } else { builder.credentials(credentialStore.get("node#" + from.getHref().toASCIIString())); @@ -122,8 +122,7 @@ public class VAppToNodeMetadata implements Function { credentialStore.put("node#" + nodeId, creds); } // this is going to need refactoring.. we really need a credential list in - // the store per - // node. + // the store per node. String adminPasswordKey = "node#" + nodeId + "#adminPassword"; if (credentialStore.containsKey(adminPasswordKey)) { builder.adminPassword(credentialStore.get(adminPasswordKey).credential);