rhtyd closed pull request #2441: CLOUDSTACK-10261: Libvirt metadata: only 
create one nuage-extension tag
URL: https://github.com/apache/cloudstack/pull/2441
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java
 
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java
index 385fe79ef2a..90674eb99a8 100644
--- 
a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java
+++ 
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java
@@ -1543,16 +1543,15 @@ public void addNuageExtension(String macAddress, String 
vrIp) {
         @Override
         public String toString() {
             StringBuilder fsBuilder = new StringBuilder();
+            fsBuilder.append("<nuage-extension 
xmlns='nuagenetworks.net/nuage/cna'>\n");
             for (Map.Entry<String, String> address : addresses.entrySet()) {
-                fsBuilder.append("<nuage-extension 
xmlns='nuagenetworks.net/nuage/cna'>\n")
-                        .append("  <interface mac='")
-                        .append(address.getKey())
-                        .append("' vsp-vr-ip='")
-                        .append(address.getValue())
-                        .append("'></interface>\n")
-                        .append("</nuage-extension>\n");
+                fsBuilder.append("  <interface mac='")
+                         .append(address.getKey())
+                         .append("' vsp-vr-ip='")
+                         .append(address.getValue())
+                         .append("'></interface>\n");
             }
-            return fsBuilder.toString();
+            return fsBuilder.append("</nuage-extension>\n").toString();
         }
     }
 
diff --git 
a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtVMDefTest.java
 
b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtVMDefTest.java
index 006562c213e..b391b94e740 100644
--- 
a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtVMDefTest.java
+++ 
b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtVMDefTest.java
@@ -209,4 +209,21 @@ public void testSCSIDef() {
         assertEquals(str, expected);
     }
 
+    public void testMetadataDef() {
+        LibvirtVMDef.MetadataDef metadataDef = new LibvirtVMDef.MetadataDef();
+
+        
metadataDef.getMetadataNode(LibvirtVMDef.NuageExtensionDef.class).addNuageExtension("mac1",
 "ip1");
+        
metadataDef.getMetadataNode(LibvirtVMDef.NuageExtensionDef.class).addNuageExtension("mac2",
 "ip2");
+
+        String xmlDef = metadataDef.toString();
+        String expectedXml = "<metadata>\n" +
+                "<nuage-extension xmlns='nuagenetworks.net/nuage/cna'>\n" +
+                "  <interface mac='mac2' vsp-vr-ip='ip2'></interface>\n" +
+                "  <interface mac='mac1' vsp-vr-ip='ip1'></interface>\n" +
+                "</nuage-extension>\n" +
+                "</metadata>\n";
+
+        assertEquals(xmlDef, expectedXml);
+    }
+
 }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to