Log of acicobra Install with 2.7.16 Virtual Environment.

Home

1 Background.

1.1 My Goal is a virtual environement for ACI using Python 2.7.16

I have installed the following:

  • pyenv, 2.7.16 and 3.6.5
  • virtaulenv, and used it to create a virtual environment

2 Current State

2.1 Outside of my virtual env:


/Users/zintis/.local/lib[15] % pip list
Package           Version   
----------------- ----------
-irtualenv        16.4.3    
appdirs           1.4.3     
asn1crypto        0.24.0    
attrs             19.1.0    
autopep8          1.4.4     
bcrypt            3.1.6     
black             19.3b0    
certifi           2018.11.29
cffi              1.12.2    
chardet           3.0.4     
ciscosparkapi     0.9.2     
Click             7.0       
cryptography      2.6.1     
dnac              1.2.10.1  
elpy              1.999     
entrypoints       0.3       
flake8            3.7.7     
future            0.17.1    
idna              2.5       
jedi              0.13.3    
lxml              4.3.3     
mccabe            0.6.1     
meraki            0.34      
ncclient          0.5.3     
netmiko           1.4.2     
paramiko          2.4.2     
parso             0.4.0     
pip               19.1.1    
prettytable       0.7.2     
pyang             1.7.8     
pyasn1            0.4.5     
pycodestyle       2.5.0     
pycparser         2.19      
pyflakes          2.1.1     
PyNaCl            1.3.0     
PyYAML            5.1       
requests          2.21.0    
requests-toolbelt 0.9.1     
rope              0.14.0    
scp               0.13.2    
setuptools        39.0.1    
six               1.12.0    
toml              0.10.0    
urllib3           1.21.1    
virtualenv        16.5.0    
xmltodict         0.11.0    
yapf              0.27.0    
/Users/zintis/.local/lib[16] % 

/Users/zintis/.local/lib[16] % python --version
Python 3.6.5
/Users/zintis/.local/lib[17] % 

2.2 I have installed the virtual env for Python 2.7.16 called "controllers-venv"

Users/zintis/bin[98] % virtualenv controllers-venv2.7 –python=python2.7 Running virtualenv with interpreter /Users/zintis.pyenv/shims/python2.7 New python executable in /Users/zintis/bin/controllers-venv2.7/bin/python2.7 Also creating executable in /Users/zintis/bin/controllers-venv2.7/bin/python Installing setuptools, pip, wheel…

2.3 Activated

/Users/zintis/bin[102]source controllers-venv2.7/bin/activate.csh (controllers-venv2.7) /Users/zintis/bin[103] %

2.4 Confirmed where my python site-packages are.

(controllers-venv2.7) Users/zintis/bin[103] % python -m site –user-site /Users/zintis.local/lib/python2.7/site-packages (controllers-venv2.7) /Users/zintis/bin[104] %

2.5 Confirmed 2.7.16 python version and pip list

(controllers-venv2.7) /Users/zintis/bin[107] % python –version Python 2.7.16 (controllers-venv2.7) /Users/zintis/bin[108] % pip list DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. Package Version -——— -—— pip 19.1.1 setuptools 41.0.1 wheel 0.33.4 (controllers-venv2.7) /Users/zintis/bin[109] %

2.6 Confirmed that I am calling python 2.7.16

(controllers-venv2.7) /Users/zintis/bin/controllers-venv2.7/bin[112] % ls -la
total 4192
drwxr-xr-x  17 zintis  staff      544 15 May 10:13 .
drwxr-xr-x   5 zintis  staff      160 15 May 10:11 ..
-rw-r--r--   1 zintis  staff     2113 15 May 10:13 activate
-rw-r--r--   1 zintis  staff     1445 15 May 10:13 activate.csh
-rw-r--r--   1 zintis  staff     3069 15 May 10:13 activate.fish
-rw-r--r--   1 zintis  staff     1804 15 May 10:13 activate.ps1
-rw-r--r--   1 zintis  staff     1512 15 May 10:13 activate_this.py
-rwxr-xr-x   1 zintis  staff      268 15 May 10:12 easy_install
-rwxr-xr-x   1 zintis  staff      268 15 May 10:12 easy_install-2.7
-rwxr-xr-x   1 zintis  staff      250 15 May 10:12 pip
-rwxr-xr-x   1 zintis  staff      250 15 May 10:12 pip2
-rwxr-xr-x   1 zintis  staff      250 15 May 10:12 pip2.7
lrwxr-xr-x   1 zintis  staff        9 15 May 10:11 python -> python2.7
-rwxr-xr-x   1 zintis  staff     2355 15 May 10:13 python-config
lrwxr-xr-x   1 zintis  staff        9 15 May 10:11 python2 -> python2.7
-rwxr-xr-x   1 zintis  staff  2096124 15 May 10:11 python2.7
-rwxr-xr-x   1 zintis  staff      246 15 May 10:12 wheel
(controllers-venv2.7) /Users/zintis/bin/controllers-venv2.7/bin[113] % which python
/Users/zintis/bin/controllers-venv2.7/bin/python
(controllers-venv2.7) /Users/zintis/bin/controllers-venv2.7/bin[114] % 

