Change in vdsm[master]: net: remove mac address from ifcfg
ibarkan at redhat.com
ibarkan at redhat.com
Sun Nov 15 13:17:58 UTC 2015
Ido Barkan has uploaded a new change for review.
Change subject: net: remove mac address from ifcfg
......................................................................
net: remove mac address from ifcfg
In el7, the HWADDR field in ifcfg files is no longer needed by udev
and is considered a bad practice. Hence, VDSM shouldn't handle it
anymore.
Change-Id: I4fa6f01f3232ed6bf0fca1d68061b2e90a54209a
Signed-off-by: Ido Barkan <ibarkan at redhat.com>
---
M lib/vdsm/config.py.in
M vdsm/network/configurators/ifcfg.py
2 files changed, 1 insertion(+), 38 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/79/48579/1
diff --git a/lib/vdsm/config.py.in b/lib/vdsm/config.py.in
index 83dcdb4..5982d75 100644
--- a/lib/vdsm/config.py.in
+++ b/lib/vdsm/config.py.in
@@ -51,11 +51,6 @@
('net_persistence', 'unified',
'Whether to use "ifcfg" or "unified" persistence for networks.'),
- ('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.'),
-
('ethtool_opts', '',
'Which special ethtool options should be applied to NICs after '
'they are taken up, e.g. "lro off" on buggy devices. '
diff --git a/vdsm/network/configurators/ifcfg.py b/vdsm/network/configurators/ifcfg.py
index c2b0345..41f14d8 100644
--- a/vdsm/network/configurators/ifcfg.py
+++ b/vdsm/network/configurators/ifcfg.py
@@ -61,10 +61,6 @@
return True
-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, inRollback=False):
@@ -607,12 +603,7 @@
conf = ''
if ipwrapper.Link._detectType(nic.name) == 'dummy':
opts['hotplug'] = 'no'
- if _hwaddr_required():
- _netinfo = netinfo.NetInfo()
- hwaddr = (_netinfo.nics[nic.name].get('permhwaddr') or
- _netinfo.nics[nic.name]['hwaddr'])
- conf += 'HWADDR=%s\n' % pipes.quote(hwaddr)
if nic.bridge:
conf += 'BRIDGE=%s\n' % pipes.quote(nic.bridge.name)
if nic.bond:
@@ -652,34 +643,11 @@
mtu = int(mtu)
return ipv4, ipv6, mtu
- @staticmethod
- def _hwaddr_from_ifcfg_or_system(nic, ifcfg):
- if not _hwaddr_required():
- return []
- try:
- with open(ifcfg) as ifcfg_file:
- return [line for line in ifcfg_file if line.startswith(
- 'HWADDR=')]
- except IOError as e:
- if e.errno != errno.ENOENT:
- logging.error("%s couldn't be read (errno %s)", ifcfg, e.errno)
- raise
- logging.warning("%s doesn't exist, reading HWADDR from the system",
- ifcfg)
- try:
- return ['HWADDR=%s\n' % netinfo.gethwaddr(nic)]
- except IOError as e:
- logging.exception("couldn't determine hardware address of %s "
- "(errno %s)", nic, e.errno)
- return []
-
def removeNic(self, nic):
cf = netinfo.NET_CONF_PREF + nic
self._backup(cf)
- hwlines = self._hwaddr_from_ifcfg_or_system(nic, cf)
l = [self.CONFFILE_HEADER + '\n', 'DEVICE=%s\n' % nic, 'ONBOOT=yes\n',
- 'MTU=%s\n' % netinfo.DEFAULT_MTU] + hwlines
- l.append('NM_CONTROLLED=no\n')
+ 'MTU=%s\n' % netinfo.DEFAULT_MTU, 'NM_CONTROLLED=no\n']
with open(cf, 'w') as nicFile:
nicFile.writelines(l)
--
To view, visit https://gerrit.ovirt.org/48579
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4fa6f01f3232ed6bf0fca1d68061b2e90a54209a
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Ido Barkan <ibarkan at redhat.com>
More information about the vdsm-patches
mailing list