07-07-2025 12:57 AM
I develop a tool base on NSO Action. I'd like to log the input received by the Action. I can do that with a lengthy code that access to all the data (including containers and lists) to retrive and log each data.
I wonder if a smarter way to do so exists. Maybe something that produces a printable text of a completa data tree.
Solved! Go to Solution.
07-23-2025 04:10 AM
An Action input is a maagic.Node object.
You should be able to use the ncs.maagic.as_pyval(node) method and then print the python object as it fits you.
Relative example follows.
In [7]: node = root.ncs__devices.global_settings
In [8]: ncs.maagic.as_pyval(node)
Out[8]:
{'connect_timeout': 20,
'read_timeout': 20,
'write_timeout': 20,
'no_wait_for_lock': False,
'wait_for_lock': None,
'ssh_keep_alive': {'interval': 20, 'count': 3},
'ssh_algorithms': {'public_key': [Enum string="ssh-ed25519" value="2",
Enum string="ecdsa-sha2-nistp256" value="3",
Enum string="ecdsa-sha2-nistp384" value="4",
Enum string="ecdsa-sha2-nistp521" value="5",
Enum string="rsa-sha2-512" value="8",
Enum string="rsa-sha2-256" value="7"],
'kex': [Enum string="curve25519-sha256" value="18",
Enum string="curve25519-sha256@libssh.org" value="19",
Enum string="ecdh-sha2-nistp256" value="21",
07-23-2025 04:10 AM
An Action input is a maagic.Node object.
You should be able to use the ncs.maagic.as_pyval(node) method and then print the python object as it fits you.
Relative example follows.
In [7]: node = root.ncs__devices.global_settings
In [8]: ncs.maagic.as_pyval(node)
Out[8]:
{'connect_timeout': 20,
'read_timeout': 20,
'write_timeout': 20,
'no_wait_for_lock': False,
'wait_for_lock': None,
'ssh_keep_alive': {'interval': 20, 'count': 3},
'ssh_algorithms': {'public_key': [Enum string="ssh-ed25519" value="2",
Enum string="ecdsa-sha2-nistp256" value="3",
Enum string="ecdsa-sha2-nistp384" value="4",
Enum string="ecdsa-sha2-nistp521" value="5",
Enum string="rsa-sha2-512" value="8",
Enum string="rsa-sha2-256" value="7"],
'kex': [Enum string="curve25519-sha256" value="18",
Enum string="curve25519-sha256@libssh.org" value="19",
Enum string="ecdh-sha2-nistp256" value="21",
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