-
Notifications
You must be signed in to change notification settings - Fork 8
/
s2aio.sh
executable file
·124 lines (101 loc) · 2.64 KB
/
s2aio.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/bash
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
set -e
set -o xtrace
REPO_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
DEVSTACK_DIR=~/devstack
SWIFT_IP=127.0.0.1
KEYSTONE_IP=$SWIFT_IP
KEYSTONE_PROTOCOL=http
KEYSTONE_PUBLIC_URL=${KEYSTONE_PROTOCOL}://${KEYSTONE_IP}/identity/v3
SWIFT_DATA_DIR=/opt/stack/data/swift
function usage {
echo "Usage: s2aio.sh install"
echo " s2aio.sh start"
echo " s2aio.sh stop"
exit 1
}
function _prepare_devstack_env {
# Checkout devstack
if [ ! -e $DEVSTACK_DIR ]; then
git clone https://opendev.org/openstack/devstack.git $DEVSTACK_DIR
cp devstack/localrc.sample $DEVSTACK_DIR/localrc
fi
source $DEVSTACK_DIR/stackrc
source $DEVSTACK_DIR/functions
source $DEVSTACK_DIR/functions-common
source $DEVSTACK_DIR/lib/keystone
source $DEVSTACK_DIR/lib/swift
source devstack/plugin.sh
}
function start_s2aio {
set -e
start_keystone
start_swift
exit 0
}
function _stop_s2aio {
set +e
stop_keystone
stop_swift
set -e
}
function stop_s2aio {
_stop_s2aio
exit 0
}
function install_swift_using_devstack {
cd $DEVSTACK_DIR
./stack.sh
cd -
}
function install_s2aio {
_prepare_devstack_env
install_swift_using_devstack
install_storlets
echo "export OS_USERNAME=$SWIFT_DEFAULT_USER; export OS_PASSWORD=$SWIFT_DEFAULT_USER_PWD" >> ~/.bashrc
echo "export OS_PROJECT_NAME=$SWIFT_DEFAULT_PROJECT; export OS_DEFAULT_DOMAIN=default" >> ~/.bashrc
echo "export OS_AUTH_URL=$KEYSTONE_PUBLIC_URL" >> ~/.bashrc
}
function uninstall_swift_using_devstack {
_stop_s2aio
cd $DEVSTACK_DIR
./unstack.sh
cd -
}
function uninstall_s2aio {
_prepare_devstack_env
echo "Removing all storlets run time data"
uninstall_storlets
echo "Uninstalling Swift"
uninstall_swift_using_devstack
}
COMMAND="$1"
case $COMMAND in
"install" )
install_s2aio
;;
"uninstall" )
uninstall_s2aio
;;
"start" )
start_s2aio
;;
"stop" )
stop_s2aio
;;
* )
usage
esac
set +e
set +o xtrace