Class: Construqt::Flavour::Ciscian::DeployTemplate

Inherits:
Object
  • Object
show all
Defined in:
lib/construqt/flavour/ciscian/deploy_template.rb

Class Method Summary collapse

Class Method Details

.write_template(host, flavour, ip, user, pass) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/construqt/flavour/ciscian/deploy_template.rb', line 5

def self.write_template(host, flavour, ip, user, pass)
          template = <<-TEMPLATE
#!/bin/bash

CURRENT_DIR="`pwd`/$(dirname $0)"
if [[ ! -e $CURRENT_DIR ]]
then
CURRENT_DIR="$(dirname $0)"
fi

if [ -z "$CONSTRUQT_PATH" ]
then
if [[ $CURRENT_DIR =~ (.*construqt).* ]]
then
CONSTRUQT_PATH=${BASH_REMATCH[1]}
else
echo "could not automatically find construqt path"
exit
fi
fi

FLAVOUR="#{flavour}"
cd $CONSTRUQT_PATH
bash $CONSTRUQT_PATH/construqt/switch/deploy/deploy.sh $FLAVOUR #{ip} #{user} #{pass} "$CURRENT_DIR/$FLAVOUR.cfg"
cd - > /dev/null
TEMPLATE
  Util.write_str(template, File.join(host.name, "deploy.sh"))
end