Showing results for 
Search instead for 
Did you mean: 

Hierarchichal device groups using REGEX

It would be really nice to have the option to use the device-group statement within a device-group and provide a regex to dynamically select the child groups to include. Right now the only option is to statically include groups within groups. This is generally preferred, but for specific use cases, using a well designed hierarchical naming schema for groups, it would make the configuration much easier just to use a regex. Example:


GR-{Region}-{Device_Type} could contain all child groups with the following format:

GR-{Region}-{Country}-{Device_Type} where country refers to all possible countries within a region. If this were to be defined with Regex:


set devices device-group GR-EMEA-FIREWALL device-group regex '^GR-EMEA-.+-FIREWALL$'

would automatically select the desired groups. Adding new sub-groups would not require the extra effort to update all possible parent groups. This would be evaluated at every commit and the groups updated accordingly.


Has this feature been considered for NSO?

Jason Belk
Cisco Employee

I can't speak to whether that feature has been considered or not, but I do have a possible solution. You can access the device groups from the Python API and then use Python logic to select the groups you want from that list. like 

for group in groups:

    if "AMER" in group:

         do something()


I have done that before with device-names, where our naming conventions were logical such as:

for device in device_list:

     if "wan" in

         do  something()



Thanks for the reply, that could help. However the use case in my case is to use CDB configuration templates, no services or python involved. When applying templates you specify either device or device group. There is where I would ideally select groups dynamically via Regex. The solution is just to manually include new groups in parent groups, but that is just a bit static and more tedious to maintain, but it works:

set devices device-group GR-EMEA-FIREWALLS device-group GR-EMEA-DE-FIREWALLS
set devices device-group GR-EMEA-FIREWALLS device-group GR-EMEA-IT-FIREWALLS
set devices device-group GR-EMEA-FIREWALLS device-group GR-EMEA-FR-FIREWALLS
set devices device-group GR-EMEA-FIREWALLS device-group GR-EMEA-ES-FIREWALLS

request devices device-group GR-EMEA-FIREWALLS apply-template template-name TEMPLATE-EMEA-FIREWALLS