[node-patches] Change in ovirt-node[master]: enhance class NicTable

hadong0720 at gmail.com hadong0720 at gmail.com
Fri Mar 21 08:57:37 UTC 2014


hadong has uploaded a new change for review.

Change subject: enhance class NicTable
......................................................................

enhance class NicTable

enhance class NicTable to make sure it could filter out nics that
was managed by rhevm or configured when it as nictable of createBondDialog

Change-Id: I6943f34ae8ee137fef5c3fb6dc84bed1e360c891
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1078087
Signed-off-by: hadong <hadong0720 at gmail.com>
---
M src/ovirt/node/setup/core/network_page.py
1 file changed, 34 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/71/25971/1

diff --git a/src/ovirt/node/setup/core/network_page.py b/src/ovirt/node/setup/core/network_page.py
index 41dc830..59627e7 100644
--- a/src/ovirt/node/setup/core/network_page.py
+++ b/src/ovirt/node/setup/core/network_page.py
@@ -44,12 +44,18 @@
         header = "Device  Status       Model         MAC Address"
         if multi:
             header = "    " + header
-
-        super(NicTable, self).__init__(path,
-                                       "Available System NICs",
-                                       header,
-                                       self._get_nics(),
-                                       height=height, multi=multi),
+        if path == "bond.slaves":
+            super(NicTable, self).__init__(path,
+                                           "Available System NICs",
+                                           header,
+                                           self._get_nics_bond(),
+                                           height=height, multi=multi),
+        else:
+            super(NicTable, self).__init__(path,
+                                           "Available System NICs",
+                                           header,
+                                           self._get_nics(),
+                                           height=height, multi=multi),
 
     def _get_nics(self):
         def justify(txt, l):
@@ -73,6 +79,28 @@
             node_nics.append((name, description))
         return node_nics
 
+    def _get_nics_bond(self):
+        def justify(txt, l):
+            txt = txt if txt else ""
+            return txt.ljust(l)[0:l]
+        node_nics = []
+        first_nic = None
+        model = utils.network.NodeNetwork()
+        for name, nic in sorted(model.nics().items()):
+            if first_nic is None:
+                first_nic = name
+            if has_managed_ifnames() or nic.is_configured():
+                continue
+            else:
+                is_cfg = "Unconfigured"
+                description = " ".join([justify(nic.ifname, 7),
+                                        justify(is_cfg, 12),
+                                        justify(nic.vendor, 13),
+                                        justify(nic.hwaddr, 17)
+                                        ])
+                node_nics.append((name, description))
+        return node_nics
+
 
 class Plugin(plugins.NodePlugin):
     """This is the network page


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6943f34ae8ee137fef5c3fb6dc84bed1e360c891
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: hadong <hadong0720 at gmail.com>



More information about the node-patches mailing list