blob: 664cb663fe396ad5ae8e97afac7d59b74dd790c1 [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
Joe Gordon46400262013-06-30 04:32:27 -07004# at the successful conclusion of ``stack.sh``.
Dean Troyerf5633dd2012-03-28 11:21:40 -05005
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
Dean Troyer38e38fb2014-01-10 12:05:51 -060026if is_service_enabled nova; then
Dean Troyerf5633dd2012-03-28 11:21:40 -050027
Dean Troyer38e38fb2014-01-10 12:05:51 -060028 # Import ssh keys
29 # ---------------
Dean Troyerf5633dd2012-03-28 11:21:40 -050030
Dean Troyer38e38fb2014-01-10 12:05:51 -060031 # Import keys from the current user into the default OpenStack user (usually
32 # ``demo``)
Dean Troyerf5633dd2012-03-28 11:21:40 -050033
Dean Troyer38e38fb2014-01-10 12:05:51 -060034 # Get OpenStack user auth
35 source $TOP_DIR/openrc
Dean Troyerf5633dd2012-03-28 11:21:40 -050036
Dean Troyer38e38fb2014-01-10 12:05:51 -060037 # Add first keypair found in localhost:$HOME/.ssh
38 for i in $HOME/.ssh/id_rsa.pub $HOME/.ssh/id_dsa.pub; do
39 if [[ -r $i ]]; then
40 nova keypair-add --pub_key=$i `hostname`
41 break
42 fi
43 done
44
45
46 # Create A Flavor
47 # ---------------
48
49 # Get OpenStack admin auth
50 source $TOP_DIR/openrc admin admin
51
52 # Name of new flavor
53 # set in ``localrc`` with ``DEFAULT_INSTANCE_TYPE=m1.micro``
54 MI_NAME=m1.micro
55
56 # Create micro flavor if not present
57 if [[ -z $(nova flavor-list | grep $MI_NAME) ]]; then
58 nova flavor-create $MI_NAME 6 128 0 1
Dean Troyerf5633dd2012-03-28 11:21:40 -050059 fi
Dean Troyerf5633dd2012-03-28 11:21:40 -050060
61
Dean Troyer38e38fb2014-01-10 12:05:51 -060062 # Other Uses
63 # ----------
Dean Troyerf5633dd2012-03-28 11:21:40 -050064
Dean Troyer38e38fb2014-01-10 12:05:51 -060065 # Add tcp/22 and icmp to default security group
66 nova secgroup-add-rule default tcp 22 22 0.0.0.0/0
67 nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0
Dean Troyerf5633dd2012-03-28 11:21:40 -050068
Dean Troyerf5633dd2012-03-28 11:21:40 -050069fi