Change in vdsm[ovirt-3.3]: ifcfg: exclude HWADDR lines if requested
danken at redhat.com
danken at redhat.com
Fri Jan 24 11:45:54 UTC 2014
Hello Antoni Segura Puimedon, Assaf Muller,
I'd like you to do a code review. Please visit
http://gerrit.ovirt.org/23662
to review the following change.
Change subject: ifcfg: exclude HWADDR lines if requested
......................................................................
ifcfg: exclude HWADDR lines if requested
In prehistoric days, our ifcfg files included HWADDR lines for
persistent NIC names on EL5 hosts. Our currently-supported
systems no longer require HWADDR for that, but rather use udev rules.
HWADDRs are still required if NetworkManager is running and needs them
to adhere to our NM_CONTROLLED=no directive.
HWADDR lines in ifcfg files are frowned upon, since they essentially
duplicate information that already exists in udev rules. Users who
would like to avoid them can now configure hwaddr_in_ifcfg to "never"
instead of the default "always".
Bug-Url: https://bugzilla.redhat.com/1044060
Change-Id: Ifc4904251150756594502367d4bea87620dfba58
Signed-off-by: Dan Kenigsberg <danken at redhat.com>
Reviewed-on: http://gerrit.ovirt.org/22288
Reviewed-by: Assaf Muller <amuller at redhat.com>
Reviewed-by: Antoni Segura Puimedon <asegurap at redhat.com>
---
M lib/vdsm/config.py.in
M vdsm/netconf/ifcfg.py
2 files changed, 14 insertions(+), 3 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/62/23662/1
diff --git a/lib/vdsm/config.py.in b/lib/vdsm/config.py.in
index a229998..ff4cebe 100644
--- a/lib/vdsm/config.py.in
+++ b/lib/vdsm/config.py.in
@@ -42,6 +42,11 @@
'Comma-separated list of fnmatch-patterns for dummy hosts nics to '
'be shown to vdsm.'),
+ ('hwaddr_in_ifcfg', 'always',
+ 'Whether to set HWADDR in ifcfg files. Set to "never" if '
+ 'NetworkManager is disabled and device name persistence does '
+ 'not depend on HWADDR.'),
+
('nic_model', 'rtl8139,pv',
'NIC model is rtl8139, ne2k_pci pv or any other valid device '
'recognized by kvm/qemu if a coma separated list given then a '
diff --git a/vdsm/netconf/ifcfg.py b/vdsm/netconf/ifcfg.py
index f9da0e7..5eb0d59 100644
--- a/vdsm/netconf/ifcfg.py
+++ b/vdsm/netconf/ifcfg.py
@@ -40,6 +40,10 @@
import neterrors as ne
+def _hwaddr_required():
+ return config.get('vars', 'hwaddr_in_ifcfg') == 'always'
+
+
class Ifcfg(Configurator):
# TODO: Do all the configApplier interaction from here.
def __init__(self):
@@ -543,10 +547,12 @@
def addNic(self, nic, **opts):
""" Create ifcfg-* file with proper fields for NIC """
_netinfo = netinfo.NetInfo()
- hwaddr = (_netinfo.nics[nic.name].get('permhwaddr') or
- _netinfo.nics[nic.name]['hwaddr'])
+ conf = ''
+ if _hwaddr_required():
+ hwaddr = (_netinfo.nics[nic.name].get('permhwaddr') or
+ _netinfo.nics[nic.name]['hwaddr'])
- conf = 'HWADDR=%s\n' % pipes.quote(hwaddr)
+ conf += 'HWADDR=%s\n' % pipes.quote(hwaddr)
if nic.bridge:
conf += 'BRIDGE=%s\n' % pipes.quote(nic.bridge.name)
if nic.bond:
--
To view, visit http://gerrit.ovirt.org/23662
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifc4904251150756594502367d4bea87620dfba58
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.3
Gerrit-Owner: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Antoni Segura Puimedon <asegurap at redhat.com>
Gerrit-Reviewer: Assaf Muller <amuller at redhat.com>
More information about the vdsm-patches
mailing list