[node-patches] Change in ovirt-node[master]: add ipv6 menus

jboggs at redhat.com jboggs at redhat.com
Fri May 10 17:21:14 UTC 2013


Joey Boggs has uploaded a new change for review.

Change subject: add ipv6 menus
......................................................................

add ipv6 menus

Signed-off-by: Joey Boggs <jboggs at redhat.com>
Change-Id: If442d6e8289713c2e392c6e5253df56e64db02f8
---
M src/ovirt/node/config/defaults.py
M src/ovirt/node/setup/network_page.py
2 files changed, 114 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/56/14656/1

diff --git a/src/ovirt/node/config/defaults.py b/src/ovirt/node/config/defaults.py
index 048c03a..b2bb561 100644
--- a/src/ovirt/node/config/defaults.py
+++ b/src/ovirt/node/config/defaults.py
@@ -293,6 +293,7 @@
     - OVIRT_IP_ADDRESS, OVIRT_IP_NETMASK, OVIRT_IP_GATEWAY
     - OVIRT_VLAN
     - OVIRT_IPV6
+    - OVIRT_IPV6_ADDRESS, OVIRT_IPV6_NETMASK, OVIRT_IPV6_GATEWAY
 
     >>> fn = "/tmp/cfg_dummy"
     >>> cfgfile = ConfigFile(fn, SimpleProvider)
@@ -317,11 +318,17 @@
             "OVIRT_IP_ADDRESS",
             "OVIRT_IP_NETMASK",
             "OVIRT_IP_GATEWAY",
-            "OVIRT_VLAN")
+            "OVIRT_VLAN",
+            "OVIRT_IPV6",
+            "OVIRT_IPV6_ADDRESS",
+            "OVIRT_IPV6_NETMASK",
+            "OVIRT_IPV6_GATEWAY"
+          )
 
     @NodeConfigFileSection.map_and_update_defaults_decorator
     def update(self, iface, bootproto, ipaddr=None, netmask=None, gateway=None,
-               vlanid=None):
+               vlanid=None, ipv6=None, ipv6_address=None, ipv6_netmask=None,
+               ipv6_gateway=None):
         if bootproto not in ["static", "none", "dhcp", None]:
             raise exceptions.InvalidData("Unknown bootprotocol: %s" %
                                          bootproto)
