meraki / automation-scripts

MIT License
391 stars 198 forks source link

manageadmins.py traceback #5

Closed systemfailx closed 5 years ago

systemfailx commented 5 years ago

When I run the manageadmins.py script to add an admin to every organization my API key has access too it starts to run through and then throws the following traceback error:

Traceback (most recent call last): File "manageadmins.py", line 412, in main(sys.argv[1:]) File "manageadmins.py", line 403, in main cmdadd(arg_apikey, matchedorgs, arg_admin, arg_name, arg_privilege) File "manageadmins.py", line 273, in cmdadd adminid = findadminid(orgadmins, p_email) File "manageadmins.py", line 193, in findadminid if admin['email'] == p_adminemail: KeyError: 'email'

Any idea why it would throw this?

mpapazog commented 5 years ago

Hi,

Could you run this modified debug version of the script and send the output to me at merakixathon@gmail.com?

It looks like you have an admin account in your organization with no email defined, which does not make sense. I would like to understand why the script ends up in such a state.

The modified script can be found here: https://github.com/mpapazog/unfinished/blob/master/manageadmins_debug_2018-12-05_1.py

Regards, Mihail

systemfailx commented 5 years ago

I just sent that over to you. Thanks!

mpapazog commented 5 years ago

Please check if this updated version fixes the issue for you: https://github.com/meraki/automation-scripts/blob/master/manageadmins.py

systemfailx commented 5 years ago

This took care of it. Thank you very much!

mpapazog commented 5 years ago

@enviex Could you copy paste here the exact syntax you use to run the script? Please mask any sensitive information, like email addresses and API keys. Do you try to run it using Python 2 (the default for some operating systems) or Python 3?

Christopher020 commented 1 year ago

i get this syntax error when i run the script in juypter and vs code

Cell In[3], line 1 pythonmanageadmins.py -k -o /all -c list ^ SyntaxError: invalid syntax

mpapazog commented 1 year ago

i get this syntax error when i run the script in juypter and vs code

Cell In[3], line 1 pythonmanageadmins.py -k -o /all -c list ^ SyntaxError: invalid syntax

You seem to be missing a space between the word "python" and the name of the script. Not sure what the syntax needs to be in those tools, but if running it from the Windows command line, you run the script as: python manageadmins.py

I assume you removed the API key from the copied command on purpose. If not, after "-k" you need to provide your Meraki Dashboard API key.

Christopher020 commented 1 year ago

okay, I was able to spot my error in your response and corrected it. But now when I ran it again...... python manageadmins.py -k -o /all -c list, it listed nothing

mpapazog commented 1 year ago

Troubleshooting checklist: Do you have the latest Python 3 and Requests modules installed? https://www.python.org/downloads/ https://pypi.org/project/requests/

Are you using the correct API key?

Are your organizations configured for API access? https://documentation.meraki.com/General_Administration/Other_Topics/Cisco_Meraki_Dashboard_API

Christopher020 commented 1 year ago

Yes it is configured for api access

Christopher020 commented 1 year ago

How do i install the latest requests? I am using python 3.10.8

mpapazog commented 1 year ago

You can find instructions here: https://pypi.org/project/requests/

Christopher020 commented 1 year ago

I have installed it, yet still not seeing any out put..... do I need to upgrade my python to python3.11.1 or continue with the current version

mpapazog commented 1 year ago

No need to upgrade. The script was developed a long time before either of those versions was released, so both should be equally well suited. Not sure what your issue is. For now, it does not seem to be a bug in the script though.

Does the script throw some sort of error, or simply not produce any output at all?

Christopher020 commented 1 year ago

Simply not produce any output at all..... Would it be possible to connect with you privately?

mpapazog commented 1 year ago

For going over the basics of interacting with the Meraki Dashboard API using Python 3, it is a good idea to start with the relevant Cisco DevNet Learning Labs: https://developer.cisco.com/learning/tracks/meraki-devnet-express/

If you manage to run the examples of that learning module, you should be able to run scripts in this repository as well.

mpapazog commented 1 year ago

Support for scripts in this repository is best-effort and only for fixing bugs. For more general guidance on how to run Python scripts that use API calls in your lab environment, please refer to other resources, such as the Learning Labs linked above.

Christopher020 commented 1 year ago

Okay Thanks a lot for your help, I'd get back to you if anything.