jclouds-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Svet <notificati...@github.com>
Subject Re: [jclouds] [Softlayer] Implements setting and retrieving the notes property (#756)
Date Wed, 03 Jun 2015 10:01:37 GMT
> +         Map<String, String> meta = templateOptions.getUserMetadata();
> +         if (meta != null && !meta.isEmpty()) {
> +            if (meta.containsKey(USER_META_NOTES)) {
> +               return meta.get(USER_META_NOTES);
> +            } else {
> +               String notes = "User Metadata\n===========\n\n" + Joiner.on("\n").withKeyValueSeparator(":
").join(meta);
> +               if (notes.length() > SoftLayerTemplateOptions.NOTES_MAX_LENGTH) {
> +                  String suffix = "...\n<truncated>";
> +                  notes = notes.substring(0, SoftLayerTemplateOptions.NOTES_MAX_LENGTH
- suffix.length()) + suffix;
> +               }
> +               return notes;
> +            }
> +         }
> +      }
> +      return null;
> +   }

The canonical way to set the notes is through the property on the `SoftlayerTemplateOptions`.
As the user metadata is part of the generic API it might be easier for users to write provider-independent
code by setting the notes there, but don't mind removing it if you think it's too much.

Softlayer doesn't support user metadata, so the values there are ignored. The notes looked
like a good place to store this information if not overridden by an explicit value. That was
my thinking behind the various ways of getting the notes - wdyt?

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/756/files#r31609033
Mime
View raw message