cancel
Showing results forĀ 
Search instead forĀ 
Did you mean:Ā 
cancel
1003
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