From bee181aa167edfef8c8e2f647ae459a5a1abff42 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sat, 10 Nov 2012 01:16:59 +0100 Subject: using planet name for output dir --- src/flufigut.py | 8 ++++---- src/manage.sh | 51 ++++++++++++++++++++++++++++----------------------- src/ssh.config | 19 ------------------- src/update.sh | 12 ++++++------ 4 files changed, 38 insertions(+), 52 deletions(-) delete mode 100644 src/ssh.config diff --git a/src/flufigut.py b/src/flufigut.py index 4634ccc..2372fc8 100755 --- a/src/flufigut.py +++ b/src/flufigut.py @@ -373,7 +373,7 @@ if output_format == 'flumotion': # import shutil - shutil.rmtree('output/%s' % output_format, ignore_errors=True) + shutil.rmtree('%s/%s' % (globals['name'], output_format), ignore_errors=True) env = Environment(loader=FileSystemLoader('../templates/%s/%s/' % (output_format,globals['templates'])), line_statement_prefix = '%%') @@ -381,7 +381,7 @@ if output_format == 'flumotion': template = env.get_template('planet.xml') planet = template.render(globals=globals, atmosphere=atmosphere, flow=flow) - dir = 'output/%s/%s/managers/%s/' % (output_format, globals['manager']['machine'], globals['name']) + dir = '%s/%s/%s/managers/%s/' % (globals['name'], output_format, globals['manager']['machine'], globals['name']) if not os.path.exists(dir): os.makedirs(dir) f = open('%s/planet.xml' % (dir), 'w') @@ -389,7 +389,7 @@ if output_format == 'flumotion': f.write('\n') f.close() - passwd = open('output/%s/%s/%s.passwd' % (output_format, globals['manager']['machine'], globals['name']), 'w') + passwd = open('%s/%s/%s/%s.passwd' % (globals['name'], output_format, globals['manager']['machine'], globals['name']), 'w') port = 9000 for w in worker: @@ -405,7 +405,7 @@ if output_format == 'flumotion': ports = "%i-%i" % (port, port+1) port+=2 workerconf = template.render(globals=globals, name=w, password=password, portrange=ports) - dir = 'output/%s/%s/workers' % (output_format, machine) + dir = '%s/%s/%s/workers' % (globals['name'], output_format, machine) if not os.path.exists(dir): os.makedirs(dir) f = open('%s/%s-%s.xml' % (dir, globals['name'], w), 'w') diff --git a/src/manage.sh b/src/manage.sh index 1cd3a03..ff3f88c 100755 --- a/src/manage.sh +++ b/src/manage.sh @@ -37,9 +37,9 @@ # $ sudo ./flufigut-client.sh install # -OUTPUT_DIR="output/flumotion" -SSH_KEY="id_rsa" -SSH_CONFIG="ssh.config" +OUTPUT_DIR="$1/flumotion" +SSH_KEY="$1/id_rsa" +SSH_CONFIG="$1/ssh.config" SSH_USER="flufigut" deploy_all() { @@ -66,7 +66,7 @@ clean_all() { } wipe_all() { - for machine in `grep "^Host" ssh.config | awk '{ print($2) }'`; do + for machine in `grep "^Host" $SSH_CONFIG | awk '{ print($2) }'`; do echo "wipeing files belonging to planet '$1' from $machine ... " ssh -i "$SSH_KEY" -F "$SSH_CONFIG" $SSH_USER@"$machine" wipe "$1" done @@ -130,7 +130,27 @@ stop_all() { done } -case "$1" in +print_usage() { + echo "flufigut management script by Christian Pointner " + echo "" + echo "Usage $0 " + echo "" + echo "Commands:" + echo " deploy copies all configuration file to all servers and installs them" + echo " clean remove all configuration file from all servers" + echo " wipe purges all configuration files belonging the planet" + echo " start starts all instances on all servers (manager starts first)" + echo " stop stop all instances on all servers (manager stops last)" + echo " restart same as stop, start" + echo " help prints this" +} + +if [ -z "$1" ]; then + print_usage + exit 1 +fi + +case "$2" in deploy) echo "Deploying configuration to all machines ..." deploy_all @@ -140,12 +160,8 @@ case "$1" in clean_all ;; wipe) - if [ -z "$2" ]; then - echo "Usage: $0 wipe " - exit 1 - fi echo "wipeing configuration for from all machines inside ssh-config ..." - wipe_all "$2" + wipe_all "$1" ;; start) echo "Start manager and worker on all machines ..." @@ -162,21 +178,10 @@ case "$1" in start_all ;; help) - echo "flufigut managemnt script by Christian Pointner " - echo "" - echo "Usage $0 [param] " - echo "" - echo "Commands:" - echo " deploy copies all configuration file to all servers and installs them" - echo " clean remove all configuration file from all servers" - echo " wipe purges all configuration files belonging to a given planet" - echo " start starts all instances on all servers (manager starts first)" - echo " stop stop all instances on all servers (manager stops last)" - echo " restart same as stop, start" - echo " help prints this" + print_usage ;; *) - echo "Usage $0 (deploy|clean|wipe|start|stop|restart|help)" + echo "Usage $0 (deploy|clean|wipe|start|stop|restart|help)" exit 1 ;; esac diff --git a/src/ssh.config b/src/ssh.config deleted file mode 100644 index f215e66..0000000 --- a/src/ssh.config +++ /dev/null @@ -1,19 +0,0 @@ -Host telesto - HostName 109.73.158.69 - Port 22000 - -Host calypso - HostName 109.73.158.68 - Port 22000 - -Host elevate0 - Hostname 88.198.152.244 - Port 22000 - -Host elevate1 - HostName 5.9.104.71 - Port 22000 - -Host elevate2 - HostName 213.239.193.206 - Port 22000 diff --git a/src/update.sh b/src/update.sh index 18ab61a..bb77181 100755 --- a/src/update.sh +++ b/src/update.sh @@ -28,15 +28,15 @@ # along with flufigut. If not, see . # -if [ -z "$1" ]; then - echo "Usage: $0 " +if [ -z "$1" ] || [ -z "$2" ]; then + echo "Usage: $0 " exit 1 fi -./manage.sh stop -./manage.sh clean +./manage.sh $1 stop +./manage.sh $1 clean ./flufigut.py flumotion $1 -./manage.sh deploy -./manage.sh start +./manage.sh $1 deploy +./manage.sh $1 start exit 0 -- cgit v1.2.3