summaryrefslogtreecommitdiff
path: root/lib/ansible/module_utils/network
diff options
context:
space:
mode:
authorMikhail Yohman <mikhail.yohman@gmail.com>2020-02-18 23:53:59 -0700
committerGitHub <noreply@github.com>2020-02-19 12:23:59 +0530
commitcceb517aff5775cf8acf06453998a1120f66efd6 (patch)
treeeeeb0f45ad4341c7e4813285063dc91eb4477298 /lib/ansible/module_utils/network
parente632d9337120efaa0adaf791f8e6ec9107ff6dbc (diff)
downloadansible-cceb517aff5775cf8acf06453998a1120f66efd6.tar.gz
IOS: Add voice vlan to ios_l2_interfaces (#67211)
* Add voice vlan to ios_l2_interfaces * Fixed pep8 issues, added voice vlan to tests, updated module docs
Diffstat (limited to 'lib/ansible/module_utils/network')
-rw-r--r--lib/ansible/module_utils/network/ios/argspec/l2_interfaces/l2_interfaces.py3
-rw-r--r--lib/ansible/module_utils/network/ios/config/l2_interfaces/l2_interfaces.py11
-rw-r--r--lib/ansible/module_utils/network/ios/facts/l2_interfaces/l2_interfaces.py4
3 files changed, 18 insertions, 0 deletions
diff --git a/lib/ansible/module_utils/network/ios/argspec/l2_interfaces/l2_interfaces.py b/lib/ansible/module_utils/network/ios/argspec/l2_interfaces/l2_interfaces.py
index 6d7e406107..0c25758a91 100644
--- a/lib/ansible/module_utils/network/ios/argspec/l2_interfaces/l2_interfaces.py
+++ b/lib/ansible/module_utils/network/ios/argspec/l2_interfaces/l2_interfaces.py
@@ -39,6 +39,9 @@ class L2_InterfacesArgs(object):
'access': {'type': 'dict',
'options': {'vlan': {'type': 'int'}}
},
+ 'voice': {'type': 'dict',
+ 'options': {'vlan': {'type': 'int'}}
+ },
'trunk': {'type': 'dict',
'options': {'allowed_vlans': {'type': 'list'},
'encapsulation': {'type': 'str',
diff --git a/lib/ansible/module_utils/network/ios/config/l2_interfaces/l2_interfaces.py b/lib/ansible/module_utils/network/ios/config/l2_interfaces/l2_interfaces.py
index ec96aef13f..552d2974bb 100644
--- a/lib/ansible/module_utils/network/ios/config/l2_interfaces/l2_interfaces.py
+++ b/lib/ansible/module_utils/network/ios/config/l2_interfaces/l2_interfaces.py
@@ -36,6 +36,7 @@ class L2_Interfaces(ConfigBase):
]
access_cmds = {'access_vlan': 'switchport access vlan'}
+ voice_cmds = {'voice_vlan': 'switchport voice vlan'}
trunk_cmds = {'encapsulation': 'switchport trunk encapsulation', 'pruning_vlans': 'switchport trunk pruning vlan',
'native_vlan': 'switchport trunk native vlan', 'allowed_vlans': 'switchport trunk allowed vlan'}
@@ -250,6 +251,10 @@ class L2_Interfaces(ConfigBase):
cmd = 'switchport access vlan {0}'.format(diff.get('access')[0][1])
add_command_to_config_list(interface, cmd, commands)
+ if diff.get('voice'):
+ cmd = 'switchport voice vlan {0}'.format(diff.get('voice')[0][1])
+ add_command_to_config_list(interface, cmd, commands)
+
if want_trunk:
if diff.get('trunk'):
diff = dict(diff.get('trunk'))
@@ -287,6 +292,12 @@ class L2_Interfaces(ConfigBase):
if have.get('access').get('vlan') != want.get('access').get('vlan'):
remove_command_from_config_list(interface, L2_Interfaces.access_cmds['access_vlan'], commands)
+ if have.get('voice') and want.get('voice') is None:
+ remove_command_from_config_list(interface, L2_Interfaces.voice_cmds['voice_vlan'], commands)
+ elif have.get('voice') and want.get('voice'):
+ if have.get('voice').get('vlan') != want.get('voice').get('vlan'):
+ remove_command_from_config_list(interface, L2_Interfaces.voice_cmds['voice_vlan'], commands)
+
if have.get('trunk') and want.get('trunk') is None:
# Check when no config is passed
if have.get('trunk').get('encapsulation'):
diff --git a/lib/ansible/module_utils/network/ios/facts/l2_interfaces/l2_interfaces.py b/lib/ansible/module_utils/network/ios/facts/l2_interfaces/l2_interfaces.py
index bddb273bad..27a3b03dca 100644
--- a/lib/ansible/module_utils/network/ios/facts/l2_interfaces/l2_interfaces.py
+++ b/lib/ansible/module_utils/network/ios/facts/l2_interfaces/l2_interfaces.py
@@ -91,6 +91,10 @@ class L2_InterfacesFacts(object):
if has_access:
config["access"] = {"vlan": int(has_access)}
+ has_voice = utils.parse_conf_arg(conf, 'switchport voice vlan')
+ if has_voice:
+ config["voice"] = {"vlan": int(has_voice)}
+
trunk = dict()
trunk["encapsulation"] = utils.parse_conf_arg(conf, 'encapsulation')
native_vlan = utils.parse_conf_arg(conf, 'native vlan')