How do I get a list of models or model handles from a Spectrum Global Collection
There are a couple ways to get a complete list of models in a Global Collection, depending on whether you want to use the OneClick GUI or retrieve the data from command line for scripting purposes.
If you want to export this list of models to a spreadsheet format perform the following steps.
If you want to use the Command Line Interface (CLI) for scripting purposes then you need to connect to CLI on each SpectroSERVER in the Global Collection (GC). For example, you may want to get a list of model handles in the GC and then perform a certain action on the device or devices.
If you are unsure which SpectroSERVERs are configured for the GC you can determine this by:
The only way to get the list of model handles for the models in a Global Collection (GC) is to connect through Command Line Interface (CLI) p.er SpectroSERVER where the GC is created on and query the GC to get the models.
For example, if you had one GC called "Router Test" on three SpectroSERVERs you would have to connect to all three SpectroSERVERs, get the model handle of the GC and then execute the "./show children" action. In my example below my three SpectroSERVER names are spectrum01, spectrum02 and spectrum03.
You need to get the model handle of the GC per server. In my example I am going to grep for the model type handle for a Global Collection, 0x10474.
The variable $SPECROOT refers to the SPECTRUM installation area.
From the $SPECROOT/vnmsh directory you would have to execute:
./show models |grep 0x10474 0x1e00a63 Router Test 0x10474 GlobalCollection 0x1e00a62 Routers 0x10474 GlobalCollection
I see two GCs but I am only interested in "Router Test". The model handle for "Router Test" is "0x1e00a63"
From here I execute the "show children" command to get a list of models in that GC:
> ./show children mh=0x1e00a63 MHandle MName MTypeHnd MTypeName &.nbsp; Relation 0x1e0045b 220.127.116.11 0x21000c Rtr_Cisco dynamicGlobalCollects
The results show me I have one model from SpectroSERVER spectrum01.
You then need to "./disconnect" from spectrum01 and connect to the second SpectroSERVER spectrum02.
> ./disconnect disconnect: successful from spectrum01 - connected for 0 hours, 3 minutes
> ./connect spectrum02 connect: successful spectrum02 current landscape is 0x3e900000
You need to get the model handle for the GC on this server:
> ./show models |grep 0x10474 0x3e918bce Router Test 0x10474 GlobalCollection 0x3e918bcd Routers 0x10474 GlobalCollection
The model handle for "Router Test" is "0x3e918bce". I need to use this model handle to get a list of models:
> ./show children mh=0x3e918bce MHandle MName MTypeHnd MTy.peName Relation 0x3e900050 Router1 0x21000c Rtr_Cisco dynamicGlobalCollects 0x3e900058 Router2 0x21000c Rtr_Cisco dynamicGlobalCollects 0x3e900060 Router3 0x21000c Rtr_Cisco dynamicGlobalCollects 0x3e900b68 Router4 0x21000c Rtr_Cisco dynamicGlobalCollects 0x3e900c58 Router5 0x21000c Rtr_Cisco dynamicGlobalCollects 0x3e900c68 Router6 0x21000c Rtr_Cisco dynamicGlobalCollects 0x3e900059 Router7 0x21000c Rtr_Cisco dynamicGlobalCollects 0x3e900052 Router8 0x21000c Rtr_Cisco dynamicGlobalCollects 0x3e900062 Router9 0x21000c Rtr_Cisco dynamicGlobalCollects 0x3e900063 Router10 0x21000c Rtr_Cisco dynamicGlobalCollects . x3e900c4b Router11 0x21000c Rtr_Cisco dynamicGlobalCollects 0x3e912f9b Router12 0x21000c Rtr_Cisco dynamicGlobalCollects 0x3e900044 Router13 0x21000c Rtr_Cisco dynamicGlobalCollects 0x3e900054 Router14 0x21000c Rtr_Cisco dynamicGlobalCollects 0x3e900b74 Router15 0x21000c Rtr_Cisco dynamicGlobalCollects 0x3e900c4c Router16 0x21000c Rtr_Cisco dynamicGlobalCollects 0x3e90004d Router17 0x21000c Rtr_Cisco dynamicGlobalCollects 0x3e900b6d Router18 0x21000c Rtr_Cisco dynamicGlobalCollects 0x3e900c55 Router19 0x21000c Rtr_Cisco dynamicGlobalCollects 0x3e90004e Router20 0x21000c Rtr_Cisco dynamicGlobalCollects 0.x3e900056 Router21 0x21000c Rtr_Cisco dynamicGlobalCollects 0x3e90006e Router22 0x21000c Rtr_Cisco dynamicGlobalCollects 0x3e900b2e Router23 0x21000c Rtr_Cisco dynamicGlobalCollects 0x3e900c4e Router24 0x21000c Rtr_Cisco dynamicGlobalCollects 0x3e90005f Router25 0x21000c Rtr_Cisco dynamicGlobalCollects 0x3e900b1f Router26 0x21000c Rtr_Cisco dynamicGlobalCollects
Here is the list of models and model handles in the GC from spectrum02.
You need to disconnect from second SpectroSERVER and connect to the third SpectroSERVER spectrum03.
> ./disconnect disconnect: successful from spectrum02- connected for 0 hours, 1 minutes
> ./connect spectrum03 connect: successful spectrum03 current landscape is 0x1100000
Get the model handle of the GC on this server:
> ./show models |grep 0x10474 0x110003e Router Test 0x10474 GlobalCollection 0x110003d Routers 0x10474 GlobalCollection
Model handle for GC "Router Test" is "0x110003e".
> ./show children mh=0x110003e MHandle MName MTypeHnd MTypeName Relation
No models exist from this SpectroSERVER spectrum03.
So, in order to get all models within a GC you need to connect to each SpectroSERVER where the GC is created on, get the model handle of the GC and then execute "show children" on that particular model handle. Once you get the model handle from each SpectroSERVER it won't change unless you destroy and recreate it so in your script you don't have to constantly grep for the GC model handle on each server. In the "show children" command you can direct the output to a file so you have the models stored. You just need to use the ">>" so the output is appended to the file and is not overwritten. You would then have to parse/manipulate the data in the file however you want it presented.
So, in my example I know the three GC model handles on each SpectroSERVER. I could write something like the following.
./connect spectrum01 ./show children mh=0x1e00a63 >> GC_RouterTest_Models.out ./disconnect
./connect spectrum02 ./show children mh=0x3e918bce >> GC_RouterTest_Models.out ./disconnect
./connect spectrum03 ./show children mh=0x110003e >> GC_RouterTest_Models.out ./disconnect
The output file "GC_RouterTest_Models.out" will contain all models from all three SpectroSERVERs. From the list of model handles you can then retrieve data or perform actions per model handle.
The Global Collection is updated every 24 hours by default. The attribute on the GC is:
0x12a68 dynamicUpdateInterval 1440 1440 is in minutes, which equals 24 hours.
There is a CLI action you can send on behalf of the GC model handle to update it immediately. You may want to do this to update the GC before running the script to make sure the GC has all the models that meet that criteria.
From CLI you use the "update" command on the model handle of the GC using the action code of 0x1006f.
./update action=0x100f6 mh=0x3e918bce
update action: successful