Logging into the APIC using Cobra
Once we have set up our, environment we can log in.
How to do it...
- Create a new Python file (on Linux, this can be done using the command
vi aciLogin.py
. - In the VI editor, switch to insert mode by pressing i on the keyboard.
- Enter the following:
importcobra.mit.access importcobra.mit.session apicUri='https://192.168.1.205' apicUser='admin' apicPassword='admin123' ls=cobra.mit.session.LoginSession(apicUri,apicUser,apicPassword) md=cobra.mit.access.MoDirectory(ls) md.login()
- Save the file by pressing the Esc key and then typingÂ
:wq!
. - Make the file executable, using the command
chmod a+x aciLogin.py
. - Run the file using the command
python ./aciLogin.py
.