Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add local.sh support and samples of local.sh and locarc

Run $TOP_DIR/local.sh at the end of stack.sh if it exists and is executable.
This allows the user to automatically perform local actions on every re-stack,
such as creating custom flavors or specific tenants/users.  Like localrc, this
file is not distributed with DevStack so user modifications will be undisturbed.

Add local.sh to .gitignore

Examples of local.sh and localrc are in the samples/ directory.

Change-Id: I0be6b4d80ce084981cac8a3a8f1dc9bc8c3bbd4e
  • Loading branch information...
commit f5633ddb7d543397fb881a4d3cbf9207abd6b1de 1 parent 08e07fb
@dtroyer dtroyer authored
Showing with 147 additions and 0 deletions.
  1. +1 −0  .gitignore
  2. +59 −0 samples/local.sh
  3. +77 −0 samples/localrc
  4. +10 −0 stack.sh
View
1  .gitignore
@@ -3,3 +3,4 @@ proto
*.log
src
localrc
+local.sh
View
59 samples/local.sh
@@ -0,0 +1,59 @@
+#!/usr/bin/env bash
+
+# Sample ``local.sh`` for user-configurable tasks to run automatically
+# at the sucessful conclusion of ``stack.sh``.
+
+# NOTE: Copy this file to the root ``devstack`` directory for it to
+# work properly.
+
+# This is a collection of some of the things we have found to be useful to run
+# after stack.sh to tweak the OpenStack configuration that DevStack produces.
+# These should be considered as samples and are unsupported DevStack code.
+
+# Keep track of the devstack directory
+TOP_DIR=$(cd $(dirname "$0") && pwd)
+
+# Use openrc + stackrc + localrc for settings
+source $TOP_DIR/stackrc
+
+# Destination path for installation ``DEST``
+DEST=${DEST:-/opt/stack}
+
+
+# Import ssh keys
+# ---------------
+
+# Import keys from the current user into the default OpenStack user (usually
+# ``demo``)
+
+# Get OpenStack auth
+source $TOP_DIR/openrc
+
+# Add first keypair found in localhost:$HOME/.ssh
+for i in $HOME/.ssh/id_rsa.pub $HOME/.ssh/id_dsa.pub; do
+ if [[ -f $i ]]; then
+ nova keypair-add --pub_key=$i `hostname`
+ break
+ fi
+done
+
+
+# Create A Flavor
+# ---------------
+
+# Get OpenStack admin auth
+source $TOP_DIR/openrc admin admin
+
+# Name of new flavor
+# set in ``localrc`` with ``DEFAULT_INSTANCE_TYPE=m1.micro``
+MI_NAME=m1.micro
+
+# Create micro flavor if not present
+if [[ -z $(nova flavor-list | grep $MI_NAME) ]]; then
+ nova flavor-create $MI_NAME 6 128 0 1
+fi
+# Other Uses
+# ----------
+
+# Add tcp/22 to default security group
+
View
77 samples/localrc
@@ -0,0 +1,77 @@
+# Sample ``localrc`` for user-configurable variables in ``stack.sh``
+
+# NOTE: Copy this file to the root ``devstack`` directory for it to work properly.
+
+# ``localrc`` is a user-maintained setings file that is sourced at the end of
+# ``stackrc``. This gives it the ability to override any variables set in ``stackrc``.
+# Also, most of the settings in ``stack.sh`` are written to only be set if no
+# value has already been set; this lets ``localrc`` effectively override the
+# default values.
+
+# This is a collection of some of the settings we have found to be useful
+# in our DevStack development environments. Additional settings are described
+# in http://devstack.org/localrc.html
+# These should be considered as samples and are unsupported DevStack code.
+
+
+# Minimal Contents
+# ----------------
+
+# While ``stack.sh`` is happy to run without ``localrc``, devlife is better when
+# there are a few minimal variables set:
+
+# If the ``*_PASSWORD`` variables are not set here you will be prompted to enter
+# values for them by ``stack.sh``.
+ADMIN_PASSWORD=nomoresecrete
+MYSQL_PASSWORD=stackdb
+RABBIT_PASSWORD=stackqueue
+SERVICE_PASSWORD=$ADMIN_PASSWORD
+
+# HOST_IP should be set manually for best results. It is auto-detected during the
+# first run of ``stack.sh`` but often is indeterminate on later runs due to the IP
+# being moved from an Ethernet interface to a bridge on the host. Setting it here
+# also makes it available for ``openrc`` to include when setting ``OS_AUTH_URL``.
+# ``HOST_IP`` is not set by default.
+HOST_IP=w.x.y.z
+
+
+# Set DevStack Install Directory
+# ------------------------------
+
+# The DevStack install directory is set by the ``DEST`` variable. By setting it
+# early in ``localrc`` you can reference it in later variables. The default value
+# is ``/opt/stack``. It can be useful to set it even though it is not changed from
+# the default value.
+DEST=/opt/stack
+
+
+# Using milestone-proposed branches
+# ---------------------------------
+
+# Uncomment these to grab the milestone-proposed branches from the repos:
+#GLANCE_BRANCH=milestone-proposed
+#HORIZON_BRANCH=milestone-proposed
+#KEYSTONE_BRANCH=milestone-proposed
+#KEYSTONECLIENT_BRANCH=milestone-proposed
+#NOVA_BRANCH=milestone-proposed
+#NOVACLIENT_BRANCH=milestone-proposed
+#SWIFT_BRANCH=milestone-proposed
+
+
+# Swift
+# -----
+
+# Swift is now used as the back-end for the S3-like object store. If Nova's
+# objectstore (``n-obj`` in ``ENABLED_SERVICES``) is enabled, it will NOT
+# run if Swift is enabled. Setting the hash value is required and you will
+# be prompted for it if Swift is enabled so just set it to something already:
+SWIFT_HASH=66a3d6b56c1f479c8b4e70ab5c2000f5
+
+# For development purposes the default of 3 replicas is usually not required.
+# Set this to 1 to save some resources:
+SWIFT_REPLICAS=1
+
+# The data for Swift is stored in the source tree by default (``$DEST/swift/data``)
+# and can be moved by setting ``SWIFT_DATA_DIR``. The directory will be created
+# if it does not exist.
+SWIFT_DATA_DIR=$DEST/data
View
10 stack.sh
@@ -1706,6 +1706,16 @@ if is_service_enabled g-reg; then
fi
+# Run local script
+# ================
+
+# Run ``local.sh`` if it exists to perform user-managed tasks
+if [[ -x $TOP_DIR/local.sh ]]; then
+ echo "Running user script $TOP_DIR/local.sh"
+ $TOP_DIR/local.sh
+fi
+
+
# Fin
# ===
Please sign in to comment.
Something went wrong with that request. Please try again.