Change in vdsm[master]: netinfo: remove code duplication between nics, bonds and vlans
asegurap at redhat.com
asegurap at redhat.com
Thu Feb 6 15:38:46 UTC 2014
Antoni Segura Puimedon has uploaded a new change for review.
Change subject: netinfo: remove code duplication between nics, bonds and vlans
......................................................................
netinfo: remove code duplication between nics, bonds and vlans
Change-Id: I7c54801822d487bde7f0e4ba9e79bf278e2a7598
Signed-off-by: Antoni S. Puimedon <asegurap at redhat.com>
---
M lib/vdsm/netinfo.py
1 file changed, 13 insertions(+), 25 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/74/24174/1
diff --git a/lib/vdsm/netinfo.py b/lib/vdsm/netinfo.py
index 0e28de4..3ff09fb 100644
--- a/lib/vdsm/netinfo.py
+++ b/lib/vdsm/netinfo.py
@@ -35,14 +35,13 @@
from .config import config
from . import constants
-from .ipwrapper import getLink, getLinks
+from .ipwrapper import getLink, getLinks, Link
from .ipwrapper import IPRoute2Error
from .ipwrapper import Route
from .ipwrapper import routeGet
from .ipwrapper import routeShowGateways, routeShowAllDefaultGateways
from . import libvirtconnection
from .ipwrapper import linkShowDev
-from .utils import anyFnmatch
from .netconfpersistence import RunningConfig
from .netlink import iter_addrs
@@ -82,36 +81,25 @@
OPERSTATE_UP = 'up'
-def nics():
- """Returns a list of nics and fake nics devices available (not hidden) to
- be used by vdsm."""
- return [dev.name for dev in getLinks() if dev.isNICLike() and
+def _visible_devs(predicate):
+ """Returns a list of visible links for which the predicate is True"""
+ return [dev.name for dev in getLinks() if predicate(dev) and
not dev.isHidden()]
+def nics():
+ """Returns a list of available nic like devices manageable by vdsm."""
+ return _visible_devs(Link.isNICLike)
+
+
def bondings():
- """
- Returns list of available bonds managed by vdsm.
- """
-
- hidden_bonds = config.get('vars', 'hidden_bonds').split(',')
- res = []
- try:
- for bond in open(BONDING_MASTERS).readline().split():
- if not anyFnmatch(bond, hidden_bonds):
- res.append(bond)
- except IOError as e:
- if e.errno == os.errno.ENOENT:
- return res
- else:
- raise
-
- return res
+ """Returns a list of available bonds manageable by vdsm."""
+ return _visible_devs(Link.isBOND)
def vlans():
- return [link.name for link in getLinks() if link.isVLAN() and
- not link.isHidden()]
+ """Returns a list of available vlans manageable by vdsm."""
+ return _visible_devs(Link.isVLAN)
def bridges():
--
To view, visit http://gerrit.ovirt.org/24174
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7c54801822d487bde7f0e4ba9e79bf278e2a7598
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Antoni Segura Puimedon <asegurap at redhat.com>
More information about the vdsm-patches
mailing list