I will not provide examples of how to install the Cobra SDK or any of the Python modules you need. There are plenty of other places on the internet that you can get those instructions from.
First off, lets start off with the absolute basics. Authentication is obviously the first step as we begin out discussion of Cisco ACI.
I have provided a basic auth module that can be imported into any Python SDK program. Its not really all that useful, but it will be easier for me to include code later as these posts will build on each other.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/Python27/python | |
#Environment Python 2.7 Windows 10 ACI 2.3(1f) | |
#Simple module for ACI login and logout | |
from cobra.mit.access import MoDirectory | |
from cobra.mit.session import LoginSession | |
# Suppress HTTPS Warnings | |
import urllib3 | |
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) | |
def aci_login(apic_url, username, password): | |
#Create login session and actually login | |
loginSession = LoginSession(apic_url, username, password) | |
moDir = MoDirectory(loginSession) | |
moDir.login() | |
return moDir | |
def aci_logout(moDir): | |
#Logout | |
moDir.logout() |
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.