cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
362
Views
5
Helpful
5
Replies
Highlighted
Cisco Employee

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

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
Highlighted
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

Highlighted
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
Highlighted
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

Highlighted
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

Highlighted

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)#

Highlighted

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

Highlighted

Thanks, that make sense!