diff --git a/elements/nova-api/README.md b/elements/nova-api/README.md new file mode 100644 index 00000000..135ae30f --- /dev/null +++ b/elements/nova-api/README.md @@ -0,0 +1,2 @@ +Installs Nova API service from github. + diff --git a/elements/nova-api/install.d/05-nova-api b/elements/nova-api/install.d/05-nova-api new file mode 100755 index 00000000..80752f68 --- /dev/null +++ b/elements/nova-api/install.d/05-nova-api @@ -0,0 +1,39 @@ +#!/bin/sh +set -eux + +useradd -G admin -m nova -s /bin/false + +DEBIAN_FRONTEND=noninteractive apt-get -y install \ + python-pip git-core python-setuptools python-dev python-lxml python-netaddr \ + python-pastescript python-pastedeploy python-paste python-sqlalchemy \ + python-greenlet python-routes python-simplejson python-webob rabbitmq-server + +OS_ROOT=/opt/stack +mkdir -p $OS_ROOT + +# clone source +NOVA_ROOT=$OS_ROOT/nova +git clone https://github.com/openstack/nova.git $NOVA_ROOT +cd $NOVA_ROOT +git checkout master + +# pip dependencies +python setup.py egg_info +pip install -r nova.egg-info/requires.txt +cd - + +SYS_DIRS="/etc/nova /var/log/nova $NOVA_ROOT/keys" +for d in $SYS_DIRS; do + mkdir -p $d + chown nova:nova $d +done + +# config +cp $NOVA_ROOT/etc/nova/nova.conf.sample /etc/nova/nova.conf +cp $NOVA_ROOT/etc/nova/logging_sample.conf /etc/nova/logging.conf +cp $NOVA_ROOT/etc/nova/api-paste.ini /etc/nova +cp $NOVA_ROOT/etc/nova/policy.json /etc/nova + +# upstart script +cp -f $(dirname $0)/../upstart/nova-api.conf /etc/init + diff --git a/elements/nova-api/upstart/nova-api.conf b/elements/nova-api/upstart/nova-api.conf new file mode 100644 index 00000000..8a1576c3 --- /dev/null +++ b/elements/nova-api/upstart/nova-api.conf @@ -0,0 +1,30 @@ +description "OpenStack Nova API Service" + +start on runlevel [2345] +stop on runlevel [016] + +setuid nova +setgid nova + +respawn + +exec /opt/stack/nova/bin/nova-api + +# wait until service is running. +post-start script + svc_port=$(grep ^osapi_compute_listen_port /etc/nova/nova.conf ||:) + svc_port=${svc_port##*=} + if [ -z "$svc_port" ] ; then + svc_port="8774" + fi + + for try in $(seq 9 -1 1); do + if nc -w 1 localhost $svc_port < /dev/null ; then + echo Connected to port $svc_port! + exit 0 + fi + echo Could not connect to $svc_port, retrying $try more times... + sleep 1 + done +end script +