(controllers-venv2.7) /Users/zintis/bin/controllers-venv2.7/bin[115] % python
Python 2.7.16 (default, May 14 2019, 13:26:11) 
[GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.46.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()
(controllers-venv2.7) /Users/zintis/bin/controllers-venv2.7/bin[116] % 

2.6.1 Even checked that 2.7 is mapping to 2.7.16 correctly:

 
drwxr-xr-x   3 zintis  staff     96 15 May 10:11 ..
lrwxr-xr-x   1 zintis  staff     62 15 May 10:11 LICENSE.txt -> /Users/zintis/.pyenv/versions/2.7.16/lib/python2.7/LICENSE.txt
lrwxr-xr-x   1 zintis  staff     62 15 May 10:11 UserDict.py -> /Users/zintis/.pyenv/versions/2.7.16/lib/python2.7/UserDict.py
-rw-r--r--   1 zintis  staff  11106 15 May 10:11 UserDict.pyc
   #+BEGIN_EXAMPLE

2.6.2 So now what?

% pip install -r requirements.txt DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. Collecting acicobra (from -r requirements.txt (line 1)) ERROR: Could not find a version that satisfies the requirement acicobra (from -r requirements.txt (line 1)) (from versions: none) ERROR: No matching distribution found for acicobra (from -r requirements.txt (line 1))

2.7 So, I downloaded Cobra in the current directory:


remote: Enumerating objects: 1254, done.
remote: Total 1254 (delta 0), reused 0 (delta 0), pack-reused 1254
Receiving objects: 100% (1254/1254), 761.18 KiB | 3.22 MiB/s, done.
Resolving deltas: 100% (726/726), done.
(controllers-venv) /Users/zintis/bin/controllers-venv[70] % lst
total 48
drwxr-xr-x  15 zintis  staff   480 15 May 09:33 cobra
drwxr-xr-x  11 zintis  staff   352 15 May 09:33 .
-rw-r--r--   1 zintis  staff  2334 15 May 09:20 toolkit_new_policy.py
-rw-r--r--   1 zintis  staff   734 15 May 09:20 toolkit_getting_started.py
-rw-r--r--   1 zintis  staff    51 15 May 09:20 requirements.txt
-rwxr-xr-x   1 zintis  staff  1678 15 May 09:20 device_info.py
-rw-r--r--   1 zintis  staff  5251 15 May 09:20 README.md
drwxr-xr-x  17 zintis  staff   544 14 May 21:30 bin
drwxr-xr-x   3 zintis  staff    96 14 May 21:30 include

2.8 Cobra has a set up subdirectories and its own requirements.txt file

I ended up running the setup.py script in the bin sub directory successfully. But here is my personal log, that raises some general quesitons:

2.8.1 From where does pip read the source files? i.e. Cobra ???

I can clone it from here: https://github.com/datacenter/cobra.git but can I install it directly from there? like maybe pip install? No that did not work for me. Instead I did this:


(controllers-venv2.7) /Users/zintis/bin/controllers-venv2.7/cobra[185] % python setup.py install
running install
running bdist_egg
running egg_info
writing requirements to acicobra.egg-info/requires.txt
writing acicobra.egg-info/PKG-INFO
writing namespace_packages to acicobra.egg-info/namespace_packages.txt
writing top-level names to acicobra.egg-info/top_level.txt
writing dependency_links to acicobra.egg-info/dependency_links.txt
reading manifest file 'acicobra.egg-info/SOURCES.txt'
writing manifest file 'acicobra.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.14-x86_64/egg
running install_lib
running build_py
creating build/bdist.macosx-10.14-x86_64/egg
creating build/bdist.macosx-10.14-x86_64/egg/cobra
copying build/lib/cobra/services.py -> build/bdist.macosx-10.
.
.
.
Installed /Users/zintis/bin/controllers-venv2.7/lib/python2.7/site-packages/certifi-2019.3.9-py2.7.egg
Finished processing dependencies for acicobra==0.1

(controllers-venv2.7) /Users/zintis/bin/controllers-venv2.7/cobra[187] % pip list
Package    Version 
---------- --------
acicobra   0.1     
certifi    2019.3.9
chardet    3.0.4   
future     0.14.3  
idna       2.8     
pip        19.1.1  
requests   2.21.0  
setuptools 41.0.1  
urllib3    1.24.3  
wheel      0.33.4  
(controllers-venv2.7) /Users/zintis/bin/controllers-venv2.7/cobra[188] % 

Where before this install my 2.7.16 virtualenv had this:
Package    Version
---------- -------
pip        19.1.1 
setuptools 41.0.1 
wheel      0.33.4 
(controllers-venv2.7) /Users/zintis/bin[109] % 

2.8.2 Downloading acicobra and acimodel

Both packages are required. You can download the two .egg files from a running instance of APIC at this URL:

http[s]://<APIC address>/cobra/downloads/

The /cobra/downloads directory contains the two .egg files. The actual filenames may contain extra information such as the APIC and Python versions, as shown in this example:

https://sandboxapicdc.cisco.com/cobra/_downloads/ I tried this an got a 404 not found error.

Finally found this link in the Cisco support community

acimodel is downloadable here: https://developer.cisco.com/fileMedia/download/928a762b-c2c7-4374-840a-9d3242aa8e27

2.9 ACIMODEL install (installing in 2.7.16 virtualenv)


   (controllers-venv2.7) /Users/zintis/bin/controllers-venv2.7[13] % lst
   total 196816
   drwxr-xr-x  18 zintis  staff       576 16 May 11:58 ..
   drwxr-xr-x   9 zintis  staff       288 16 May 11:58 .
   -rw-r--r--@  1 zintis  staff  98170955 16 May 11:52 acimodel-3.0_1k-py2.7.egg
   drwxr-xr-x  20 zintis  staff       640 15 May 15:49 bin
   drwxr-xr-x  18 zintis  staff       576 15 May 14:48 cobra
   drwxr-xr-x   8 zintis  staff       256 15 May 12:51 aci
   -rw-r--r--@  1 zintis  staff      6148 15 May 10:40 .DS_Store
   drwxr-xr-x   3 zintis  staff        96 15 May 10:11 include
   drwxr-xr-x   3 zintis  staff        96 15 May 10:11 lib
   
   (controllers-venv2.7) /Users/zintis/bin/controllers-venv2.7[14] % easy_i
   easy_install     easy_install-2.7 easy_install-3.5 easy_install-3.6 easy_install-3.7 
   
   (controllers-venv2.7) /Users/zintis/bin/controllers-venv2.7[14] % which easy_install
   /Users/zintis/bin/controllers-venv2.7/bin/easy_install
   
   (controllers-venv2.7) /Users/zintis/bin/controllers-venv2.7[21] % easy_install -Z ./acimodel-3.0_1k-py2.7.egg
   Processing acimodel-3.0_1k-py2.7.egg
p   creating /Users/zintis/bin/controllers-venv2.7/lib/python2.7/site-packages/acimodel-3.0_1k-py2.7.egg
   Extracting acimodel-3.0_1k-py2.7.egg to /Users/zintis/bin/controllers-venv2.7/lib/python2.7/site-packages
   Removing acimodel 3.0-1k from easy-install.pth file
   Adding acimodel 3.0-1k to easy-install.pth file
   Installed /Users/zintis/bin/controllers-venv2.7/lib/python2.7/site-packages/acimodel-3.0_1k-py2.7.egg
   Processing dependencies for acimodel===3.0-1k
   Finished processing dependencies for acimodel===3.0-1k
   (controllers-venv2.7) /Users/zintis/bin/controllers-venv2.7[22] % 


3 Another serious flaw with pyenv .local/lib folder

(controllers-venv) /Users/zintis/bin/controllers-venv/cobra[76] % python –version Python 2.7.16

and (controllers-venv) Users/zintis/bin/controllers-venv/cobra[75] % python -m site –user-site /Users/zintis.local/lib/python2.7/site-packages

But, if I look at my .local/lib folder it ONLY has 3.6

3.0.1 Where is the 2.7.16 folder????


/Users/zintis/.local/lib[14] % ls -lta
total 0
drwx------  4 zintis  staff  128 28 Apr 23:56 ..
drwx------  3 zintis  staff   96 28 Apr 23:56 python3.6
drwx------  3 zintis  staff   96 28 Apr 23:56 .
/Users/zintis/.local/lib[15] % 

4 Uninstalling cobra (to upgrade to version 3.0)


(controllers-venv2.7) /Users/zintis/bin/controllers-venv2.7/cobra[36] % pip list
 DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
 Package    Version 
  ---------- --------
  acicobra   0.1  
  acimodel   3.0-1k  
  certifi    2019.3.9
  chardet    3.0.4   
  future     0.14.3  
  idna       2.8     
  pip        19.1.1  
  requests   2.21.0  
  setuptools 41.0.1  
  urllib3    1.24.3  
  wheel      0.33.4  



 (controllers-venv2.7) /Users/zintis/bin/controllers-venv2.7/cobra[37] % pip uninstall acicobra
 DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
 Uninstalling acicobra-0.1:
 Would remove:
   /Users/zintis/bin/controllers-venv2.7/lib/python2.7/site-packages/acicobra-0.1-py2.7.egg
 Proceed (y/n)? y
 Successfully uninstalled acicobra-0.1
 (controllers-venv2.7) /Users/zintis/bin/controllers-venv2.7/cobra[38] % 

4.1 I uninstalled this in order to upgrade to cobra 3.0

But I may also ahve to uninstall and reinstall acimodel, because acimodel was installed while cobra 0.x was in force.

4.2 Installing acicobra again, this time using easyinstall


(controllers-venv2.7) /Users/zintis/bin/controllers-venv2.7[41] % lst
total 197000
drwxr-xr-x  10 zintis  staff       320 16 May 12:10 .
-rw-r--r--@  1 zintis  staff     92412 16 May 12:09 acicobra-3.0_1k-py2.7.egg
drwxr-xr-x  18 zintis  staff       576 16 May 11:58 ..
-rw-r--r--@  1 zintis  staff  98170955 16 May 11:52 acimodel-3.0_1k-py2.7.egg
drwxr-xr-x  20 zintis  staff       640 15 May 15:49 bin
drwxr-xr-x  18 zintis  staff       576 15 May 14:48 cobra
drwxr-xr-x   8 zintis  staff       256 15 May 12:51 aci
-rw-r--r--@  1 zintis  staff      6148 15 May 10:40 .DS_Store
drwxr-xr-x   3 zintis  staff        96 15 May 10:11 include
drwxr-xr-x   3 zintis  staff        96 15 May 10:11 lib
(controllers-venv2.7) /Users/zintis/bin/controllers-venv2.7[42] % easy_install -Z ./acicobra-3.0_1k-py2.7.egg 
Processing acicobra-3.0_1k-py2.7.egg
creating /Users/zintis/bin/controllers-venv2.7/lib/python2.7/site-packages/acicobra-3.0_1k-py2.7.egg
Extracting acicobra-3.0_1k-py2.7.egg to /Users/zintis/bin/controllers-venv2.7/lib/python2.7/site-packages
Adding acicobra 3.0-1k to easy-install.pth file

Installed /Users/zintis/bin/controllers-venv2.7/lib/python2.7/site-packages/acicobra-3.0_1k-py2.7.egg
Processing dependencies for acicobra===3.0-1k
Finished processing dependencies for acicobra===3.0-1k
(controllers-venv2.7) /Users/zintis/bin/controllers-venv2.7[43] % pip list
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Package    Version 
---------- --------
acicobra   3.0-1k  
acimodel   3.0-1k  
certifi    2019.3.9
chardet    3.0.4   
future     0.14.3  
idna       2.8     
pip        19.1.1  
requests   2.21.0  
setuptools 41.0.1  
urllib3    1.24.3  
wheel      0.33.4  

5 Possible solution through requirements.txt file modification

Assuming you have virtualenv and a requirements.txt file, then you can define inside this file where to get the packages:


# Published pypi packages 
PyJWT==1.6.4
email_validator==1.0.3
# Remote GIT repo package, this will install as django-bootstrap-themes
git+https://github.com/marquicus/django-bootstrap-themes#egg=django-bootstrap-themes
# Local GIT repo package, this will install as django-knowledge
git+file:///soft/SANDBOX/python/django/forks/django-knowledge#egg=django-knowledge

I tried this but did not fully explore this. I ended up using setup.py that came with acicobra.

https://sandboxapicdc.cisco.com/cobra/_downloads/

5.1 Home