CiscoDevNet / ydk-gen

Generate model-driven APIs from YANG models
http://ciscodevnet.github.io/ydk-gen/
Apache License 2.0
137 stars 74 forks source link

Cisco-IOS-XR-aaa-locald-admin-cfg : Bad element error for leaf "secret" #556

Closed sabommen closed 7 years ago

sabommen commented 7 years ago

I am trying to configure user using "Cisco-IOS-XR-aaa-locald-admin-cfg" module , getting bad element error for "secret" leaf. Corresponding code and values are show below:

aaa = xr_aaa_localid_adm_cfg.Aaa() username = aaa.usernames.Username() usergroup_under_username = username.usergroup_under_usernames.UsergroupUnderUsername() usergroup_under_username.name = "root-lr" username.usergroup_under_usernames.usergroup_under_username.append(usergroup_under_username) username.name = "labuser" username.secret ="$1$qW1C$fyjWzR/IsB/gD7Dxlkpjc/" aaa.usernames.username.append(username) crud_service.create(provider,aaa)

Error screen shot is attached.

sabommen commented 7 years ago

bad_element aaa_admin_logs.txt

psykokwak4 commented 7 years ago

546

111pontes commented 7 years ago

If you're trying to create a username on an XR device, take a look at the ydk-py-sample repo. The error that you captured came from the XR device. You don't seem to get any exception from local data validation on your script. Do you have an XML payload that works with your device?

sabommen commented 7 years ago

Have tried configuring username using "Cisco-IOS-XR-aaa-lib-cfg" module, I am able to configure without any issue. But ,same thing if I am trying with "Cisco-IOS-XR-aaa-locald-admin-cfg" module, getting bad element error for "secret" field. I don't see any difference between both the modules for "username container" except that, in Cisco-IOS-XR-aaa-lib-cfg module username container has two extra leaves (ordering_index and password) compared to Cisco-IOS-XR-aaa-locald-admin-cfg.

ghost commented 7 years ago

The issue is with your script. It seems that in XR 6.3.1 the model changed and the <secret/> leaf changed to a container. See the YDK 6.3.1 documentation for this here.

So, when I installed ydk 0.6.1 and ydk-models-cisco-ios-xr 6.3.1, I get the below error with your script.

YPYModelError: Invalid value '$1$qW1C$fyjWzR/IsB/gD7Dxlkpjc/' in '<ydk.models.cisco_ios_xr.Cisco_IOS_XR_aaa_locald_admin_cfg.Aaa.Usernames.Username.Secret object at 0x1087dcf68>'

After modifying the script for 6.3.1, it is working:

from ydk.models.cisco_ios_xr import Cisco_IOS_XR_aaa_locald_admin_cfg as xr_aaa_localid_adm_cfg
aaa = xr_aaa_localid_adm_cfg.Aaa()

username = aaa.usernames.Username()

usergroup_under_username = username.usergroup_under_usernames.UsergroupUnderUsername()
usergroup_under_username.name = "root-lr" 
username.usergroup_under_usernames.usergroup_under_username.append(usergroup_under_username)

username.name = "labuser"
username.secret.secret5 =  "$1$qW1C$fyjWzR/IsB/gD7Dxlkpjc/"
aaa.usernames.username.append(username)
ghost commented 7 years ago

You could even create a DDTS for the aaa component for the 'Cisco_IOS_XR_aaa_locald_admin_cfg' yang model breakage of backward compatibility as the same problem you faced could also affect customers.