Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
Brian_Deutmeyer
Collaborator
Jump to solution

VSX: show configuration For All Virtual Systems

Is there a way to show the clish configuration for all virtual systems in VSX?  There are a few things we configure specifically in certain contexts (like bootp relay and dynamic routing).  I have a script that pulls a show configuration and backs it up, but it only gets data from vs0.  I tried setting my virual system and doing a vsenv with no luck...  It always pulls vs0 configuration.

[Expert@vsx:0]# clish -c "show configuration bootp"

CLINFR0771  Config lock is owned by admin. Use the command 'lock database override' to acquire the lock.

show instance 0 configuration bootp

 [Expert@vsx:0]# clish -c "set virtual-system 2"

CLINFR0771  Config lock is owned by admin. Use the command 'lock database override' to acquire the lock.

Context is set to vsid 2

[Expert@vsx:0]# clish -c "show configuration bootp"

CLINFR0771  Config lock is owned by admin. Use the command 'lock database override' to acquire the lock.

show instance 0 configuration bootp

[Expert@vsx:0]# vsenv 2

Context is set to Virtual Device vsx_vs2 (ID 2).

[Expert@vsx:2]# clish -c "show configuration bootp"

CLINFR0771  Config lock is owned by admin. Use the command 'lock database override' to acquire the lock.

show instance 0 configuration bootp

[Expert@vsx:2]#

1 Solution

Accepted Solutions
PhoneBoy
Admin
Admin

set virtual-system is not persistent across clish -c commands. 

clish -c is only meant to execute a single command.

You will need to execute a clish script (e.g. clish -f filename) to achieve what you are after.

View solution in original post

5 Replies
PhoneBoy
Admin
Admin

set virtual-system is not persistent across clish -c commands. 

clish -c is only meant to execute a single command.

You will need to execute a clish script (e.g. clish -f filename) to achieve what you are after.

Brian_Deutmeyer
Collaborator

That did the trick!  I'm able to build a file of clish commands iterating over each available VS.  Thanks!

0 Kudos
Harald_Hansen
Advisor
Advisor

Please add clish --vsid <VSID> -c "command". 

I hate jumping from bash to clish every time I have to check something miniscule.

Harald_Hansen
Advisor
Advisor

I have written a simple bash script to emulate the above functions. Use with care, no validation is done, though maybe I'll add some sanity checks.

#!/bin/bash
source /etc/profile.d/CP.sh
source /etc/profile.d/vsenv.sh
  
MYPID=$$
myVSID=0
TMPCLISH="/tmp/tmpclish-$MYPID"
scriptname=`basename ${BASH_SOURCE[0]}`
usage () { echo "$scriptname -v <vsid> <command>"; exit 1; }
  
NUMARGS=$#
if [ $NUMARGS -eq 0 ]; then
  usage
fi
  
while getopts ":h:v:" opt; do
  case $opt in
    h)usage;;
    \?)usage;;
    v)myVSID="$OPTARG";;
    🙂echo "missing option for -$OPTARG"; exit 1;;
    *)usage;;
  esac
done
  
shift $((OPTIND-1))
 
#in case -v is not set (don't use this script for VS0)
if [[ $myVSID == 0 ]]; then
  usage
fi
 
echo "$TMPCLISH"
if [[ ! -e "$TMPCLISH" ]]; then
  echo "set virtual-system $myVSID">$TMPCLISH
  echo "$@">>$TMPCLISH
  clish -f "$TMPCLISH"
  #cleanup
  rm $TMPCLISH
else
  echo "$TMPCLISH already exists. Try again!"
fi
0 Kudos
cosmos
Advisor

Seems there is still no vendor-provided way to do this without the community chipping in. I know you guys are fans of one-liners so I wrote a quick and dirty one to get the job done fast 🙂

echo "set vsx on" >tmpfile; for i in $(vsx stat -v | grep "| S " | awk '{print $1};'); do echo set virtual-system $i>>tmpfile; echo show configuration>>tmpfile; done; clish -f tmpfile >all_vs_config; rm -f tmpfile

 

It would be great if the output was limited to the config for the current context, and things configured from the console (e.g. static-routes) distinguished from those done from the cli (e.g. advanced routing).

0 Kudos

Leaderboard

Epsum factorial non deposit quid pro quo hic escorol.

Upcoming Events

    CheckMates Events