cancel
Showing results for 
Search instead for 
Did you mean: 
cancel

** Deprecated - Cisco UCS Python SDK - Deprecated**

32247
Views
20
Helpful
46
Comments

This version of the UCS Manager Python SDK has been deprecated please use the UCS Manager Python SDK  located here, Cisco UCS Python SDK - ucsmsdk


The following Python SDKs are available for download from Cisco:

Cisco UCS Manager Python SDK v0.8.3:

Downloads:

Documentation Links:

----------------------------------------------------------------------------------------------------

Cisco IMC Python SDK v0.7.2:

Downloads:



Cisco IMC Python SDK v0.7.1:

Downloads:

Documentation Links:

Note: Due to the changes in the naming convention of the APIs in the SDK release 0.7.1, scripts written using SDK release 0.6.x need to be modified to make it work with SDK release 0.7.1. Also this version is not compatible with IMC Plugin 0.9.1 for Nagios.



Cisco IMC Python SDK v0.6.2:

Downloads:

Documentation Links:

For any queries/feedback on the Python SDK, please add a discussion to the Cisco Developed Integrations sub-space on Cisco UCS Communities.


Internal (Cisco) developers/users can contact the team at ucs-python@cisco.com

Comments
Community Member

Hi,I am now using the SDK to write some test cases ,but I wonder how to send command to the host os of the blade ?If I want to install or uninstall some test tools to the host os of one blade ,say install linpack to test memory , how can I write the cases ? Is there some APIs to send command to the os ?

Cisco Employee

This SDK is for UCS Manager and you will be able to automate/script any actions that you can perform via UCS manager. This SDK cannot be used for sending command to the host OS.

Community Member

Thanks very much  for you reply.

Cisco Employee

Just got started using Python UCS SDK and getting an exception in UcsHandler.py. It says connection failed, but I can see that cookie information in xml response. Wondering what could be the issue.

UcsHandler.py throws the error code as 300 (I have added a logger statement to see the error code), is this something specific to sdk or general http error code? Appreciate your help.

Error:

None ====> <?xml version="1.0" ?><aaaLogin inName="admin" inPassword="@dm1nC1sc0"/>

None <====  <aaaLogin cookie="" response="yes" outCookie="1394321925/3546ec0b-19f8-49f5-93a6-ecdff6550d14" outRefreshPeriod="600" outPriv="admin,read-only" outDomains="" outChannel="noencssl" outEvtChannel="noencssl" outSessionId="web_33310_A" outVersion="2.2(1b)" outName="admin"> </aaaLogin>

300 – Response error code from UcsHandler.py

Exception: [Error]: Login : Connection to <10.67.82.90> Failed

------------------------------------------------------------

Traceback (most recent call last):

  File "/Users/rpapiset/Development/liclipseworkspace/Hackathon/DatacenterAutomation/com/cisco/hack/ia/UcsmLogin.py", line 7, in <module>

    handle.Login("10.67.82.90",username="admin",password="@dm1nC1sc0",dumpXml=True)

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/UcsHandle.py", line 341, in Login

    raise Exception('[Error]: Login : Connection to <%s> Failed' %(name))

Exception: [Error]: Login : Connection to <10.67.82.90> Failed

Snippet (this is same from developer guide with appropriate server details):

from UcsSdk import *

import UcsHandle

if __name__ == "__main__":

    try:

        handle = UcsHandle.UcsHandle()

        handle.Login("x.x.x.x",username="admin",password="password",dumpXml=True)

        handle.Logout()

    except Exception, err:

        print "Exception:", str(err)

        import traceback, sys

        print '-'*60

        traceback.print_exc(file=sys.stdout)

        print '-'*60

Cisco Employee

Solved using downgrading python version to 2.7.3.

Thanks,

Ravi Kumar P.

Cisco Employee

Yes, there is a known issue in sdk with latest version of python 2.7. We will release an sdk with fix soon.

Community Member

Any word on when the fix for newer versions of 2.7 will be released? Any chance of this code moving to github where other people could help out?

Cisco Employee

