| 1 |
#!/usr/bin/python |
| 2 |
# -*- coding: utf-8 -*- |
| 3 |
|
| 4 |
# Copyright (c) 2021, Cisco Systems |
| 5 |
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) |
| 6 |
|
| 7 |
DOCUMENTATION = r""" |
| 8 |
module: devices_switch_ports |
| 9 |
short_description: Resource module for devices _switch _ports |
| 10 |
description: |
| 11 |
- Manage operation update of the resource devices _switch _ports. |
| 12 |
- Update a switch port. |
| 13 |
version_added: '1.0.0' |
| 14 |
extends_documentation_fragment: |
| 15 |
- cisco.meraki.module |
| 16 |
author: Francisco Munoz (@fmunoz) |
| 17 |
options: |
| 18 |
accessPolicyNumber: |
| 19 |
description: The number of a custom access policy to configure on the switch port. |
| 20 |
Only applicable when 'accessPolicyType' is 'Custom access policy'. |
| 21 |
type: int |
| 22 |
accessPolicyType: |
| 23 |
description: The type of the access policy of the switch port. Only applicable |
| 24 |
to access ports. Can be one of 'Open', 'Custom access policy', 'MAC allow list' |
| 25 |
or 'Sticky MAC allow list'. |
| 26 |
type: str |
| 27 |
adaptivePolicyGroupId: |
| 28 |
description: The adaptive policy group ID that will be used to tag traffic through |
| 29 |
this switch port. This ID must pre-exist during the configuration, else needs |
| 30 |
to be created using adaptivePolicy/groups API. Cannot be applied to a port on |
| 31 |
a switch bound to profile. |
| 32 |
type: str |
| 33 |
allowedVlans: |
| 34 |
description: The VLANs allowed on the switch port. Only applicable to trunk ports. |
| 35 |
type: str |
| 36 |
daiTrusted: |
| 37 |
description: If true, ARP packets for this port will be considered trusted, and |
| 38 |
Dynamic ARP Inspection will allow the traffic. |
| 39 |
type: bool |
| 40 |
dot3az: |
| 41 |
description: Dot3az settings for the port. |
| 42 |
suboptions: |
| 43 |
enabled: |
| 44 |
description: The Energy Efficient Ethernet status of the switch port. |
| 45 |
type: bool |
| 46 |
type: dict |
| 47 |
enabled: |
| 48 |
description: The status of the switch port. |
| 49 |
type: bool |
| 50 |
flexibleStackingEnabled: |
| 51 |
description: For supported switches (e.g. MS420/MS425), whether or not the port |
| 52 |
has flexible stacking enabled. |
| 53 |
type: bool |
| 54 |
highSpeed: |
| 55 |
description: High speed port enablement settings for C9500-32QC. |
| 56 |
suboptions: |
| 57 |
enabled: |
| 58 |
description: For C9500-32QC, whether or not the port is enabled for high speed. |
| 59 |
type: bool |
| 60 |
type: dict |
| 61 |
isolationEnabled: |
| 62 |
description: The isolation status of the switch port. |
| 63 |
type: bool |
| 64 |
linkNegotiation: |
| 65 |
description: The link speed for the switch port. |
| 66 |
type: str |
| 67 |
macAllowList: |
| 68 |
description: Only devices with MAC addresses specified in this list will have |
| 69 |
access to this port. Up to 20 MAC addresses can be defined. Only applicable |
| 70 |
when 'accessPolicyType' is 'MAC allow list'. |
| 71 |
elements: str |
| 72 |
type: list |
| 73 |
macWhitelistLimit: |
| 74 |
description: The maximum number of MAC addresses for regular MAC allow list. Only |
| 75 |
applicable when 'accessPolicyType' is 'MAC allow list'. Note Config only supported |
| 76 |
on verions greater than ms18 only for classic switches. |
| 77 |
type: int |
| 78 |
name: |
| 79 |
description: The name of the switch port. |
| 80 |
type: str |
| 81 |
peerSgtCapable: |
| 82 |
description: If true, Peer SGT is enabled for traffic through this switch port. |
| 83 |
Applicable to trunk port only, not access port. Cannot be applied to a port |
| 84 |
on a switch bound to profile. |
| 85 |
type: bool |
| 86 |
poeEnabled: |
| 87 |
description: The PoE status of the switch port. |
| 88 |
type: bool |
| 89 |
portId: |
| 90 |
description: PortId path parameter. Port ID. |
| 91 |
type: str |
| 92 |
portScheduleId: |
| 93 |
description: The ID of the port schedule. A value of null will clear the port |
| 94 |
schedule. |
| 95 |
type: str |
| 96 |
profile: |
| 97 |
description: Profile attributes. |
| 98 |
suboptions: |
| 99 |
enabled: |
| 100 |
description: When enabled, override this port's configuration with a port |
| 101 |
profile. |
| 102 |
type: bool |
| 103 |
id: |
| 104 |
description: When enabled, the ID of the port profile used to override the |
| 105 |
port's configuration. |
| 106 |
type: str |
| 107 |
iname: |
| 108 |
description: When enabled, the IName of the profile. |
| 109 |
type: str |
| 110 |
type: dict |
| 111 |
rstpEnabled: |
| 112 |
description: The rapid spanning tree protocol status. |
| 113 |
type: bool |
| 114 |
serial: |
| 115 |
description: Serial path parameter. |
| 116 |
type: str |
| 117 |
stickyMacAllowList: |
| 118 |
description: The initial list of MAC addresses for sticky Mac allow list. Only |
| 119 |
applicable when 'accessPolicyType' is 'Sticky MAC allow list'. |
| 120 |
elements: str |
| 121 |
type: list |
| 122 |
stickyMacAllowListLimit: |
| 123 |
description: The maximum number of MAC addresses for sticky MAC allow list. Only |
| 124 |
applicable when 'accessPolicyType' is 'Sticky MAC allow list'. |
| 125 |
type: int |
| 126 |
stormControlEnabled: |
| 127 |
description: The storm control status of the switch port. |
| 128 |
type: bool |
| 129 |
stpGuard: |
| 130 |
description: The state of the STP guard ('disabled', 'root guard', 'bpdu guard' |
| 131 |
or 'loop guard'). |
| 132 |
type: str |
| 133 |
stpPortFastTrunk: |
| 134 |
description: The state of STP PortFast Trunk on the switch port. |
| 135 |
type: bool |
| 136 |
tags: |
| 137 |
description: The list of tags of the switch port. |
| 138 |
elements: str |
| 139 |
type: list |
| 140 |
type: |
| 141 |
description: The type of the switch port ('access', 'trunk', 'stack', 'routed', |
| 142 |
'svl' or 'dad'). |
| 143 |
type: str |
| 144 |
udld: |
| 145 |
description: The action to take when Unidirectional Link is detected (Alert only, |
| 146 |
Enforce). Default configuration is Alert only. |
| 147 |
type: str |
| 148 |
vlan: |
| 149 |
description: The VLAN of the switch port. For a trunk port, this is the native |
| 150 |
VLAN. A null value will clear the value set for trunk ports. |
| 151 |
type: int |
| 152 |
voiceVlan: |
| 153 |
description: The voice VLAN of the switch port. Only applicable to access ports. |
| 154 |
type: int |
| 155 |
requirements: |
| 156 |
- meraki >= 2.4.9 |
| 157 |
- python >= 3.5 |
| 158 |
seealso: |
| 159 |
- name: Cisco Meraki documentation for switch updateDeviceSwitchPort |
| 160 |
description: Complete reference of the updateDeviceSwitchPort API. |
| 161 |
link: https://developer.cisco.com/meraki/api-v1/#!update-device-switch-port |
| 162 |
notes: |
| 163 |
- SDK Method used are |
| 164 |
switch.Switch.update_device_switch_port, |
| 165 |
- Paths used are |
| 166 |
put /devices/{serial}/switch/ports/{portId}, |
| 167 |
""" |
| 168 |
|
| 169 |
EXAMPLES = r""" |
| 170 |
- name: Update by id |
| 171 |
cisco.meraki.devices_switch_ports: |
| 172 |
meraki_api_key: "{{ meraki_api_key }}" |
| 173 |
meraki_base_url: "{{ meraki_base_url }}" |
| 174 |
meraki_single_request_timeout: "{{ meraki_single_request_timeout }}" |
| 175 |
meraki_certificate_path: "{{ meraki_certificate_path }}" |
| 176 |
meraki_requests_proxy: "{{ meraki_requests_proxy }}" |
| 177 |
meraki_wait_on_rate_limit: "{{ meraki_wait_on_rate_limit }}" |
| 178 |
meraki_nginx_429_retry_wait_time: "{{ meraki_nginx_429_retry_wait_time }}" |
| 179 |
meraki_action_batch_retry_wait_time: "{{ meraki_action_batch_retry_wait_time }}" |
| 180 |
meraki_retry_4xx_error: "{{ meraki_retry_4xx_error }}" |
| 181 |
meraki_retry_4xx_error_wait_time: "{{ meraki_retry_4xx_error_wait_time }}" |
| 182 |
meraki_maximum_retries: "{{ meraki_maximum_retries }}" |
| 183 |
meraki_output_log: "{{ meraki_output_log }}" |
| 184 |
meraki_log_file_prefix: "{{ meraki_log_file_prefix }}" |
| 185 |
meraki_log_path: "{{ meraki_log_path }}" |
| 186 |
meraki_print_console: "{{ meraki_print_console }}" |
| 187 |
meraki_suppress_logging: "{{ meraki_suppress_logging }}" |
| 188 |
meraki_simulate: "{{ meraki_simulate }}" |
| 189 |
meraki_be_geo_id: "{{ meraki_be_geo_id }}" |
| 190 |
meraki_caller: "{{ meraki_caller }}" |
| 191 |
meraki_use_iterator_for_get_pages: "{{ meraki_use_iterator_for_get_pages }}" |
| 192 |
meraki_inherit_logging_config: "{{ meraki_inherit_logging_config }}" |
| 193 |
state: present |
| 194 |
accessPolicyNumber: 2 |
| 195 |
accessPolicyType: Sticky MAC allow list |
| 196 |
adaptivePolicyGroupId: '123' |
| 197 |
allowedVlans: 1,3,5-10 |
| 198 |
daiTrusted: false |
| 199 |
dot3az: |
| 200 |
enabled: false |
| 201 |
enabled: true |
| 202 |
flexibleStackingEnabled: true |
| 203 |
highSpeed: |
| 204 |
enabled: false |
| 205 |
isolationEnabled: false |
| 206 |
linkNegotiation: Auto negotiate |
| 207 |
macAllowList: |
| 208 |
- 34:56:fe:ce:8e:a0 |
| 209 |
- 34:56:fe:ce:8e:a1 |
| 210 |
macWhitelistLimit: 10 |
| 211 |
name: My switch port |
| 212 |
peerSgtCapable: false |
| 213 |
poeEnabled: true |
| 214 |
portId: string |
| 215 |
portScheduleId: '1234' |
| 216 |
profile: |
| 217 |
enabled: false |
| 218 |
id: '1284392014819' |
| 219 |
iname: iname |
| 220 |
rstpEnabled: true |
| 221 |
serial: string |
| 222 |
stickyMacAllowList: |
| 223 |
- 34:56:fe:ce:8e:b0 |
| 224 |
- 34:56:fe:ce:8e:b1 |
| 225 |
stickyMacAllowListLimit: 5 |
| 226 |
stormControlEnabled: true |
| 227 |
stpGuard: disabled |
| 228 |
stpPortFastTrunk: false |
| 229 |
tags: |
| 230 |
- tag1 |
| 231 |
- tag2 |
| 232 |
type: access |
| 233 |
udld: Alert only |
| 234 |
vlan: 10 |
| 235 |
voiceVlan: 20 |
| 236 |
""" |
| 237 |
RETURN = r""" |
| 238 |
meraki_response: |
| 239 |
description: A dictionary or list with the response returned by the Cisco Meraki Python SDK |
| 240 |
returned: always |
| 241 |
type: dict |
| 242 |
sample: > |
| 243 |
{ |
| 244 |
"portId": "string", |
| 245 |
"name": "string", |
| 246 |
"tags": [ |
| 247 |
"string" |
| 248 |
], |
| 249 |
"enabled": true, |
| 250 |
"poeEnabled": true, |
| 251 |
"type": "string", |
| 252 |
"vlan": 0, |
| 253 |
"voiceVlan": 0, |
| 254 |
"allowedVlans": "string", |
| 255 |
"isolationEnabled": true, |
| 256 |
"rstpEnabled": true, |
| 257 |
"stpGuard": "string", |
| 258 |
"stpPortFastTrunk": true, |
| 259 |
"linkNegotiation": "string", |
| 260 |
"linkNegotiationCapabilities": [ |
| 261 |
"string" |
| 262 |
], |
| 263 |
"portScheduleId": "string", |
| 264 |
"schedule": { |
| 265 |
"id": "string", |
| 266 |
"name": "string" |
| 267 |
}, |
| 268 |
"udld": "string", |
| 269 |
"accessPolicyType": "string", |
| 270 |
"accessPolicyNumber": 0, |
| 271 |
"macAllowList": [ |
| 272 |
"string" |
| 273 |
], |
| 274 |
"macWhitelistLimit": 0, |
| 275 |
"stickyMacAllowList": [ |
| 276 |
"string" |
| 277 |
], |
| 278 |
"stickyMacAllowListLimit": 0, |
| 279 |
"stormControlEnabled": true, |
| 280 |
"adaptivePolicyGroupId": "string", |
| 281 |
"adaptivePolicyGroup": { |
| 282 |
"id": "string", |
| 283 |
"name": "string" |
| 284 |
}, |
| 285 |
"peerSgtCapable": true, |
| 286 |
"flexibleStackingEnabled": true, |
| 287 |
"daiTrusted": true, |
| 288 |
"profile": { |
| 289 |
"enabled": true, |
| 290 |
"id": "string", |
| 291 |
"iname": "string" |
| 292 |
}, |
| 293 |
"module": { |
| 294 |
"model": "string", |
| 295 |
"serial": "string", |
| 296 |
"slot": 0 |
| 297 |
}, |
| 298 |
"mirror": { |
| 299 |
"mode": "string" |
| 300 |
}, |
| 301 |
"dot3az": { |
| 302 |
"enabled": true |
| 303 |
}, |
| 304 |
"highSpeed": { |
| 305 |
"enabled": true |
| 306 |
} |
| 307 |
} |
| 308 |
""" |