samples/local.sh
f5633ddb
 #!/usr/bin/env bash
 
 # Sample ``local.sh`` for user-configurable tasks to run automatically
4640026c
 # at the successful conclusion of ``stack.sh``.
f5633ddb
 
dc97cb71
 # NOTE: Copy this file to the root DevStack directory for it to work properly.
f5633ddb
 
 # This is a collection of some of the things we have found to be useful to run
5547baa5
 # after ``stack.sh`` to tweak the OpenStack configuration that DevStack produces.
f5633ddb
 # These should be considered as samples and are unsupported DevStack code.
 
5547baa5
 
dc97cb71
 # Keep track of the DevStack directory
f5633ddb
 TOP_DIR=$(cd $(dirname "$0") && pwd)
 
05530caf
 # Import common functions
 source $TOP_DIR/functions
 
f5633ddb
 # Use openrc + stackrc + localrc for settings
 source $TOP_DIR/stackrc
 
 # Destination path for installation ``DEST``
 DEST=${DEST:-/opt/stack}
 
38e38fb1
 if is_service_enabled nova; then
f5633ddb
 
38e38fb1
     # Import ssh keys
     # ---------------
f5633ddb
 
38e38fb1
     # Import keys from the current user into the default OpenStack user (usually
     # ``demo``)
f5633ddb
 
38e38fb1
     # Get OpenStack user auth
     source $TOP_DIR/openrc
f5633ddb
 
38e38fb1
     # Add first keypair found in localhost:$HOME/.ssh
     for i in $HOME/.ssh/id_rsa.pub $HOME/.ssh/id_dsa.pub; do
         if [[ -r $i ]]; then
             nova keypair-add --pub_key=$i `hostname`
             break
         fi
     done
f5633ddb
 
 
38e38fb1
     # Create A Flavor
     # ---------------
f5633ddb
 
38e38fb1
     # Get OpenStack admin auth
     source $TOP_DIR/openrc admin admin
f5633ddb
 
38e38fb1
     # Name of new flavor
dc97cb71
     # set in ``local.conf`` with ``DEFAULT_INSTANCE_TYPE=m1.micro``
38e38fb1
     MI_NAME=m1.micro
f5633ddb
 
38e38fb1
     # 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
5547baa5
 
 
38e38fb1
     # Other Uses
     # ----------
f5633ddb
 
38e38fb1
     # Add tcp/22 and icmp to default security group
     nova secgroup-add-rule default tcp 22 22 0.0.0.0/0
     nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0
8dac568a
 
38e38fb1
 fi