| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
from __future__ import absolute_import, division, print_function |
| 8 |
__metaclass__ = type |
| 9 |
|
| 10 |
ANSIBLE_METADATA = { |
| 11 |
'metadata_version': '1.1', |
| 12 |
"status": ['deprecated'], |
| 13 |
'supported_by': 'community' |
| 14 |
} |
| 15 |
|
| 16 |
DOCUMENTATION = r''' |
| 17 |
--- |
| 18 |
module: meraki_mr_rf_profile |
| 19 |
short_description: Manage RF profiles for Meraki wireless networks |
| 20 |
description: |
| 21 |
- Allows for configuration of radio frequency (RF) profiles in Meraki MR wireless networks. |
| 22 |
deprecated: |
| 23 |
removed_in: '3.0.0' |
| 24 |
why: Updated modules released with increased functionality |
| 25 |
alternative: cisco.meraki.networks_wireless_rf_profiles |
| 26 |
options: |
| 27 |
state: |
| 28 |
description: |
| 29 |
- Query, edit, or delete wireless RF profile settings. |
| 30 |
type: str |
| 31 |
choices: [ present, query, absent] |
| 32 |
default: present |
| 33 |
net_name: |
| 34 |
description: |
| 35 |
- Name of network. |
| 36 |
type: str |
| 37 |
net_id: |
| 38 |
description: |
| 39 |
- ID of network. |
| 40 |
type: str |
| 41 |
profile_id: |
| 42 |
description: |
| 43 |
- Unique identifier of existing RF profile. |
| 44 |
type: str |
| 45 |
aliases: [ id ] |
| 46 |
band_selection_type: |
| 47 |
description: |
| 48 |
- Sets whether band selection is assigned per access point or SSID. |
| 49 |
- This param is required on creation. |
| 50 |
choices: [ ssid, ap ] |
| 51 |
type: str |
| 52 |
min_bitrate_type: |
| 53 |
description: |
| 54 |
- Type of minimum bitrate. |
| 55 |
choices: [ band, ssid ] |
| 56 |
type: str |
| 57 |
name: |
| 58 |
description: |
| 59 |
- The unique name of the new profile. |
| 60 |
- This param is required on creation. |
| 61 |
type: str |
| 62 |
client_balancing_enabled: |
| 63 |
description: |
| 64 |
- Steers client to best available access point. |
| 65 |
type: bool |
| 66 |
ap_band_settings: |
| 67 |
description: |
| 68 |
- Settings that will be enabled if selectionType is set to 'ap'. |
| 69 |
type: dict |
| 70 |
suboptions: |
| 71 |
mode: |
| 72 |
description: |
| 73 |
- Sets which RF band the AP will support. |
| 74 |
choices: [ 2.4ghz, 5ghz, dual ] |
| 75 |
aliases: [ band_operation_mode ] |
| 76 |
type: str |
| 77 |
band_steering_enabled: |
| 78 |
description: |
| 79 |
- Steers client to most open band. |
| 80 |
type: bool |
| 81 |
five_ghz_settings: |
| 82 |
description: |
| 83 |
- Settings related to 5Ghz band. |
| 84 |
type: dict |
| 85 |
suboptions: |
| 86 |
max_power: |
| 87 |
description: |
| 88 |
- Sets max power (dBm) of 5Ghz band. |
| 89 |
- Can be integer between 8 and 30. |
| 90 |
type: int |
| 91 |
min_power: |
| 92 |
description: |
| 93 |
- Sets minmimum power (dBm) of 5Ghz band. |
| 94 |
- Can be integer between 8 and 30. |
| 95 |
type: int |
| 96 |
min_bitrate: |
| 97 |
description: |
| 98 |
- Sets minimum bitrate (Mbps) of 5Ghz band. |
| 99 |
choices: [ 6, 9, 12, 18, 24, 36, 48, 54 ] |
| 100 |
type: int |
| 101 |
rxsop: |
| 102 |
description: |
| 103 |
- The RX-SOP level controls the sensitivity of the radio. |
| 104 |
- It is strongly recommended to use RX-SOP only after consulting a wireless expert. |
| 105 |
- RX-SOP can be configured in the range of -65 to -95 (dBm). |
| 106 |
type: int |
| 107 |
channel_width: |
| 108 |
description: |
| 109 |
- Sets channel width (MHz) for 5Ghz band. |
| 110 |
choices: [ auto, '20', '40', '80' ] |
| 111 |
type: str |
| 112 |
valid_auto_channels: |
| 113 |
description: |
| 114 |
- Sets valid auto channels for 5Ghz band. |
| 115 |
type: list |
| 116 |
elements: int |
| 117 |
choices: [36, |
| 118 |
40, |
| 119 |
44, |
| 120 |
48, |
| 121 |
52, |
| 122 |
56, |
| 123 |
60, |
| 124 |
64, |
| 125 |
100, |
| 126 |
104, |
| 127 |
108, |
| 128 |
112, |
| 129 |
116, |
| 130 |
120, |
| 131 |
124, |
| 132 |
128, |
| 133 |
132, |
| 134 |
136, |
| 135 |
140, |
| 136 |
144, |
| 137 |
149, |
| 138 |
153, |
| 139 |
157, |
| 140 |
161, |
| 141 |
165] |
| 142 |
two_four_ghz_settings: |
| 143 |
description: |
| 144 |
- Settings related to 2.4Ghz band |
| 145 |
type: dict |
| 146 |
suboptions: |
| 147 |
max_power: |
| 148 |
description: |
| 149 |
- Sets max power (dBm) of 2.4Ghz band. |
| 150 |
- Can be integer between 5 and 30. |
| 151 |
type: int |
| 152 |
min_power: |
| 153 |
description: |
| 154 |
- Sets minmimum power (dBm) of 2.4Ghz band. |
| 155 |
- Can be integer between 5 and 30. |
| 156 |
type: int |
| 157 |
min_bitrate: |
| 158 |
description: |
| 159 |
- Sets minimum bitrate (Mbps) of 2.4Ghz band. |
| 160 |
choices: [ 1, 2, 5.5, 6, 9, 11, 12, 18, 24, 36, 48, 54 ] |
| 161 |
type: float |
| 162 |
rxsop: |
| 163 |
description: |
| 164 |
- The RX-SOP level controls the sensitivity of the radio. |
| 165 |
- It is strongly recommended to use RX-SOP only after consulting a wireless expert. |
| 166 |
- RX-SOP can be configured in the range of -65 to -95 (dBm). |
| 167 |
type: int |
| 168 |
ax_enabled: |
| 169 |
description: |
| 170 |
- Determines whether ax radio on 2.4Ghz band is on or off. |
| 171 |
type: bool |
| 172 |
valid_auto_channels: |
| 173 |
description: |
| 174 |
- Sets valid auto channels for 2.4Ghz band. |
| 175 |
choices: [ 1, 6, 11 ] |
| 176 |
type: list |
| 177 |
elements: int |
| 178 |
author: |
| 179 |
- Kevin Breit (@kbreit) |
| 180 |
extends_documentation_fragment: cisco.meraki.meraki |
| 181 |
''' |
| 182 |
|
| 183 |
EXAMPLES = r''' |
| 184 |
- name: Create RF profile in check mode |
| 185 |
meraki_mr_rf_profile: |
| 186 |
auth_key: abc123 |
| 187 |
org_name: YourOrg |
| 188 |
net_name: YourNet |
| 189 |
state: present |
| 190 |
name: Test Profile |
| 191 |
band_selection_type: ap |
| 192 |
client_balancing_enabled: true |
| 193 |
ap_band_settings: |
| 194 |
mode: dual |
| 195 |
band_steering_enabled: true |
| 196 |
five_ghz_settings: |
| 197 |
max_power: 10 |
| 198 |
min_bitrate: 12 |
| 199 |
min_power: 8 |
| 200 |
rxsop: -65 |
| 201 |
channel_width: 20 |
| 202 |
valid_auto_channels: |
| 203 |
- 36 |
| 204 |
- 40 |
| 205 |
- 44 |
| 206 |
two_four_ghz_settings: |
| 207 |
max_power: 10 |
| 208 |
min_bitrate: 12 |
| 209 |
min_power: 8 |
| 210 |
rxsop: -65 |
| 211 |
ax_enabled: false |
| 212 |
valid_auto_channels: |
| 213 |
- 1 |
| 214 |
delegate_to: localhost |
| 215 |
|
| 216 |
- name: Query all RF profiles |
| 217 |
meraki_mr_rf_profile: |
| 218 |
auth_key: abc123 |
| 219 |
org_name: YourOrg |
| 220 |
net_name: YourNet |
| 221 |
state: query |
| 222 |
delegate_to: localhost |
| 223 |
|
| 224 |
- name: Query one RF profile by ID |
| 225 |
meraki_mr_rf_profile: |
| 226 |
auth_key: abc123 |
| 227 |
org_name: YourOrg |
| 228 |
net_name: YourNet |
| 229 |
state: query |
| 230 |
profile_id: '{{ profile_id }}' |
| 231 |
delegate_to: localhost |
| 232 |
|
| 233 |
- name: Update profile |
| 234 |
meraki_mr_rf_profile: |
| 235 |
auth_key: abc123 |
| 236 |
org_name: YourOrg |
| 237 |
net_name: YourNet |
| 238 |
state: present |
| 239 |
profile_id: 12345 |
| 240 |
band_selection_type: ap |
| 241 |
client_balancing_enabled: true |
| 242 |
ap_band_settings: |
| 243 |
mode: dual |
| 244 |
band_steering_enabled: true |
| 245 |
five_ghz_settings: |
| 246 |
max_power: 10 |
| 247 |
min_bitrate: 12 |
| 248 |
min_power: 8 |
| 249 |
rxsop: -65 |
| 250 |
channel_width: 20 |
| 251 |
valid_auto_channels: |
| 252 |
- 36 |
| 253 |
- 44 |
| 254 |
two_four_ghz_settings: |
| 255 |
max_power: 10 |
| 256 |
min_bitrate: 12 |
| 257 |
min_power: 8 |
| 258 |
rxsop: -75 |
| 259 |
ax_enabled: false |
| 260 |
valid_auto_channels: |
| 261 |
- 1 |
| 262 |
delegate_to: localhost |
| 263 |
|
| 264 |
- name: Delete RF profile |
| 265 |
meraki_mr_rf_profile: |
| 266 |
auth_key: abc123 |
| 267 |
org_name: YourOrg |
| 268 |
net_name: YourNet |
| 269 |
state: absent |
| 270 |
profile_id: 12345 |
| 271 |
delegate_to: localhost |
| 272 |
''' |
| 273 |
|
| 274 |
RETURN = r''' |
| 275 |
data: |
| 276 |
description: List of wireless RF profile settings. |
| 277 |
returned: success |
| 278 |
type: complex |
| 279 |
contains: |
| 280 |
id: |
| 281 |
description: |
| 282 |
- Unique identifier of existing RF profile. |
| 283 |
type: str |
| 284 |
returned: success |
| 285 |
sample: 12345 |
| 286 |
band_selection_type: |
| 287 |
description: |
| 288 |
- Sets whether band selection is assigned per access point or SSID. |
| 289 |
- This param is required on creation. |
| 290 |
type: str |
| 291 |
returned: success |
| 292 |
sample: ap |
| 293 |
min_bitrate_type: |
| 294 |
description: |
| 295 |
- Type of minimum bitrate. |
| 296 |
type: str |
| 297 |
returned: success |
| 298 |
sample: ssid |
| 299 |
name: |
| 300 |
description: |
| 301 |
- The unique name of the new profile. |
| 302 |
- This param is required on creation. |
| 303 |
type: str |
| 304 |
returned: success |
| 305 |
sample: Guest RF profile |
| 306 |
client_balancing_enabled: |
| 307 |
description: |
| 308 |
- Steers client to best available access point. |
| 309 |
type: bool |
| 310 |
returned: success |
| 311 |
sample: true |
| 312 |
ap_band_settings: |
| 313 |
description: |
| 314 |
- Settings that will be enabled if selectionType is set to 'ap'. |
| 315 |
type: complex |
| 316 |
returned: success |
| 317 |
contains: |
| 318 |
mode: |
| 319 |
description: |
| 320 |
- Sets which RF band the AP will support. |
| 321 |
type: str |
| 322 |
returned: success |
| 323 |
sample: dual |
| 324 |
band_steering_enabled: |
| 325 |
description: |
| 326 |
- Steers client to most open band. |
| 327 |
type: bool |
| 328 |
returned: success |
| 329 |
sample: true |
| 330 |
five_ghz_settings: |
| 331 |
description: |
| 332 |
- Settings related to 5Ghz band. |
| 333 |
type: complex |
| 334 |
returned: success |
| 335 |
contains: |
| 336 |
max_power: |
| 337 |
description: |
| 338 |
- Sets max power (dBm) of 5Ghz band. |
| 339 |
- Can be integer between 8 and 30. |
| 340 |
type: int |
| 341 |
returned: success |
| 342 |
sample: 12 |
| 343 |
min_power: |
| 344 |
description: |
| 345 |
- Sets minmimum power (dBm) of 5Ghz band. |
| 346 |
- Can be integer between 8 and 30. |
| 347 |
type: int |
| 348 |
returned: success |
| 349 |
sample: 12 |
| 350 |
min_bitrate: |
| 351 |
description: |
| 352 |
- Sets minimum bitrate (Mbps) of 5Ghz band. |
| 353 |
type: int |
| 354 |
returned: success |
| 355 |
sample: 6 |
| 356 |
rxsop: |
| 357 |
description: |
| 358 |
- The RX-SOP level controls the sensitivity of the radio. |
| 359 |
type: int |
| 360 |
returned: success |
| 361 |
sample: -70 |
| 362 |
channel_width: |
| 363 |
description: |
| 364 |
- Sets channel width (MHz) for 5Ghz band. |
| 365 |
type: str |
| 366 |
returned: success |
| 367 |
sample: auto |
| 368 |
valid_auto_channels: |
| 369 |
description: |
| 370 |
- Sets valid auto channels for 5Ghz band. |
| 371 |
type: list |
| 372 |
returned: success |
| 373 |
two_four_ghz_settings: |
| 374 |
description: |
| 375 |
- Settings related to 2.4Ghz band |
| 376 |
type: complex |
| 377 |
returned: success |
| 378 |
contains: |
| 379 |
max_power: |
| 380 |
description: |
| 381 |
- Sets max power (dBm) of 2.4Ghz band. |
| 382 |
type: int |
| 383 |
returned: success |
| 384 |
sample: 12 |
| 385 |
min_power: |
| 386 |
description: |
| 387 |
- Sets minmimum power (dBm) of 2.4Ghz band. |
| 388 |
type: int |
| 389 |
returned: success |
| 390 |
sample: 12 |
| 391 |
min_bitrate: |
| 392 |
description: |
| 393 |
- Sets minimum bitrate (Mbps) of 2.4Ghz band. |
| 394 |
type: float |
| 395 |
returned: success |
| 396 |
sample: 5.5 |
| 397 |
rxsop: |
| 398 |
description: |
| 399 |
- The RX-SOP level controls the sensitivity of the radio. |
| 400 |
type: int |
| 401 |
returned: success |
| 402 |
sample: -70 |
| 403 |
ax_enabled: |
| 404 |
description: |
| 405 |
- Determines whether ax radio on 2.4Ghz band is on or off. |
| 406 |
type: bool |
| 407 |
returned: success |
| 408 |
sample: true |
| 409 |
valid_auto_channels: |
| 410 |
description: |
| 411 |
- Sets valid auto channels for 2.4Ghz band. |
| 412 |
type: list |
| 413 |
returned: success |
| 414 |
sample: 6 |
| 415 |
''' |
| 416 |
|
| 417 |
from ansible.module_utils.basic import AnsibleModule, json |
| 418 |
from ansible_collections.cisco.meraki.plugins.module_utils.network.meraki.meraki import MerakiModule, meraki_argument_spec |
| 419 |
|
| 420 |
|
| 421 |
def get_profile(meraki, profiles, name): |
| 422 |
for profile in profiles: |
| 423 |
if profile['name'] == name: |
| 424 |
return profile |
| 425 |
return None |
| 426 |
|
| 427 |
|
| 428 |
def construct_payload(meraki): |
| 429 |
payload = {} |
| 430 |
if meraki.params['name'] is not None: |
| 431 |
payload['name'] = meraki.params['name'] |
| 432 |
if meraki.params['band_selection_type'] is not None: |
| 433 |
payload['bandSelectionType'] = meraki.params['band_selection_type'] |
| 434 |
if meraki.params['min_bitrate_type'] is not None: |
| 435 |
payload['minBitrateType'] = meraki.params['min_bitrate_type'] |
| 436 |
if meraki.params['client_balancing_enabled'] is not None: |
| 437 |
payload['clientBalancingEnabled'] = meraki.params['client_balancing_enabled'] |
| 438 |
if meraki.params['ap_band_settings'] is not None: |
| 439 |
payload['apBandSettings'] = {} |
| 440 |
if meraki.params['ap_band_settings']['mode'] is not None: |
| 441 |
payload['apBandSettings']['bandOperationMode'] = meraki.params['ap_band_settings']['mode'] |
| 442 |
if meraki.params['ap_band_settings']['band_steering_enabled'] is not None: |
| 443 |
payload['apBandSettings']['bandSteeringEnabled'] = meraki.params['ap_band_settings']['band_steering_enabled'] |
| 444 |
if meraki.params['five_ghz_settings'] is not None: |
| 445 |
payload['fiveGhzSettings'] = {} |
| 446 |
if meraki.params['five_ghz_settings']['max_power'] is not None: |
| 447 |
payload['fiveGhzSettings']['maxPower'] = meraki.params['five_ghz_settings']['max_power'] |
| 448 |
if meraki.params['five_ghz_settings']['min_bitrate'] is not None: |
| 449 |
payload['fiveGhzSettings']['minBitrate'] = meraki.params['five_ghz_settings']['min_bitrate'] |
| 450 |
if meraki.params['five_ghz_settings']['min_power'] is not None: |
| 451 |
payload['fiveGhzSettings']['minPower'] = meraki.params['five_ghz_settings']['min_power'] |
| 452 |
if meraki.params['five_ghz_settings']['rxsop'] is not None: |
| 453 |
payload['fiveGhzSettings']['rxsop'] = meraki.params['five_ghz_settings']['rxsop'] |
| 454 |
if meraki.params['five_ghz_settings']['channel_width'] is not None: |
| 455 |
payload['fiveGhzSettings']['channelWidth'] = meraki.params['five_ghz_settings']['channel_width'] |
| 456 |
if meraki.params['five_ghz_settings']['valid_auto_channels'] is not None: |
| 457 |
payload['fiveGhzSettings']['validAutoChannels'] = meraki.params['five_ghz_settings']['valid_auto_channels'] |
| 458 |
if meraki.params['two_four_ghz_settings'] is not None: |
| 459 |
payload['twoFourGhzSettings'] = {} |
| 460 |
if meraki.params['two_four_ghz_settings']['max_power'] is not None: |
| 461 |
payload['twoFourGhzSettings']['maxPower'] = meraki.params['two_four_ghz_settings']['max_power'] |
| 462 |
if meraki.params['two_four_ghz_settings']['min_bitrate'] is not None: |
| 463 |
payload['twoFourGhzSettings']['minBitrate'] = meraki.params['two_four_ghz_settings']['min_bitrate'] |
| 464 |
if meraki.params['two_four_ghz_settings']['min_power'] is not None: |
| 465 |
payload['twoFourGhzSettings']['minPower'] = meraki.params['two_four_ghz_settings']['min_power'] |
| 466 |
if meraki.params['two_four_ghz_settings']['rxsop'] is not None: |
| 467 |
payload['twoFourGhzSettings']['rxsop'] = meraki.params['two_four_ghz_settings']['rxsop'] |
| 468 |
if meraki.params['two_four_ghz_settings']['ax_enabled'] is not None: |
| 469 |
payload['twoFourGhzSettings']['axEnabled'] = meraki.params['two_four_ghz_settings']['ax_enabled'] |
| 470 |
if meraki.params['two_four_ghz_settings']['valid_auto_channels'] is not None: |
| 471 |
payload['twoFourGhzSettings']['validAutoChannels'] = meraki.params['two_four_ghz_settings']['valid_auto_channels'] |
| 472 |
return payload |
| 473 |
|
| 474 |
|
| 475 |
def main(): |
| 476 |
|
| 477 |
|
| 478 |
|
| 479 |
band_arg_spec = dict(mode=dict(type='str', aliases=['band_operation_mode'], choices=['2.4ghz', '5ghz', 'dual']), |
| 480 |
band_steering_enabled=dict(type='bool'), |
| 481 |
) |
| 482 |
|
| 483 |
five_arg_spec = dict(max_power=dict(type='int'), |
| 484 |
min_bitrate=dict(type='int', choices=[6, 9, 12, 18, 24, 36, 48, 54]), |
| 485 |
min_power=dict(type='int'), |
| 486 |
rxsop=dict(type='int'), |
| 487 |
channel_width=dict(type='str', choices=['auto', '20', '40', '80']), |
| 488 |
valid_auto_channels=dict(type='list', elements='int', choices=[36, |
| 489 |
40, |
| 490 |
44, |
| 491 |
48, |
| 492 |
52, |
| 493 |
56, |
| 494 |
60, |
| 495 |
64, |
| 496 |
100, |
| 497 |
104, |
| 498 |
108, |
| 499 |
112, |
| 500 |
116, |
| 501 |
120, |
| 502 |
124, |
| 503 |
128, |
| 504 |
132, |
| 505 |
136, |
| 506 |
140, |
| 507 |
144, |
| 508 |
149, |
| 509 |
153, |
| 510 |
157, |
| 511 |
161, |
| 512 |
165]), |
| 513 |
) |
| 514 |
|
| 515 |
two_arg_spec = dict(max_power=dict(type='int'), |
| 516 |
min_bitrate=dict(type='float', choices=[1, |
| 517 |
2, |
| 518 |
5.5, |
| 519 |
6, |
| 520 |
9, |
| 521 |
11, |
| 522 |
12, |
| 523 |
18, |
| 524 |
24, |
| 525 |
36, |
| 526 |
48, |
| 527 |
54]), |
| 528 |
min_power=dict(type='int'), |
| 529 |
rxsop=dict(type='int'), |
| 530 |
ax_enabled=dict(type='bool'), |
| 531 |
valid_auto_channels=dict(type='list', elements='int', choices=[1, 6, 11]), |
| 532 |
) |
| 533 |
|
| 534 |
argument_spec = meraki_argument_spec() |
| 535 |
argument_spec.update(state=dict(type='str', choices=['present', 'query', 'absent'], default='present'), |
| 536 |
org_name=dict(type='str', aliases=['organization']), |
| 537 |
org_id=dict(type='str'), |
| 538 |
net_name=dict(type='str'), |
| 539 |
net_id=dict(type='str'), |
| 540 |
profile_id=dict(type='str', aliases=['id']), |
| 541 |
band_selection_type=dict(type='str', choices=['ssid', 'ap']), |
| 542 |
min_bitrate_type=dict(type='str', choices=['band', 'ssid']), |
| 543 |
name=dict(type='str'), |
| 544 |
client_balancing_enabled=dict(type='bool'), |
| 545 |
ap_band_settings=dict(type='dict', options=band_arg_spec), |
| 546 |
five_ghz_settings=dict(type='dict', options=five_arg_spec), |
| 547 |
two_four_ghz_settings=dict(type='dict', options=two_arg_spec), |
| 548 |
) |
| 549 |
|
| 550 |
|
| 551 |
|
| 552 |
|
| 553 |
|
| 554 |
module = AnsibleModule(argument_spec=argument_spec, |
| 555 |
supports_check_mode=True, |
| 556 |
) |
| 557 |
meraki = MerakiModule(module, function='mr_rf_profile') |
| 558 |
|
| 559 |
meraki.params['follow_redirects'] = 'all' |
| 560 |
|
| 561 |
query_all_urls = {'mr_rf_profile': '/networks/{net_id}/wireless/rfProfiles'} |
| 562 |
query_urls = {'mr_rf_profile': '/networks/{net_id}/wireless/rfProfiles/{profile_id}'} |
| 563 |
create_urls = {'mr_rf_profile': '/networks/{net_id}/wireless/rfProfiles'} |
| 564 |
update_urls = {'mr_rf_profile': '/networks/{net_id}/wireless/rfProfiles/{profile_id}'} |
| 565 |
delete_urls = {'mr_rf_profile': '/networks/{net_id}/wireless/rfProfiles/{profile_id}'} |
| 566 |
|
| 567 |
meraki.url_catalog['get_all'].update(query_all_urls) |
| 568 |
meraki.url_catalog['get_one'].update(query_urls) |
| 569 |
meraki.url_catalog['create'] = create_urls |
| 570 |
meraki.url_catalog['update'] = update_urls |
| 571 |
meraki.url_catalog['delete'] = delete_urls |
| 572 |
|
| 573 |
if meraki.params['five_ghz_settings'] is not None: |
| 574 |
if meraki.params['five_ghz_settings']['max_power'] is not None: |
| 575 |
if meraki.params['five_ghz_settings']['max_power'] < 8 or meraki.params['five_ghz_settings']['max_power'] > 30: |
| 576 |
meraki.fail_json(msg="5ghz max power must be between 8 and 30.") |
| 577 |
if meraki.params['five_ghz_settings']['min_power'] is not None: |
| 578 |
if meraki.params['five_ghz_settings']['min_power'] < 8 or meraki.params['five_ghz_settings']['min_power'] > 30: |
| 579 |
meraki.fail_json(msg="5ghz min power must be between 8 and 30.") |
| 580 |
if meraki.params['five_ghz_settings']['rxsop'] is not None: |
| 581 |
if meraki.params['five_ghz_settings']['rxsop'] < -95 or meraki.params['five_ghz_settings']['rxsop'] > -65: |
| 582 |
meraki.fail_json(msg="5ghz min power must be between 8 and 30.") |
| 583 |
if meraki.params['two_four_ghz_settings'] is not None: |
| 584 |
if meraki.params['two_four_ghz_settings']['max_power'] is not None: |
| 585 |
if meraki.params['two_four_ghz_settings']['max_power'] < 5 or meraki.params['two_four_ghz_settings']['max_power'] > 30: |
| 586 |
meraki.fail_json(msg="5ghz max power must be between 5 and 30.") |
| 587 |
if meraki.params['two_four_ghz_settings']['min_power'] is not None: |
| 588 |
if meraki.params['two_four_ghz_settings']['min_power'] < 5 or meraki.params['two_four_ghz_settings']['min_power'] > 30: |
| 589 |
meraki.fail_json(msg="5ghz min power must be between 5 and 30.") |
| 590 |
if meraki.params['two_four_ghz_settings']['rxsop'] is not None: |
| 591 |
if meraki.params['two_four_ghz_settings']['rxsop'] < -95 or meraki.params['two_four_ghz_settings']['rxsop'] > -65: |
| 592 |
meraki.fail_json(msg="5ghz min power must be between 8 and 30.") |
| 593 |
|
| 594 |
org_id = meraki.params['org_id'] |
| 595 |
net_id = meraki.params['net_id'] |
| 596 |
profile_id = meraki.params['profile_id'] |
| 597 |
profile = None |
| 598 |
profiles = None |
| 599 |
if org_id is None: |
| 600 |
org_id = meraki.get_org_id(meraki.params['org_name']) |
| 601 |
if net_id is None: |
| 602 |
nets = meraki.get_nets(org_id=org_id) |
| 603 |
net_id = meraki.get_net_id(org_id, meraki.params['net_name'], data=nets) |
| 604 |
if profile_id is None: |
| 605 |
path = meraki.construct_path('get_all', net_id=net_id) |
| 606 |
profiles = meraki.request(path, method='GET') |
| 607 |
|
| 608 |
profile_id = next((profile['id'] for profile in profiles if profile['name'] == meraki.params['name']), None) |
| 609 |
|
| 610 |
if meraki.params['state'] == 'query': |
| 611 |
if profile_id is not None: |
| 612 |
path = meraki.construct_path('get_one', net_id=net_id, custom={'profile_id': profile_id}) |
| 613 |
result = meraki.request(path, method='GET') |
| 614 |
meraki.result['data'] = result |
| 615 |
meraki.exit_json(**meraki.result) |
| 616 |
if profiles is None: |
| 617 |
path = meraki.construct_path('get_all', net_id=net_id) |
| 618 |
profiles = meraki.request(path, method='GET') |
| 619 |
meraki.result['data'] = profiles |
| 620 |
meraki.exit_json(**meraki.result) |
| 621 |
elif meraki.params['state'] == 'present': |
| 622 |
payload = construct_payload(meraki) |
| 623 |
if profile_id is None: |
| 624 |
if meraki.check_mode is True: |
| 625 |
meraki.result['data'] = payload |
| 626 |
meraki.result['changed'] = True |
| 627 |
meraki.exit_json(**meraki.result) |
| 628 |
path = meraki.construct_path('create', net_id=net_id) |
| 629 |
response = meraki.request(path, method='POST', payload=json.dumps(payload)) |
| 630 |
meraki.result['data'] = response |
| 631 |
meraki.result['changed'] = True |
| 632 |
meraki.exit_json(**meraki.result) |
| 633 |
else: |
| 634 |
path = meraki.construct_path('get_one', net_id=net_id, custom={'profile_id': profile_id}) |
| 635 |
original = meraki.request(path, method='GET') |
| 636 |
if meraki.is_update_required(original, payload) is True: |
| 637 |
if meraki.check_mode is True: |
| 638 |
meraki.result['data'] = payload |
| 639 |
meraki.result['changed'] = True |
| 640 |
meraki.exit_json(**meraki.result) |
| 641 |
path = meraki.construct_path('update', net_id=net_id, custom={'profile_id': profile_id}) |
| 642 |
response = meraki.request(path, method='PUT', payload=json.dumps(payload)) |
| 643 |
meraki.result['data'] = response |
| 644 |
meraki.result['changed'] = True |
| 645 |
meraki.exit_json(**meraki.result) |
| 646 |
else: |
| 647 |
meraki.result['data'] = original |
| 648 |
meraki.exit_json(**meraki.result) |
| 649 |
elif meraki.params['state'] == 'absent': |
| 650 |
if meraki.check_mode is True: |
| 651 |
meraki.result['data'] = {} |
| 652 |
meraki.result['changed'] = True |
| 653 |
meraki.exit_json(**meraki.result) |
| 654 |
path = meraki.construct_path('delete', net_id=net_id, custom={'profile_id': profile_id}) |
| 655 |
response = meraki.request(path, method='DELETE') |
| 656 |
meraki.result['data'] = {} |
| 657 |
meraki.result['changed'] = True |
| 658 |
meraki.exit_json(**meraki.result) |
| 659 |
|
| 660 |
|
| 661 |
|
| 662 |
meraki.exit_json(**meraki.result) |
| 663 |
|
| 664 |
|
| 665 |
if __name__ == '__main__': |
| 666 |
main() |