| VE mutual dependence [message #34464] | 
			Wed, 07 January 2009 19:08   | 
		 
		
			
				
				
				
					
						  
						laotse
						 Messages: 35 Registered: December 2008 
						
					 | 
					Member  | 
					 | 
		 
		 
	 | 
 
	
		Hi there, 
 
is there a standard way to resolve mutual dependences of VE during startup? E.g. a container might host a file-server, which exports file systems, which another container shall import (or DNS, DHCP, ...) 
 
Of course the dependent VE could be marked as not auto-starting and I could chain a script for the rest; which I'll probably do. The question is, whether there is some canonical way to achieve that? 
 
Regards, 
 - lars. 
		
		
		
 |  
	| 
		
	 | 
 
 
 | 
	| 
		
 | 
	
		
		
			| Re: VE mutual dependence [message #34481 is a reply to message #34478] | 
			Fri, 09 January 2009 19:18    | 
		 
		
			
				
				
				
					
						  
						laotse
						 Messages: 35 Registered: December 2008 
						
					 | 
					Member  | 
					 | 
		 
		 
	 | 
 
	
		Well, for my personal needs I'd simply put up a more or less sequential script. 
 
As a proposal for a canonical way, I'd consider a mechanism like the passes in fstab. If there is some public interest in it, I guess I could implement that - once I have the system out of any severe functional problems. 
		
		
		[Updated on: Fri, 09 January 2009 19:19] Report message to a moderator  
 |  
	| 
		
	 | 
 
 
 | 
	
		
		
			| Re: VE mutual dependence [message #34488 is a reply to message #34464] | 
			Mon, 12 January 2009 06:56   | 
		 
		
			
				
				
				  | 
					
						
						curx
						 Messages: 739 Registered: February 2006  Location: Nürnberg, Germany
						
					 | 
					Senior Member  | 
					 
  | 
		 
		 
	 | 
 
	
		you can use the OpenVZ Action script for a single dependecy mechanism, here using a mount script. 
 
Checks if a container is running, if not, mount script exit with error code greater than 0 and vzctl start is aborted. 
 
#!/bin/bash
#  Copyright (C) 2006-2008 :
#	Thorsten Schifferdecker <tsd@debian.systs.org>
#  	All rights reserved.
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
#  /usr/share/vzctl/scripts/vps.mount-10-ct-dependency.sh 
# include main vz.conf
VZCONF=/etc/vz/vz.conf
[ -f ${VZCONF} ] || exit 0
. ${VZCONF}
# debug mode in main vz.conf set ?
[ "$DEBUG" == "yes" ] && set -x
# single dependency container id 
CT_DEPEND="`awk -F '"' '/^CT_DEPEND/ { print $2 }' /etc/vz/conf/$VEID.conf`"
[ -f /etc/vz/conf/${CT_DEPEND}.conf ] || exit 0
[ $VEID -ne $CT_DEPEND ] || exit 0
# cycles to check
CHECK_CYCLE=10
# sleep time
SLEEP_TIME=5
LOG_MESSAGE="Container dependency"
__OK="is solved"
__FAILED="has failed"
#
# main
#
for i in ${CHECK_CYCLE} ; do
	# started and running container has beancounters to avoid vzlist
	if [ -d /proc/bc/${CT_DEPEND} ] ; then
		[ $LOGGING == 'yes' ] && echo "`/bin/date +%FT%H:%M:%S%z` vzctl : CT ${VEID} : $LOG_MESSAGE to CT ${VEID} $__OK" >> $LOGFILE
		printf "$LOG_MESSAGE to CT ${VEID} $__OK\n"
		# add checking services, too
		# include service checks
		exit 0
	fi
sleep $SLEEP_TIME
done  
[ ${VERBOSE} -ne 0 ] && printf " to CT ${VEID} $__FAILED\n"
[ $LOGGING == 'yes' ] && printf "`/bin/date +%FT%H:%M:%S%z` vzctl : CT ${VEID} : Error $LOG_MESSAGE to CT ${VEID} $__FAILED\n" >> $LOGFILE
printf "$LOG_MESSAGE $__FAILED\n"
exit 1
 
 
save this script to /usr/share/vzctl/scripts/vps.mount-10-ct-dependency.sh and create a symbolic link : 
 
global: 
$ ln -s /usr/share/vzctl/scripts/vps.mount-10-ct-dependency.sh /etc/vz/conf/vps.mount 
 
or for single container,m only: 
$ ln -s /usr/share/vzctl/scripts/vps.mount-10-ct-dependency.sh /etc/vz/conf/<CTID>.mount 
 
and activate check: 
 
$ echo "CT_DEPEND=\"<CTID_DEPENDS_ON>\"" >> /etc/vz/conf/<CTID>.conf 
 
Bye, 
 Thorsten 
		
		
		
 |  
	| 
		
	 | 
 
 
 |