[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [virt-tools-list] [RFC 1 of2] adding 802.1Qbg VSI type support to virtinst and virtmanager



On Wed, 2011-03-09 at 14:32 -0500, Cole Robinson wrote:
> An example:
> 
>         check = self._make_checker(dev3)
>         check("type", "bridge")
> 
> This call is checking that dev3.type == "bridge"
> 
>         check("bridge", "foobr0", "newfoo0")
> 
> This call is checking that dev3.bridge == "foobr0". It is then doing

thanks .. that was very helpful

..

> You will want to do to make sure that virtinst is correctly parsing
> and
> setting every new property, ex:

done


..
> You can start with this:

again very helpful

please see new patch
> 
> Also, might as well add a property for /virtualport/@mode as well,
> even if
> changing it isn't a priority

assuming, you mean virtualport/@type: done

-- 
Best regards, 

Gerhard Stenzel, 
-----------------------------------------------------------------------------------------------------------------------------------
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
The following patch adds support for VSI type XML elements
to virt-inst, so the respective value can be viewed and edited 
via virt-manager

Signed-off-by: Gerhard Stenzel <gerhard stenzel de ibm com>

Index: python-virtinst/tests/xmlparse-xml/change-nics-in.xml
===================================================================
--- python-virtinst.orig/tests/xmlparse-xml/change-nics-in.xml
+++ python-virtinst/tests/xmlparse-xml/change-nics-in.xml
@@ -36,6 +36,14 @@
       <script path="/etc/qemu-ifup"/>
       <target dev="nic02"/>
     </interface>
+    <interface type="direct">
+      <mac address="00:11:22:33:44:55"/>
+      <source dev="eth0.1" mode="vepa"/>
+      <virtualport type="802.1Qbg">
+        <parameters managerid="12" typeid="1193046" typeidversion="1" instanceid="09b11c53-8b5c-4eeb-8f00-d84eaa0aaa3b"/>
+      </virtualport>
+      <address type="pci" domain="0x0000" bus="0x00" slot="0x07" function="0x0"/>
+    </interface>
     <input type="mouse" bus="ps2"/>
     <graphics type="sdl" display=":3.4" xauth="/tmp/.Xauthority"/>
     <console type="pty"/>
Index: python-virtinst/tests/xmlparse-xml/change-nics-out.xml
===================================================================
--- python-virtinst.orig/tests/xmlparse-xml/change-nics-out.xml
+++ python-virtinst/tests/xmlparse-xml/change-nics-out.xml
@@ -38,6 +38,14 @@
       <source dev="eth1"/>
       <script path="/etc/qemu-ifup"/>
     </interface>
+    <interface type="direct">
+      <mac address="00:11:22:33:44:55"/>
+      <source dev="eth0.1" mode="vepa"/>
+      <virtualport type="802.1Qbg">
+        <parameters managerid="11" typeid="1193047" typeidversion="2" instanceid="09b11c53-8b5c-4eeb-8f00-d84eaa0aaa4f"/>
+      </virtualport>
+      <address type="pci" domain="0x0000" bus="0x00" slot="0x07" function="0x0"/>
+    </interface>
     <input type="mouse" bus="ps2"/>
     <graphics type="sdl" display=":3.4" xauth="/tmp/.Xauthority"/>
     <console type="pty"/>
Index: python-virtinst/tests/xmlparse.py
===================================================================
--- python-virtinst.orig/tests/xmlparse.py
+++ python-virtinst/tests/xmlparse.py
@@ -362,6 +362,7 @@ class XMLParseTest(unittest.TestCase):
         dev2 = guest.get_devices("interface")[1]
         dev3 = guest.get_devices("interface")[2]
         dev4 = guest.get_devices("interface")[3]
+        dev5 = guest.get_devices("interface")[4]
 
         check = self._make_checker(dev1)
         check("type", "user")
@@ -393,6 +394,18 @@ class XMLParseTest(unittest.TestCase):
         check("target_dev", "nic03", None)
         self.assertEquals(dev4.get_source(), "eth1")
 
+        check = self._make_checker(dev5)
+        check("type", "direct")
+        check("source_dev", "eth0.1")
+
+        virtualport = dev5._get_virtualport()
+        check = self._make_checker(virtualport)
+        check("type", "802.1Qbg")
+        check("managerid", "12", "11")
+        check("typeid", "1193046", "1193047")
+        check("typeidversion", "1", "2")
+        check("instanceid", "09b11c53-8b5c-4eeb-8f00-d84eaa0aaa3b", "09b11c53-8b5c-4eeb-8f00-d84eaa0aaa4f")
+
         self._alter_compare(guest.get_config_xml(), outfile)
 
     def testAlterInputs(self):
Index: python-virtinst/virtinst/VirtualNetworkInterface.py
===================================================================
--- python-virtinst.orig/virtinst/VirtualNetworkInterface.py
+++ python-virtinst/virtinst/VirtualNetworkInterface.py
@@ -22,6 +22,7 @@ import libvirt
 
 import _util
 import VirtualDevice
+import XMLBuilderDomain
 from XMLBuilderDomain import _xml_property
 from virtinst import _virtinst as _
 
@@ -44,6 +45,52 @@ def _countMACaddr(vms, searchmac):
         count += _util.get_xml_path(xml, func=count_cb)
     return count
 
+class VirtualPort(XMLBuilderDomain.XMLBuilderDomain):
+
+    def __init__(self, conn, parsexml=None, parsexmlnode=None, caps=None):
+        XMLBuilderDomain.XMLBuilderDomain.__init__(self, conn, parsexml,
+                                                   parsexmlnode, caps=caps)
+        self._type = None
+        self._managerid = None
+        self._typeid = None
+        self._typeidversion = None
+        self._instanceid = None
+
+    def get_type(self):
+        return self._type
+    def set_type(self, val):
+        self._type = val
+    type = _xml_property(get_type, set_type,
+                                  xpath="./virtualport/@type")
+
+    def get_managerid(self):
+        return self._managerid
+    def set_managerid(self, val):
+        self._managerid = val
+    managerid = _xml_property(get_managerid, set_managerid,
+                                  xpath="./virtualport/parameters/@managerid")
+
+    def get_typeid(self):
+        return self._typeid
+    def set_typeid(self, val):
+        self._typeid = val
+    typeid = _xml_property(get_typeid, set_typeid,
+                               xpath="./virtualport/parameters/@typeid")
+
+    def get_typeidversion(self):
+        return self._typeidversion
+    def set_typeidversion(self, val):
+        self._typeidversion = val
+    typeidversion = _xml_property(get_typeidversion, set_typeidversion,
+                               xpath="./virtualport/parameters/@typeidversion")
+
+    def get_instanceid(self):
+        return self._instanceid
+    def set_instanceid(self, val):
+        self._instanceid = val
+    instanceid = _xml_property(get_instanceid, set_instanceid,
+                               xpath="./virtualport/parameters/@instanceid")
+
 class VirtualNetworkInterface(VirtualDevice.VirtualDevice):
 
     _virtual_device_type = VirtualDevice.VirtualDevice.VIRTUAL_DEV_NET
@@ -83,6 +130,7 @@ class VirtualNetworkInterface(VirtualDev
         self._model = None
         self._target_dev = None
         self._source_dev = None
+        self._virtualport = VirtualPort(conn, parsexml, parsexmlnode, caps)
 
         # Generate _random_mac
         self._random_mac = None
@@ -136,6 +184,10 @@ class VirtualNetworkInterface(VirtualDev
             return None
         return self.network or self.bridge or self.source_dev
 
+    def _get_virtualport(self):
+        return self._virtualport
+    virtualport = property(_get_virtualport)
+
     def get_type(self):
         return self._type
     def set_type(self, val):

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]