cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1608
Views
5
Helpful
5
Replies

Any way to configure a selective set of devices from NSO cli?

Simon Chow
Cisco Employee
Cisco Employee

Hi,

 

I have device c0, c1, c2, and want to configure c0 and c1 from NSO cli.  If I use the following wildcard, it would catch c2 as well which is unwanted:

 

admin@ncs(config)# devices device c*

admin@ncs(config-device-c*)# config

admin@ncs(config-config)#

 

Is there a way to do this from NSO CLI ?

 

I know about device template, but want to check if there is another way.

 

Thanks,

Simon

2 Accepted Solutions

Accepted Solutions

yfherzog
Cisco Employee
Cisco Employee

One simple way to go about it is to make your configs for one device and before you commit do "top ; show conf | display xml", then copy the output to notepad, and duplicate the <device> block per the devices you want (setting the device names accordingly).

Then you can load these configs to NSO (e.g. with "load merge terminal") and commit.

View solution in original post

lmanor
Cisco Employee
Cisco Employee

Hello Simon,

 

Presuming you want to change the same config on all devices specified as indicated by your example, you can list the devices that you want to configure, much like your c*, but more specifically with a comma separated 'range':

 

admin@ncs(config)# devices device
Possible completions:
A string uniquely identifying the managed device
devxr-0
devxr-1
devxr-2
devxr-3

admin@ncs(config)# devices device devxr-0,2

admin@ncs(config-device-devxr-0,2)# description "test device list"

admin@ncs(config-device-devxr-0,2)# commit dry-run

cli {

    local-node {

        data  devices {

                  device devxr-0 {

             +        description "test device list";

                  }

                  device devxr-2 {

             +        description "test device list";

                  }

              }

    }

}

A bit of a discussion on this in the NSO User Guide, see "Range Expressions" section

 

Device-groups may be a consideration as well.

View solution in original post

5 Replies 5

yfherzog
Cisco Employee
Cisco Employee

One simple way to go about it is to make your configs for one device and before you commit do "top ; show conf | display xml", then copy the output to notepad, and duplicate the <device> block per the devices you want (setting the device names accordingly).

Then you can load these configs to NSO (e.g. with "load merge terminal") and commit.

lmanor
Cisco Employee
Cisco Employee

Hello Simon,

 

Presuming you want to change the same config on all devices specified as indicated by your example, you can list the devices that you want to configure, much like your c*, but more specifically with a comma separated 'range':

 

admin@ncs(config)# devices device
Possible completions:
A string uniquely identifying the managed device
devxr-0
devxr-1
devxr-2
devxr-3

admin@ncs(config)# devices device devxr-0,2

admin@ncs(config-device-devxr-0,2)# description "test device list"

admin@ncs(config-device-devxr-0,2)# commit dry-run

cli {

    local-node {

        data  devices {

                  device devxr-0 {

             +        description "test device list";

                  }

                  device devxr-2 {

             +        description "test device list";

                  }

              }

    }

}

A bit of a discussion on this in the NSO User Guide, see "Range Expressions" section

 

Device-groups may be a consideration as well.

Thanks, both of these solution would do the job!

 

Device-group would have been ideal, but somehow the config option is not available with it:

admin@ncs(config)# devices device-group dg1
admin@ncs(config-device-group-dg1)# config
------------------------------------^
syntax error: unknown command
admin@ncs(config-device-group-dg1)#

The way it works with device-groups is to apply a device template as device-groups could have members from different type of devices.

Thanks, that make sense!
Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the NSO Developer community: