cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
461
Views
0
Helpful
2
Replies

How to set metadata on a device config (refcount and backpointer)

Nicolas3
Level 1
Level 1

Hi everyone, 

We need a way to set or modify refcounts on some configurations due to some migrations we are doing.

There is a _ncs.maapi.get_attrs() that gets metadata from a config that works great, we are having trouble making the _ncs.maapi.set_attr() operation:

Captura.PNG

We are doing the following on ipython to test:

#1 - Get Hkeypath from an existing service.
val = _ncs.maapi.get_attrs(m.msock, t.th, [], '/devices/device{TC2471-LAB-02}/config/cisco-ios-xr:prefix-set{CLIENTES_CORPO_GPON_NSO}')
pypath = kpath[0].as_pyval()


#2 - Create _ncs.Value objects for refcount and backref / type C_OBJECTREF(34), type C_INT32(12)
refcount = _ncs.Value(1 , 12)
backref = _ncs.Value(pypath , 34)


#3 - Set backpointer
_ncs.maapi.set_attr(m.msock, t.th, 2147483651, backref,'/devices/device{TC2471-LAB-02}/config/cisco-ios-xr:prefix-set{CLIENTES_CORPO_TC2471-GP-99}')

#4 -Set refcount
_ncs.maapi.set_attr(m.msock, t.th, 2147483650, refcount,'/devices/device{TC2471-LAB-02}/config/cisco-ios-xr:prefix-set{CLIENTES_CORPO_TC2471-GP-99}')

Both set_attr command fails with:

Error: item has a bad/wrong type (5): Not a valid value

Any ideas what we are doing wrong?

2 Replies 2

bstep
Level 1
Level 1

I am in the same boat, I did not have any luck with the python/confd_lib path. Here is where I am at,

  1. Get the original config in xml annotated with metadata with `config?with-service-meta-data` GET request
  2. Process the new config offline
  3. PATCH the new config with new annotations (this updates the config data with annotations but they are useless)
  4. redeploy services with reconcile defaults (this doesn't modify refcounts from above but seems like they now work as expected with shared config)

I haven't fully tested all cases and haven't settled on this solution just yet, but it's the best solution I have thus far...
 

huayyang
Cisco Employee
Cisco Employee

I know you have reasons to do so, but you should NOT modify the refcount/backpointer directly.