Added VLAN configuration. (#35343)

Fixes GH 22147

Signed-off-by: Amol Kahat <akahat@redhat.com>
This commit is contained in:
Amol Kahat 2018-01-26 21:51:59 +05:30 committed by Adam Miller
parent 1f1e5c11a9
commit e8633b7a22
2 changed files with 98 additions and 3 deletions

View file

@ -1,9 +1,10 @@
# Copyright: (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
import pytest
import json
import pytest
from ansible.modules.net_tools import nmcli
pytestmark = pytest.mark.usefixtures('patch_ansible_module')
@ -118,6 +119,18 @@ TESTCASE_BRIDGE_SLAVE = [
}
]
TESTCASE_VLAN = [
{
'type': 'vlan',
'conn_name': 'non_existent_nw_device',
'ifname': 'vlan_not_exists',
'ip4': '10.10.10.10',
'gw4': '10.10.10.1',
'state': 'present',
'_ansible_check_mode': False,
}
]
def mocker_set(mocker, connection_exists=False):
"""
@ -360,3 +373,37 @@ def test_mod_bridge_slave(mocked_generic_connection_modify):
for param in ['bridge-port.path-cost', '100']:
assert param in args[0]
@pytest.mark.parametrize('patch_ansible_module', TESTCASE_VLAN, indirect=['patch_ansible_module'])
def test_create_vlan_con(mocked_generic_connection_create):
"""
Test if Bridge_slave 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]
for param in ['vlan']:
assert param in args[0]
@pytest.mark.parametrize('patch_ansible_module', TESTCASE_VLAN, indirect=['patch_ansible_module'])
def test_mod_vlan_conn(mocked_generic_connection_modify):
"""
Test if Bridge_slave 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]
for param in ['vlan.id']:
assert param in args[0]