cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1065
Views
0
Helpful
2
Replies

Service Template XML Variable when using Choice

lukezskywalk
Level 1
Level 1

Hi everyone, I am trying to build a simple qos service template. Just wondering about passing variables to the template xml from Yang using the choice 

 

module qos {

augment /ncs:services {

 

list qos {
key vpn-name;
uses ncs:service-data;
ncs:servicepoint "qos";

 

leaf vpn-name {
type string;
}

// may replace this with other ways of refering to the devices.

leaf-list device {
type leafref {
path "/ncs:devices/ncs:device/ncs:name";
}
}

 

container perqos {
  choice qos-model {
    case model1 {
      container vpn-trunk {

         leaf vlan-id {
            type uint16 {
             range "1..4096";

            }

        }

       }

    }

  case model2 {
      container vpn-access {

         leaf vlan-id {
            type uint16 {
             range "1..4096";

           }

      }

    }

 }

}

}

}

}

 

My XML template

 

<class-map>
   <name>LAN_{/vpn-name}</name>
     <prematch>match-any</prematch>
     <match>
     <matchRule>vlan {<NEED HELP HERE>/vlan-id}</matchRule>
</match>
</class-map>

 

How do I reference the vlan-id in a node that is chosen based on the Choice structure? Preferred not to use a script language.

 

2 Replies 2

lukezskywalk
Level 1
Level 1
I figured it out. I can just use //vlan-id. The Xpath definition for // = Selects nodes in the document from the current node that match the selection no matter where they are.

Since the choice will only leave 1 configurable sub container, the vlan-id is unique in my case and I can use this without conflict.

lukezskywalk
Level 1
Level 1
So my original question of using some of logic to fill the XML template still remains. If I have two configuration snipet (1 for each Choice), how do I do this?

If choice = vpn-trunk, xml template will use vpn-trunk configuration. If choice = vpn=access, xml template will use vpn-access configuration.