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 |
Joe Gordon | 4640026 | 2013-06-30 04:32:27 -0700 | [diff] [blame^] | 4 | # at the successful conclusion of ``stack.sh``. |
Dean Troyer | f5633dd | 2012-03-28 11:21:40 -0500 | [diff] [blame] | 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 Troyer | 5547baa | 2012-08-31 10:55:36 -0500 | [diff] [blame] | 10 | # after ``stack.sh`` to tweak the OpenStack configuration that DevStack produces. |
Dean Troyer | f5633dd | 2012-03-28 11:21:40 -0500 | [diff] [blame] | 11 | # These should be considered as samples and are unsupported DevStack code. |
| 12 | |
Dean Troyer | 5547baa | 2012-08-31 10:55:36 -0500 | [diff] [blame] | 13 | |
Dean Troyer | f5633dd | 2012-03-28 11:21:40 -0500 | [diff] [blame] | 14 | # Keep track of the devstack directory |
| 15 | TOP_DIR=$(cd $(dirname "$0") && pwd) |
| 16 | |
Dean Troyer | 05530ca | 2012-07-06 15:09:10 -0500 | [diff] [blame] | 17 | # Import common functions |
| 18 | source $TOP_DIR/functions |
| 19 | |
Dean Troyer | f5633dd | 2012-03-28 11:21:40 -0500 | [diff] [blame] | 20 | # Use openrc + stackrc + localrc for settings |
| 21 | source $TOP_DIR/stackrc |
| 22 | |
| 23 | # Destination path for installation ``DEST`` |
| 24 | DEST=${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 |
| 34 | source $TOP_DIR/openrc |
| 35 | |
| 36 | # Add first keypair found in localhost:$HOME/.ssh |
| 37 | for i in $HOME/.ssh/id_rsa.pub $HOME/.ssh/id_dsa.pub; do |
Dean Troyer | 5547baa | 2012-08-31 10:55:36 -0500 | [diff] [blame] | 38 | if [[ -r $i ]]; then |
Dean Troyer | f5633dd | 2012-03-28 11:21:40 -0500 | [diff] [blame] | 39 | nova keypair-add --pub_key=$i `hostname` |
| 40 | break |
| 41 | fi |
| 42 | done |
| 43 | |
| 44 | |
| 45 | # Create A Flavor |
| 46 | # --------------- |
| 47 | |
| 48 | # Get OpenStack admin auth |
| 49 | source $TOP_DIR/openrc admin admin |
| 50 | |
| 51 | # Name of new flavor |
| 52 | # set in ``localrc`` with ``DEFAULT_INSTANCE_TYPE=m1.micro`` |
| 53 | MI_NAME=m1.micro |
| 54 | |
| 55 | # Create micro flavor if not present |
| 56 | if [[ -z $(nova flavor-list | grep $MI_NAME) ]]; then |
| 57 | nova flavor-create $MI_NAME 6 128 0 1 |
| 58 | fi |
Dean Troyer | 5547baa | 2012-08-31 10:55:36 -0500 | [diff] [blame] | 59 | |
| 60 | |
Dean Troyer | f5633dd | 2012-03-28 11:21:40 -0500 | [diff] [blame] | 61 | # Other Uses |
| 62 | # ---------- |
| 63 | |
Dean Troyer | 5547baa | 2012-08-31 10:55:36 -0500 | [diff] [blame] | 64 | # Add tcp/22 and icmp to default security group |
long-wang | 8dac568 | 2012-09-09 11:19:58 +0800 | [diff] [blame] | 65 | nova secgroup-add-rule default tcp 22 22 0.0.0.0/0 |
| 66 | nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0 |
| 67 | |