06-10-2017 02:32 AM - edited 03-01-2019 03:51 AM
Hi,
I'm trying to build L2VPN service in which we need to allow a range of vlans in the customer side. The configuration is as follow:
device {
name ME0
data interface GigabitEthernet0/2
no switchport
service instance 2 ethernet
encapsulation dot1q 2-10
bridge-domain 2
exit
no shutdown
exit
}
The xml template is as follow:
result-xml <devices xmlns="http://tail-f.com/ns/ncs">
<device>
<name>ME0</name>
<config>
<interface xmlns="urn:ios">
<GigabitEthernet>
<name>0/2</name>
<service>
<instance>
<id>2</id>
<ethernet/>
<encapsulation>
<dot1q>
<id>2</id>
<id>3</id>
<id>4</id>
<id>5</id>
<id>6</id>
<id>7</id>
<id>8</id>
<id>9</id>
<id>10</id>
</dot1q>
</encapsulation>
<bridge-domain>
<bridge-id>2</bridge-id>
</bridge-domain>
</instance>
</service>
</GigabitEthernet>
</interface>
</config>
</device>
</devices>
The question is how to orchestrate this range of vlans and how to translate the output of vlan range from yang model into xml file.
Note that in this service, the customer will enter the first and the last vlan (vlan range can be variable) and NSO will configure this range under the interface.
Thank you.
06-12-2017 12:02 AM
Hi Mohamed,
There could be multiple ways to achieve it but two of them could be as below. You need to write some logic in your RFS service code.
1) Get the first and last VLAN range in yang input. Define a list of VLAN in yang that should be populated by your RFS code. Then you can keep foreach loop in <dot1q> tag in template which will repeat <id> section for all the items of VLAN list.
2) You can move encapsulation portion in another template having single <id> tag and you can repeat this template for all the VLAN values from RFS code.
06-12-2017 05:15 AM
Hi Vishesh,
Thank you for your response.
Regarding the first scenario, how can we make a pool in xml file and receive all values from RFS code.
As I know in xml file, we will receive only one value ($vlan-ID) from RFS code.
Thank you.
06-12-2017 07:29 AM
Hi Mohamed,
That pool you need to make in CDB using Yang model of your service. For example, you can create a list in your service model that will be empty initially. When you get first and last lan range, based on that you need to populate that yang list from RFS code. At the same time, you need to give the reference of your yang list in the xml template using foreach loop. NSO will repeat the section under foreach loop for all the elements of the yang VLAN list. Like, in the below example, tunnel is the yang list which is part of service yang model. <prefix>, <mask> and <forwarding-address> will be repeated for each element of tunnel list. Hope it will help.
<ip xmlns="urn:ios">
<route>
<vrf>
<name>VPN{/vpn-number}</name>
NSO 4.4 Development
257
Templates
Capabilities and Namespaces
<ip-route-forwarding-list foreach="{tunnel}">
<prefix>{network}</prefix>
<mask>{netmask}</mask>
<forwarding-address>10.255.254.{(tunnel-number-1)*4+2}</forwarding-address>
</ip-route-forwarding-list>
</vrf>
</route>
</ip>
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide