cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
987
Views
0
Helpful
3
Replies

HowTo Handle Interfaces as a dropdown list in NSO

Jerems
Spotlight
Spotlight

Hi,

I am currently trying to build a l3vpn service which requests several parameters. Some of these mandatory parameters are interfaces.

Instead of having to input a string i would have liked to modelize the devices and their interfaces to let me select the first available one from a dropdown menu. A criteria to select the first available interface could be both the admin state of the interface and a specific description like "free" or "available".

Can you please help me in achieving that ?

Thanks in advance for your help.

Best Regards,

Jerems

1 Accepted Solution

Accepted Solutions

bdolenc01
Level 1
Level 1

If by dropdown list you mean ability to use tab completion in the NSO CLI you can try something like this:

container ios {​
  when "deref(../name)/../ncs:module[1]/ncs:name='tailf-ned-cisco-ios'" {​
    tailf:dependency "../name";​
  }​
  tailf:cli-drop-node-name;​
  list interface {​
    tailf:info "GigabitEthernet interface";​
    key intf-id;​
    leaf intf-id{​
      tailf:info "GigabitEthernet Interface ID";​
      mandatory true;​
      type leafref {​
        path "deref(../../../name)/../ncs:config/ios:interface/ios:GigabitEthernet/ios:name";​
      }​
    }​
  }
}

This roughly translates to:

* This container is only applicable if device-type is IOS

* tailf:dependency ensure that when statement is re-evaluated when device is changed

* tailf:cli-drop-node-name hides ios so you are configuring interfaces directly

* Point to the existing interfaces on the devices by:

   deref(../../../name)../ -> evaluates to /devices/device[name]/ncs:config/ios:interface/ios:GigabitEthernet/ios:name

 

Then you repeat the whole thing with appropriate paths for other device types you want to support. Use model above just as guidance, if you are using NSO with CDM, paths will be probably different. By expanding the leafref you can probably achieve what you want by looking into the description.

 

Note that having references to device models in your service model is kinda antipattern, since service models should be device agnostic. 

View solution in original post

3 Replies 3

bdolenc01
Level 1
Level 1

If by dropdown list you mean ability to use tab completion in the NSO CLI you can try something like this:

container ios {​
  when "deref(../name)/../ncs:module[1]/ncs:name='tailf-ned-cisco-ios'" {​
    tailf:dependency "../name";​
  }​
  tailf:cli-drop-node-name;​
  list interface {​
    tailf:info "GigabitEthernet interface";​
    key intf-id;​
    leaf intf-id{​
      tailf:info "GigabitEthernet Interface ID";​
      mandatory true;​
      type leafref {​
        path "deref(../../../name)/../ncs:config/ios:interface/ios:GigabitEthernet/ios:name";​
      }​
    }​
  }
}

This roughly translates to:

* This container is only applicable if device-type is IOS

* tailf:dependency ensure that when statement is re-evaluated when device is changed

* tailf:cli-drop-node-name hides ios so you are configuring interfaces directly

* Point to the existing interfaces on the devices by:

   deref(../../../name)../ -> evaluates to /devices/device[name]/ncs:config/ios:interface/ios:GigabitEthernet/ios:name

 

Then you repeat the whole thing with appropriate paths for other device types you want to support. Use model above just as guidance, if you are using NSO with CDM, paths will be probably different. By expanding the leafref you can probably achieve what you want by looking into the description.

 

Note that having references to device models in your service model is kinda antipattern, since service models should be device agnostic. 

Jerems
Spotlight
Spotlight

Hi bdolenc01 !

Thanks a lot for your quick answer ! Looking at your last note, i guess this is where SLA (CFS/RFS) comes in

Thanks,

Jerems

 

 

Jerems
Spotlight
Spotlight

I aim to have specific packages for each type of devices. In my case there could be Cisco and Juniper devices.

How should i proceed when i have to call an external package called "interface" in  my "upper" service package where i need to populate my template with an interface ? Moreover Would you create a specific package per vendor interface implementation ? cisco-interface, juniper-interface and so on...

Thanks again !
Jerems