06-26-2019 02:07 PM
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
08-08-2019 01:32 PM
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
In the "Copy XML" box that comes up, the classid is the first element in the output:
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.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide