cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1136
Views
0
Helpful
0
Comments
mtimm
Cisco Employee
Cisco Employee

In version 1.0(2j) and later the ACI Python SDK (Cobra) is included on the APIC along with the docs for the SDK.  The SDK documentation on the APIC can viewed by going to either https://<apic>/cobra or http://<apic>/cobra depending on if you have http or https enabled.  A direct link to this documentation is being added to the APIC GUI in versions after 1.0(2*).

The Python SDK documentation index page on the GUI has been updated to include links to the egg files which are now staged on the APIC.

However, the egg files are not easily installed directly from the APIC using easy_install or pip.  Instead you will need to download them locally.

In addition if the egg files are installed as they were downloaded from the APIC problems may be seen trying to install the SDK egg using the easy_install extras [ssl] and difficulty may be seen trying to uninstall them using pip uninstall because the egg files staged on the APIC in 1.0(2*) have been renamed from their original names.  To avoid those problems later it is recommended that you rename the egg files locally to provide a version number and python version so that easy_install and pip work normally.  Renaming the files should follow this convention:
 

Old NameNew Name
acicobrasdk.eggacicobra-1.0_2j-py2.7.egg
or
acicobra-1.0_2m-py2.7.egg
acicobramodel.egg

acimodel-1.0_2j-py2.7.egg
or
acimodel-1.0_2m-py2.7.egg


If future versions of the eggs come out in 1.0(2*) the "New Name" may need to be adjusted to match the version of the APIC following the same convention seen above.  This renaming issue has been corrected for the next major release.

If the eggs were installed without being renamed the following may be seen when installing the model egg:

$ easy_install -Z ~/Downloads/1.0_2j/acicobramodel.egg 
Processing acicobramodel.egg
creating /Users/mtimm/.virtualenvs/oldname/lib/python2.7/site-packages/acicobramodel.egg
Extracting acicobramodel.egg to /Users/mtimm/.virtualenvs/oldname/lib/python2.7/site-packages
Adding acicobramodel 1.0-2j to easy-install.pth file

Installed /Users/mtimm/.virtualenvs/oldname/lib/python2.7/site-packages/acicobramodel.egg
Processing dependencies for acicobramodel==1.0-2j
Searching for acicobra
Reading https://pypi.python.org/simple/acicobra/
Couldn't find index page for 'acicobra' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.python.org/simple/
No local packages or download links found for acicobra
error: Could not find suitable distribution for Requirement.parse('acicobra')

However, both eggs are installed and pip freeze will show something along the lines of:

$ pip freeze
acicobramodel==1.0-2j
acicobrasdk==1.0-2j
requests==2.5.0
wsgiref==0.1.2

Imports do work normally so all should be well:

Python 2.7.8 (default, Oct 19 2014, 16:03:53) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.51)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from cobra.model.pol import Uni
>>> from cobra.mit.access import MoDirectory
>>>

However, attempting to install the acicobrasdk.egg file with the setuptools extras [ssl] option (used to indicate that PyOpenSSL and all it's dependancies should be installed as well) will fail:

$ easy_install -Z ~/Downloads/1.0_2j/acicobrasdk.egg[ssl]
error: Not a URL, existing file, or requirement spec: '/Users/mtimm/Downloads/1.0_2j/acicobrasdk.egg[ssl]'

Once the eggs are installed without renaming them pip uninstall will also fail even though pip freeze can find the installation:

$ pip freeze
acicobramodel==1.0-2j
acicobrasdk==1.0-2j
requests==2.5.0
wsgiref==0.1.2
$ pip uninstall acicobrasdk
Can't uninstall 'acicobrasdk'. No files were found to uninstall.
$ pip uninstall acicobramodel
Can't uninstall 'acicobramodel'. No files were found to uninstall.

To uninstall acicobrsdk and acicobramodel that were installed without renaming, a workaround is to use the --multi-version (-m) option for easy_install and then manually recursively remove the directories the eggs were installed into which is displayed in the output of easy_install -m <package>.  For example:

$ pip freeze
acicobramodel==1.0-2j
acicobrasdk==1.0-2j
requests==2.5.0
wsgiref==0.1.2
$ easy_install -m acicobramodel
Searching for acicobramodel
Best match: acicobramodel 1.0-2j
Processing acicobramodel.egg
Removing acicobramodel 1.0-2j from easy-install.pth file

Using /Users/mtimm/.virtualenvs/oldname/lib/python2.7/site-packages/acicobramodel.egg

Because this distribution was installed --multi-version, before you can
import modules from this package in an application, you will need to
'import pkg_resources' and then use a 'require()' call similar to one of
these examples, in order to select the desired version:

    pkg_resources.require("acicobramodel")  # latest installed version
    pkg_resources.require("acicobramodel==1.0-2j")  # this exact version
    pkg_resources.require("acicobramodel>=1.0-2j")  # this version or higher

Processing dependencies for acicobramodel
Searching for acicobra
Reading https://pypi.python.org/simple/acicobra/
Couldn't find index page for 'acicobra' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.python.org/simple/
No local packages or download links found for acicobra
error: Could not find suitable distribution for Requirement.parse('acicobra')
$ rm -r /Users/mtimm/.virtualenvs/oldname/lib/python2.7/site-packages/acicobramodel.egg
$ easy_install -m acicobrasdk
Searching for acicobrasdk
Best match: acicobrasdk 1.0-2j
Processing acicobrasdk.egg
Removing acicobrasdk 1.0-2j from easy-install.pth file

Using /Users/mtimm/.virtualenvs/oldname/lib/python2.7/site-packages/acicobrasdk.egg

Because this distribution was installed --multi-version, before you can
import modules from this package in an application, you will need to
'import pkg_resources' and then use a 'require()' call similar to one of
these examples, in order to select the desired version:

    pkg_resources.require("acicobrasdk")  # latest installed version
    pkg_resources.require("acicobrasdk==1.0-2j")  # this exact version
    pkg_resources.require("acicobrasdk>=1.0-2j")  # this version or higher

Processing dependencies for acicobrasdk
Finished processing dependencies for acicobrasdk
$ rm -r /Users/mtimm/.virtualenvs/oldname/lib/python2.7/site-packages/acicobrasdk.egg
$ 

 

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:

Review Cisco Networking for a $25 gift card