On 16/08/2007 6:14 AM, Steve Wray wrote:


vzctl does respect the given 'name' however vzquota does not appear to and seems to require the numeric id.



I have a similar issue with scripts that need to convert from the VEID or VE Name to either the VEID, the VE Name, or host name.

I've written this simple script to do the conversions for me. It's handy in scripts, but may be useful where your list of VE's is too large to simply scan the vzlist for the information you need.

/usr/local/bin/vmid
- - - - - - - -
#!/bin/bash

if [ "${1}" == "" ]; then
 echo "$0 {veid|name} [-i|-n|-h]"
 echo "        -i returns id \(default\)"
 echo "        -n returns name"
 echo "        -h returns host name"
 exit 1
fi

case "$2" in
 "" | "-i")
   PARM=veid
   ;;
 "-n")
   PARM=name
   ;;
 "-h")
   PARM=hostname
   ;;
 *)
   echo Bad parameter $2
   exit 1
   ;;
esac

VM_ID=`vzlist -o ${PARM} -H -N ${1} | sed -e "s/ //g"`

if [ "${VM_ID}" == "" ]; then
 VM_ID=`vzlist -o ${PARM} -H ${1} | sed -e "s/ //g"`
fi

if [ "${VM_ID}" == "" ]; then
 exit 1
else
 echo ${VM_ID}
 exit 0
fi
- - - - - - - -


Since my scripts can be passed either the veid or the vename, I might code something like this:

ping $(vmid $1 -h)

more practically I use it to access things like the config files that are named according to the VEID.

Steve
_______________________________________________
Users mailing list
[email protected]
https://openvz.org/mailman/listinfo/users

Reply via email to