@@ -366,17 +373,40 @@
         """
         iface = iface or self.retrieve()["iface"]
         name = iface + "-DISABLED"
-        self.update(name, None, None, None, None, None)
+        self.update(name, None, None, None, None, None, None, None, None, None)
 
     def configure_dhcp(self, iface, vlanid=None):
         """Can be used to configure NIC iface on the vlan vlanid with DHCP
         """
-        self.update(iface, "dhcp", None, None, None, vlanid)
+        self.update(iface, "dhcp", None, None, None, vlanid, None, None, None, None)
 
     def configure_static(self, iface, ipaddr, netmask, gateway, vlanid):
         """Can be used to configure a static IP on a NIC
         """
-        self.update(iface, "static", ipaddr, netmask, gateway, vlanid)
+        self.update(iface, "static", ipaddr, netmask, gateway, vlanid, None, None, None, None)
+
+    def configure_ipv6_no_networking(self, iface=None):
+        """Can be used to disable all networking
+        """
+        iface = iface or self.retrieve()["iface"]
+        name = iface + "-DISABLED"
+        self.update(name, None, None, None, None, None, None, None, None, None)
+
+    def configure_ipv6_dhcp(self, iface, vlanid=None):
+        """Can be used to configure NIC iface on the vlan vlanid with DHCP
+        """
+        self.update(iface, None, None, None, None, vlanid, "dhcp", None, None, None)
+
+    def configure_ipv6_static(self, iface, ipv6_address, ipv6_netmask, ipv6_gateway, vlanid):
+        """Can be used to configure a static IPv6 IP on a NIC
+        """
+        self.update(iface, None, None, None, None, vlanid, "static", ipv6_address, ipv6_netmask, ipv6_gateway)
+
+    def configure_ipv6_auto(self, iface, vlanid):
+        """Can be used to autoconfigure IPv6 on a NIC
+        """
+        self.update(iface, None, None, None, None, vlanid, "auto", None, None, None)
+
 
 
 class Hostname(NodeConfigFileSection):
diff --git a/src/ovirt/node/setup/network_page.py b/src/ovirt/node/setup/network_page.py
index 834797b..9afbe93 100644
--- a/src/ovirt/node/setup/network_page.py
+++ b/src/ovirt/node/setup/network_page.py
@@ -43,6 +43,8 @@
         self._nic_details_group = self.widgets.group([
             "dialog.nic.ipv4.bootproto", "dialog.nic.ipv4.address",
             "dialog.nic.ipv4.netmask", "dialog.nic.ipv4.gateway",
+            "dialog.nic.ipv6.bootproto", "dialog.nic.ipv6.address",
+            "dialog.nic.ipv6.netmask", "dialog.nic.ipv6.gateway",
             "dialog.nic.vlanid"])
 
     def name(self):
@@ -91,6 +93,9 @@
                 "dialog.nic.ipv4.address": valid.IPv4Address() | valid.Empty(),
                 "dialog.nic.ipv4.netmask": valid.IPv4Address() | valid.Empty(),
                 "dialog.nic.ipv4.gateway": valid.IPv4Address() | valid.Empty(),
+                "dialog.nic.ipv6.address": valid.IPv6Address() | valid.Empty(),
+                "dialog.nic.ipv6.netmask": valid.IPv6Address() | valid.Empty(),
+                "dialog.nic.ipv6.gateway": valid.IPv6Address() | valid.Empty(),
                 "dialog.nic.vlanid": (valid.Number(bounds=[0, 4096]) |
                                       valid.Empty()),
                 }
@@ -143,16 +148,42 @@
     def on_change(self, changes):
         self.logger.info("Checking network stuff")
         helper = plugins.Changeset(changes)
-        bootproto = helper["dialog.nic.ipv4.bootproto"]
-        if bootproto:
-            if bootproto in ["static"]:
-                self._nic_details_group.enabled(True)
-            elif bootproto in ["dhcp"]:
-                self._nic_details_group.enabled(False)
-                self.widgets["dialog.nic.vlanid"].enabled(True)
+        nic_ipv4_group = [ "dialog.nic.ipv4.bootproto", "dialog.nic.ipv4.address",
+            "dialog.nic.ipv4.netmask", "dialog.nic.ipv4.gateway"]
+
+        nic_ipv6_group = [ "dialog.nic.ipv6.bootproto", "dialog.nic.ipv6.address",
+            "dialog.nic.ipv6.netmask", "dialog.nic.ipv6.gateway"]
+
+        ipv4_bootproto = helper["dialog.nic.ipv4.bootproto"]
+        if ipv4_bootproto:
+            if ipv4_bootproto in ["static"]:
+                for w in nic_ipv4_group:
+                    self.widgets[w].enabled(True)
+            elif ipv4_bootproto in ["dhcp"]:
+                for w in nic_ipv4_group:
+                    self.widgets[w].enabled(False)
+                    self.widgets["dialog.nic.vlanid"].enabled(True)
             else:
-                self._nic_details_group.enabled(False)
+                for w in nic_ipv4_group:
+                    self.widgets[w].enabled(False)
+                    self.widgets["dialog.nic.vlanid"].enabled(True)
             self.widgets["dialog.nic.ipv4.bootproto"].enabled(True)
+
+        ipv6_bootproto = helper["dialog.nic.ipv6.bootproto"]
+        if ipv6_bootproto:
+            if ipv6_bootproto in ["static"]:
+                for w in nic_ipv6_group:
+                    self.widgets[w].enabled(True)
+            elif ipv6_bootproto in ["dhcp"]:
+                for w in nic_ipv6_group:
+                    self.widgets[w].enabled(False)
+                    self.widgets["dialog.nic.vlanid"].enabled(True)
+            else:
+                for w in nic_ipv6_group:
+                    self.widgets[w].enabled(False)
+                    self.widgets["dialog.nic.vlanid"].enabled(True)
+            self.widgets["dialog.nic.ipv6.bootproto"].enabled(True)
+
 
     def on_merge(self, effective_changes):
         self.logger.info("Saving network stuff")
@@ -237,7 +268,7 @@
         # Behaves like a page reload
         return self.ui_content()
 
-    def _configure_nic(self, bootproto, ipaddr, netmask, gateway, vlanid):
+    def _configure_nic(self, bootproto, ipaddr, netmask, gateway, ipv6_bootproto, ipv6_address, ipv6_netmask, ipv6_gateway, vlanid):
         vlanid = vlanid or None
         model = defaults.Network()
         iface = self._model_extra["dialog.nic.iface"]
@@ -251,7 +282,28 @@
             self.logger.debug("Configuring static ip")
             model.configure_static(iface, ipaddr, netmask, gateway, vlanid)
         else:
-            self.logger.debug("No interface configuration found")
+            self.logger.debug("No ipv4 interface configuration found")
+
+        if ipv6_bootproto == "none":
+            self.logger.debug("Configuring no ipv6 networking")
+            model.configure_ipv6_no_networking(iface)
+
+        elif ipv6_bootproto == "dhcp":
+            self.logger.debug("Configuring ipv6 dhcp")
+            model.configure_ipv6_dhcp(iface, vlanid)
+
+        elif ipv6_bootproto == "auto":
+            self.logger.debug("Configuring ipv6 auto")
+            model.configure_ipv6_auto(iface, vlanid)
+
+        elif ipv6_bootproto == "static":
+            self.logger.debug("Configuring ipv6 static ip")
+            model.configure_ipv6_static(iface, ipv6_address, ipv6_netmask, ipv6_gateway, vlanid)
+        else:
+            self.logger.debug("No ipv6 interface configuration found")
+
+
+
         # Return the resulting transaction
         return model.transaction()
 
@@ -309,6 +361,10 @@
             "dialog.nic.ipv4.address": ipaddr,
             "dialog.nic.ipv4.netmask": netmask,
             "dialog.nic.ipv4.gateway": gateway,
+            "dialog.nic.ipv6.bootproto": cfg["bootproto"],
+            "dialog.nic.ipv6.address": ipaddr,
+            "dialog.nic.ipv6.netmask": netmask,
+            "dialog.nic.ipv6.gateway": gateway,
             "dialog.nic.vlanid": vlanid,
         })
 
@@ -345,10 +401,22 @@
               ui.Entry("dialog.nic.ipv4.gateway", padd("Gateway: ")),
 
               ui.Divider("dialog.nic._divider[1]"),
+              ui.Header("dialog.nic.ipv46._header", "IPv6 Settings"),
+              ui.Options("dialog.nic.ipv6.bootproto",
+                         "Bootprotocol: ", [("none", "Disabled"),
+                                            ("auto", "Auto"),
+                                            ("dhcp", "DHCP"),
+                                            ("static", "Static")
+                                            ]),
+
+              ui.Entry("dialog.nic.ipv6.address", padd("IP Address: ")),
+              ui.Entry("dialog.nic.ipv6.netmask", padd("Netmask: ")),
+              ui.Entry("dialog.nic.ipv6.gateway", padd("Gateway: ")),
+              ui.Divider("dialog.nic._divider[2]"),
 
               ui.Entry("dialog.nic.vlanid", padd("VLAN ID: ")),
 
-              ui.Divider("dialog.nic._divider[2]"),
+              ui.Divider("dialog.nic._divider[3]"),
               ui.Button("dialog.nic.identify", "Flash Lights to Identify")
               ]
         self.plugin.widgets.add(ws)


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If442d6e8289713c2e392c6e5253df56e64db02f8
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Joey Boggs <jboggs at redhat.com>



More information about the node-patches mailing list