cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1182
Views
0
Helpful
3
Replies

Multiple versions of Cobra SDK in a single python environment

heyphets
Level 1
Level 1

Hi, 

I've been developing an internal orchestration tool for ACI based on Cobra SDK with webservices/web-interface provided by Flask. I'd like to have a single application (in a single environment) which manages different APIC clusters. Unfortunately these APIC clusters, being deployed at different times in different datacenters run different versions of code - 1.2.1m and 2.0.2n.  

When initially tried to use login to 2.0.2n using eggs from 1.2.1m it failed right there. I'm assuming for safety and sanity of everyone involved, I should be using appropriate Cobra SDK library downloaded from the APIC to be managed to each cluster. And there comes a problem - both Cobra SDK packages are in the same namepaces. What's more, the individual modules inside Cobra SDK are using absolute imports, meaning that I can't just move each SDK package into a different folder without requirement to edit every single file in the Cobra SDK package to import from a different namespace. 

Based on discussions I had with other Python developers, it appears we're down to 3 options:

  • Completely separate applications running in different virtual environments each with appropriate Cobra SDK version. The downside is that either user has to connect to different URLs or some other infrastructure (such as HA proxy) needed in front of app servers to redirect to appropriate application based on some criteria.
  • Bite the bullet, move each Cobra SDK version to a separate Python package and find/replace all absolute references to "cobra." with "<new top package name>.cobra." in all files inside Cobra SDK. Dynamically load top package (using importlib) based on which APIC Cluster user of the application wants to manage.
  • Perform some other magic hackery with Python internals, such as sys.paths and/or sys.modules. (I don't have a clear plan on this one yet). 

I'm hoping someone has already faced and dealt with this issue previously or to get a recommendation from Cobra SDK developers. 

Thanks!

3 Replies 3

dpita
Cisco Employee
Cisco Employee

i use multiple virtual environments on my MAC, install the egg files in those environments. 

Hi Daniel

Since cobra skd is bound to APIC version, without correct cobra sdk eggs, script will not work.

Coud you share the  cobra sdk eggs for 2.0(2h)?

Thank much

Mathieu M
Level 1
Level 1

Hello,

Would it be possible to connect to the "older" APIC with the newer cobra eggs ?

Sincerely yours, Mathieu.

Save 25% on Day-2 Operations Add-On License