Last active
October 25, 2018 14:17
-
-
Save cdent/59dfde7c1e91eb2245b7863d59fcda03 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -xe | |
# Change these as required | |
CONF_DIR=/etc/placement | |
DB_DRIVER=mysql+pymysql # we assume mysql throughout, feel free to change | |
DB_NAME=placement | |
DB_USER=root | |
DB_PASS=secret | |
REPO=git://git.openstack.org/openstack/placement | |
# The placement-manage branch, this will go away soon. | |
BRANCH=refs/changes/61/600161/13 | |
# Create a directory for configuration to live. | |
[[ -d $CONF_DIR ]] || (sudo mkdir $CONF_DIR && sudo chown $USER $CONF_DIR) | |
# Establish database. Some of this may need sudo powers. Don't be shy | |
# about changing the script. | |
mysql -u$DB_USER -p$DB_PASS -e "DROP DATABASE IF EXISTS $DB_NAME;" | |
mysql -u$DB_USER -p$DB_PASS -e "CREATE DATABASE $DB_NAME CHARACTER SET utf8;" | |
mysql -u$DB_USER -p$DB_PASS -e "GRANT ALL PRIVILEGES ON $DB_NAME.* TO '$DB_USER'@'%' identified by '$DB_PASS';" | |
# clone the right code | |
git clone $REPO | |
cd placement | |
git pull $REPO $BRANCH | |
# establish virtenv | |
tox -epy36 --notest | |
# write placement.conf | |
cat<<EOF > $CONF_DIR/placement.conf | |
[DEFAULT] | |
debug = True | |
[placement_database] | |
connection = $DB_DRIVER://${DB_USER}:${DB_PASS}@127.0.0.1/${DB_NAME}?charset=utf8 | |
[api] | |
auth_strategy = noauth2 | |
EOF | |
# Create database tables | |
.tox/py36/bin/placement-manage db table_create | |
# install uwsgi | |
.tox/py36/bin/pip install uwsgi | |
# run uwsgi | |
.tox/py36/bin/uwsgi --http :8000 --wsgi-file .tox/py36/bin/placement-api |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment