Change in vdsm[master]: configNet: allow delete/update of devices with no ifcfg
danken at redhat.com
danken at redhat.com
Fri Feb 1 21:21:21 UTC 2013
Dan Kenigsberg has uploaded a new change for review.
Change subject: configNet: allow delete/update of devices with no ifcfg
......................................................................
configNet: allow delete/update of devices with no ifcfg
In Fedora 18, ifcfg files are missing by default. This patch assumes
that there are no custom MTU setting for a device with no ifcfg file.
Change-Id: Icb3a623ca3d3b560288cbe4141eea6bd060ac798
Bug-Url: https://bugzilla.redhat.com/906383
Signed-off-by: Dan Kenigsberg <danken at redhat.com>
---
M tests/configNetworkTests.py
M vdsm/configNetwork.py
2 files changed, 25 insertions(+), 7 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/21/11621/1
diff --git a/tests/configNetworkTests.py b/tests/configNetworkTests.py
index 0a129b9..41164b2 100644
--- a/tests/configNetworkTests.py
+++ b/tests/configNetworkTests.py
@@ -344,3 +344,7 @@
cw.restorePersistentBackup()
self._assertFilesRestored()
+
+ def test_getMTUofMissingDev(self):
+ cw = configNetwork.ConfigWriter()
+ self.assertIs(cw._getDeviceConfigMtu('DEVICE.DOES.NOT.EXIST'), None)
diff --git a/vdsm/configNetwork.py b/vdsm/configNetwork.py
index 5380f31..d43f2a9 100755
--- a/vdsm/configNetwork.py
+++ b/vdsm/configNetwork.py
@@ -618,13 +618,29 @@
it check if a vlan, bond that have a higher mtu value
"""
for nic in nics:
- cf = netinfo.NET_CONF_PREF + nic
- mtuval = self._getConfigValue(cf, 'MTU')
+ mtuval = self._getDeviceConfigMtu(nic)
+
if not mtuval is None:
mtuval = int(mtuval)
if mtuval > mtu:
mtu = mtuval
return mtu
+
+ def _getDeviceConfigMtu(self, dev):
+ "Return custom MTU from ifcfg of device or None if none is set"
+ cf = self.NET_CONF_PREF + dev
+ try:
+ currmtu = self._getConfigValue(cf, 'MTU')
+ except IOError as e:
+ if e.errno == os.errno.ENOENT:
+ currmtu = None
+ else:
+ raise
+
+ if currmtu:
+ currmtu = int(currmtu)
+
+ return currmtu
def setNewMtu(self, network, bridged):
"""
@@ -641,11 +657,9 @@
_netinfo = netinfo.NetInfo()
currmtu = None
if bridged:
- cf = netinfo.NET_CONF_PREF + network
- currmtu = self._getConfigValue(cf, 'MTU')
- if currmtu:
- currmtu = int(currmtu)
- else:
+ currmtu = self._getDeviceConfigMtu(network)
+
+ if not currmtu:
# Optimization: if network hasn't custom MTU, do nothing
return
--
To view, visit http://gerrit.ovirt.org/11621
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Icb3a623ca3d3b560288cbe4141eea6bd060ac798
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dan Kenigsberg <danken at redhat.com>
More information about the vdsm-patches
mailing list