07-24-2019 12:55 AM
From nso cli i can rename device name to some new name
rename devices device old_name new_name
commit no-networking
i am trying this but getting error:
with ncs.maapi.Maapi() as m:
with ncs.maapi.Session(m, 'azhar', 'system'):
with m.start_write_trans() as t:
root = ncs.maagic.get_root(t)
old_device = root.devices.device['MADSIM11']
m.move(t.th, ['new_device'], old_device._path)
t.apply(True, maapi.COMMIT_NCS_NO_NETWORKING)
this is the error i am getting:
Traceback (most recent call last):
File "/home/azhar/Documents/scripts/rename_nso_devices.py", line 173, in <module>
m.move(t.th, [new_device], old_device._path)
File "/opt/ncs/current/src/ncs/pyapi/ncs/maapi.py", line 272, in proxy
return real(self2.msock, *args, **kwargs)
TypeError: tokey[0] must be a _ncs.Value instance
[Finished in 0.1s with exit code 1]
Can someone please help here.
Thanks
Solved! Go to Solution.
07-24-2019 03:38 AM
Hi,
from _ncs.maapi docs tokey argument is a list of confdValues.
So try creating the Value object first and use that when calling move method. E.g
... _new_device = _ncs.Value('new_device', _ncs.C_BUF) m.move(t.th, [_new_device], old_device._path) t.apply(True, maapi.COMMIT_NCS_NO_NETWORKING)
Hope it helps,
Simon
07-24-2019 03:38 AM
Hi,
from _ncs.maapi docs tokey argument is a list of confdValues.
So try creating the Value object first and use that when calling move method. E.g
... _new_device = _ncs.Value('new_device', _ncs.C_BUF) m.move(t.th, [_new_device], old_device._path) t.apply(True, maapi.COMMIT_NCS_NO_NETWORKING)
Hope it helps,
Simon
07-24-2019 06:27 AM
Hi Simon,
Thank you, it works fine.
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