[node-patches] Change in ovirt-node[master]: setup: Disable network page when managed

fabiand at fedoraproject.org fabiand at fedoraproject.org
Tue Mar 4 17:17:19 UTC 2014


Fabian Deutsch has uploaded a new change for review.

Change subject: setup: Disable network page when managed
......................................................................

setup: Disable network page when managed

Previously the suer could edit the network connections even when the
system was managed.
This could lead to problems when the management instance did a network
configuration which wasn'tunderstood by the TUI.
To prevent these kind of problems the NIC details dialog is now disabled
when any NIC on the Node is managed.

Change-Id: Ia0ec61ec3c655fea0b8274519e105e4c7a74409f
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1065385
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M src/ovirt/node/config/defaults.py
M src/ovirt/node/plugins.py
M src/ovirt/node/setup/core/network_page.py
3 files changed, 40 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/51/25351/1

diff --git a/src/ovirt/node/config/defaults.py b/src/ovirt/node/config/defaults.py
index 1fc06c2..b497ea9 100644
--- a/src/ovirt/node/config/defaults.py
+++ b/src/ovirt/node/config/defaults.py
@@ -80,7 +80,7 @@
     def update(self, *args, **kwargs):
         """This function set's the correct entries in the defaults file for
         that specififc subclass.
-        Is expected to be decorated by _map_config_and_update_defaults()
+        Is expected to call _map_config_and_update_defaults()
         """
         raise NotImplementedError
 
@@ -94,13 +94,14 @@
         raise NotImplementedError
 
     def commit(self, *args, **kwargs):
-        """Shotcut to run the transaction associtated with the class
+        """This method updates the to this subclass specific configuration
+        files according to the config keys set with configure.
 
         A shortcut for:
-        tx = obj.transaction(pw="foo")
+        tx = obj.ransaction()
         tx()
         """
-        tx = self.transaction(*args, **kwargs)
+        tx = self.transaction()
         return tx()
 
     def _args_to_keys_mapping(self, keys_to_args=False):
@@ -152,9 +153,6 @@
             "Keys: %s, Args: %s" % (self.keys, kwargs)
         new_dict = dict((k.upper(), v) for k, v in kwargs.items())
         self.raw_file.update(new_dict, remove_empty=True)
-
-        # Returning self allows chaining for decorated functions
-        return self
 
     @staticmethod
     def map_and_update_defaults_decorator(func):
@@ -983,10 +981,8 @@
             def commit(self):
                 # pylint: disable-msg=E0611
                 from ovirt_config_setup import collectd  # @UnresolvedImport
-                from ovirtnode.ovirtfunctions import ovirt_store_config
                 # pylint: enable-msg=E0611
                 if collectd.write_collectd_config(server, port):
-                    ovirt_store_config("/etc/collectd.conf")
                     self.logger.debug("Collectd was configured successfully")
                 else:
                     raise exceptions.TransactionError("Failed to configure " +
@@ -1028,16 +1024,16 @@
                 }
 
     def configure_nfs(self, nfs_location):
-        self.update(nfs_location, None, None, None)
+        self.update(nfs_location, None, None)
 
-    def configure_ssh(self, ssh_location, ssh_key=None):
-        self.update(None, ssh_location, ssh_key, None)
+    def configure_ssh(self, ssh_location):
+        self.update(None, ssh_location, None)
 
     def configure_local(self):
-        self.update(None, None, None, True)
+        self.update(None, None, True)
 
     def disable_kdump(self):
-        self.update(None, None, None, None)
+        self.update(None, None, None)
 
     def retrieve(self):
         cfg = dict(NodeConfigFileSection.retrieve(self))
@@ -1583,3 +1579,9 @@
 
     def transaction(self):
         return None
+
+    def is_managed(self):
+        return True if self.retrieve()["managed_by"] else False
+
+    def has_managed_ifnames(self):
+        return True if self.retrieve()["managed_ifnames"] else False
diff --git a/src/ovirt/node/plugins.py b/src/ovirt/node/plugins.py
index 282f5b5..cb8ae6f 100644
--- a/src/ovirt/node/plugins.py
+++ b/src/ovirt/node/plugins.py
@@ -488,7 +488,7 @@
         self.add(widgets)
 
     def subset(self, paths):
-        return [self[p] for p in paths]
+        return [self[p] for p in paths if p in self]
 
     def group(self, paths):
         """Group the specified (by-path) widgets
diff --git a/src/ovirt/node/setup/core/network_page.py b/src/ovirt/node/setup/core/network_page.py
index 73fc40f..41dc830 100644
--- a/src/ovirt/node/setup/core/network_page.py
+++ b/src/ovirt/node/setup/core/network_page.py
@@ -32,6 +32,13 @@
 """
 
 
+def has_managed_ifnames():
+    """Determin if any NIC is managed
+    """
+    mgmt = defaults.Management()
+    return mgmt.has_managed_ifnames()
+
+
 class NicTable(ui.Table):
     def __init__(self, path, height=3, multi=False):
         header = "Device  Status       Model         MAC Address"
@@ -54,7 +61,10 @@
         for name, nic in sorted(model.nics().items()):
             if first_nic is None:
                 first_nic = name
-            is_cfg = "Configured" if nic.is_configured() else "Unconfigured"
+            if has_managed_ifnames():
+                is_cfg = "Managed"
+            else:
+                is_cfg = "Configured" if nic.is_configured() else "Unconfigured"
             description = " ".join([justify(nic.ifname, 7),
                                     justify(is_cfg, 12),
                                     justify(nic.vendor, 13),
@@ -184,6 +194,18 @@
         page = ui.Page("page", ws)
         # Save it "locally" as a dict, for better accessability
         self.widgets.add(page)
+
+        #
+        # NIC Deatils Dialog and Bond creation is disabled
+        # when Node is managed
+        #
+        if has_managed_ifnames():
+            self._nic_details_group.enabled(False)
+            self.widgets["button.toggle_bond"].enabled(False)
+            nictbl = self.widgets["nics"]
+            nictbl.on_activate.clear()
+            nictbl.label(nictbl.label() + " (read-only/managed)")
+
         return page
 
     def _build_dialog(self, path, txt, widgets):


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

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