Change in vdsm[master]: net: find toplevel iterface name based on net attributes
Jenkins CI RO has abandoned this change. Change subject: net: find toplevel iterface name based on net attributes .. Abandoned Abandoned due to no activity - please restore if still relevant -- To view, visit https://gerrit.ovirt.org/55323 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: abandon Gerrit-Change-Id: Ieb6ec043091eed6b3b0d8b3b66924aed66af3e12 Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Dan KenigsbergGerrit-Reviewer: Edward Haas Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Jenkins CI RO Gerrit-Reviewer: Petr Horáček Gerrit-Reviewer: gerrit-hooks ___ vdsm-patches mailing list -- vdsm-patches@lists.fedorahosted.org To unsubscribe send an email to vdsm-patches-le...@lists.fedorahosted.org
Change in vdsm[master]: net: find toplevel iterface name based on net attributes
gerrit-hooks has posted comments on this change. Change subject: net: find toplevel iterface name based on net attributes .. Patch Set 2: * Update tracker: IGNORE, no Bug-Url found -- To view, visit https://gerrit.ovirt.org/55323 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ieb6ec043091eed6b3b0d8b3b66924aed66af3e12 Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Dan KenigsbergGerrit-Reviewer: Edward Haas Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Jenkins CI RO Gerrit-Reviewer: Petr Horáček Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: No ___ vdsm-patches mailing list -- vdsm-patches@lists.fedorahosted.org To unsubscribe send an email to vdsm-patches-le...@lists.fedorahosted.org
Change in vdsm[master]: net: find toplevel iterface name based on net attributes
Edward Haas has posted comments on this change. Change subject: net: find toplevel iterface name based on net attributes .. Patch Set 2: Code-Review-1 (3 comments) https://gerrit.ovirt.org/#/c/55323/2/lib/vdsm/netconfpersistence.py File lib/vdsm/netconfpersistence.py: Line 30: from . import commands Line 31: from . import constants Line 32: from . import utils Line 33: from vdsm.network.canonicalize import canonicalize_networks Line 34: from vdsm.network.utils import toplevel_iface junkyard alert! ;) what about this: (?) from vdsm.network.interface import toplevel I think we have many interface related utils/tools we can move there. it can also become a nice api to kernel interfaces. Line 35: Line 36: CONF_RUN_DIR = constants.P_VDSM_RUN + 'netconf/' Line 37: # The persistent path is inside of an extra "persistence" dir in order to get Line 38: # oVirt Node to persist the symbolic links that are necessary for the https://gerrit.ovirt.org/#/c/55323/2/tests/network/unit_test.py File tests/network/unit_test.py: PS2, Line 45: test_vlan test_vlan_with_nic PS2, Line 51: test_bond Don't we need two separate tests here? test_bond & test_vlan_with_bond -- To view, visit https://gerrit.ovirt.org/55323 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ieb6ec043091eed6b3b0d8b3b66924aed66af3e12 Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Dan KenigsbergGerrit-Reviewer: Edward Haas Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Petr Horáček Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: Yes ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
Change in vdsm[master]: net: find toplevel iterface name based on net attributes
Petr Horáček has posted comments on this change. Change subject: net: find toplevel iterface name based on net attributes .. Patch Set 2: Code-Review+1 -- To view, visit https://gerrit.ovirt.org/55323 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ieb6ec043091eed6b3b0d8b3b66924aed66af3e12 Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Dan KenigsbergGerrit-Reviewer: Edward Haas Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Petr Horáček Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
Change in vdsm[master]: net: find toplevel iterface name based on net attributes
gerrit-hooks has posted comments on this change. Change subject: net: find toplevel iterface name based on net attributes .. Patch Set 2: * Update tracker: IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6', 'ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3']) -- To view, visit https://gerrit.ovirt.org/55323 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ieb6ec043091eed6b3b0d8b3b66924aed66af3e12 Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Dan KenigsbergGerrit-Reviewer: Edward Haas Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
Change in vdsm[master]: net: find toplevel iterface name based on net attributes
Dan Kenigsberg has uploaded a new change for review. Change subject: net: find toplevel iterface name based on net attributes .. net: find toplevel iterface name based on net attributes It is quite a common task to look for the name of the top-level iterface of a network. This patch makes it a unitility function, and uses it in one location. Note that the original code, introduced in commit 70608a5, was buggy, as it forgot the dot in interfaces such as eth0.100. Change-Id: Ieb6ec043091eed6b3b0d8b3b66924aed66af3e12 Signed-off-by: Dan Kenigsberg--- M lib/vdsm/netconfpersistence.py M lib/vdsm/network/utils.py A tests/network/unit_test.py 3 files changed, 81 insertions(+), 10 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/23/55323/1 diff --git a/lib/vdsm/netconfpersistence.py b/lib/vdsm/netconfpersistence.py index 6397a7c..ad88640 100644 --- a/lib/vdsm/netconfpersistence.py +++ b/lib/vdsm/netconfpersistence.py @@ -1,5 +1,5 @@ # -# Copyright 2013 Red Hat, Inc. +# Copyright 2013-2016 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -31,6 +31,7 @@ from . import constants from . import utils from vdsm.network.canonicalize import canonicalize_networks +from vdsm.network.utils import toplevel_iface CONF_RUN_DIR = constants.P_VDSM_RUN + 'netconf/' # The persistent path is inside of an extra "persistence" dir in order to get @@ -220,13 +221,8 @@ if bridge not in nets: return [] -network = nets[bridge] -nic = network.get('nic') -bond = network.get('bonding') -vlan = str(network.get('vlan', '')) -if bond: -return [bond + vlan] -elif nic: -return [nic + vlan] -else: # isolated bridged network +iface = toplevel_iface(bridge, nets[bridge]) +if iface is None: return [] +else: +return [iface] diff --git a/lib/vdsm/network/utils.py b/lib/vdsm/network/utils.py index 4bb5e50..22c1b55 100644 --- a/lib/vdsm/network/utils.py +++ b/lib/vdsm/network/utils.py @@ -28,3 +28,23 @@ """ return ' '.join((option for option in options.split() if not option.startswith('custom='))) + + +def toplevel_iface(net, net_attr): +if net_attr['bridged']: +return net + +nic = net_attr.get('nic') +bond = net_attr.get('bonding') + +if 'vlan' in net_attr: +vlan = '.' + str(net_attr['vlan']) +else: +vlan = '' + +if bond: +return bond + vlan +elif nic: +return nic + vlan +else: +return None diff --git a/tests/network/unit_test.py b/tests/network/unit_test.py new file mode 100644 index 000..ac4decc --- /dev/null +++ b/tests/network/unit_test.py @@ -0,0 +1,55 @@ +# +# Copyright 2016 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# +# Refer to the README and COPYING files for full details of the license +# + +from __future__ import absolute_import + +from nose.plugins.attrib import attr + +from testlib import VdsmTestCase as TestCaseBase + +from vdsm.network.utils import toplevel_iface + + +@attr(type='unit') +class TopLevelIfaceTests(TestCaseBase): +def test_bridged(self): +self.assertEqual( +'n', +toplevel_iface('n', {'bridged': True, 'nic': 'eth0'})) + +def test_nicless(self): +self.assertEqual('n', toplevel_iface('n', {'bridged': True})) + +def test_nic(self): +self.assertEqual( +'eth0', +toplevel_iface('n', {'bridged': False, 'nic': 'eth0'})) + +def test_vlan(self): +self.assertEqual( +'eth0.7', +toplevel_iface( +'n', {'bridged': False, 'nic': 'eth0', 'vlan': 7})) + +def test_bond(self): +self.assertEqual( +'bond7.7', +toplevel_iface( +'n', {'bridged': False, 'bonding': 'bond7', 'vlan': 7})) -- To view, visit https://gerrit.ovirt.org/55323 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ieb6ec043091eed6b3b0d8b3b66924aed66af3e12 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master
Change in vdsm[master]: net: find toplevel iterface name based on net attributes
gerrit-hooks has posted comments on this change. Change subject: net: find toplevel iterface name based on net attributes .. Patch Set 1: * Update tracker: IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6', 'ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3']) -- To view, visit https://gerrit.ovirt.org/55323 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ieb6ec043091eed6b3b0d8b3b66924aed66af3e12 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Dan KenigsbergGerrit-Reviewer: gerrit-hooks Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches