|
Petr Šabata |
d9a596 |
#!/usr/bin/env python3
|
|
Petr Šabata |
d9a596 |
# SPDX-License-Identifier: LGPL-2.1+
|
|
Petr Šabata |
d9a596 |
# ~~~
|
|
Petr Šabata |
d9a596 |
# runtest.sh of /CoreOS/iproute/Sanity/ip-link-sanity-test
|
|
Petr Šabata |
d9a596 |
# Description: Test basic ip link funcionality
|
|
Petr Šabata |
d9a596 |
#
|
|
Petr Šabata |
d9a596 |
# Author: Susant Sahani <susant@redhat.com>
|
|
Petr Šabata |
d9a596 |
# Copyright (c) 2018 Red Hat, Inc.
|
|
Petr Šabata |
d9a596 |
# ~~~
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
import errno
|
|
Petr Šabata |
d9a596 |
import os
|
|
Petr Šabata |
d9a596 |
import sys
|
|
Petr Šabata |
d9a596 |
import time
|
|
Petr Šabata |
d9a596 |
import unittest
|
|
Petr Šabata |
d9a596 |
import subprocess
|
|
Petr Šabata |
d9a596 |
import signal
|
|
Petr Šabata |
d9a596 |
import shutil
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
def setUpModule():
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
if shutil.which('ip') is None:
|
|
Petr Šabata |
d9a596 |
raise OSError(errno.ENOENT, 'ip not found')
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
class IPLinkUtilities():
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
def read_attr(self, link, attribute):
|
|
Petr Šabata |
d9a596 |
"""Read a link attributed from the sysfs."""
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
with open(os.path.join('/sys/class/net', link, attribute)) as f:
|
|
Petr Šabata |
d9a596 |
return f.readline().strip()
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
def link_exists(self, link):
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
self.assertTrue(os.path.exists(os.path.join('/sys/class/net', link)))
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
class IPLinkSetDevTests(unittest.TestCase, IPLinkUtilities):
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
def setUp(self):
|
|
Petr Šabata |
d9a596 |
""" Setup """
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'add', 'dummy-test', 'type', 'dummy'])
|
|
Petr Šabata |
d9a596 |
self.link_exists('dummy-test')
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
def tearDown(self):
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'del', 'dummy-test'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
def test_set_dev_mtu(self):
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'set', 'dev', 'dummy-test', 'mtu', '9000'])
|
|
Petr Šabata |
d9a596 |
self.assertEqual('9000', self.read_attr('dummy-test', 'mtu'))
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
def test_set_dev_up_down(self):
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'set', 'dev', 'dummy-test', 'up'])
|
|
Petr Šabata |
d9a596 |
output=subprocess.check_output(['ip', 'link', 'show', 'dev', 'dummy-test']).rstrip().decode('utf-8')
|
|
Petr Šabata |
d9a596 |
self.assertRegex(output, 'UP,LOWER_UP')
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'set', 'dev', 'dummy-test', 'down'])
|
|
Petr Šabata |
d9a596 |
output=subprocess.check_output(['ip', 'link', 'show', 'dev', 'dummy-test']).rstrip().decode('utf-8')
|
|
Petr Šabata |
d9a596 |
self.assertNotRegex(output, 'UP,LOWER_UP')
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
def test_set_dev_address(self):
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'set', 'dev', 'dummy-test', 'address', '02:01:02:03:04:08'])
|
|
Petr Šabata |
d9a596 |
output=subprocess.check_output(['ip', 'link', 'show', 'dev', 'dummy-test']).rstrip().decode('utf-8')
|
|
Petr Šabata |
d9a596 |
self.assertRegex(output, 'link/ether 02:01:02:03:04:08')
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
def test_set_dev_alias(self):
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'set', 'dev', 'dummy-test', 'alias', 'test-test'])
|
|
Petr Šabata |
d9a596 |
output=subprocess.check_output(['ip', 'link', 'show', 'dev', 'dummy-test']).rstrip().decode('utf-8')
|
|
Petr Šabata |
d9a596 |
self.assertRegex(output, 'test-test')
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
def test_set_dev_name(self):
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'set', 'dev', 'dummy-test', 'name', 'test-test'])
|
|
Petr Šabata |
d9a596 |
output=subprocess.check_output(['ip', 'link', 'show', 'dev', 'test-test']).rstrip().decode('utf-8')
|
|
Petr Šabata |
d9a596 |
self.assertRegex(output, 'test-test')
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'set', 'dev', 'test-test', 'name', 'dummy-test'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
def test_set_dev_multicast(self):
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'set', 'dev', 'dummy-test', 'multicast', 'on'])
|
|
Petr Šabata |
d9a596 |
output=subprocess.check_output(['ip', 'link', 'show', 'dev', 'dummy-test']).rstrip().decode('utf-8')
|
|
Petr Šabata |
d9a596 |
self.assertRegex(output, 'MULTICAST')
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
def test_set_dev_all_multicast(self):
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'set', 'dev', 'dummy-test', 'allmulticast', 'on'])
|
|
Petr Šabata |
d9a596 |
output=subprocess.check_output(['ip', 'link', 'show', 'dev', 'dummy-test']).rstrip().decode('utf-8')
|
|
Petr Šabata |
d9a596 |
self.assertRegex(output, 'ALLMULTI')
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
class IPLinkKindTests(unittest.TestCase, IPLinkUtilities):
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
def setUp(self):
|
|
Petr Šabata |
d9a596 |
""" Setup """
|
|
Petr Šabata |
d9a596 |
pass
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
def tearDown(self):
|
|
Petr Šabata |
d9a596 |
pass
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
def test_add_veth_pair(self):
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'add', 'veth-test', 'type', 'veth', 'peer', 'name', 'veth-peer-test'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
self.link_exists('veth-test')
|
|
Petr Šabata |
d9a596 |
self.link_exists('veth-peer-test')
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'del', 'veth-test'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
def test_add_dummy(self):
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'add', 'dummy-test', 'type', 'dummy'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
self.link_exists('dummy-test')
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'del', 'dummy-test'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
def test_add_vcan(self):
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'add', 'vcan-test', 'type', 'vcan'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
self.link_exists('vcan-test')
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'del', 'vcan-test'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
def test_add_vxcan(self):
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'add', 'vxcan-test', 'type', 'vxcan'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
self.link_exists('vxcan-test')
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'del', 'vxcan-test'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
def test_add_vlan(self):
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'add', 'dummy-test', 'type', 'dummy'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
self.link_exists('dummy-test')
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'add', 'link', 'dummy-test', 'name', 'vlantest.100', 'type', 'vlan', 'id', '100'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
self.link_exists('vlantest.100')
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'del', 'vlantest.100'])
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'del', 'dummy-test'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
def test_add_macvlan(self):
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'add', 'dummy-test', 'type', 'dummy'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
self.link_exists('dummy-test')
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'add', 'link', 'dummy-test', 'macvlan-test', 'type', 'macvlan', 'mode', 'bridge'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
self.link_exists('macvlan-test')
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'del', 'macvlan-test'])
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'del', 'dummy-test'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
def test_add_macvtap(self):
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'add', 'dummy-test', 'type', 'dummy'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
self.link_exists('dummy-test')
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'add', 'link', 'dummy-test', 'macvtap-test', 'type', 'macvtap', 'mode', 'bridge'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
self.link_exists('macvtap-test')
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'del', 'macvtap-test'])
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'del', 'dummy-test'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
def test_add_bridge(self):
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'add', 'bridge-test', 'type', 'bridge'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
self.link_exists('bridge-test')
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'del', 'bridge-test'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
def test_add_bond(self):
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'add', 'bond-test', 'type', 'bond'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
self.link_exists('bond-test')
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'del', 'bond-test'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
def test_add_team(self):
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'add', 'team-test', 'type', 'team'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
self.link_exists('team-test')
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'del', 'team-test'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
def test_add_ipip_tunnel(self):
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'tunnel', 'add', 'test-ipiptun', 'mode', 'ipip', 'remote', '10.3.3.3', 'local', '10.4.4.4', 'ttl' ,'64'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
self.link_exists('test-ipiptun')
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'del', 'test-ipiptun'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
def test_add_gre_tunnel(self):
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'tunnel', 'add', 'test-gretun', 'mode', 'gre', 'remote', '10.3.3.3', 'local', '10.4.4.4', 'ttl' ,'64'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
self.link_exists('test-gretun')
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'del', 'test-gretun'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
def test_add_gretap_tunnel(self):
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'add', 'test-gretap', 'type', 'gretap', 'remote', '10.3.3.3', 'local', '10.4.4.4'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
self.link_exists('test-gretap')
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'del', 'test-gretap'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
def test_add_ip6gre_tunnel(self):
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'add', 'test-ip6gre', 'type', 'ip6gre', 'remote', '2a00:ffde:4567:edde::4987', 'local', '2001:473:fece:cafe::5179'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
self.link_exists('test-ip6gre')
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'del', 'test-ip6gre'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
def test_add_ip6gretap_tunnel(self):
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'add', 'test-ip6gretap', 'type', 'ip6gretap', 'remote', '2a00:ffde:4567:edde::4987', 'local', '2001:473:fece:cafe::5179'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
self.link_exists('test-ip6gretap')
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'del', 'test-ip6gretap'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
def test_add_erspan_tunnel(self):
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'add', 'dev', 'test-erspan', 'type', 'erspan', 'seq', 'key', '100','erspan', '123', 'remote', '10.3.3.3', 'local', '10.4.4.4'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
self.link_exists('test-erspan')
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'del', 'test-erspan'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
def test_add_ip6erspan_tunnel(self):
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'add', 'dev', 'test-ip6erspan', 'type', 'erspan', 'seq', 'key', '101','erspan', '1234', 'remote', '10.3.3.3', 'local', '10.4.4.4'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
self.link_exists('test-ip6erspan')
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'del', 'test-ip6erspan'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
def test_add_sit_tunnel(self):
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'tunnel', 'add', 'test-sittun', 'mode', 'sit', 'remote', '10.3.3.3', 'local', '10.4.4.4', 'ttl' ,'64'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
self.link_exists('test-sittun')
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'del', 'test-sittun'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
def test_add_vti_tunnel(self):
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'add', 'dev', 'test-vtitun', 'type', 'vti', 'remote', '10.3.3.3', 'local', '10.4.4.4'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
self.link_exists('test-vtitun')
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'del', 'test-vtitun'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
def test_add_geneve_tunnel(self):
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'add', 'dev', 'test-geneve-tun', 'type', 'geneve', 'remote', '10.3.3.3', 'vni', '1234'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
self.link_exists('test-geneve-tun')
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'del', 'test-geneve-tun'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
def test_add_ipvlan(self):
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'add', 'dummy-test', 'type', 'dummy'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
self.link_exists('dummy-test')
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'add', 'link', 'dummy-test', 'name', 'test-ipvlan', 'type', 'ipvlan'])
|
|
Petr Šabata |
d9a596 |
self.link_exists('test-ipvlan')
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'del', 'test-ipvlan'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'add', 'link', 'dummy-test', 'name', 'test-ipvlan', 'type', 'ipvlan','mode', 'l2', 'bridge'])
|
|
Petr Šabata |
d9a596 |
self.link_exists('test-ipvlan')
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'del', 'test-ipvlan'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'add', 'link', 'dummy-test', 'name', 'test-ipvlan', 'type', 'ipvlan','mode', 'l2', 'private'])
|
|
Petr Šabata |
d9a596 |
self.link_exists('test-ipvlan')
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'del', 'test-ipvlan'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'add', 'link', 'dummy-test', 'name', 'test-ipvlan', 'type', 'ipvlan','mode', 'l2', 'vepa'])
|
|
Petr Šabata |
d9a596 |
self.link_exists('test-ipvlan')
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'del', 'test-ipvlan'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'del', 'dummy-test'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
def test_add_vxlan(self):
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'add', 'dummy-test', 'type', 'dummy'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
self.link_exists('dummy-test')
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'add', 'vxlan-test', 'type', 'vxlan', 'id', '42', 'group', '239.1.1.1', 'dev', 'dummy-test' ,'dstport', '4789'])
|
|
Petr Šabata |
d9a596 |
self.link_exists('vxlan-test')
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'del', 'vxlan-test'])
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'del', 'dummy-test'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
def test_add_vrf(self):
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'add', 'vrf-test', 'type', 'vrf', 'table', '10'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
self.link_exists('vrf-test')
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'del', 'vrf-test'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
def test_add_macsec(self):
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'add', 'dummy-test', 'type', 'dummy'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
self.link_exists('dummy-test')
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'add', 'link', 'dummy-test', 'test-macsec', 'type', 'macsec'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
self.link_exists('test-macsec')
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'macsec', 'add', 'test-macsec', 'tx', 'sa', '0', 'pn', '1', 'on', 'key', '02', '09876543210987654321098765432109'])
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'macsec', 'add', 'test-macsec', 'rx', 'address', '56:68:a5:c2:4c:14', 'port', '1'])
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'macsec', 'add', 'test-macsec', 'rx', 'address', '56:68:a5:c2:4c:14', 'port', '1', 'sa', '0', 'pn', '1', 'on', 'key', '01', '12345678901234567890123456789012'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'del', 'test-macsec'])
|
|
Petr Šabata |
d9a596 |
subprocess.check_output(['ip', 'link', 'del', 'dummy-test'])
|
|
Petr Šabata |
d9a596 |
|
|
Petr Šabata |
d9a596 |
if __name__ == '__main__':
|
|
Petr Šabata |
d9a596 |
unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout,
|
|
Petr Šabata |
d9a596 |
verbosity=2))
|