You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cloudstack.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2015/12/04 06:19:10 UTC

[jira] [Commented] (CLOUDSTACK-9095) Hypervisor changes to support UserData for Nuage VSP

    [ https://issues.apache.org/jira/browse/CLOUDSTACK-9095?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15039765#comment-15039765 ] 

ASF GitHub Bot commented on CLOUDSTACK-9095:
--------------------------------------------

Github user jburwell commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1142#discussion_r46650119
  
    --- Diff: plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java ---
    @@ -1276,6 +1277,53 @@ public String toString() {
             }
         }
     
    +    public static class MetadataDef {
    +        Map<String, Object> customNodes = new HashMap<>();
    +
    +        public <T> T getMetadataNode(Class<T> fieldClass) {
    +            T field = (T) customNodes.get(fieldClass.getName());
    +            if (field == null) {
    +                try {
    +                    field = fieldClass.newInstance();
    +                    customNodes.put(field.getClass().getName(), field);
    +                } catch (InstantiationException e) {
    +                } catch (IllegalAccessException e) {
    +                }
    +            }
    +            return field;
    +        }
    +
    +        @Override
    +        public String toString() {
    +            StringBuilder fsBuilder = new StringBuilder();
    +            fsBuilder.append("<metadata>\n");
    +            for (Object field : customNodes.values()) {
    +                fsBuilder.append(field.toString());
    +            }
    +            fsBuilder.append("</metadata>\n");
    +            return fsBuilder.toString();
    +        }
    +    }
    +
    +    public static class NuageExtensionDef {
    +        private Map<String, String> addresses = Maps.newHashMap();
    +
    +        public void addNuageExtension(String macAddress, String vrIp) {
    +            addresses.put(macAddress, vrIp);
    +        }
    +
    +        @Override
    +        public String toString() {
    +            StringBuilder fsBuilder = new StringBuilder();
    +            for (Map.Entry<String, String> address : addresses.entrySet()) {
    +                fsBuilder.append("<nuage-extension>\n");
    +                fsBuilder.append("  <interface mac='" + address.getKey() + "' vsp-vr-ip='" + address.getValue() + "'></interface>\n");
    --- End diff --
    
    Performing string append operations when using a ``StringBuilder`` defeats purpose of the class.  Please change to the following to avoid unnecessary string re-allocation:
    ```
    fsBuilder.append("  <interface mac='")
                  .append(address.getKey() )
                  .append("' vsp-vr-ip='")
                  .append(address.getValue())
                  .append("'></interface>\n");
    ```


> Hypervisor changes to support UserData for Nuage VSP
> ----------------------------------------------------
>
>                 Key: CLOUDSTACK-9095
>                 URL: https://issues.apache.org/jira/browse/CLOUDSTACK-9095
>             Project: CloudStack
>          Issue Type: Improvement
>      Security Level: Public(Anyone can view this level - this is the default.) 
>            Reporter: Nick Livens
>            Assignee: Nick Livens
>
> Hypervisor changes to support UserData for Nuage VSP



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)