12-10-2018 02:34 PM - edited 03-01-2019 04:14 AM
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.
12-11-2018 12:52 AM
12-12-2018 09:46 AM
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.
12-12-2018 10:10 AM
12-18-2018 12:36 PM
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:])
12-19-2018 10:54 AM
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.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide