SDK Documentation

Report 13 Downloads 48 Views
DevNet Workshop ACI API Devarshi Shah – Technical Marketing Engineer, INSBU DEVNET-2054

Workshop objectives •

This workshop will step through installing the ACI Cobra Python SDK



The SDK files can be installed on Windows/Unix/Linux environments. This presentation will guide the user through the installation on Windows 10 using the dCloud environment. Installation steps may vary for Unix/Linux environments



All Cobra SDK documentation and egg files can be downloaded directly from the APIC



We will also use API inspector to capture an API post message and use the arya tool to convert JSON to python script

DEVNET-2054

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

3

Installing Cobra EGG files •

The Python SDK (Cobra) comes in two installable .egg files



These egg files are distributed with every APIC



From the APIC web interface select admin drop down  Documentation  Python SDK Documentation

DEVNET-2054

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

4

Cobra Documentation •

The Cobra documentation page can be reached from the APIC GUI or directly at https:///cobra

DEVNET-2054

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

5

Egg file download •

The egg file location is at https:///cobra/_downloads

Task: Download these files to the Downloads folder

DEVNET-2054

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

6

Cobra SDK installation requirements It is recommended to have the following installed prior to installing the SDK • Python 2.7 • easy_install • pip • virtualenv (recommended but not used in the workshop) The dCloud environment has Python 2.7.8 installed. Version 2.7.9 or above automatically comes with setup_tools (easy_install) and pip. For ease of installation we will upgrade Python 2.7.8 to 2.7.13

DEVNET-2054

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

7

Install Python 2.7.13 •

Go to www.python.org and select Downloads



Select Python 2.7.13 and open the installer

DEVNET-2054

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

8

Installing python 2.7.13 continued •

Select “Install for all users”



Accept default C:\Python27\



Acknowledge overwriting files



Select next



python –m pip install –U pip setuptools



After installing Python 2.7.13 pip and setup-tools should be installed.



Add the Scripts directory to the path (this will allow running pip command)

DEVNET-2054

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

9

Install SDK •

Remove previous versions (You should see no previous versions installed)



Install APIC Python SDK



Install model package

DEVNET-2054

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

10

Create simple python script to add a tenant Examples from https:///cobra/getting-started.html

DEVNET-2054

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

11

Run script

Security warnings can be ignored for workshop

DEVNET-2054

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

12

Verify Tenant creation is successful from GUI

DEVNET-2054

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

13

API Documentation Cobra documentation can be found at https:///cobra/index.html. This includes API reference, Model reference, and examples

DEVNET-2054

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

14

Automate script creation with arya arya is a tool that will convert XML or JSON posts into equivalent Python code leveraging the Cobra SDK arya can be installed using pip

DEVNET-2054

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

15

Capture an XML/JSON post using API inspector API inspector can be launched from the admin drop down in the ACI GUI

DEVNET-2054

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

16

Generate a Post operation Add a tenant using the GUI to generate a post operation

Copy the JSON payload from the post into a file

DEVNET-2054

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

17

Run the JSON through arya JSON payload captured from API inspector

File containing JSON payload

Output file with python code generated by arya

DEVNET-2054

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

18

Arya generated code

DEVNET-2054

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

19

Complete Your Online Session Evaluation •

Please complete your Online Session Evaluations after each session



Complete 4 Session Evaluations & the Overall Conference Evaluation (available from Thursday) to receive your Cisco Live T-shirt



All surveys can be completed via the Cisco Live Mobile App or the Communication Stations

Don’t forget: Cisco Live sessions will be available for viewing on-demand after the event at CiscoLive.com/Online

DEVNET-2054

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

47

Continue Your Education •

Devnet https://developer.cisco.com/site/aci/



Demos in the Cisco campus



Walk-in Self-Paced Labs



Lunch & Learn



Meet the Engineer 1:1 meetings



Related sessions

DEVNET-2054

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

48

Thank You