OpenVZ Forum


Home » Mailing lists » Users » openvz naming conventions; numeric vs symbolic
Re: openvz naming conventions; numeric vs symbolic [message #15920 is a reply to message #15916] Thu, 16 August 2007 00:00 Go to previous message
Steve Hodges is currently offline  Steve Hodges
Messages: 17
Registered: July 2007
Junior Member
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
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Template for Centos 5 ve
Next Topic: swap space?
Goto Forum:
  


Current Time: Thu Aug 14 12:06:57 GMT 2025

Total time taken to generate the page: 0.33036 seconds