cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements

302
Views
5
Helpful
1
Replies
anthonyperry
Cisco Employee

Cisco_IOS_XR_um_interface_cfg perf-mon container not accessible

Spoiler
 

Hello,

 

When trying to configure “controller optics 0/0/0/3 perf-mon enable” on a NCS5500 I get the “’Controller’ object has no attribute ‘perf_mon’” error even though the Cisco-IOS-XR-um-interface-cfg.yang augments the CiscoIOS-XR-um-cont-optics-cfg.yang data model that has a perf-mon container:

 

1240        def set_perf_monitor(self ,port, perf_mon_enabled=True, enable=True):

1241            """

1242            This configures perf_mon

1243            :param port: port, ex 0/0/0/5 0/0/0/10

1244            :param perf_mon_enabled: True to enable perf-mon, False to disable perf-mon

1245            :param enable: False to remove perf-mon config

1246            :return: None

1247            """

1248            port_instance = re.search(r'^(\d+/\d+/\d+/\d+)', port).group()

1249            contr_conf = xr_um_int_cfg.Interfaces()

1250

1251            contr_configuration = contr_conf.Controller()

1252            contr_configuration.controller_name = 'Optics' + port_instance

1253            pdb.set_trace()

1254 ->         contr_perf_mon_cfg = contr_configuration.Perf_mon()

1255            if enable:

1256                if perf_mon_enabled:

1257                    contr_perf_mon_cfg.disable = DELETE()

1258                    contr_perf_mon_cfg.enable._is_presence = True

1259                else:

1260                    contr_perf_mon_cfg.enable = DELETE()

1261                    contr_perf_mon_cfg.disable._is_presence = True

1262            else:

1263                    contr_perf_mon_cfg.enable = DELETE()

1264                    contr_perf_mon_cfg.disable._is_presence = True

1265            contr_configuration.perf_mon = contr_perf_mon_cfg

1266            contr_conf.controller.append(contr_configuration)

1267            self.device.create(contr_conf)

(Pdb) contr_configuration

<ydk.models.cisco_ios_xr.Cisco_IOS_XR_um_interface_cfg.Interfaces.Controller object at 0x7f0b5b238518>

(Pdb) contr_configuration.controller_name

'Optics0/0/0/3'

(Pdb) contr_configuration.perf_mon

*** AttributeError: 'Controller' object has no attribute 'perf_mon'

(Pdb)

(Pdb) contr_configuration.fec

*** AttributeError: 'Controller' object has no attribute 'fec'

(Pdb) contr_configuration.baud_rate

(Pdb)

 

I see there are other containers that are not accessible as well.

 

This issue is seen with other augmented data models as well.

 

So can you all please let me know if I am missing something or if this is a known issue?

 

http://allure.cisco.com/auto/tftpboot-projects/anthonyp/Cafy/cafyap/work/archive/optics_ydk_test_20220505-222314_p26015/reports/index.html

1 REPLY 1
ygorelik
Cisco Employee

First of all, you are erroneously use the model API when building the model object. Please check the generated Python API (module Cisco_IOS_XR_um_interface_cfg.py in your bundle). You have to keep in mind that all the components of the class are pre-initialized in the class instance, just do not have values. The exception is for the presence containers, if applicable the corresponding object must be initialized explicitly. The list elements must be initialized explicitly and then added to corresponding YList in the parent class. 

Let's check your code:

1249            contr_conf = xr_um_int_cfg.Interfaces()
1250
1251            contr_configuration = contr_conf.Controller()
1252            contr_configuration.controller_name = 'Optics' + port_instance

missing here: contr_conf.controller.append(contr_configuration) # have to add list element to YList

1253            pdb.set_trace()

1254 ->         contr_perf_mon_cfg = contr_configuration.perf_mon # all the containers are present in the instance

Second. The errors like "AttributeError: 'Controller' object has no attribute 'perf_mon'" show that YANG module CiscoIOS-XR-um-cont-optics-cfg.yang was not added to the bundle. Please check your bundle profile, add the missing module, and regenerate the bundle.

Yan

Create
Recognize Your Peers
Content for Community-Ad