nmcli: Introduce SIT Tunnel (#45937)

This work enables to add sit tunnel via nmcli module

Signed-off-by: Susant Sahani susant@redhat.com

SUMMARY
ISSUE TYPE
Feature Pull Request
COMPONENT NAME
nmcli

ANSIBLE VERSION
2.8
ADDITIONAL INFORMATION
  - nmcli:
       state: present
       type: sit
       conn_name: sit_test1
       autoconnect: yes
       ip_tunnel_dev: enp0s8
       ip_tunnel_local: 192.168.1.2
       ip_tunnel_remote: 192.168.1.5
This commit is contained in:
Susant Sahani 2018-12-13 09:36:09 +05:30 committed by ansibot
parent 190d1ed7f1
commit 59dcf3f277
2 changed files with 137 additions and 6 deletions

View file

@ -64,7 +64,12 @@ TESTCASE_CONNECTION = [
'state': 'absent',
'_ansible_check_mode': True,
},
{
'type': 'sit',
'conn_name': 'non_existent_nw_device',
'state': 'absent',
'_ansible_check_mode': True,
},
]
TESTCASE_GENERIC = [
@ -170,6 +175,19 @@ TESTCASE_IPIP = [
}
]
TESTCASE_SIT = [
{
'type': 'sit',
'conn_name': 'non_existent_nw_device',
'ifname': 'sit-existent_nw_device',
'ip_tunnel_dev': 'non_existent_sit_device',
'ip_tunnel_local': '192.168.225.5',
'ip_tunnel_remote': '192.168.225.6',
'state': 'present',
'_ansible_check_mode': False,
}
]
TESTCASE_ETHERNET_DHCP = [
{
'type': 'ethernet',
@ -571,6 +589,57 @@ def test_ipip_mod(mocked_generic_connection_modify):
assert param in args[0]
@pytest.mark.parametrize('patch_ansible_module', TESTCASE_SIT, indirect=['patch_ansible_module'])
def test_create_sit(mocked_generic_connection_create):
"""
Test if sit created
"""
with pytest.raises(SystemExit):
nmcli.main()
assert nmcli.Nmcli.execute_command.call_count == 1
arg_list = nmcli.Nmcli.execute_command.call_args_list
args, kwargs = arg_list[0]
assert args[0][0] == '/usr/bin/nmcli'
assert args[0][1] == 'con'
assert args[0][2] == 'add'
assert args[0][3] == 'type'
assert args[0][4] == 'ip-tunnel'
assert args[0][5] == 'mode'
assert args[0][6] == 'sit'
assert args[0][7] == 'con-name'
assert args[0][8] == 'non_existent_nw_device'
assert args[0][9] == 'ifname'
assert args[0][10] == 'sit-existent_nw_device'
assert args[0][11] == 'dev'
assert args[0][12] == 'non_existent_sit_device'
for param in ['ip-tunnel.local', '192.168.225.5', 'ip-tunnel.remote', '192.168.225.6']:
assert param in args[0]
@pytest.mark.parametrize('patch_ansible_module', TESTCASE_SIT, indirect=['patch_ansible_module'])
def test_sit_mod(mocked_generic_connection_modify):
"""
Test if sit modified
"""
with pytest.raises(SystemExit):
nmcli.main()
assert nmcli.Nmcli.execute_command.call_count == 1
arg_list = nmcli.Nmcli.execute_command.call_args_list
args, kwargs = arg_list[0]
assert args[0][0] == '/usr/bin/nmcli'
assert args[0][1] == 'con'
assert args[0][2] == 'mod'
assert args[0][3] == 'non_existent_nw_device'
for param in ['ip-tunnel.local', '192.168.225.5', 'ip-tunnel.remote', '192.168.225.6']:
assert param in args[0]
@pytest.mark.parametrize('patch_ansible_module', TESTCASE_ETHERNET_DHCP, indirect=['patch_ansible_module'])
def test_eth_dhcp_client_id_con_create(mocked_generic_connection_create):
"""