devstack/samples/local.sh
Jake Yip 5441b3df6e Use OS_CLOUD in sample local.sh
local.sh, if present, will be executed at the end of stack.sh. The
sample file here is meant to be copied to devstack root if desired.

Unfortunately, due to Change I86ffa9cd52454f1c1c72d29b3a0e0caa3e44b829
changing to use OS_CLOUD in stack.sh, sourcing openrc here will cause
both OS_CLOUD and traditional OS_* env vars to be set, which causes a
conflict.

Change-Id: Id80b46acab7d600ad7394ab5bc1984304825a672
2023-09-20 11:32:33 +00:00

68 lines
1.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# Sample ``local.sh`` for user-configurable tasks to run automatically
# at the successful conclusion of ``stack.sh``.
# NOTE: Copy this file to the root DevStack directory for it to work properly.
# This is a collection of some of the things we have found to be useful to run
# after ``stack.sh`` to tweak the OpenStack configuration that DevStack produces.
# These should be considered as samples and are unsupported DevStack code.
# Keep track of the DevStack directory
TOP_DIR=$(cd $(dirname "$0") && pwd)
# Import common functions
source $TOP_DIR/functions
# Use openrc + stackrc + localrc for settings
source $TOP_DIR/stackrc
# Destination path for installation ``DEST``
DEST=${DEST:-/opt/stack}
if is_service_enabled nova; then
# Import ssh keys
# ---------------
# Import keys from the current user into the default OpenStack user (usually
# ``demo``)
# Get OpenStack user auth
export OS_CLOUD=devstack
# 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
openstack keypair create --public-key $i `hostname`
break
fi
done
# Update security default group
# -----------------------------
# Add tcp/22 and icmp to default security group
default=$(openstack security group list -f value -c ID)
openstack security group rule create $default --protocol tcp --dst-port 22
openstack security group rule create $default --protocol icmp
# Create A Flavor
# ---------------
# Get OpenStack admin auth
source $TOP_DIR/openrc admin admin
# Name of new flavor
# set in ``local.conf`` with ``DEFAULT_INSTANCE_TYPE=m1.micro``
MI_NAME=m1.micro
# Create micro flavor if not present
if [[ -z $(openstack flavor list | grep $MI_NAME) ]]; then
openstack flavor create $MI_NAME --id 6 --ram 128 --disk 0 --vcpus 1
fi
fi