[node-patches] Change in ovirt-node[master]: network: Configure NIC only if NIC given

fabiand at fedoraproject.org fabiand at fedoraproject.org
Tue Dec 11 20:09:43 UTC 2012


Fabian Deutsch has uploaded a new change for review.

Change subject: network: Configure NIC only if NIC given
......................................................................

network: Configure NIC only if NIC given

Change-Id: Iaa3c9dfdeac9b693c5f2c352ededb0117fa24bd3
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M scripts/tui/src/ovirt/node/config/defaults.py
M scripts/tui/src/ovirt/node/setup/network_page.py
2 files changed, 16 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/72/9972/1

diff --git a/scripts/tui/src/ovirt/node/config/defaults.py b/scripts/tui/src/ovirt/node/config/defaults.py
index 5e90eae..37e2c8b 100644
--- a/scripts/tui/src/ovirt/node/config/defaults.py
+++ b/scripts/tui/src/ovirt/node/config/defaults.py
@@ -121,7 +121,7 @@
         contents = []
         # Sort the dict, looks nicer
         for key in sorted(cfg.iterkeys()):
-            contents.append("%s='%s'" % (key, cfg[key]))
+            contents.append("%s=%s" % (key, cfg[key]))
         with open(self.filename, "w+") as dst:
             dst.write("\n".join(contents))
 
@@ -283,8 +283,8 @@
     keys = ("OVIRT_BOOTIF",
             "OVIRT_BOOTPROTO",
             "OVIRT_IP_ADDRESS",
-            "OVIRT_NETMASK",
-            "OVIRT_GATEWAY",
+            "OVIRT_IP_NETMASK",
+            "OVIRT_IP_GATEWAY",
             "OVIRT_VLAN")
 
     @NodeConfigFileSection.map_and_update_defaults_decorator
@@ -303,6 +303,8 @@
         FIXME this should be rewritten o allow more fine grained progress
         informations
         """
+        iface = self.retrieve()["iface"]
+
         class ConfigureNIC(utils.Transaction.Element):
             title = "Configuring NIC"
 
@@ -312,8 +314,10 @@
             def commit(self):
                 from ovirtnode.network import Network as oNetwork
                 net = oNetwork()
-                net.configure_interface()
+                if iface:
+                    net.configure_interface()
                 net.save_network_configuration()
+                utils.AugeasWrapper.force_reload()
 
         tx = utils.Transaction("Saving network configuration")
         tx.append(ConfigureNIC())
diff --git a/scripts/tui/src/ovirt/node/setup/network_page.py b/scripts/tui/src/ovirt/node/setup/network_page.py
index eedbb88..2460a45 100644
--- a/scripts/tui/src/ovirt/node/setup/network_page.py
+++ b/scripts/tui/src/ovirt/node/setup/network_page.py
@@ -74,9 +74,8 @@
         return self._model
 
     def validators(self):
-        Empty = ovirt.node.valid.Empty
-        ip_or_empty = valid.IPAddress() | Empty()
-        fqdn_ip_or_empty = valid.FQDNOrIPAddress() | Empty()
+        ip_or_empty = valid.IPAddress() | valid.Empty()
+        fqdn_ip_or_empty = valid.FQDNOrIPAddress() | valid.Empty()
 
         return {
                 "hostname": valid.FQDNOrIPAddress(),
@@ -85,10 +84,11 @@
                 "ntp[0]": valid.FQDNOrIPAddress(),
                 "ntp[1]": fqdn_ip_or_empty,
 
-                "dialog.nic.ipv4.address": valid.IPv4Address(),
-                "dialog.nic.ipv4.netmask": valid.IPv4Address(),
-                "dialog.nic.ipv4.gateway": valid.IPv4Address(),
-                "dialog.nic.vlanid": valid.Number(range=[0, 4096]),
+                "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.vlanid": (valid.Number(range=[0, 4096]) |
+                                      valid.Empty()),
             }
 
     def ui_content(self):
@@ -318,6 +318,7 @@
         d.close()
 
     def _configure_nic(self, bootproto, ipaddr, netmask, gateway, vlanid):
+        vlanid = vlanid or None
         model = defaults.Network()
         iface = self._model["dialog.nic.iface"]
         if bootproto == "none":


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaa3c9dfdeac9b693c5f2c352ededb0117fa24bd3
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