Change in vdsm[master]: WIP: Introduce a base network configurator class
wudxw at linux.vnet.ibm.com
wudxw at linux.vnet.ibm.com
Mon Jun 3 07:41:39 UTC 2013
Mark Wu has uploaded a new change for review.
Change subject: WIP: Introduce a base network configurator class
......................................................................
WIP: Introduce a base network configurator class
To reuse the code not related to specific configurator, this
patch introduce a base network configurator class. The both the persist
configurator ifcfg and the non-persist configurator iproute2 (to be added)
could inherit from this base class
Change-Id: I672c4d671ae2a9d6c6eeede051e7989d58b8c005
Signed-off-by: Mark Wu <wudxw at linux.vnet.ibm.com>
---
M vdsm/netconf/__init__.py
M vdsm/netconf/ifcfg.py
2 files changed, 40 insertions(+), 33 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/00/15300/1
diff --git a/vdsm/netconf/__init__.py b/vdsm/netconf/__init__.py
index 8e88115..0da4d35 100644
--- a/vdsm/netconf/__init__.py
+++ b/vdsm/netconf/__init__.py
@@ -16,3 +16,40 @@
#
# Refer to the README and COPYING files for full details of the license
#
+
+from vdsm import netinfo
+from netmodels import Bond, Vlan
+
+
+class Configurator(object):
+
+ # TODO: Do all the configWriter interaction from here.
+ def __init__(self, configWriter=None):
+ self.configWriter = configWriter
+ self._libvirtAdded = set()
+
+ def _setNewMtu(self, iface, _netinfo=None):
+ """
+ Update an interface's MTU when one of its users is removed.
+
+ :param iface: interface object (bond or nic device)
+ :type iface: NetDevice instance
+
+ """
+ ifaceMtu = netinfo.getMtu(iface.name)
+ if isinstance(iface.master, Vlan):
+ if iface.master.mtu < ifaceMtu:
+ return
+
+ vlans = _netinfo.getVlansForIface(iface.name)
+ try:
+ maxMtu = max(int(netinfo.getMtu(iface.name + '.' + vlan))
+ for vlan in vlans)
+ except ValueError:
+ maxMtu = None
+
+ if maxMtu and maxMtu < ifaceMtu:
+ if isinstance(iface, Bond):
+ self.configWriter.setBondingMtu(iface.name, maxMtu)
+ else:
+ self.configWriter.setIfaceMtu(iface.name, maxMtu)
diff --git a/vdsm/netconf/ifcfg.py b/vdsm/netconf/ifcfg.py
index e1840ee..510bdac 100644
--- a/vdsm/netconf/ifcfg.py
+++ b/vdsm/netconf/ifcfg.py
@@ -35,16 +35,12 @@
from vdsm import constants
from vdsm import netinfo
from vdsm import utils
-from netmodels import Bond, Vlan, Bridge
+from netmodels import Bridge
+from netconf import Configurator
import neterrors as ne
-class Ifcfg(object):
- # TODO: Do all the configWriter interaction from here.
- def __init__(self, configWriter=None):
- self.configWriter = configWriter
- self._libvirtAdded = set()
-
+class Ifcfg(Configurator):
def begin(self):
if self.configWriter is None:
self.configWriter = ConfigWriter()
@@ -162,32 +158,6 @@
with self.removeIface(nic) as to_be_removed:
if to_be_removed:
self.configWriter.removeNic(nic.name)
-
- def _setNewMtu(self, iface, _netinfo=None):
- """
- Update an interface's MTU when one of its users is removed.
-
- :param iface: interface object (bond or nic device)
- :type iface: NetDevice instance
-
- """
- ifaceMtu = netinfo.getMtu(iface.name)
- if isinstance(iface.master, Vlan):
- if iface.master.mtu < ifaceMtu:
- return
-
- vlans = _netinfo.getVlansForIface(iface.name)
- try:
- maxMtu = max(int(netinfo.getMtu(iface.name + '.' + vlan))
- for vlan in vlans)
- except ValueError:
- maxMtu = None
-
- if maxMtu and maxMtu < ifaceMtu:
- if isinstance(iface, Bond):
- self.configWriter.setBondingMtu(iface.name, maxMtu)
- else:
- self.configWriter.setIfaceMtu(iface.name, maxMtu)
class ConfigWriter(object):
--
To view, visit http://gerrit.ovirt.org/15300
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I672c4d671ae2a9d6c6eeede051e7989d58b8c005
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Mark Wu <wudxw at linux.vnet.ibm.com>
More information about the vdsm-patches
mailing list