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

Shutdown interface before applying a service, and turn it on later

W. Y.
Level 1
Level 1

Hello everyone, 

I am facing an implementation problem in NSO. I tried several approaches, but none of them works.

The program should on updating process (within pre_modification if po == 1) turn off interfaces, and turn on then in post_modification and if op==1.

Approach 1: open another write transaction and shutdown ( shutdown.create() ) interfaces, and apply the transaction.

Approach 2: call a NSO action that can turn off or turn on the interface. The program calls the action in order to shutdown the interface.

But neither of them works. The program stops after the interface face has been turned off and does not until the application is timeout.

I am looking for a solution to achieve it. Any advice or sharing is appreciated.

Best, 

Wei

Error Message in log:

 

<INFO> 05-Aug-2022::11:29:11.271 dbsystel_common.helpers ncs-dp-4002-network-access-control:main-2-usid-169-interface-switcher: - Gi1/0/11 is from Active ==> Inactive

<ERROR> 05-Aug-2022::11:31:11.693 network-access-control ncs-dp-4002-network-access-control:main-1-th-631: - external error (19): application timeout

<ERROR> 05-Aug-2022::11:31:11.693 network-access-control ncs-dp-4002-network-access-control:main-1-th-631: - Traceback (most recent call last):

  File "/opt/ncs/ncs-5.6.4/src/ncs/pyapi/ncs/application.py", line 463, in wrapper

    pl = fn(self, tctx, op, kp, root, proplist)

  File "/nso/run/state/packages-in-use/1/network-access-control/python/network_access_control/main.py", line 117, in cb_pre_modification

    self.interfaces_switcher(root, device.name, 'Gi', self.interfaces['Gi'], 'off')

  File "/nso/run/state/packages-in-use/1/network-access-control/python/network_access_control/main.py", line 143, in interfaces_switcher

    action.request(action_input)

  File "/opt/ncs/ncs-5.6.4/src/ncs/pyapi/ncs/maagic.py", line 1602, in request

    output = self._backend._request_action(tv, 0, self._path)

  File "/opt/ncs/ncs-5.6.4/src/ncs/pyapi/ncs/maagic.py", line 139, in _request_action

    return self.request_action_th(params, path)

  File "/opt/ncs/ncs-5.6.4/src/ncs/pyapi/ncs/maapi.py", line 1511, in proxy

    return real(self2.maapi.msock, self2.th, *args, **kwargs)

_ncs.error.Error: external error (19): application timeout

 

2 Replies 2

rogaglia
Cisco Employee
Cisco Employee

Hi wei,

I believe you are misinterpret what pre/post modifications do. They are all part of the same transactions, the difference is that they are applied before or after the FASTMAP algorithm.

To solve your problem, the first question is why would you need to do this? sounds like a badly behaving device. If this is "how I program this device", maybe that logic needs to be part of the NED logic. Look at the ALU-SR NED where we do need to do exactly that but it is all hidden from the NSO developer as the NED takes care of it.

If it is not the "device issue" but rather how you want to make your process running, you can program this logic in NSO but you would need to use the "nano-services" framework. There you can specify to run pre-post actions for every service call and in this case it would be in a different transaction. Check nano-services here: https://developer.cisco.com/docs/nso/guides/#!nano-services-for-staged-provisioning

Hi rogaglia, 

thank you for pointing out that pre_ and post_ are using the same transaction. I am also aware of that, but didnt expect that opening another transaction is somehow interrupting it.

I tested it on NetSim currently, so it should not be a badly behaving device. 

I read about nano service I think it can actualise it, but just preferred a straightforward/easy implementation. 

I will try nano service and update this post. Thank you rogaglia.