brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aleds...@apache.org
Subject [1/2] incubator-brooklyn git commit: Put user metadata into SL notes.
Date Fri, 19 Jun 2015 21:01:56 GMT
Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master d2b47e770 -> 17baa8b7a


Put user metadata into SL notes.


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/233e0a6c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/233e0a6c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/233e0a6c

Branch: refs/heads/master
Commit: 233e0a6cb3096fbc6f139f8d273d28667593fdf3
Parents: 1a28193
Author: Svetoslav Neykov <svetoslav.neykov@cloudsoftcorp.com>
Authored: Tue Jun 9 16:01:40 2015 +0300
Committer: Svetoslav Neykov <svetoslav.neykov@cloudsoftcorp.com>
Committed: Tue Jun 16 22:45:59 2015 +0300

----------------------------------------------------------------------
 .../brooklyn/location/jclouds/JcloudsLocation.java    | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/233e0a6c/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
b/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
index e0e7990..1e04b73 100644
--- a/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
+++ b/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
@@ -207,6 +207,8 @@ public class JcloudsLocation extends AbstractCloudMachineProvisioningLocation
im
     private static final Pattern LIST_PATTERN = Pattern.compile("^\\[(.*)\\]$");
     private static final Pattern INTEGER_PATTERN = Pattern.compile("^\\d*$");
 
+    private static final int NOTES_MAX_LENGTH = 1000;
+
     private final AtomicBoolean loggedSshKeysHint = new AtomicBoolean(false);
     private final AtomicBoolean listedAvailableTemplatesOnNoSuchTemplate = new AtomicBoolean(false);
 
@@ -1214,7 +1216,7 @@ public class JcloudsLocation extends AbstractCloudMachineProvisioningLocation
im
                 // NB: things like brooklyn.local are disallowed
                 slT.domainName("local.brooklyncentral.org");
             }
-            // convert user metadata to tags because user metadata is otherwise ignored
+            // convert user metadata to tags and notes because user metadata is otherwise
ignored
             Map<String, String> md = slT.getUserMetadata();
             if (md!=null && !md.isEmpty()) {
                 Set<String> tags = MutableSet.copyOf(slT.getTags());
@@ -1222,8 +1224,16 @@ public class JcloudsLocation extends AbstractCloudMachineProvisioningLocation
im
                     tags.add(AbstractCloudMachineNamer.sanitize(entry.getKey())+":"+AbstractCloudMachineNamer.sanitize(entry.getValue()));
                 }
                 slT.tags(tags);
+
+                if (!md.containsKey("notes")) {
+                    String notes = "User Metadata\n=============\n\n  * " + Joiner.on("\n
 * ").withKeyValueSeparator(": ").join(md);
+                    if (notes.length() > NOTES_MAX_LENGTH) {
+                        String truncatedMsg = "...\n<truncated - notes total length is
" + notes.length() + " characters>";
+                        notes = notes.substring(0, NOTES_MAX_LENGTH - truncatedMsg.length())
+ truncatedMsg;
+                    }
+                    md.put("notes", notes);
+                }
             }
-            // TODO put user metadata and tags into notes, when jclouds exposes notes, because
metadata not exposed via web portal 
         }
     }
 


Mime
View raw message