03-27-2020 02:24 AM
I'm following the steps here:- https://developer.cisco.com/learning/lab/sbx-intro-aci-02_programmability-options/step/7
but get the following error after trying the session:-
>>> session.login() /home/paul/Documents/Study/devnet_ll/code/aci-learning-labs-code-samples/apic_fabric_setup/lib/python3.6/site-packages/urllib3/connectionpool.py:1004: InsecureRequestWarning: Unverified HTTPS request is being made to host 'sandboxapicdc.cisco.com'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings InsecureRequestWarning,
I tried this:-
>>> auth = cobra.mit.session.LoginSession(URL, LOGIN, PASSWORD, secure=False)
but that didn't seem to make any difference.
Any advice?
03-27-2020 04:11 AM
I am not 100% sure this will work on this sandbox as it isn't a product I know super well. You can try
import urllib3 urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
It is a quick fix in most cases.
Hope this helps
03-27-2020 07:12 AM
as suggested .. you can use urllib3 to disble warnings.
from credentials import * import cobra.mit.access import cobra.mit.request import cobra.mit.session import cobra.model.fv import cobra.model.pol
# Disable #ssl-warnings InsecureRequestWarning
import urllib3 urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) # connect to the apic auth = cobra.mit.session.LoginSession(URL, LOGIN, PASSWORD) session = cobra.mit.access.MoDirectory(auth) session.login() # <Response [200]> --> If you do not see this response the login did not work # Create a Variable for your Tenant Name # Use your initials in the name # Example: tenant_name = "js_Cobra_Tenant" tenant_name = "INITIALS_Cobra_Tenant" # create a new tenant root = cobra.model.pol.Uni('') new_tenant = cobra.model.fv.Tenant(root, tenant_name) # commit the new configuration config_request = cobra.mit.request.ConfigRequest() config_request.addMo(new_tenant) session.commit(config_request) # <Response [200]> --> If you do not see this response the tenant create did not work
Tested on the sandbox and it works.
03-27-2020 07:15 AM
03-27-2020 12:22 PM
I don't get the warnings anymore but don't get the 200 OK either. More troubleshooting for me...
03-28-2020 06:12 AM
Are you looking for <Response 200> after session.login() .. ? As you can see it does not print the status code.
But the tenant is created and you get <Response 200> if you run the full script. Comment to expect 200 is probably incorrect ...
When using requests .. you can get status_code from the response.
But Cobra session. does not seem to have status_code.
Disclaimer: I'm not a software engineer... in the same boat as the others :)
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide