How to automate model creation or deletion in Spectrum via CLI script

Document ID : KB000013520
Last Modified Date : 14/02/2018
Show Technical Document Details

In Spectrum, its possible to use the command line interface (CLI) to run commands and incorporate those commands into a shell script (such as bash) to automate various processes, such as creation or deletion of models based on certain criteria.


How can the destruction of models be achieved via an automated process and then creation of new models be achieved using the CLI?

Spectrum 9.4.x, 10.x
The Spectrum CLI commands are all listed in the $SPECROOT/vnmsh directory. The specific commands pertaining to model deletion and creation are:
You can use these commands in general bash scripts and pipe their output to other system commands.
So to utilise these CLI commands, you would write a script, in either bash shell or Perl, identify the models you want using the show command then cut the model_handle from the output for use with destroy command. The following bash shell script can be used as an example where all models exhibiting the DIFFERENT TYPE MODEL alarm (0x10203): are found using ./show alarms output piped into grep and awk to get the relevant model handle and then destroy to delete it:
timestamp=`date "+%H%M%d/%m/%Y"`
# Check the CLIPATH setting
if [ -z "$CLIPATH" ]
export CLIPATH
# Connect to the VNM shell
# Using as example alarm to eliminate models - 'DIFFERENT TYPE MODEL - 0x10203'"
# For each model with this alarm, we will destroy it,
# after obtaining its IP address (attribute - Network_Address)
# and then create it again
for model in `./show alarms -a | grep $probCauseID | awk '{print $5}'`;
echo "-----------------------------------"
echo $timestamp Model Handle of device with Alarm = $model
./current mh=$model
IP=`./show attributes mh=$model | grep Network_Address | grep -v Legacy | awk '{print $3}'`
echo $timestamp IP Address = $IP
if [ $interactive -eq 1 ]
# Run silent
./destroy model -n mh=$model
# Default - Run interactive, where you will be asked if you want to destroy each model
./destroy model mh=$model
# You can then rediscover a new model with the same IP address if needed.
./create model ip=$IP
# Disconnect from the VNM shell


Additional Information: