Merge "Add start / stop to s2aio"
This commit is contained in:
@@ -15,3 +15,7 @@ rsync
|
|||||||
xfsprogs
|
xfsprogs
|
||||||
libssl-dev [platform:dpkg]
|
libssl-dev [platform:dpkg]
|
||||||
openssl-devel [platform:rpm]
|
openssl-devel [platform:rpm]
|
||||||
|
|
||||||
|
# N.B. uwsgi-plugin-python is needed only for s2aio.sh start/stop for keystone
|
||||||
|
# so that we will be able to remove if devstack or devstack plugin installs it
|
||||||
|
uwsgi-plugin-python
|
||||||
|
@@ -1,20 +1,20 @@
|
|||||||
s2aio
|
s2aio
|
||||||
=====
|
=====
|
||||||
|
|
||||||
s2aio is a script that installs Swift and Storlets all on one.
|
s2aio is a script that installs Swift (with Keystone) and Storlets all on one.
|
||||||
The script allows to do the installation either on the host
|
The script allows to do the installation either on the host
|
||||||
where it is invoked or in a Docker container.
|
where it is invoked or in a Docker container.
|
||||||
|
|
||||||
To install on the host:
|
To install on the host:
|
||||||
|
|
||||||
.. include:: s2aio_dev_host_include.rst
|
.. include:: s2aio_dev_host_include.rst
|
||||||
|
|
||||||
To install in a Docker container follow the same steps,
|
To install in a Docker container follow the same steps,
|
||||||
replacing the last command with:
|
replacing the last command with:
|
||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
./s2aio dev docker
|
./s2aio.sh install dev docker
|
||||||
|
|
||||||
If you do not have Docker installed on your host, the above script
|
If you do not have Docker installed on your host, the above script
|
||||||
will install it and set docker to use "vfs" as the docker storage driver
|
will install it and set docker to use "vfs" as the docker storage driver
|
||||||
@@ -23,3 +23,21 @@ Docker installed, you may need to change its
|
|||||||
storage driver to "vfs". The created Docker container runs yet another
|
storage driver to "vfs". The created Docker container runs yet another
|
||||||
container. Running Docker in Docker may require the usage of the "vfs" storage
|
container. Running Docker in Docker may require the usage of the "vfs" storage
|
||||||
device.
|
device.
|
||||||
|
|
||||||
|
When installed on the host, the script can be used to start and stop all
|
||||||
|
relevant services using:
|
||||||
|
|
||||||
|
::
|
||||||
|
|
||||||
|
./s2aio.sh stop
|
||||||
|
|
||||||
|
and
|
||||||
|
|
||||||
|
::
|
||||||
|
|
||||||
|
./s2aio.sh start
|
||||||
|
|
||||||
|
For the Swift data, the s2aio installation uses a loopback device over a .img file.
|
||||||
|
When shutting down the host, the .img file may get corrupted. Thus, the above stop and
|
||||||
|
start commands are useful when using s2aio.sh for in a long lived hosts that can get rebooted
|
||||||
|
from time to time.
|
||||||
|
@@ -7,4 +7,4 @@ With that user just do:
|
|||||||
sudo apt-get install python-tox python-nose git
|
sudo apt-get install python-tox python-nose git
|
||||||
git clone https://github.com/openstack/storlets.git
|
git clone https://github.com/openstack/storlets.git
|
||||||
cd storlets
|
cd storlets
|
||||||
./s2aio.sh dev host
|
./s2aio.sh install dev host
|
||||||
|
158
s2aio.sh
158
s2aio.sh
@@ -1,44 +1,38 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -eu
|
# s2aio controls an all in one installation of swift, keystone and storlets
|
||||||
# s2aio install from scratch an all in one swift with the storlet engine.
|
# s2aio has 3 sub commands: install, start and stop
|
||||||
# s2aio has two flavors:
|
# install would install from scratch an all in one swift with the storlet engine.
|
||||||
|
# the installation has two flavors:
|
||||||
# 1. Jenkins job installation, for running the funciotal tests.
|
# 1. Jenkins job installation, for running the funciotal tests.
|
||||||
# 2. Developer instalation.
|
# 2. Developer instalation.
|
||||||
|
# start and stop are currently supported only for the host flavor.
|
||||||
|
|
||||||
if [ "$#" -ne 2 ]; then
|
usage() {
|
||||||
echo "Usage: s2aio.sh <flavor> <target>"
|
echo "Usage: s2aio.sh install <flavor> <target>"
|
||||||
|
echo " s2aio.sh start"
|
||||||
|
echo " s2aio.sh stop"
|
||||||
echo "flavor = jenkins | dev"
|
echo "flavor = jenkins | dev"
|
||||||
echo "target = host | docker"
|
echo "target = host | docker"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
}
|
||||||
|
|
||||||
FLAVOR="$1"
|
start_s2aio() {
|
||||||
if [ "$FLAVOR" != "jenkins" ] && [ "$FLAVOR" != "dev" ]; then
|
set -e
|
||||||
echo "flavor must be either \"jenkins\" or \"dev\""
|
swift-init --run-dir /opt/stack/data/swift/run/ all start
|
||||||
exit 1
|
sudo mkdir -p /var/run/uwsgi
|
||||||
fi
|
sudo chown ${USER}:`id -g -n ${USER}` /var/run/uwsgi
|
||||||
|
/usr/local/bin/uwsgi /etc/keystone/keystone-uwsgi-public.ini &> /dev/null &
|
||||||
|
/usr/local/bin/uwsgi /etc/keystone/keystone-uwsgi-admin.ini &> /dev/null &
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
TARGET="$2"
|
stop_s2aio() {
|
||||||
if [ "$TARGET" != "host" ] && [ "$TARGET" != "docker" ]; then
|
sh -c 'swift-init --run-dir /opt/stack/data/swift/run/ all stop'
|
||||||
echo "target must be either \"host\" or \"docker\""
|
sh -c 'ps aux | pgrep uwsgi | xargs kill -9'
|
||||||
exit 1
|
exit 0
|
||||||
fi
|
}
|
||||||
|
|
||||||
# Make sure hostname is resolvable
|
install_docker() {
|
||||||
grep -q -F ${HOSTNAME} /etc/hosts || sudo sed -i '1i127.0.0.1\t'"$HOSTNAME"'' /etc/hosts
|
|
||||||
|
|
||||||
install/install_ansible.sh
|
|
||||||
|
|
||||||
# Allow Ansible to ssh as the current user without a password
|
|
||||||
# While at it, take care of host key verification.
|
|
||||||
# This involves:
|
|
||||||
# 1. Generate an rsa key for the current user if necessary
|
|
||||||
if [ ! -f ~/.ssh/id_rsa.pub ]; then
|
|
||||||
ssh-keygen -q -t rsa -f ~/.ssh/id_rsa -N ""
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$TARGET" == "docker" ]; then
|
|
||||||
# install docker
|
|
||||||
sudo apt-get install apt-transport-https aufs-tools linux-image-generic-lts-xenial -y --force-yes
|
sudo apt-get install apt-transport-https aufs-tools linux-image-generic-lts-xenial -y --force-yes
|
||||||
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
|
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
|
||||||
sudo sh -c "echo deb https://apt.dockerproject.org/repo ubuntu-xenial main > /etc/apt/sources.list.d/docker.list"
|
sudo sh -c "echo deb https://apt.dockerproject.org/repo ubuntu-xenial main > /etc/apt/sources.list.d/docker.list"
|
||||||
@@ -46,10 +40,12 @@ if [ "$TARGET" == "docker" ]; then
|
|||||||
sudo apt-get install docker-engine -y --force-yes
|
sudo apt-get install docker-engine -y --force-yes
|
||||||
sudo sh -c "echo DOCKER_OPTS=\"--storage-driver=vfs\" >> /etc/default/docker"
|
sudo sh -c "echo DOCKER_OPTS=\"--storage-driver=vfs\" >> /etc/default/docker"
|
||||||
sudo service docker restart
|
sudo service docker restart
|
||||||
|
}
|
||||||
|
|
||||||
|
install_swift_on_container() {
|
||||||
# run the swift docker container
|
# run the swift docker container
|
||||||
S2AIO_RUNNING=`sudo docker ps | grep s2aio | wc -l`
|
S2AIO_RUNNING=`sudo docker ps | grep -c s2aio`
|
||||||
S2AIO_EXISTS=`sudo docker ps -a | grep s2aio | wc -l`
|
S2AIO_EXISTS=`sudo docker ps -a | grep -c s2aio`
|
||||||
if [ "$S2AIO_RUNNING" == "0" ]; then
|
if [ "$S2AIO_RUNNING" == "0" ]; then
|
||||||
if [ "$S2AIO_EXISTS" == "1" ]; then
|
if [ "$S2AIO_EXISTS" == "1" ]; then
|
||||||
sudo docker rm s2aio
|
sudo docker rm s2aio
|
||||||
@@ -58,6 +54,10 @@ if [ "$TARGET" == "docker" ]; then
|
|||||||
fi
|
fi
|
||||||
export S2AIO_IP=`sudo docker exec s2aio ifconfig | grep "inet addr" | head -1 | awk '{print $2}' | awk -F":" '{print $2}'`
|
export S2AIO_IP=`sudo docker exec s2aio ifconfig | grep "inet addr" | head -1 | awk '{print $2}' | awk -F":" '{print $2}'`
|
||||||
|
|
||||||
|
# Take care of host key verification
|
||||||
|
touch ~/.ssh/known_hosts
|
||||||
|
ssh-keygen -R $S2AIO_IP -f ~/.ssh/known_hosts
|
||||||
|
ssh-keyscan -H $S2AIO_IP >> ~/.ssh/known_hosts
|
||||||
sudo docker exec s2aio sh -c "echo deb http://us.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse >> /etc/apt/sources.list"
|
sudo docker exec s2aio sh -c "echo deb http://us.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse >> /etc/apt/sources.list"
|
||||||
sudo docker exec s2aio apt-get update
|
sudo docker exec s2aio apt-get update
|
||||||
sudo docker exec s2aio apt-get install software-properties-common -y --force-yes
|
sudo docker exec s2aio apt-get install software-properties-common -y --force-yes
|
||||||
@@ -69,12 +69,6 @@ if [ "$TARGET" == "docker" ]; then
|
|||||||
# Add the key to the user's authorized keys
|
# Add the key to the user's authorized keys
|
||||||
sudo docker exec s2aio mkdir -p /root/.ssh
|
sudo docker exec s2aio mkdir -p /root/.ssh
|
||||||
sudo docker exec s2aio bash -c "echo `cat ~/.ssh/id_rsa.pub` > /root/.ssh/authorized_keys"
|
sudo docker exec s2aio bash -c "echo `cat ~/.ssh/id_rsa.pub` > /root/.ssh/authorized_keys"
|
||||||
|
|
||||||
# Take care of host key verification for the current user
|
|
||||||
touch ~/.ssh/known_hosts
|
|
||||||
ssh-keygen -R $S2AIO_IP -f ~/.ssh/known_hosts
|
|
||||||
ssh-keyscan -H $S2AIO_IP >> ~/.ssh/known_hosts
|
|
||||||
|
|
||||||
sudo docker exec s2aio useradd stack
|
sudo docker exec s2aio useradd stack
|
||||||
sudo docker exec s2aio mkdir /home/stack
|
sudo docker exec s2aio mkdir /home/stack
|
||||||
sudo docker exec s2aio bash -c 'grep -q "^#includedir.*/etc/sudoers.d" /etc/sudoers ||\
|
sudo docker exec s2aio bash -c 'grep -q "^#includedir.*/etc/sudoers.d" /etc/sudoers ||\
|
||||||
@@ -87,7 +81,9 @@ if [ "$TARGET" == "docker" ]; then
|
|||||||
sudo docker exec --user stack s2aio chmod -R 0755 /home/stack
|
sudo docker exec --user stack s2aio chmod -R 0755 /home/stack
|
||||||
sudo docker exec --user stack s2aio /home/stack/install_swift.sh docker $S2AIO_IP
|
sudo docker exec --user stack s2aio /home/stack/install_swift.sh docker $S2AIO_IP
|
||||||
sudo docker exec s2aio service rsyslog restart
|
sudo docker exec s2aio service rsyslog restart
|
||||||
else
|
}
|
||||||
|
|
||||||
|
install_swift_on_host() {
|
||||||
export S2AIO_IP='127.0.0.1'
|
export S2AIO_IP='127.0.0.1'
|
||||||
|
|
||||||
# Add the key to the user's authorized keys
|
# Add the key to the user's authorized keys
|
||||||
@@ -113,18 +109,84 @@ else
|
|||||||
cd install/swift
|
cd install/swift
|
||||||
./install_swift.sh host $S2AIO_IP
|
./install_swift.sh host $S2AIO_IP
|
||||||
cd -
|
cd -
|
||||||
|
}
|
||||||
|
|
||||||
|
install_storlets() {
|
||||||
|
install/storlets/prepare_storlets_install.sh "$FLAVOR" "$TARGET"
|
||||||
|
|
||||||
|
# Install Storlets
|
||||||
|
cd install/storlets
|
||||||
|
./install_storlets.sh
|
||||||
|
cd -
|
||||||
|
|
||||||
|
# TODO: this is for tests. Deal accordingly.
|
||||||
|
cp install/storlets/deploy/cluster_config.json .
|
||||||
|
sudo chown $USER:$USER cluster_config.json
|
||||||
|
}
|
||||||
|
|
||||||
|
install_s2aio() {
|
||||||
|
# Make sure hostname is resolvable
|
||||||
|
grep -q -F ${HOSTNAME} /etc/hosts || sudo sed -i '1i127.0.0.1\t'"$HOSTNAME"'' /etc/hosts
|
||||||
|
|
||||||
|
install/install_ansible.sh
|
||||||
|
|
||||||
|
# Allow Ansible to ssh as the current user without a password
|
||||||
|
# While at it, take care of host key verification.
|
||||||
|
# This involves:
|
||||||
|
# 1. Generate an rsa key for the current user if necessary
|
||||||
|
if [ ! -f ~/.ssh/id_rsa.pub ]; then
|
||||||
|
ssh-keygen -q -t rsa -f ~/.ssh/id_rsa -N ""
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$TARGET" == "docker" ]; then
|
||||||
|
install_docker
|
||||||
|
install_swift_on_container
|
||||||
|
else
|
||||||
|
install_swift_on_host
|
||||||
|
fi
|
||||||
|
|
||||||
|
install_storlets
|
||||||
|
|
||||||
|
echo "export OS_IDENTITY_API_VERSION=3" >> ~/.bashrc
|
||||||
|
echo "export OS_USERNAME=tester; export OS_PASSWORD=testing" >> ~/.bashrc
|
||||||
|
echo "export OS_PROJECT_NAME=test; OS_DEFAULT_DOMAIN=default" >> ~/.bashrc
|
||||||
|
echo "export OS_AUTH_URL=http://"$S2AIO_IP":5000/v3" >> ~/.bashrc
|
||||||
|
}
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
if [ "$#" -ne 1 ] && [ "$#" -ne 3 ]; then
|
||||||
|
usage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
install/storlets/prepare_storlets_install.sh "$FLAVOR" "$TARGET"
|
COMMAND="$1"
|
||||||
|
case $COMMAND in
|
||||||
|
"install" )
|
||||||
|
if [ "$#" -ne 3 ]; then
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
FLAVOR="$2"
|
||||||
|
if [ "$FLAVOR" != "jenkins" ] && [ "$FLAVOR" != "dev" ]; then
|
||||||
|
echo "flavor must be either \"jenkins\" or \"dev\""
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
TARGET="$3"
|
||||||
|
if [ "$TARGET" != "host" ] && [ "$TARGET" != "docker" ]; then
|
||||||
|
echo "target must be either \"host\" or \"docker\""
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
install_s2aio
|
||||||
|
;;
|
||||||
|
|
||||||
# Install Storlets
|
"start" )
|
||||||
cd install/storlets
|
start_s2aio
|
||||||
./install_storlets.sh
|
;;
|
||||||
cd -
|
|
||||||
|
|
||||||
# TODO: this is for tests. Deal accordingly.
|
"stop" )
|
||||||
cp install/storlets/deploy/cluster_config.json .
|
stop_s2aio
|
||||||
sudo chown $USER:$USER cluster_config.json
|
;;
|
||||||
|
* )
|
||||||
|
usage
|
||||||
|
esac
|
||||||
|
|
||||||
echo "export OS_IDENTITY_API_VERSION=3" >> ~/.bashrc
|
echo "export OS_IDENTITY_API_VERSION=3" >> ~/.bashrc
|
||||||
echo "export OS_USERNAME=tester; export OS_PASSWORD=testing" >> ~/.bashrc
|
echo "export OS_USERNAME=tester; export OS_PASSWORD=testing" >> ~/.bashrc
|
||||||
|
@@ -1,2 +1,2 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
./s2aio.sh jenkins host
|
./s2aio.sh install jenkins host
|
||||||
|
Reference in New Issue
Block a user