cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
170
Views
0
Helpful
2
Replies
Highlighted
Cisco Employee

YDK : adding encapsulation dot1q 10 under interface - not getting pushed

please help, all other parameters except encapsulation are being pushed

 

ydk code:

from ydk.models.cisco_ios_xr import Cisco_IOS_XR_ifmgr_cfg as xr_intf
from ydk.models.cisco_ios_xr import Cisco_IOS_XR_l2_eth_infra_datatypes as xr_l2_eth_infra_datatypes
from ydk.types import Empty
 
#interface encapsulation
interface_configurations = xr_intf.InterfaceConfigurations()
interface_configuration = interface_configurations.InterfaceConfiguration()
interface_configuration.active = "act"
interface_configuration.interface_name = "GigabitEthernet0/0/0/0.200" 
interface_configuration.interface_mode_non_physical = xr_intf.InterfaceModeEnum.default
interface_configuration.description= "*****DESCRIPTION*******" #INTERFACE INPUT GIVEN HERE
 
interface_configurations.interface_configuration.append(interface_configuration)
primary = interface_configuration.ipv4_network.addresses.Primary()
primary.address = "192.168.200.2"
primary.netmask = "255.255.255.252"
 
interface_configuration.ipv4_network.addresses.primary = primary

#encapsulation under interface
encapsulation_under_int = interface_configuration.VlanSubConfiguration.VlanIdentifier()
encapsulation_under_int.vlan_type = xr_l2_eth_infra_datatypes.Vlan.vlan_type_dot1q
encapsulation_under_int.first_tag = 10
 
the encapsulation data is not getting added to RPC sent to device:
============= Sending RPC to device =============
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"><edit-config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<target>
<candidate/>
</target>
<config><interface-configurations xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="merge">
<interface-configuration>
<active>act</active>
<interface-name>GigabitEthernet0/0/0/0.200</interface-name>
<interface-mode-non-physical>default</interface-mode-non-physical>
<description>*****DESCRIPTION*******</description>
<vrf xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-infra-rsi-cfg">TEST-VRF</vrf>
<ipv4-network xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ipv4-io-cfg">
<addresses>
<primary>
<address>192.168.200.2</address>
<netmask>255.255.255.252</netmask>
</primary>
</addresses>
</ipv4-network>
<qos xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-qos-ma-cfg">
<output>
<service-policy>
<service-policy-name>TEST_POLICY</service-policy-name>
</service-policy>
</output>
<input>
<service-policy>
<service-policy-name>TEST_POLICY</service-policy-name>
</service-policy>
</input>
</qos>
</interface-configuration>
</interface-configurations>
</config>
</edit-config>
</rpc>
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Participant

The vlan-identifier is a presence container; see documentation. Therefore you are missing one line:

#encapsulation under interface
encapsulation_under_int = interface_configuration.VlanSubConfiguration.VlanIdentifier()
encapsulation_under_int.vlan_type = xr_l2_eth_infra_datatypes.Vlan.vlan_type_dot1q

encapsulation_under_int.first_tag = 10
interface_configuration.vlan_sub_configuration.vlan_identifier = encapsulation_under_int

 

Yan Gorelik
YDK Solutions

View solution in original post

2 REPLIES 2
Highlighted
Participant

The vlan-identifier is a presence container; see documentation. Therefore you are missing one line:

#encapsulation under interface
encapsulation_under_int = interface_configuration.VlanSubConfiguration.VlanIdentifier()
encapsulation_under_int.vlan_type = xr_l2_eth_infra_datatypes.Vlan.vlan_type_dot1q

encapsulation_under_int.first_tag = 10
interface_configuration.vlan_sub_configuration.vlan_identifier = encapsulation_under_int

 

Yan Gorelik
YDK Solutions

View solution in original post

Highlighted

Thank you! It has been great help in understanding how to use ydk-py

 

Content for Community-Ad
Cisco Community October 2020 Spotlight Award Winners