diff options
| author | Donald Sharp <sharpd@cumulusnetworks.com> | 2018-12-17 10:33:37 -0500 |
|---|---|---|
| committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2018-12-17 10:33:37 -0500 |
| commit | 7cc96035a73e66f110116ef7cde1b1717b694911 (patch) | |
| tree | 90b460fa91901447ae0a032e4cef469f63d308ca /tests/topotests/lib/topotest.py | |
| parent | b31c2a2ebf46dbffe9376b7c37e3d419a072b9dd (diff) | |
topotests: Make 'LinuxRouter' a class of 'Router'
Modify the LinuxRouter code such that it inherits from the
Router class. This is setup work for (a) pulling out linux
specific config from class Router and (b) creating a FreebsdRouter
that inherits from class 'Router'.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'tests/topotests/lib/topotest.py')
| -rw-r--r-- | tests/topotests/lib/topotest.py | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/tests/topotests/lib/topotest.py b/tests/topotests/lib/topotest.py index c7f405fac2..101f1776aa 100644 --- a/tests/topotests/lib/topotest.py +++ b/tests/topotests/lib/topotest.py @@ -581,7 +581,7 @@ def addRouter(topo, name): '/var/run/frr', '/var/run/quagga', '/var/log'] - return topo.addNode(name, cls=Router, privateDirs=MyPrivateDirs) + return topo.addNode(name, cls=LinuxRouter, privateDirs=MyPrivateDirs) def set_sysctl(node, sysctl, value): "Set a sysctl value and return None on success or an error string" @@ -603,21 +603,6 @@ def assert_sysctl(node, sysctl, value): "Set and assert that the sysctl is set with the specified value." assert set_sysctl(node, sysctl, value) is None -class LinuxRouter(Node): - "A Node with IPv4/IPv6 forwarding enabled." - - def config(self, **params): - super(LinuxRouter, self).config(**params) - # Enable forwarding on the router - assert_sysctl(self, 'net.ipv4.ip_forward', 1) - assert_sysctl(self, 'net.ipv6.conf.all.forwarding', 1) - def terminate(self): - """ - Terminate generic LinuxRouter Mininet instance - """ - set_sysctl(self, 'net.ipv4.ip_forward', 0) - set_sysctl(self, 'net.ipv6.conf.all.forwarding', 0) - super(LinuxRouter, self).terminate() class Router(Node): "A Node with IPv4/IPv6 forwarding enabled and Quagga as Routing Engine" @@ -1084,6 +1069,24 @@ class Router(Node): if leakfound: leakfile.close() +class LinuxRouter(Router): + "A Node with IPv4/IPv6 forwarding enabled." + + def __init__(self, name, **params): + Router.__init__(self, name, **params) + + def config(self, **params): + Router.config(self, **params) + # Enable forwarding on the router + assert_sysctl(self, 'net.ipv4.ip_forward', 1) + assert_sysctl(self, 'net.ipv6.conf.all.forwarding', 1) + def terminate(self): + """ + Terminate generic LinuxRouter Mininet instance + """ + set_sysctl(self, 'net.ipv4.ip_forward', 0) + set_sysctl(self, 'net.ipv6.conf.all.forwarding', 0) + Router.terminate(self) class LegacySwitch(OVSSwitch): "A Legacy Switch without OpenFlow" |