I'm kicking the tires on the SDK and I've run into the following issue using one of the sample scripts (I also see the same behavior when using handle.Login(<ip or hostname>) in the documentation:

#python GetInventory.py -i "x.x.x.x" -u "admin" -p "password"

Connecting to IMC Server <x.x.x.x>....

Exception: <urlopen error [Errno 1] _ssl.c:490: error:1408D108:SSL routines:SSL3_GET_KEY_EXCHANGE:wrong signature length>

#python --version

Python 2.6.6

I'm connecting to a UCS C-series (C200 m2) and it doesn't have an SSL cert assigned (just using out of the box self-signed cert.)

Any help or guidance is greatly appreciated.

Cisco Employee

Hi Melvin,

A few items...

1. Instructions for creating your own Self-Signed certificate are available here:

http://www.cisco.com/c/en/us/td/docs/unified_computing/ucs/c/sw/cli/config/guide/1-5/b_Cisco_UCS_C-series_CLI_Configuration_Guide_151/b_Cisco_UCS_C-series_CLI_Configuration_Guide_151_chapter_01011.pdf

2. You mention you are trying to run this against the C200 M2 - Which CIMC FW version are you running? The reason I ask is that the XML API is rather limited in pre-v1.5 releases and our intergrations have not been tested against these older releases (although queries should still work). This particular system supports only formware upda to v1.4(...)

3. I am not sure which IMC Python SDK you are using, but we did release v0.6.1 earlier this week.

Cheers!

Jeff 

Cisco Employee

Thanks Jeff!

See below:


1. Instructions for creating your own Self-Signed certificate are available here:

Thanks for the doc! Does this mean we need to have a cert (self-signed cert or otherwise) installed before using the API? If so, could there be a note added to the documentation to make other administrators aware?


I've tried it with the self-signed certificate and the error persists. I've also tried generating a certificate using an internal root CA but I see errors when attempting to upload the *.cer certificate.


2. You mention you are trying to run this against the C200 M2 - Which CIMC FW version are you running? The reason I ask is that the XML API is rather limited in pre-v1.5 releases and our intergrations have not been tested against these older releases (although queries should still work). This particular system supports only formware upda to v1.4(...)


Is used the latest HUU (posted to CCO) to upgrade firmware to 1.4(3v) (see below). I'm hoping this will suffice.

ucs-c2xx-m2# show version

Firmware Version    

--------------------

1.4(3v)

3. I am not sure which IMC Python SDK you are using, but we did release v0.6.1 earlier this week.

I was upgraded to v0.6.1 when I stumbled on this issue.

Cisco Employee

Hi Melvin,

The XML API works without any additional setup - I have not run across the particular message that you shared. I tested a few of the Python samples with one of my C200 M2's running 1.4(3c) and where the API was developed with that release I was able to query the system without issue with the IMCSDK 0.6.1.

Cheers!

Jeff

Community Member

I am developing some utilities with the python sdk. It works great for the most part. Tho I believe I can benefit from certain improvements.

Is it possible the external developers can see the tracking of known issues, requested features & such?

I concurred with Chris on his comment to have this (python sdk) hosted on github, to allow easier patch submission and feature/bug tracking?

Thanks.


Jerry

Cisco Employee

Hi Jeff,

     I am maggie from UCS QA department. We are writing Python-based test scripts. The first phase, we rebuilt a UCS Class and lots of sub MOs based on inquiring all the UCS sub devices with 'UCS CLI' commands. For example, 'show chassis inventory expand detail'. Now we are thinking whether we should transfer to 'XML API' instead of 'UCS CLI'.

    After reading the UcsSdk-0.8.1 source codes, I'd like to ask some questions. Please give some instructions.

  What is the main differences between the 'XML API' way and the 'UCS CLI' way?

        So far, we realized our MOs don't change the MOs status until compulsorily inquiring CLI commands. May these MOs in 'UcsSdk' change the status dynamically?  Do 'UCS CLI' commands support the event subscription like 'UcsSdk'?

       We found building so many MOs are very time consuming. In fact, these MOs are very similar. And one line 'This is an auto-generated module' in Mos.py and MethodMeta.py hints us, these MOs python codes can be generated automatically. Which tool can automatically generate the Mos.py and MethodMeta.py module for us? Please give some instructions.

     Thanks!

Beginner

Hi Reswaran,

Can anyone please clarify the following:

In PowerShell we can do:

Get-UcsNetworkElement | Select-Object Ucs,Rn,OobIfIp,OobIfMask,OobIfGw,Operability,Model,Serial | ConvertTo-Html -Fragment

In Python, if I do:

for mo in handle.GetManagedObject(None, NetworkElement.ClassId()):

echo mo.Rn . mo.Model

But mo.Ucs doesn't exist:


Can someone clarify to me how I can retrieve that value?

Thanks,

Amir

Enthusiast

Reswaran!

It is Java! Problem Disappears with Java 7.40.

Any plans on fixing this in Python SDK (if issue is there)? Otherwise please update "release notes" if it is a pure Java bug, when You see, that that Java bug has been fixed

BR

Jesper

Hi Reswaran (assume this is Your e-mail alias, but anyway)

I keep getting "Index out of range" (on Windows 7 pc) when I perform ConvertToPython(guiLog =True,path=logfile) using Guilog (one time out of 10, it succeeds, and I do not get this error).

I have tried with Python 2.7.8 and 2.7.3, with Java 7.55 and 7.64, and both "natively" in Windows 7 and through Cygwin.

The ConvertToPython is crucial for creating Python programs, so this is a Servere Issue.

BR

Jesper

*** Convert to Python ***

### Please review the generated cmdlets before deployment

Traceback (most recent call last):

  File "conv1.py", line 57, in <module>

    main()

  File "conv1.py", line 53, in main

    if not f1(args): pass

  File "conv1.py", line 34, in f1

    ConvertToPython(guiLog =True,path=logfile)

  File "C:\Python27\lib\site-packages\UcsSdk\WatchUcsGui.py", line 1185, in ConvertToPython

    IfPathOrLiteralPath(path,literalPath,True)

  File "C:\Python27\lib\site-packages\UcsSdk\WatchUcsGui.py", line 1144, in IfPathOrLiteralPath

    FindXmlRequestsInFile_test(fileStream, guiLog)

  File "C:\Python27\lib\site-packages\UcsSdk\WatchUcsGui.py", line 1126, in FindXmlRequestsInFile_test

    ExtractXML(fileStream, line)

  File "C:\Python27\lib\site-packages\UcsSdk\WatchUcsGui.py", line 1109, in ExtractXML

    GenerateCmdlets(requestString)

  File "C:\Python27\lib\site-packages\UcsSdk\WatchUcsGui.py", line 1064, in GenerateCmdlets

    cmdlet = GenerateConfigConfCmdlets(xmlString)

  File "C:\Python27\lib\site-packages\UcsSdk\WatchUcsGui.py", line 524, in GenerateConfigConfCmdlets

    node = topNode.getElementsByTagName("inConfig")[0]

IndexError: list index out of range

CreatePlease to create content
Content for Community-Ad
July's Community Spotlight Awards
This widget could not be displayed.