mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 21:32:49 +00:00
meraki - Rewrite update requirement check (#48394)
* Rewrite idempotency check - Check now operates recursively and works on multiple types - Order of lists matter * Remove blank line for lint * Fixed idempotency checks in meraki_ssid - New sanitize() method for finding keys unique in compared dicts - Fixed bug in meraki_ssid where SSID specified by number breaks - This will require a backport - Converted ignored_keys from tuple to list * Made changes required for idempotency * Add changelog fragment * Add unidirectional option for testing * Disable option 1 check * General fixes for is_update_required testing - Added commented out debug statements in method - Fixed ignored_keys modifications * Remove old commented algorithm
This commit is contained in:
committed by
Nathaniel Case
parent
57e1063fc7
commit
7864df8cb9
@@ -331,9 +331,12 @@ def main():
|
||||
path = meraki.construct_path('get_all', net_id=net_id)
|
||||
devices = meraki.request(path, method='GET')
|
||||
for unit in devices:
|
||||
if unit['name'] == meraki.params['hostname']:
|
||||
device.append(unit)
|
||||
meraki.result['data'] = device
|
||||
try:
|
||||
if unit['name'] == meraki.params['hostname']:
|
||||
device.append(unit)
|
||||
meraki.result['data'] = device
|
||||
except KeyError:
|
||||
pass
|
||||
elif meraki.params['model']:
|
||||
path = meraki.construct_path('get_all', net_id=net_id)
|
||||
devices = meraki.request(path, method='GET')
|
||||
@@ -372,6 +375,7 @@ def main():
|
||||
query_path = meraki.construct_path('get_device', net_id=net_id) + meraki.params['serial']
|
||||
device_data = meraki.request(query_path, method='GET')
|
||||
ignore_keys = ['lanIp', 'serial', 'mac', 'model', 'networkId', 'moveMapMarker', 'wan1Ip', 'wan2Ip']
|
||||
# meraki.fail_json(msg="Compare", original=device_data, payload=payload, ignore=ignore_keys)
|
||||
if meraki.is_update_required(device_data, payload, optional_ignore=ignore_keys):
|
||||
path = meraki.construct_path('update', net_id=net_id) + meraki.params['serial']
|
||||
updated_device = []
|
||||
|
||||
@@ -201,7 +201,7 @@ def set_snmp(meraki, org_id):
|
||||
full_compare['v2cEnabled'] = False
|
||||
path = meraki.construct_path('create', org_id=org_id)
|
||||
snmp = get_snmp(meraki, org_id)
|
||||
ignored_parameters = ('v3AuthPass', 'v3PrivPass', 'hostname', 'port', 'v2CommunityString', 'v3User')
|
||||
ignored_parameters = ['v3AuthPass', 'v3PrivPass', 'hostname', 'port', 'v2CommunityString', 'v3User']
|
||||
if meraki.is_update_required(snmp, full_compare, optional_ignore=ignored_parameters):
|
||||
r = meraki.request(path,
|
||||
method='PUT',
|
||||
|
||||
@@ -377,7 +377,7 @@ def main():
|
||||
original = meraki.request(query_path, method='GET')
|
||||
if meraki.params['type'] == 'trunk':
|
||||
proposed['voiceVlan'] = original['voiceVlan'] # API shouldn't include voice VLAN on a trunk port
|
||||
if meraki.is_update_required(original, proposed, optional_ignore=('number')):
|
||||
if meraki.is_update_required(original, proposed, optional_ignore=['number']):
|
||||
path = meraki.construct_path('update', custom={'serial': meraki.params['serial'],
|
||||
'number': meraki.params['number'],
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user