meraki / automation-scripts

MIT License
391 stars 198 forks source link

uplink.py multiple Orgs #20

Closed rhinbourgeois closed 3 years ago

rhinbourgeois commented 3 years ago

Is it possible to update the script uplink.py to poll multiple orgs instead of just one at a time?

mpapazog commented 3 years ago

As documented by the original creator of that script, "report_statuses.py" should be used instead, as "uplink.py" is deprecated. Added command line option "-o /all" to "report_statuses.py" that iterates through all organizations accessible by the given API key.

Please test and let me know if this achieves what you are looking for.

rhinbourgeois commented 3 years ago

Thanks mpapazog. That script is bugged for me with the following:

'base_url': 'https://api.meraki.com/api/v1', 'single_request_timeout': 60, 'certificate_path': '', 'requests_proxy': '', 'wait_on_rate_limit': True, 'nginx_429_retry_wait_time': 60, 'action_batch_retry_wait_time': 60, 'retry_4xx_error': False, 'retry_4xx_error_wait_time': 60, 'maximum_retries': 2, 'simulate': False, 'be_geo_id': None, 'caller': None} 2020-12-11 10:27:11 meraki: INFO > GET https://api.meraki.com/api/v1/organizations//all/appliance/uplink/statuses 2020-12-11 10:27:12 meraki: ERROR > appliance, getOrganizationApplianceUplinkStatuses - 404 Not Found, b' ' Traceback (most recent call last): File "report_statuses.py", line 121, in main() File "report_statuses.py", line 40, in main appliance_statuses = dashboard.appliance.getOrganizationApplianceUplinkStatuses(org_id, total_pages='all') File "C:\Python38\lib\site-packages\meraki\api\appliance.py", line 1522, in getOrganizationApplianceUplinkStatuses return self._session.get_pages(metadata, resource, params, total_pages, direction) File "C:\Python38\lib\site-packages\meraki\rest_session.py", line 283, in get_pages response = self.request(metadata, 'GET', url, params=params) File "C:\Python38\lib\site-packages\meraki\rest_session.py", line 262, in request raise APIError(metadata, response) meraki.exceptions.APIError: appliance, getOrganizationApplianceUplinkStatuses - 404 Not Found, please wait a minute if the key or org was just newly created.

I believe it has to do with the -o /all

Look here:

GET https://api.meraki.com/api/v1/organizations//all/appliance/uplink/statuses

Which would explain the 404 error, because the page doesn't exist. I also looked at the code and don't see a note about the -o /all

My command looked like this:

python report_statuses.py -k 1234 -o /all

Is there another switch for the all portion I should be using? Thanks for your help. I really appreciate your patience.

mpapazog commented 3 years ago

Sounds like an older version of the script. Could you please make sure you are using the latest one: https://raw.githubusercontent.com/meraki/automation-scripts/master/report_statuses.py

rhinbourgeois commented 3 years ago

mpapazog, sorry for the delay. The newer version worked. It's weird because I don't loaded the script back about a week back and I assumed everything in there was up to date. Sorry about that, and it is greatly appreciated that you pointed me in the right direction. This issue is closed.

mpapazog commented 3 years ago

The feature was added just for you, following your support request. ;)