Closed sabommen closed 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?
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.
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)
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.
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.