[node-patches] Change in ovirt-node[master]: defaults: Add IPv6 class

fabiand at fedoraproject.org fabiand at fedoraproject.org
Fri May 10 17:23:56 UTC 2013


Fabian Deutsch has uploaded a new change for review.

Change subject: defaults: Add IPv6 class
......................................................................

defaults: Add IPv6 class

A class is added to handle IPv6 related configuration keys.

Change-Id: I7f21e914ad1ccd1e0d9c49cf67ae1e87aa094274
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M src/ovirt/node/config/defaults.py
1 file changed, 50 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/58/14658/1

diff --git a/src/ovirt/node/config/defaults.py b/src/ovirt/node/config/defaults.py
index 1894fc0..904f895 100644
--- a/src/ovirt/node/config/defaults.py
+++ b/src/ovirt/node/config/defaults.py
@@ -294,7 +294,6 @@
     - OVIRT_BOOTIF
     - OVIRT_IP_ADDRESS, OVIRT_IP_NETMASK, OVIRT_IP_GATEWAY
     - OVIRT_VLAN
-    - OVIRT_IPV6
 
     >>> fn = "/tmp/cfg_dummy"
     >>> cfgfile = ConfigFile(fn, SimpleProvider)
@@ -381,6 +380,56 @@
         self.update(iface, "static", ipaddr, netmask, gateway, vlanid)
 
 
+class IPv6(NodeConfigFileSection):
+    """Sets IPv6 network stuff
+    - OVIRT_IPV6_*
+
+    >>> fn = "/tmp/cfg_dummy"
+    >>> cfgfile = ConfigFile(fn, SimpleProvider)
+    >>> n = IPv6(cfgfile)
+    >>> n.update(True, "11::22", "11::33", "11::44")
+    >>> data = sorted(n.retrieve().items())
+    >>> data[0:3]
+    [('enabled', True), ('gateway', '11::44'), ('ipaddr', '11::22')]
+    >>> data[3:]
+    [('netmask', '11::33')]
+    """
+    keys = ("OVIRT_IPV6",
+            "OVIRT_IPV6_ADDRESS",
+            "OVIRT_IPV6_NETMASK",
+            "OVIRT_IPV6_GATEWAY")
+
+    @NodeConfigFileSection.map_and_update_defaults_decorator
+    def update(self, enabled, ipaddr, netmask, gateway):
+        (valid.Boolean() | valid.Empty(or_none=True))(enabled)
+        (valid.IPv6Address() | valid.Empty(or_none=True))(ipaddr)
+        (valid.IPv6Address() | valid.Empty(or_none=True))(netmask)
+        (valid.IPv6Address() | valid.Empty(or_none=True))(gateway)
+        return {"OVIRT_IPV6": "yes" if enabled else None}
+
+    def retrieve(self):
+        cfg = dict(NodeConfigFileSection.retrieve(self))
+        cfg.update({"enabled": cfg["enabled"] == "yes"})
+        return cfg
+
+    def transaction(self):
+        return self.__legacy_transaction()
+
+    def __legacy_transaction(self):
+        """The transaction is the same as in the Network class - using the
+        legacy stuff.
+        This should be rewritten to allow a more fine grained progress
+        monitoring.
+        """
+        tx = Network().transaction()
+        return tx
+
+    def disable(self):
+        """Can be used to disable IPv6
+        """
+        self.update(None, None, None, None, None)
+
+
 class Hostname(NodeConfigFileSection):
     """Configure hostname
     >>> fn = "/tmp/cfg_dummy"


--
To view, visit http://gerrit.ovirt.org/14658
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7f21e914ad1ccd1e0d9c49cf67ae1e87aa094274
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Fabian Deutsch <fabiand at fedoraproject.org>



More information about the node-patches mailing list