OpenVZ Forum


Home » General » Support » *SOLVED* Network script like vps.mount
*SOLVED* Network script like vps.mount [message #9751] Fri, 19 January 2007 14:05 Go to next message
arpad is currently offline  arpad
Messages: 16
Registered: November 2006
Junior Member
Hi!

I want to use my VEs in "bridged mode". I mean I want to use the veth devices not the venet. I added the veth* devices into a bridge at the end of the hosts boot process.
Everything is working fine but when I restart the VE it's (of course) removed from the hosts bridge interface. I looked after it and found there is a vps.mount or $VEID.mount named script which automatically runs at the start of the VE. But it runs too early, the network interfaces aren't up at this time.
Is there any script which runs automatically after the network initialization? I don't want to write a wrapper for vzctl just for this.
Thanks for any help.

[Updated on: Sun, 21 January 2007 14:13]

Report message to a moderator

Re: Network script like vps.mount [message #9758 is a reply to message #9751] Fri, 19 January 2007 15:43 Go to previous messageGo to next message
Vasily Tarasov is currently offline  Vasily Tarasov
Messages: 1345
Registered: January 2006
Senior Member
Make sure, that you're using vzctl not older then 3.0.14 and look at file /sbin/vznetcfg. This file is created exactly for this purposes.

HTH,
Vasily.
Re: Network script like vps.mount [message #9762 is a reply to message #9758] Sat, 20 January 2007 02:14 Go to previous messageGo to next message
larsks is currently offline  larsks
Messages: 3
Registered: January 2007
Junior Member
Vasily,

There's no documentation in vznetcfg itself, there's no man page, and it's not mentioned anywhere else in the documentation distributed with the vzctl package. So, for posterity:

vznetcfg (probably /usr/sbin/vznetcfg) is run by vzctl just after it creates the veth interfaces specified in your configuration. You can find the call in src/lib/veth.c in the vzctl distribution in the veth_ctl() function.

The script is called like this:

vznetcfg init veth <veth_device>


E.g.,

vznetcfg init veth veth101.0


The environment variable VEID contains the current VEID. Unlike other scripts, VE_CONFFILE is not available so you'll have to calculate it yourself if you need it. Vasily et al: wouldn't it be simpler to set up the environment in the run_script() function so that it's the same for all scripts?

The script is called once for each veth interface defined in your configuration file.

If you set EXTERNAL_SCRIPT in /etc/vz/vznet.conf, vznetcfg will call this script with whatever arguments were originally passed to vznetcfg.

The script is only called during startup -- if you need to do something special to unconfigure the interfaces you're on your own.

I'm using the following EXTERNAL_SCRIPT (the BRIDGE variable is set in the VE configuration file. I should probably make this settable per-interface, rather than per-VE):

#!/bin/sh

. /etc/vz/conf/${VEID}.conf

case $1 in
 (init) shift
  case $1 in
   (veth) shift
    dev=$1 
    if [ -n "$BRIDGE" ]; then
     echo "+ Adding $dev to bridge $BRIDGE."
     brctl addif $BRIDGE $1
    fi
    ;;
  esac
  ;;
esac

Re: Network script like vps.mount [message #9770 is a reply to message #9762] Sun, 21 January 2007 14:13 Go to previous messageGo to next message
arpad is currently offline  arpad
Messages: 16
Registered: November 2006
Junior Member
Hi!

Thanks the script. I read the source of vznetcfg and wrote a similar myself before I read it :-)
But anyway thanks for this script I got some extra ideas from it.
Maybe this can be added to the official documentation too.
Thanks,

Arpad
Re: Network script like vps.mount [message #9828 is a reply to message #9762] Wed, 24 January 2007 07:59 Go to previous message
Vasily Tarasov is currently offline  Vasily Tarasov
Messages: 1345
Registered: January 2006
Senior Member
Lars,

Thank you very much for your detailed explanation.
Can you, please, create a small wiki-page at wiki.openvz.org about vznetcfg?
It will be really useful!

Thank in advance,
Vasily.
Previous Topic: Trouble starting/accessing Gentoo VPS
Next Topic: TCP stack virtualization
Goto Forum:
  


Current Time: Tue Sep 10 04:47:30 GMT 2024

Total time taken to generate the page: 0.07862 seconds