Dean Troyer | f5633dd | 2012-03-28 11:21:40 -0500 | [diff] [blame] | 1 | #!/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 |
| 10 | # after stack.sh to tweak the OpenStack configuration that DevStack produces. |
| 11 | # These should be considered as samples and are unsupported DevStack code. |
| 12 | |
| 13 | # Keep track of the devstack directory |
| 14 | TOP_DIR=$(cd $(dirname "$0") && pwd) |
| 15 | |
| 16 | # Use openrc + stackrc + localrc for settings |
| 17 | source $TOP_DIR/stackrc |
| 18 | |
| 19 | # Destination path for installation ``DEST`` |
| 20 | DEST=${DEST:-/opt/stack} |
| 21 | |
| 22 | |
| 23 | # Import ssh keys |
| 24 | # --------------- |
| 25 | |
| 26 | # Import keys from the current user into the default OpenStack user (usually |
| 27 | # ``demo``) |
| 28 | |
| 29 | # Get OpenStack auth |
| 30 | source $TOP_DIR/openrc |
| 31 | |
| 32 | # Add first keypair found in localhost:$HOME/.ssh |
| 33 | for i in $HOME/.ssh/id_rsa.pub $HOME/.ssh/id_dsa.pub; do |
| 34 | if [[ -f $i ]]; then |
| 35 | nova keypair-add --pub_key=$i `hostname` |
| 36 | break |
| 37 | fi |
| 38 | done |
| 39 | |
| 40 | |
| 41 | # Create A Flavor |
| 42 | # --------------- |
| 43 | |
| 44 | # Get OpenStack admin auth |
| 45 | source $TOP_DIR/openrc admin admin |
| 46 | |
| 47 | # Name of new flavor |
| 48 | # set in ``localrc`` with ``DEFAULT_INSTANCE_TYPE=m1.micro`` |
| 49 | MI_NAME=m1.micro |
| 50 | |
| 51 | # Create micro flavor if not present |
| 52 | if [[ -z $(nova flavor-list | grep $MI_NAME) ]]; then |
| 53 | nova flavor-create $MI_NAME 6 128 0 1 |
| 54 | fi |
| 55 | # Other Uses |
| 56 | # ---------- |
| 57 | |
| 58 | # Add tcp/22 to default security group |
| 59 | |