cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements
616
Views
0
Helpful
3
Replies
Jerems
Beginner

HowTo Handle Interfaces as a dropdown list in NSO

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
Beginner

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
Beginner

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

Jerems
Beginner

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
Beginner

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