From bfdad75eda98c5eec4c7a59ad7dd7ac45a5712cf Mon Sep 17 00:00:00 2001 From: Steve Baker Date: Sat, 18 Aug 2012 09:00:42 +1200 Subject: [PATCH] Add support to optionally launch the heat service. This allows the heat service to be started as a devstack service. Heat is disabled by default, and can be enabled with this in your localrc: ENABLED_SERVICES+=,heat There is now a repo of heat-enabled images here: https://github.com/heat-api/prebuilt-jeos-images/downloads These can be added to the IMAGE_URLS in your localrc. After devstack is launched, a template can be invoked with: nova keypair-add --pub_key $HOME/.ssh/id_rsa.pub heat_key heat -d create wordpress \ --template-file=../heat/templates/WordPress_Single_Instance.template \ --parameters="InstanceType=m1.tiny;DBUsername=wpuser;DBPassword=wppassword;\ KeyName=heat_key;LinuxDistribution=F16" Change-Id: I07591295eb2b9eb7868b1577dd3c24b19812a689 --- files/default_catalog.templates | 5 + files/keystone_data.sh | 25 +++++ lib/heat | 156 ++++++++++++++++++++++++++++++++ stack.sh | 18 +++- stackrc | 4 + 5 files changed, 207 insertions(+), 1 deletion(-) create mode 100644 lib/heat diff --git a/files/default_catalog.templates b/files/default_catalog.templates index 66052b6add..ceb6458f86 100644 --- a/files/default_catalog.templates +++ b/files/default_catalog.templates @@ -34,3 +34,8 @@ catalog.RegionOne.image.publicURL = http://%SERVICE_HOST%:9292 catalog.RegionOne.image.adminURL = http://%SERVICE_HOST%:9292 catalog.RegionOne.image.internalURL = http://%SERVICE_HOST%:9292 catalog.RegionOne.image.name = Image Service + +catalog.RegionOne.heat.publicURL = http://%SERVICE_HOST%:8000/v1 +catalog.RegionOne.heat.adminURL = http://%SERVICE_HOST%:8000/v1 +catalog.RegionOne.heat.internalURL = http://%SERVICE_HOST%:8000/v1 +catalog.RegionOne.heat.name = Heat Service diff --git a/files/keystone_data.sh b/files/keystone_data.sh index 6987797a37..2a8d07030d 100755 --- a/files/keystone_data.sh +++ b/files/keystone_data.sh @@ -10,6 +10,7 @@ # service quantum admin # if enabled # service swift admin # if enabled # service cinder admin # if enabled +# service heat admin # if enabled # demo admin admin # demo demo Member, anotherrole # invisible_to_admin demo Member @@ -154,6 +155,29 @@ if [[ "$ENABLED_SERVICES" =~ "n-vol" ]]; then fi fi +# Heat +if [[ "$ENABLED_SERVICES" =~ "heat" ]]; then + HEAT_USER=$(get_id keystone user-create --name=heat \ + --pass="$SERVICE_PASSWORD" \ + --tenant_id $SERVICE_TENANT \ + --email=heat@example.com) + keystone user-role-add --tenant_id $SERVICE_TENANT \ + --user_id $HEAT_USER \ + --role_id $ADMIN_ROLE + if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then + HEAT_SERVICE=$(get_id keystone service-create \ + --name=heat \ + --type=orchestration \ + --description="Heat Service") + keystone endpoint-create \ + --region RegionOne \ + --service_id $HEAT_SERVICE \ + --publicurl "http://$SERVICE_HOST:$HEAT_API_PORT/v1" \ + --adminurl "http://$SERVICE_HOST:$HEAT_API_PORT/v1" \ + --internalurl "http://$SERVICE_HOST:$HEAT_API_PORT/v1" + fi +fi + # Glance if [[ "$ENABLED_SERVICES" =~ "g-api" ]]; then GLANCE_USER=$(get_id keystone user-create \ @@ -296,3 +320,4 @@ if [[ "$ENABLED_SERVICES" =~ "c-api" ]]; then --internalurl "http://$SERVICE_HOST:8776/v1/\$(tenant_id)s" fi fi + diff --git a/lib/heat b/lib/heat new file mode 100644 index 0000000000..6f442f877a --- /dev/null +++ b/lib/heat @@ -0,0 +1,156 @@ +# lib/heat +# Install and start Heat service +# To enable, add the following to localrc +# ENABLED_SERVICES+=,heat,h-api,h-eng,h-meta + +# Dependencies: +# - functions + +# stack.sh +# --------- +# install_XXX +# configure_XXX +# init_XXX +# start_XXX +# stop_XXX +# cleanup_XXX + +# Print the commands being run so that we can see the command that triggers +# an error. It is also useful for following along as the install occurs. +set -o xtrace + + +# Defaults +# -------- +HEAT_DIR=$DEST/heat + +# set up default directories + +# cleanup_heat() - Remove residual data files, anything left over from previous +# runs that a clean run would need to clean up +function cleanup_heat() { + # This function intentionally left blank + : +} + +# configure_heat() - Set config files, create data dirs, etc +function configure_heat() { + setup_develop $HEAT_DIR + + HEAT_CONF_DIR=/etc/heat + if [[ ! -d $HEAT_CONF_DIR ]]; then + sudo mkdir -p $HEAT_CONF_DIR + fi + sudo chown `whoami` $HEAT_CONF_DIR + + HEAT_API_HOST=${HEAT_API_HOST:-$SERVICE_HOST} + HEAT_API_PORT=${HEAT_API_PORT:-8000} + HEAT_ENGINE_HOST=${HEAT_ENGINE_HOST:-$SERVICE_HOST} + HEAT_ENGINE_PORT=${HEAT_ENGINE_PORT:-8001} + HEAT_METADATA_HOST=${HEAT_METADATA_HOST:-$SERVICE_HOST} + HEAT_METADATA_PORT=${HEAT_METADATA_PORT:-8002} + + HEAT_API_CONF=$HEAT_CONF_DIR/heat-api.conf + cp $HEAT_DIR/etc/heat-api.conf $HEAT_API_CONF + iniset $HEAT_API_CONF DEFAULT debug True + inicomment $HEAT_API_CONF DEFAULT log_file + iniset $HEAT_API_CONF DEFAULT use_syslog $SYSLOG + iniset $HEAT_API_CONF DEFAULT bind_host $HEAT_API_HOST + iniset $HEAT_API_CONF DEFAULT bind_port $HEAT_API_PORT + + if is_service_enabled rabbit; then + iniset $HEAT_API_CONF DEFAULT rpc_backend heat.openstack.common.rpc.impl_kombu + iniset $HEAT_API_CONF DEFAULT rabbit_password $RABBIT_PASSWORD + iniset $HEAT_API_CONF DEFAULT rabbit_host $RABBIT_HOST + elif is_service_enabled qpid; then + iniset $HEAT_API_CONF DEFAULT rpc_backend heat.openstack.common.rpc.impl_qpid + fi + + HEAT_API_PASTE_INI=$HEAT_CONF_DIR/heat-api-paste.ini + cp $HEAT_DIR/etc/heat-api-paste.ini $HEAT_API_PASTE_INI + iniset $HEAT_API_PASTE_INI filter:authtoken auth_host $KEYSTONE_AUTH_HOST + iniset $HEAT_API_PASTE_INI filter:authtoken auth_port $KEYSTONE_AUTH_PORT + iniset $HEAT_API_PASTE_INI filter:authtoken auth_protocol $KEYSTONE_AUTH_PROTOCOL + iniset $HEAT_API_PASTE_INI filter:authtoken auth_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/v2.0 + iniset $HEAT_API_PASTE_INI filter:authtoken admin_tenant_name $SERVICE_TENANT_NAME + iniset $HEAT_API_PASTE_INI filter:authtoken admin_user heat + iniset $HEAT_API_PASTE_INI filter:authtoken admin_password $SERVICE_PASSWORD + iniset $HEAT_API_PASTE_INI filter:ec2authtoken auth_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/v2.0 + iniset $HEAT_API_PASTE_INI filter:ec2authtoken keystone_ec2_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/v2.0/ec2tokens + + HEAT_ENGINE_CONF=$HEAT_CONF_DIR/heat-engine.conf + cp $HEAT_DIR/etc/heat-engine.conf $HEAT_ENGINE_CONF + iniset $HEAT_ENGINE_CONF DEFAULT debug True + inicomment $HEAT_ENGINE_CONF DEFAULT log_file + iniset $HEAT_ENGINE_CONF DEFAULT use_syslog $SYSLOG + iniset $HEAT_ENGINE_CONF DEFAULT bind_host $HEAT_ENGINE_HOST + iniset $HEAT_ENGINE_CONF DEFAULT bind_port $HEAT_ENGINE_PORT + iniset $HEAT_ENGINE_CONF DEFAULT sql_connection $BASE_SQL_CONN/heat?charset=utf8 + iniset $HEAT_ENGINE_CONF DEFAULT auth_encryption_key `hexdump -n 16 -v -e '/1 "%02x"' /dev/random` + + if is_service_enabled rabbit; then + iniset $HEAT_ENGINE_CONF DEFAULT rpc_backend heat.openstack.common.rpc.impl_kombu + iniset $HEAT_ENGINE_CONF DEFAULT rabbit_password $RABBIT_PASSWORD + iniset $HEAT_ENGINE_CONF DEFAULT rabbit_host $RABBIT_HOST + elif is_service_enabled qpid; then + iniset $HEAT_ENGINE_CONF DEFAULT rpc_backend heat.openstack.common.rpc.impl_qpid + fi + + HEAT_ENGINE_PASTE_INI=$HEAT_CONF_DIR/heat-engine-paste.ini + cp $HEAT_DIR/etc/heat-engine-paste.ini $HEAT_ENGINE_PASTE_INI + iniset $HEAT_ENGINE_PASTE_INI filter:authtoken auth_host $KEYSTONE_AUTH_HOST + iniset $HEAT_ENGINE_PASTE_INI filter:authtoken auth_port $KEYSTONE_AUTH_PORT + iniset $HEAT_ENGINE_PASTE_INI filter:authtoken auth_protocol $KEYSTONE_AUTH_PROTOCOL + iniset $HEAT_ENGINE_PASTE_INI filter:authtoken auth_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/v2.0 + iniset $HEAT_ENGINE_PASTE_INI filter:authtoken admin_tenant_name $SERVICE_TENANT_NAME + iniset $HEAT_ENGINE_PASTE_INI filter:authtoken admin_user heat + iniset $HEAT_ENGINE_PASTE_INI filter:authtoken admin_password $SERVICE_PASSWORD + + HEAT_METADATA_CONF=$HEAT_CONF_DIR/heat-metadata.conf + cp $HEAT_DIR/etc/heat-metadata.conf $HEAT_METADATA_CONF + iniset $HEAT_METADATA_CONF DEFAULT debug True + inicomment $HEAT_METADATA_CONF DEFAULT log_file + iniset $HEAT_METADATA_CONF DEFAULT use_syslog $SYSLOG + iniset $HEAT_METADATA_CONF DEFAULT bind_host $HEAT_METADATA_HOST + iniset $HEAT_METADATA_CONF DEFAULT bind_port $HEAT_METADATA_PORT + + if is_service_enabled rabbit; then + iniset $HEAT_METADATA_CONF DEFAULT rpc_backend heat.openstack.common.rpc.impl_kombu + iniset $HEAT_METADATA_CONF DEFAULT rabbit_password $RABBIT_PASSWORD + iniset $HEAT_METADATA_CONF DEFAULT rabbit_host $RABBIT_HOST + elif is_service_enabled qpid; then + iniset $HEAT_METADATA_CONF DEFAULT rpc_backend heat.openstack.common.rpc.impl_qpid + fi + + HEAT_METADATA_PASTE_INI=$HEAT_CONF_DIR/heat-metadata-paste.ini + cp $HEAT_DIR/etc/heat-metadata-paste.ini $HEAT_METADATA_PASTE_INI + +} + +# init_heat() - Initialize database +function init_heat() { + + # (re)create heat database + mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'DROP DATABASE IF EXISTS heat;' + mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'CREATE DATABASE heat CHARACTER SET utf8;' + + $HEAT_DIR/bin/heat-db-setup $os_PACKAGE -r $MYSQL_PASSWORD +} + +# install_heat() - Collect source and prepare +function install_heat() { + git_clone $HEAT_REPO $HEAT_DIR $HEAT_BRANCH +} + +# start_heat() - Start running processes, including screen +function start_heat() { + screen_it h-eng "cd $HEAT_DIR; bin/heat-engine --config-file=$HEAT_CONF_DIR/heat-engine.conf" + screen_it h-api "cd $HEAT_DIR; bin/heat-api --config-dir=$HEAT_CONF_DIR/heat-api.conf" + screen_it h-meta "cd $HEAT_DIR; bin/heat-metadata --config-dir=$HEAT_CONF_DIR/heat-metadata.conf" +} + +# stop_heat() - Stop running processes (non-screen) +function stop_heat() { + # This function intentionally left blank + : +} diff --git a/stack.sh b/stack.sh index e6576e0391..910c3877fe 100755 --- a/stack.sh +++ b/stack.sh @@ -2,7 +2,7 @@ # ``stack.sh`` is an opinionated OpenStack developer installation. It # installs and configures various combinations of **Glance**, **Horizon**, -# **Keystone**, **Nova**, **Quantum** and **Swift** +# **Keystone**, **Nova**, **Quantum**, **Heat** and **Swift** # This script allows you to specify configuration options of what git # repositories to use, enabled services, network configuration and various @@ -241,6 +241,7 @@ sudo chown `whoami` $DATA_DIR # Get project function libraries source $TOP_DIR/lib/cinder source $TOP_DIR/lib/ceilometer +source $TOP_DIR/lib/heat # Set the destination directories for openstack projects NOVA_DIR=$DEST/nova @@ -787,6 +788,9 @@ if is_service_enabled quantum; then # quantum git_clone $QUANTUM_REPO $QUANTUM_DIR $QUANTUM_BRANCH fi +if is_service_enabled heat; then + install_heat +fi if is_service_enabled cinder; then install_cinder fi @@ -827,6 +831,9 @@ if is_service_enabled quantum; then setup_develop $QUANTUM_CLIENT_DIR setup_develop $QUANTUM_DIR fi +if is_service_enabled heat; then + configure_heat +fi if is_service_enabled cinder; then configure_cinder fi @@ -1945,6 +1952,11 @@ if is_service_enabled mysql && is_service_enabled nova; then $NOVA_BIN_DIR/nova-manage db sync fi +# Heat +# ------ +if is_service_enabled heat; then + init_heat +fi # Launch Services # =============== @@ -2142,6 +2154,10 @@ screen_it swift "cd $SWIFT_DIR && $SWIFT_DIR/bin/swift-proxy-server ${SWIFT_CONF is_service_enabled swift3 || \ screen_it n-obj "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-objectstore" +# launch heat engine, api and metadata +if is_service_enabled heat; then + start_heat +fi # Install Images # ============== diff --git a/stackrc b/stackrc index cd70284d8a..d8d10086e1 100644 --- a/stackrc +++ b/stackrc @@ -95,6 +95,10 @@ QUANTUM_CLIENT_BRANCH=master TEMPEST_REPO=${GIT_BASE}/openstack/tempest.git TEMPEST_BRANCH=master +# heat service +HEAT_REPO=${GIT_BASE}/heat-api/heat.git +HEAT_BRANCH=master + # Nova hypervisor configuration. We default to libvirt with **kvm** but will # drop back to **qemu** if we are unable to load the kvm module. ``stack.sh`` can # also install an **LXC** or **OpenVZ** based system.