[node-patches] Change in ovirt-node[master]: Add config keys to exchange management infos

fabiand at fedoraproject.org fabiand at fedoraproject.org
Fri Dec 13 15:14:16 UTC 2013


Fabian Deutsch has uploaded a new change for review.

Change subject: Add config keys to exchange management infos
......................................................................

Add config keys to exchange management infos

Previously the TUI had assumptions about the network layout (e.g. it
knew about ovirtmgmt), but those assumptions were dropped.
To still be able to provide relevant informations to the user a couple
of keys were added to let the TUI know about
- The management instance which is managing Node
- Important NICs on the system
- Pages to be locked

Change-Id: I855f03559c4e47ab2a71726849425db0ef2d5a6a
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1021647
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M src/ovirt/node/config/defaults.py
M src/ovirt/node/setup/core/status_page.py
2 files changed, 86 insertions(+), 19 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/74/22374/1

diff --git a/src/ovirt/node/config/defaults.py b/src/ovirt/node/config/defaults.py
index 426b34f..3260303 100644
--- a/src/ovirt/node/config/defaults.py
+++ b/src/ovirt/node/config/defaults.py
@@ -1503,3 +1503,58 @@
         """
         self.update(upgrade=True,
                     install=None)
+
+
+class Management(NodeConfigFileSection):
+    """Exchange informations with management part
+
+    Plugins can use this class as follows:
+
+    from ovirt.node.config.defaults import Management
+    mgmt.update("oVirt Engine at <url>",
+                ["ovirtmgmt"],
+                [])
+
+
+    Keys
+    ----
+    MANAGED_BY=<descriptive-text>
+        This key is used to (a) signal the Node is being managed and
+        (b) signaling who is managing this node.
+        The value can be a descriptive text inclduning e.g. an URL to point
+        to the management instance.
+
+    MANAGED_IFNAMES=<ifname>[,<ifname>,...]
+        This key is used to specify a number (comma separated list) if
+        ifnames which are managed and for which the TUI shall display some
+        information (IP, ...).
+        This can also be used by the TUI to decide to not offer NIC
+        configuration to the user.
+        This is needed to tell the TUI the _important_ NICs on this host.
+        E.g. it's probably worth to provide the ifname of the management
+        interface here, e.g ovirtmgmt.
+
+    MANAGED_LOCKED_PAGES=<pagename>[,<pagename>,...]
+        (Future) A list of pages which shall be locked e.g. because the
+        management instance is configuring the aspect (e.g. networking or
+        logging).
+    """
+    keys = ("MANAGED_BY",
+            "MANAGED_IFNAMES",
+            "MANAGED_LOCKED_PAGES"
+            )
+
+    @NodeConfigFileSection.map_and_update_defaults_decorator
+    def update(self, managed_by, managed_ifnames, managed_locked_pages):
+        assert type(managed_ifnames) is list
+        return {"MANAGED_IFNAMES": (",".join(managed_ifnames)
+                                    if managed_ifnames else None)}
+
+    def retrieve(self):
+        cfg = dict(NodeConfigFileSection.retrieve(self))
+        cfg["managed_ifnames"] = (cfg["managed_ifnames"].split(",")
+                                  if cfg["managed_ifnames"] else None)
+        return cfg
+
+    def transaction(self):
+        return None
diff --git a/src/ovirt/node/setup/core/status_page.py b/src/ovirt/node/setup/core/status_page.py
index f1be2cd..e87a72f 100644
--- a/src/ovirt/node/setup/core/status_page.py
+++ b/src/ovirt/node/setup/core/status_page.py
@@ -46,9 +46,15 @@
         return 0
 
     def model(self):
+        mng = defaults.Management()
         bootif = defaults.Network().retrieve()["iface"]
+        managementifs = mng.retrieve()["managed_ifnames"]
+        primaryif = managementifs[0] if managementifs else bootif
+
+        self.logger.debug("NIC for status: %s" % primaryif)
+
         net_status, net_br, net_addrs = \
-            utils.network.networking_status(bootif)
+            utils.network.networking_status(primaryif)
         net_addrs_str = ""
         if net_addrs:
             net_addrs_str = "\nIPv4: {inet}\nIPv6: {inet6}".format(**net_addrs)
@@ -57,6 +63,7 @@
 
         return {
             "status": virt.hardware_status(),
+            "managed_by": mng.retrieve()["managed_by"],
             "networking": net_status,
             "networking.bridge": "%s %s" % (net_br, net_addrs_str),
             "logs": self._logging_summary(),
@@ -87,30 +94,35 @@
 
         widgets = [ui.Header("header[0]", _("System Information")),
 
-                   ui.KeywordLabel("status", aligned(_("Status: "))),
-                   ui.Divider("divider[0]"),
+                   ui.KeywordLabel("status", aligned(_("Status: ")))]
 
-                   ui.Row("row[0]", network_widgets),
-                   ui.Divider("divider[1]"),
+        if self.model()["managed_by"]:
+            widgets += [ui.KeywordLabel("managed_by",
+                                        aligned(_("Managed by: ")))]
 
-                   ui.KeywordLabel("logs", aligned(_("Logs: "))),
-                   ui.Divider("divider[2]"),
+        widgets += [ui.Divider("divider[0]"),
 
-                   ui.KeywordLabel("libvirt.num_guests",
-                                   aligned(_("Running VMs: "))),
-                   ui.Divider("divider[3]"),
+                    ui.Row("row[0]", network_widgets),
+                    ui.Divider("divider[1]"),
 
-                   ui.Label("support.hint", _("Press F8 for support menu")),
-                   ui.Divider("divider[4]"),
+                    ui.KeywordLabel("logs", aligned(_("Logs: "))),
+                    ui.Divider("divider[2]"),
 
-                   ui.Row("row[1]",
-                          [ui.Button("action.hostkey", _("View Host Key")),
-                           ui.Button("action.cpu_details",
-                                     _("View CPU Details")),
-                           ]),
+                    ui.KeywordLabel("libvirt.num_guests",
+                                    aligned(_("Running VMs: "))),
+                    ui.Divider("divider[3]"),
 
-                   ui.Row("row[2]", action_widgets),
-                   ]
+                    ui.Label("support.hint", _("Press F8 for support menu")),
+                    ui.Divider("divider[4]"),
+
+                    ui.Row("row[1]",
+                           [ui.Button("action.hostkey", _("View Host Key")),
+                            ui.Button("action.cpu_details",
+                                      _("View CPU Details")),
+                            ]),
+
+                    ui.Row("row[2]", action_widgets),
+                    ]
 
         self.widgets.add(widgets)
 


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

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