blob: eb9bc241e96c529e5e9cf0190a8949cf2e4e6b64 [file] [log] [blame]
Dean Troyerf5633dd2012-03-28 11:21:40 -05001#!/usr/bin/env bash
2
3# Sample ``local.sh`` for user-configurable tasks to run automatically
4# at the sucessful conclusion of ``stack.sh``.
5
6# NOTE: Copy this file to the root ``devstack`` directory for it to
7# work properly.
8
9# This is a collection of some of the things we have found to be useful to run
Dean Troyer5547baa2012-08-31 10:55:36 -050010# after ``stack.sh`` to tweak the OpenStack configuration that DevStack produces.
Dean Troyerf5633dd2012-03-28 11:21:40 -050011# These should be considered as samples and are unsupported DevStack code.
12
Dean Troyer5547baa2012-08-31 10:55:36 -050013
Dean Troyerf5633dd2012-03-28 11:21:40 -050014# Keep track of the devstack directory
15TOP_DIR=$(cd $(dirname "$0") && pwd)
16
Dean Troyer05530ca2012-07-06 15:09:10 -050017# Import common functions
18source $TOP_DIR/functions
19
Dean Troyerf5633dd2012-03-28 11:21:40 -050020# Use openrc + stackrc + localrc for settings
21source $TOP_DIR/stackrc
22
23# Destination path for installation ``DEST``
24DEST=${DEST:-/opt/stack}
25
26
27# Import ssh keys
28# ---------------
29
30# Import keys from the current user into the default OpenStack user (usually
31# ``demo``)
32
33# Get OpenStack auth
34source $TOP_DIR/openrc
35
36# Add first keypair found in localhost:$HOME/.ssh
37for i in $HOME/.ssh/id_rsa.pub $HOME/.ssh/id_dsa.pub; do
Dean Troyer5547baa2012-08-31 10:55:36 -050038 if [[ -r $i ]]; then
Dean Troyerf5633dd2012-03-28 11:21:40 -050039 nova keypair-add --pub_key=$i `hostname`
40 break
41 fi
42done
43
44
45# Create A Flavor
46# ---------------
47
48# Get OpenStack admin auth
49source $TOP_DIR/openrc admin admin
50
51# Name of new flavor
52# set in ``localrc`` with ``DEFAULT_INSTANCE_TYPE=m1.micro``
53MI_NAME=m1.micro
54
55# Create micro flavor if not present
56if [[ -z $(nova flavor-list | grep $MI_NAME) ]]; then
57 nova flavor-create $MI_NAME 6 128 0 1
58fi
Dean Troyer5547baa2012-08-31 10:55:36 -050059
60
Dean Troyerf5633dd2012-03-28 11:21:40 -050061# Other Uses
62# ----------
63
Dean Troyer5547baa2012-08-31 10:55:36 -050064# Add tcp/22 and icmp to default security group