Change in vdsm[master]: sourceroute: replace configureSourceRoute by configure_sourc...
osvoboda at redhat.com
osvoboda at redhat.com
Fri May 29 16:48:41 UTC 2015
Ondřej Svoboda has uploaded a new change for review.
Change subject: sourceroute: replace configureSourceRoute by configure_source_route
......................................................................
sourceroute: replace configureSourceRoute by configure_source_route
The new function is used by sourceRoute thread and internally by
configurators. It makes no distinction between configuring a "static"
or a "dynamic" source route.
Change-Id: I44adf27199de412650885923097a1b40d27ef25b
Signed-off-by: Ondřej Svoboda <osvoboda at redhat.com>
---
M tests/functional/networkTests.py
M vdsm/network/configurators/__init__.py
M vdsm/network/configurators/ifcfg.py
M vdsm/network/configurators/iproute2.py
M vdsm/network/sourceroute.py
M vdsm/network/sourceroutethread.py
6 files changed, 13 insertions(+), 15 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/14/41614/1
diff --git a/tests/functional/networkTests.py b/tests/functional/networkTests.py
index 63666a7..888b92b 100644
--- a/tests/functional/networkTests.py
+++ b/tests/functional/networkTests.py
@@ -192,7 +192,7 @@
def _get_source_route(device_name, ipv4_address):
ipv4 = IPv4(ipv4_address, IP_MASK, IP_GATEWAY)
- return sourceroute.StaticSourceRoute(device_name, ipv4)
+ return sourceroute.SourceRoute(device_name, ipv4)
@expandPermutations
diff --git a/vdsm/network/configurators/__init__.py b/vdsm/network/configurators/__init__.py
index 3eb96af..20ac6f2 100644
--- a/vdsm/network/configurators/__init__.py
+++ b/vdsm/network/configurators/__init__.py
@@ -29,7 +29,7 @@
from ..errors import ConfigNetworkError, ERR_FAILED_IFUP
from . import qos
from ..models import Bond, Bridge
-from ..sourceroute import StaticSourceRoute
+from ..sourceroute import SourceRoute
class RollbackIncomplete(Exception):
@@ -99,8 +99,10 @@
def removeNic(self, nic):
raise NotImplementedError
- def configureSourceRoute(self, source_route):
- raise NotImplementedError
+ def configure_source_route(self, device_name, ipv4):
+ source_route = SourceRoute(device_name, ipv4)
+ source_route.prepare_configuration()
+ self._configure_source_route(source_route)
def remove_dynamic_source_route(self, device_name):
raise NotImplementedError
@@ -130,9 +132,7 @@
except:
logging.exception('Invalid input for source routing')
else:
- source_route = StaticSourceRoute(device.name, device.ipv4)
- source_route.prepare_configuration()
- self.configureSourceRoute(source_route)
+ self.configure_source_route(device.name, device.ipv4)
def _setNewMtu(self, iface, ifaceVlans):
"""
diff --git a/vdsm/network/configurators/ifcfg.py b/vdsm/network/configurators/ifcfg.py
index b896711..33bf5ed 100644
--- a/vdsm/network/configurators/ifcfg.py
+++ b/vdsm/network/configurators/ifcfg.py
@@ -44,7 +44,7 @@
from . import Configurator, dhclient, getEthtoolOpts, libvirt
from ..errors import ConfigNetworkError, ERR_FAILED_IFUP
from ..models import Nic, Bridge, IPv4, IPv6
-from ..sourceroute import StaticSourceRoute, DynamicSourceRoute
+from ..sourceroute import DynamicSourceRoute
import dsaversion # TODO: Make parent package import when vdsm is a package
NET_LOGICALNET_CONF_BACK_DIR = netinfo.NET_CONF_BACK_DIR + 'logicalnetworks/'
@@ -231,7 +231,7 @@
if set_mtu is not None:
ipwrapper.linkSet(nic.name, ['mtu', str(set_mtu)])
- def configureSourceRoute(self, source_route):
+ def _configure_source_route(self, source_route):
self.configApplier.write_source_route_file(
source_route.routes, 'route', source_route.device)
self.configApplier.write_source_route_file(
diff --git a/vdsm/network/configurators/iproute2.py b/vdsm/network/configurators/iproute2.py
index 5f58369..6c77764 100644
--- a/vdsm/network/configurators/iproute2.py
+++ b/vdsm/network/configurators/iproute2.py
@@ -199,7 +199,7 @@
self._setNewMtu(nic, netinfo.vlanDevsForIface(nic.name))
@staticmethod
- def configureSourceRoute(source_route):
+ def _configure_source_route(source_route):
try:
for route in source_route.routes:
routeAdd(route)
diff --git a/vdsm/network/sourceroute.py b/vdsm/network/sourceroute.py
index 9f6079d..86cd41c 100644
--- a/vdsm/network/sourceroute.py
+++ b/vdsm/network/sourceroute.py
@@ -34,7 +34,7 @@
TRACKED_INTERFACES_FOLDER = P_VDSM_RUN + 'trackedInterfaces'
-class StaticSourceRoute(object):
+class SourceRoute(object):
def __init__(self, device, ipv4=None):
self.device = device
self.ipv4 = ipv4 or IPv4()
@@ -80,7 +80,7 @@
return True
-class DynamicSourceRoute(StaticSourceRoute):
+class DynamicSourceRoute(SourceRoute):
@staticmethod
def getTrackingFilePath(device):
return os.path.join(TRACKED_INTERFACES_FOLDER, device)
diff --git a/vdsm/network/sourceroutethread.py b/vdsm/network/sourceroutethread.py
index b672d2c..ad423ed 100644
--- a/vdsm/network/sourceroutethread.py
+++ b/vdsm/network/sourceroutethread.py
@@ -52,9 +52,7 @@
except:
logging.exception('Invalid DHCP response')
else:
- source_route = DynamicSourceRoute(device, ipv4)
- source_route.prepare_configuration()
- configurator.configureSourceRoute(source_route)
+ configurator.configure_source_route(device, ipv4)
else:
configurator.remove_dynamic_source_route(device)
else:
--
To view, visit https://gerrit.ovirt.org/41614
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I44adf27199de412650885923097a1b40d27ef25b
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Ondřej Svoboda <osvoboda at redhat.com>
More information about the vdsm-patches
mailing list