-
Notifications
You must be signed in to change notification settings - Fork 2
/
start_local_cluster.sh
executable file
·88 lines (80 loc) · 2.17 KB
/
start_local_cluster.sh
1
2
3
4
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash
#
# Copyright (C) 2010-2012 Eugen Feller, INRIA <[email protected]>
#
# This file is part of Snooze, a scalable, autonomic, and
# energy-aware virtual machine (VM) management framework.
#
# 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, see <http://www.gnu.org/licenses>.
#
scriptpath=$(dirname $0)
source $scriptpath/scripts/cluster.sh
source $scriptpath/scripts/libvirt.sh
source $scriptpath/scripts/distribution.sh
set_distribution
# Prints the usage information
print_usage () {
echo "Usage: $script_name [options]"
echo "Contact: $author"
echo "Options:"
echo "-l Start libvirt"
echo "-d Stop libvirt"
echo "-s Start cluster"
echo "-k Kill cluster"
}
# Process the user input
option_found=0
while getopts ":ldsk" opt; do
option_found=1
print_settings
case $opt in
l)
start_libvirt
return_value=$?
;;
d)
stop_libvirt
return_value=$?
;;
s)
start_cluster
return_value=$?
;;
k)
stop_cluster
return_value=$?
;;
\?)
echo "$log_tag Invalid option: -$OPTARG" >&2
print_usage
exit $error_code
;;
:)
echo "$log_tag Missing argument for option: -$OPTARG" >&2
print_usage
exit $error_code
;;
esac
done
if ((!option_found)); then
print_usage
exit $error_code
fi
if [[ $? -ne $return_value ]]
then
echo "$log_tag Command failed!" >&2
exit $error_code
fi
echo "$log_tag Command executed successfully!" >&2
exit $success_code