10-05-2020 01:34 AM - edited 10-05-2020 02:57 AM
Hello,
Usually when I open a transaction with maapi on NSO, I use the below user 'admin', but I need to open transaction and keep information for each user (instead of 'admin') who is triggering the action/service, how can I do it ?
with ncs.maapi.Maapi() as m:
with ncs.maapi.Session(m, 'admin', 'python'):
10-06-2020 01:10 AM
From an action:
with ncs.maapi.Maapi() as m:
with m.start_write_trans(usid=uinfo.usid) as trans:
10-06-2020 02:09 AM
And how to insert uinfo below in service creation ?
def cb_create(self, tctx, root, service, proplist):
10-07-2020 05:43 AM
@nso20 The Transaction comes by default for a Service. If you explicitly want to store an username details then you can achieve from the following way.
1. get the mappi object from the service
2. get `uinfo` from mappi
3. `uinfo.username` contains the transaction username.
my_mappi = ncs.maagic.get_maapi(service) uinfo = my_mappi.get_user_session(my_mappi.get_my_user_session_id())
print(uinfo.username)
By default username is admin, You can add more as @hniska mentioned.
10-06-2020 04:38 AM
Hi, what is it that you want to do? The service create() automatically gives you a transaction already and the FASTMAP code runs without any access check.
From the help: This allows administrators to grant indirect but controlled access to user to execute device configuration changes on devices that they are not allowed to configure directly. The leaf /nacm/enforce-nacm-on-services has been introduced to allow NSO administrators to control this behavior: they can now enforce NACM rules even on changes done by services. Refer to the "NACM Rules and Services" section in the AAA chapter of the Administration Guide for details.
Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the NSO Developer community: