cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
983
Views
0
Helpful
1
Replies

Extracting value from python cdb.get API

shgaiton
Cisco Employee
Cisco Employee

Hi All,

 

I am trying to fetch a value via cdb.get API in python as mentioned below:

admin_state = cdb.get(cdb_socket, path)

The expectation is to get a string value but I get something like this:

Admin State: (<_ncs.Value type=C_ENUM_HASH(28) value='enum<3>'>,)

I just need the value i.e. 'enum<3>'. How to fetch that?

 

Thanks, Shanth

1 Reply 1

ramkraja
Cisco Employee
Cisco Employee

 

admin_state = cdb.get(cdb_socket, path)

The expectation is to get a string value but I get something like this:

Admin State: (<_ncs.Value type=C_ENUM_HASH(28) value='enum<3>'>,)

I just need the value i.e. 'enum<3>'. How to fetch that?


cdb.get returns a 'Value' object, as you see above.

If you only want 'enum<3>', that is easy - just use Python's builtin str() method on the returned _ncs.Value object.

If you want the corresponding label in that enumeration, it is a bit more involved.

/Ram