Denis Egorenko | a45a0a0 | 2013-10-01 16:03:39 +0000 | [diff] [blame^] | 1 | # lib/savanna |
| 2 | |
| 3 | # Dependencies: |
| 4 | # ``functions`` file |
| 5 | # ``DEST``, ``DATA_DIR``, ``STACK_USER`` must be defined |
| 6 | # ``ADMIN_{TENANT_NAME|PASSWORD}`` must be defined |
| 7 | |
| 8 | # ``stack.sh`` calls the entry points in this order: |
| 9 | # |
| 10 | # install_savanna |
| 11 | # configure_savanna |
| 12 | # start_savanna |
| 13 | # stop_savanna |
| 14 | |
| 15 | # Save trace setting |
| 16 | XTRACE=$(set +o | grep xtrace) |
| 17 | set +o xtrace |
| 18 | |
| 19 | |
| 20 | # Defaults |
| 21 | # -------- |
| 22 | |
| 23 | # Set up default repos |
| 24 | SAVANNA_REPO=${SAVANNA_REPO:-${GIT_BASE}/openstack/savanna.git} |
| 25 | SAVANNA_BRANCH=${SAVANNA_BRANCH:-master} |
| 26 | |
| 27 | # Set up default directories |
| 28 | SAVANNA_DIR=$DEST/savanna |
| 29 | SAVANNA_CONF_DIR=${SAVANNA_CONF_DIR:-/etc/savanna} |
| 30 | SAVANNA_CONF_FILE=savanna.conf |
| 31 | ADMIN_TENANT_NAME=${ADMIN_TENANT_NAME:-admin} |
| 32 | ADMIN_NAME=${ADMIN_NAME:-admin} |
| 33 | ADMIN_PASSWORD=${ADMIN_PASSWORD:-nova} |
| 34 | SAVANNA_DEBUG=${SAVANNA_DEBUG:-True} |
| 35 | |
| 36 | # Support entry points installation of console scripts |
| 37 | if [[ -d $SAVANNA_DIR/bin ]]; then |
| 38 | SAVANNA_BIN_DIR=$SAVANNA_DIR/bin |
| 39 | else |
| 40 | SAVANNA_BIN_DIR=$(get_python_exec_prefix) |
| 41 | fi |
| 42 | |
| 43 | # Functions |
| 44 | # --------- |
| 45 | |
| 46 | # configure_savanna() - Set config files, create data dirs, etc |
| 47 | function configure_savanna() { |
| 48 | |
| 49 | if [[ ! -d $SAVANNA_CONF_DIR ]]; then |
| 50 | sudo mkdir -p $SAVANNA_CONF_DIR |
| 51 | fi |
| 52 | sudo chown $STACK_USER $SAVANNA_CONF_DIR |
| 53 | |
| 54 | # Copy over savanna configuration file and configure common parameters. |
| 55 | cp $SAVANNA_DIR/etc/savanna/savanna.conf.sample $SAVANNA_CONF_DIR/$SAVANNA_CONF_FILE |
| 56 | |
| 57 | iniset $SAVANNA_CONF_DIR/$SAVANNA_CONF_FILE DEFAULT os_admin_password $ADMIN_PASSWORD |
| 58 | iniset $SAVANNA_CONF_DIR/$SAVANNA_CONF_FILE DEFAULT os_admin_username $ADMIN_NAME |
| 59 | iniset $SAVANNA_CONF_DIR/$SAVANNA_CONF_FILE DEFAULT os_admin_tenant_name $ADMIN_TENANT_NAME |
| 60 | iniset $SAVANNA_CONF_DIR/$SAVANNA_CONF_FILE DEFAULT debug $SAVANNA_DEBUG |
| 61 | |
| 62 | recreate_database savanna utf8 |
| 63 | iniset $SAVANNA_CONF_DIR/$SAVANNA_CONF_FILE database sql_connection `database_connection_url savanna` |
| 64 | inicomment $SAVANNA_CONF_DIR/$SAVANNA_CONF_FILE database connection |
| 65 | |
| 66 | if is_service_enabled neutron; then |
| 67 | iniset $SAVANNA_CONF_DIR/$SAVANNA_CONF_FILE DEFAULT use_neutron true |
| 68 | iniset $SAVANNA_CONF_DIR/$SAVANNA_CONF_FILE DEFAULT use_floating_ips true |
| 69 | fi |
| 70 | |
| 71 | iniset $SAVANNA_CONF_DIR/$SAVANNA_CONF_FILE DEFAULT use_syslog $SYSLOG |
| 72 | } |
| 73 | |
| 74 | # install_savanna() - Collect source and prepare |
| 75 | function install_savanna() { |
| 76 | git_clone $SAVANNA_REPO $SAVANNA_DIR $SAVANNA_BRANCH |
| 77 | setup_develop $SAVANNA_DIR |
| 78 | } |
| 79 | |
| 80 | # start_savanna() - Start running processes, including screen |
| 81 | function start_savanna() { |
| 82 | screen_it savanna "cd $SAVANNA_DIR && $SAVANNA_BIN_DIR/savanna-api --config-file $SAVANNA_CONF_DIR/$SAVANNA_CONF_FILE" |
| 83 | } |
| 84 | |
| 85 | # stop_savanna() - Stop running processes |
| 86 | function stop_savanna() { |
| 87 | # Kill the Savanna screen windows |
| 88 | screen -S $SCREEN_NAME -p savanna -X kill |
| 89 | } |
| 90 | |
| 91 | |
| 92 | # Restore xtrace |
| 93 | $XTRACE |
| 94 | |
| 95 | # Local variables: |
| 96 | # mode: shell-script |
| 97 | # End: |