cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1035
Views
10
Helpful
5
Replies

InsecureRequestWarning using CobraSDK in learning lab

hoylandpaul
Level 1
Level 1

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?

 

5 Replies 5

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

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io

omz
VIP Alumni
VIP Alumni

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. 

 

Thanks Omar!
Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io

I don't get the warnings anymore but don't get the 200 OK either. More troubleshooting for me...

Are you looking for <Response 200> after session.login() .. ? As you can see it does not print the status code. 

Screenshot 2020-03-28 at 12.59.04.png

 

But the tenant is created and you get <Response 200> if you run the full script. Comment to expect 200 is probably incorrect ... 

 

Screenshot 2020-03-28 at 12.44.57.png

 

When using requests .. you can get status_code from the response. 

Screenshot 2020-03-28 at 13.07.39.png

But Cobra session. does not seem to have status_code.

 

Disclaimer: I'm not a software engineer... in the same boat as the others :)

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: