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

Is there a way to adjust the spacing for NSO show commands?

We are using NSO in an enterprise network and are using service to apply company standards across the network. Because of this, we have some device-groups and services that hundreds of devices in them. When using the command 'show running-config devices device-group xyz' or 'show services ntp xyz', it is quite hard to read the clumped together wrap around terminal way that NSO displays the information. I was hoping for something like the way the devices show when performing the command 'devices device ?', where they are in columns and spaced out for easy reading. My issue isn't just with it being hard to see which devices are all affected by a service or in my device group, but if I'm making changes to either and want to do a 'commit dry-run' to check things over first, it is quite hard to be able to see the differences when there is a glob of information without a consistent spacing between devices. I know we could write an action to do this, but we'd rather spend our time on service development.

5 Replies 5

vleijon
Cisco Employee
Cisco Employee
There are a lot of options in the cli. For insance, you can try doing show x | tab to display as a table, or show x | display json (or many other options) to show in a json format. You can also use | de-select and | select to do queries.

Sometimes, the leaf is just a string that is controlled by the device, acl:s is a common example, then it is hard to do much in nso (though you can always make custom filters).

If none of these options help, please try to give me an example of the output.

Thanks for the response, but those don't help too much. The best one I think I've found is 'display xml'. But here is a small example of about 55 devices in a group, in production we have some groups/services that contain 800 devices. When trying to view the group, or making changes and performing commit dry-run to view the changes, it's hard to see everything easily. 

 

------------------------------------------------------------------------------------------------

admin@ncs# show running-config devices device-group example

devices device-group example
device-name [ fake0 fake1 fake10 fake11 fake12 fake13 fake14 fake15 fake16 fake17 fake18 fake19 fake2 fake20 fake21 fake22 fake23 fake24 fake25 fake26 fake27 fake28 fake29 fake3 fake30 fake31 fake32 fake33 fake34 fake35 fake36 fake37 fake38 fake39 fake4 fake40 fake41 fake42 fake43 fake44 fake45 fake46 fake47 fake48 fake49 fake5 fake50 fake6 fake7 fake8 fake9 ios0 ios1 ios2 ios3 ios4 ]
!
admin@ncs# show running-config devices device-group example | tab
DEVICE
NAME NAME LATITUDE LONGITUDE ALTITUDE DEVICE NAME GROUP
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
example - - - - [ fake0 fake1 fake10 fake11 fake12 fake13 fake14 fake15 fake16 fake17 fake18 fake19 fake2 fake20 fake21 fake22 fake23 fake24 fake25 fake26 fake27 fake28 fake29 fake3 fake30 fake31 fake32 fake33 fake34 fake35 fake36 fake37 fake38 fake39 fake4 fake40 fake41 fake42 fake43 fake44 fake45 fake46 fake47 fake48 fake49 fake5 fake50 fake6 fake7 fake8 fake9 ios0 ios1 ios2 ios3 ios4 ] -

!
admin@ncs# show running-config devices device-group example | display xml
<config xmlns="http://tail-f.com/ns/config/1.0">
<devices xmlns="http://tail-f.com/ns/ncs">
<device-group>
<name>example</name>
<device-name>fake0</device-name>
<device-name>fake1</device-name>
<device-name>fake10</device-name>
<device-name>fake11</device-name>
<device-name>fake12</device-name>
<device-name>fake13</device-name>
<device-name>fake14</device-name>
<device-name>fake15</device-name>
<device-name>fake16</device-name>
<device-name>fake17</device-name>
<device-name>fake18</device-name>
<device-name>fake19</device-name>
<device-name>fake2</device-name>

------------------------------------------------------------------------------------------------

 

So the XML is the best, as it's easy to separate the devices and see each (where the all in one line format is strenuous on the eyes).

With 800 devices it can be quite cluttered, and it'd be nice to see the output in something like a table or columns where the spacing is more consistent.

I tried the show x | tab, as you can see above, but it still has all of the devices in the device-group (device-list for services example) in one line.

 

So, the formatting is mostly good at formatting “between” elements not inside of elements, since this is a leaf-list the formatting falls a bit flat. As you can see | tab is completely useless for this use-case.

You can use xml format and you can use | match to search for individual things, and probably use commit dry-run outformat xml to get a better overview of changes.

Unfortunately I don’t have the perfect answer here, you can do little cli modifications, but that seems like a lot of effort for the results in this case. Someone else might know some trick though.

One thing I do sometimes for common tasks is to create a CLI command. I added the following command:

 

admin@ncs> dump-group group DAN

   ios0

   ios1

   xr0

   xr1

[ok][2018-12-18 15:28:01]

admin@ncs>

 

I've added the python script which implements the command if its of interest

-Dan

import ncs

import _ncs

import _ncs.maapi as maapi

import ncs.maagic as maagic

import sys

import argparse

import os

 

step = 1

services = []

port = 0

devcfg = ""

 

def print_ncs_command_details():

    print """

        begin command

            modes: oper config

            styles: c i j

            cmdpath: dump-group

            help: Dump device group device members

        end

 

        begin param

          name: group

          presence: mandatory

          flag: -g

          help: Device group to dump

        end

 

        """

def main(argv):

    global services

    global port

    global devcfg

    parser = argparse.ArgumentParser()

    parser.add_argument("-c", "--command", action='store_true', dest='command', help="command")

    parser.add_argument("-g", "--group", action='store', dest='group', help="device group")

    parser.add_argument("-v", "--verbose", action='store_true', dest='verbose', help="verbose")

 

    args = parser.parse_args()

 

    if args.command:

        print_ncs_command_details()

        exit(0)

 

    with ncs.maapi.single_read_trans('admin', 'Device-Group' ) as t:

 

      root = maagic.get_root(t)

 

      if root.ncs__devices.device_group.exists(args.group) == False:

         print "Device group [%s] doesn't exist !!"

      

      group = root.ncs__devices.device_group[args.group]

     

      for dev in group.device_name:

         print '   %s' % dev

      

         

if __name__ == '__main__':

    main(sys.argv[1:])

Thanks Dan, but I am looking for something more general. The device-group is one use case, but we also have some services that are network wide standards (enterprise environment). So the devices in a service list can become quite large, and there are multiple services.

For now I think I will tell the operations team to use 'dry-run | display xml' for changes to a large device-group/service lists, as this will list the affected devices (add/delete) at the bottom instead of the entire list of devices in the group/list.

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: