I am opening a maapi session and using the request_action_th API to do the job. My doubt is, how to pass the params args which expects ‘force’ and ‘noprompt’ to my reload leaf via python?
Also, both leaves force and prompt have types as empty so I am confused.
the namespace is the namespace of your action, not of the root node
the action name is part of the path
the empty-typed leaves are represented as C_XMLTAG values; if you want to indicate that an empty-typed leaf is not present, you just omit it from the TagValue list params.
Minor improvement would be to use the generated namespace Python module instead of repeated _ncs.str2hash calls, so you would do something like
import hw_module_ns as ns
ns_hash = ns.ns.hash
action_reload_hash = ns.ns.hw_module_reload
Larger improvement would be to use the high-level API. So instead of opening a socket, a session, a transaction, then using all the stuff above you would do
from ncs import maapi, maagic
with maapi.single_write_trans(user, context) as trans:
root = maagic.get_root(trans)
action = root.devices.device['netconfd'].live_status.hw_module.oper.location['lc_loc'].actions.reload
params = action.get_input()
params.force.create()
params.noprompt.create()
action.request(params)
(You may also want to check if how you are opening the transaction corresponds to what you need to do - if it really needs to be READ_WRITE towards RUNNING.)