cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1930
Views
2
Helpful
15
Replies

leaf original-value displayed in python service

ryan-hitch
Level 4
Level 4

I am seeing an odd issue where the following python service code is assigning the 'original-value' (999) of a leaf, while if I run the same code from a python shell I see the current value (2004). I am expecting to see the current value (2004) in my service code. Why am I not seeing this?

### Version: NSO 4.5.5

### XML display from ncs_cli

show configuration devices device s02-sw-2 config ios:interface GigabitEthernet 0/1 | display xml

            <vlan refcounter="2"  original-value="999">2004</vlan>

### Code from python service:

vlan = root.devices.device[switch.switch_name].config.ios__interface.GigabitEthernet[switch_interface.switch_interface_id].switchport.access.vlan

self.log.info('ASDF switch:%s service:%s vpn:%s int:%s vlan:%s' % (switch.switch_name, service.name, vpn.name,  switch_interface.switch_interface_id, vlan))

### Logged output from python service (ncs-python-vm-vpn-environment.log)

<INFO> 03-Apr-2018::15:08:18.674 vpn-environment ncs-dp-26855-vpn-environment:main-3-th-6008: - ASDF switch:s02-sw-2 service:CUST1 vpn:TEST1 int:0/1 vlan:999

### Interactive python output

[user@ncs]$ python

Python 2.7.5 (default, Aug  4 2017, 00:39:18)

[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> import ncs.maapi as maapi

>>> import ncs.maagic as maagic

>>> m = maapi.Maapi()

>>> m.start_user_session('admin', 'test_context')

>>> t = m.start_write_trans()

>>> root = maagic.get_root(t)

>>> vlan = root.devices.device['s02-sw-2'].config.ios__interface.GigabitEthernet['0/1'].switchport.access.vlan

>>> vlan

2004

>>>

15 Replies 15

Yes. "root" and "service" are handles into the current transaction, where the service changes have been undone. If you open a new transaction towards running, you will see the actual running values there (unless you start modifying that transaction too).

There are cases where reading from running is useful. I still haven't understood why that would be a good idea in your use case, however.