Change in vdsm[master]: vmxml: move containerType in the metadata section

fromani at redhat.com fromani at redhat.com
Thu May 12 14:09:04 UTC 2016


Francesco Romani has uploaded a new change for review.

Change subject: vmxml: move containerType in the metadata section
......................................................................

vmxml: move containerType in the metadata section

TODO

Change-Id: I3ef9d9f4dccf139e99acbf4c4fadacc2f92d818d
Signed-off-by: Francesco Romani <fromani at redhat.com>
---
M tests/vmTests.py
M vdsm/virt/vmxml.py
2 files changed, 34 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/83/57383/1

diff --git a/tests/vmTests.py b/tests/vmTests.py
index 6e5be33..f68ca62 100644
--- a/tests/vmTests.py
+++ b/tests/vmTests.py
@@ -477,6 +477,23 @@
             self.assertXMLEqual(xml, inputXML)
 
     @permutations([
+        # custom, expected
+        [{}, set()],
+        [{'containerType': 'docker'},
+         set(('docker',))],
+    ])
+    def testMetadataContainer(self, custom, expected):
+        conf = {'custom': custom}
+        conf.update(self.conf)
+        domxml = vmxml.Domain(conf, self.log, cpuarch.X86_64)
+        uri = 'http://github.com/mojaves/convirt/1.0'
+        elem = etree.fromstring(domxml.dom.toxml())
+        found = set(e.text for e in elem.findall(
+            './metadata/{%s}container' % uri))
+        self.assertLessEqual(len(found), 1)
+        self.assertEquals(found, expected)
+
+    @permutations([
         # custom, drivemapXML
         [{}, set()],
         [{'volume:data': 'vda'},
diff --git a/vdsm/virt/vmxml.py b/vdsm/virt/vmxml.py
index 654705f..9deebb1 100644
--- a/vdsm/virt/vmxml.py
+++ b/vdsm/virt/vmxml.py
@@ -34,6 +34,9 @@
 METADATA_VM_TUNE_ELEMENT = 'qos'
 METADATA_VM_TUNE_PREFIX = 'ovirt'
 
+METADATA_CONVIRT_PREFIX = 'convirt'
+METADATA_CONVIRT_URI = 'http://github.com/mojaves/convirt/1.0'
+METADATA_CONVIRT_ELEMENT = 'container'
 
 METADATA_VM_DRIVE_MAP_URI = 'http://github.com/mojaves/convirt/drivemap/1.0'
 METADATA_VM_DRIVE_MAP_ELEMENT = 'drivemap'
@@ -253,6 +256,7 @@
 
         metadata = Element('metadata')
         self._appendMetadataQOS(metadata)
+        self._appendMetadataContainer(metadata)
         self._appendMetadataDriveMap(metadata)
         self.dom.appendChild(metadata)
 
@@ -261,6 +265,19 @@
         qos.setAttr('xmlns:' + METADATA_VM_TUNE_PREFIX, METADATA_VM_TUNE_URI)
         metadata.appendChild(qos)
 
+    def _appendMetadataContainer(self, metadata):
+        custom = self.conf.get('custom', {})
+        container_type = custom.get('containerType')
+        if not container_type:
+            return
+
+        cont = Element(METADATA_CONVIRT_PREFIX + ':' +
+                       METADATA_CONVIRT_ELEMENT,
+                       text=container_type)
+        cont.setAttr('xmlns:' + METADATA_CONVIRT_PREFIX,
+                      METADATA_CONVIRT_URI)
+        metadata.appendChild(cont)
+
     def _appendMetadataDriveMap(self, metadata):
         drive_map = find_drive_mapping(self.conf.get('custom', {}))
         if not drive_map:


-- 
To view, visit https://gerrit.ovirt.org/57383
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3ef9d9f4dccf139e99acbf4c4fadacc2f92d818d
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani at redhat.com>


More information about the vdsm-patches mailing list