cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2454
Views
10
Helpful
1
Replies

How can I get a list of valid class ids with ucsmsdk or ucscsdk?

rcecala
Cisco Employee
Cisco Employee

Hi,

 

I am very new to UCS SDK.  I would like to be able to get a list of valid class ids.

If I do something like this ...

 

foos = ucsm_handle.query_classid(class_id='foo', filter_str=filter_str)

... I get the error ...

ucsmsdk.ucsexception.UcsException: [ErrorCode]: ERR-xml-parse-error[ErrorDescription]: XML PARSING ERROR: no class named foo

I am unsure what class ids are valid and want to obtain a list of valid class id.

 

Thanks

1 Reply 1

rbakri
Cisco Employee
Cisco Employee

Hi there,

I have been trying to figure out a way to do that myself. I have resorted to two options a the moment:

 

1. Navigate to the object in UCS Manager => right-click => copy xml

 

Screen Shot 2019-08-08 at 8.51.44 PM.png

In the "Copy XML" box that comes up, the classid is the first element in the output:

Screen Shot 2019-08-08 at 8.52.45 PM.png

To test, I have a script to check:

 

#! /usr/bin/env python

from ucsmsdk.ucshandle import UcsHandle
import getpass

def query_ucs_for_classid():
    ucs_ip = input("=> ucs system: ")
    ucs_classid = input("=> classid: ")
    ucs_username= input("=> username: ")
    user_passwd = getpass.getpass("=> passowrd: ")


    handle=UcsHandle(ip=ucs_ip, username=ucs_username, password=user_passwd)
    handle.login()
    print("=> logged into {}".format(handle.ip))

    try:
        ucs_query_classid = handle.query_classid(ucs_classid)

        for i in ucs_query_classid:
            print(i)
    except:
        print('=> {} is an incorrect classid'.format(ucs_classid))

    print("=> logging out of {}".format(handle.ip))
    handle.logout()

if __name__ == "__main__": query_ucs_for_classid()

 

The output would look like this:

 

$ ./ucs_check_classid.py
=> ucs system: ucspe1
=> classid: computeBlade
=> username: ucspe
=> passowrd:
=> logged into ucspe1

Managed Object			:	ComputeBlade
--------------
class_id                        :ComputeBlade
admin_power                     :policy
admin_state                     :in-service
asset_tag                       :None
assigned_to_dn                  :
association                     :none
availability                    :available
available_memory                :49152
chassis_id                      :1
check_point                     :discovered
child_action                    :None
conn_path                       :A,B
conn_status                     :A,B
descr                           :
discovery                       :complete
discovery_status                :
dn                              :sys/chassis-1/blade-8
flt_aggr                        :65536
fsm_descr                       :
fsm_flags                       :
fsm_prev                        :DiscoverSuccess
fsm_progr                       :100
fsm_rmt_inv_err_code            :none
fsm_rmt_inv_err_descr           :
fsm_rmt_inv_rslt                :
fsm_stage_descr                 :
fsm_stamp                       :2019-08-08T16:04:20.574
fsm_status                      :nop
fsm_try                         :0
int_id                          :51423
kmip_fault                      :None
kmip_fault_description          :None
lc                              :undiscovered
lc_ts                           :1970-01-01T00:00:00.000
local_id                        :
low_voltage_memory              :not-applicable
managing_inst                   :A
memory_speed                    :not-applicable
mfg_time                        :not-applicable
model                           :UCSB-B200-M4

 

2. Another handy resource is the ucsm xml schema search for the "namingClassId" (line 25). It will have a list of all the classids you can query.

I am sure there is an easier way of doing this but figured I would share how I do it.

I hope this helps.

 

Cisco UCS X-Series Energy Efficiency Offer