create scripts for devstack

Change-Id: Ie59b29894031ce033d68705f17edbbdb71a7fbba
This commit is contained in:
Andrey Pavlov 2015-02-04 22:49:27 +03:00
parent 5993031efc
commit 1cfaea6bed
9 changed files with 542 additions and 46 deletions

View File

@ -0,0 +1,20 @@
1. Follow Devstack documentation to setup a host for Devstack. Then clone
Devstack source code.
2. Copy ec2-api integration scripts to Devstack::
$ cp lib/ec2-api ${DEVSTACK_DIR}/lib
$ cp extras.d/70-ec2-api.sh ${DEVSTACK_DIR}/extras.d
3. Create a ``localrc`` file as input to devstack.
4. The ec2-api services are not enabled by default, so they must be
enabled in ``localrc`` before running ``stack.sh``. This example ``localrc``
file shows all of the settings required for ec2-api::
# Enable ec2-api
enable_service ec2-api
5. Deploy your OpenStack Cloud with ec2-api::
$ ./stack.sh

View File

@ -0,0 +1,24 @@
# ec2-api.sh - DevStack extras script to install ec2-api
if is_service_enabled ec2-api; then
if [[ "$1" == "source" ]]; then
# Initial source
source $TOP_DIR/lib/ec2-api
elif [[ "$1" == "stack" && "$2" == "install" ]]; then
echo_summary "Installing ec2-api"
install_ec2api
elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
echo_summary "Configuring ec2-api"
configure_ec2api
create_ec2api_accounts
elif [[ "$1" == "stack" && "$2" == "extra" ]]; then
echo_summary "Initializing ec2-api"
init_ec2api
start_ec2api
fi
if [[ "$1" == "unstack" ]]; then
stop_ec2api
cleanup_ec2api
fi
fi

View File

@ -0,0 +1,246 @@
# lib/ec2-api
# Dependencies:
# ``functions`` file
# ``DEST``, ``DATA_DIR``, ``STACK_USER`` must be defined
# ``stack.sh`` calls the entry points in this order:
#
# install_ec2api
# configure_ec2api
# start_ec2api
# stop_ec2api
# Save trace setting
XTRACE=$(set +o | grep xtrace)
set -o xtrace
# Defaults
# --------
# Set up default repos
EC2API_REPO=${EC2API_REPO:-${GIT_BASE}/stackforge/ec2-api.git}
EC2API_BRANCH=${EC2API_BRANCH:-master}
# Set up default directories
EC2API_DIR=$DEST/ec2-api
EC2API_CONF_DIR=${EC2API_CONF_DIR:-/etc/ec2api}
EC2API_CONF_FILE=${EC2API_CONF_DIR}/ec2api.conf
EC2API_DEBUG=${EC2API_DEBUG:-True}
EC2API_SERVICE_HOST=${EC2API_SERVICE_HOST:-$SERVICE_HOST}
EC2API_SERVICE_PORT=${EC2API_SERVICE_PORT:-8788}
EC2API_SERVICE_PROTOCOL=${EC2API_SERVICE_PROTOCOL:-$SERVICE_PROTOCOL}
EC2API_RABBIT_VHOST=${EC2API_RABBIT_VHOST:-''}
EC2API_ADMIN_USER=${EC2API_ADMIN_USER:-ec2api}
EC2API_KEYSTONE_SIGNING_DIR=${EC2API_KEYSTONE_SIGNING_DIR:-/tmp/keystone-signing-ec2api}
# Support entry points installation of console scripts
if [[ -d $EC2API_DIR/bin ]]; then
EC2API_BIN_DIR=$EC2API_DIR/bin
else
EC2API_BIN_DIR=$(get_python_exec_prefix)
fi
# create_ec2api_accounts() - Set up common required ec2api accounts
#
# Tenant User Roles
# ------------------------------
# service ec2api admin
function create_ec2api_accounts() {
if ! is_service_enabled key; then
return
fi
SERVICE_TENANT=$(openstack project list | awk "/ $SERVICE_TENANT_NAME / { print \$2 }")
ADMIN_ROLE=$(openstack role list | awk "/ admin / { print \$2 }")
EC2API_USER=$(openstack user create \
$EC2API_ADMIN_USER \
--password "$SERVICE_PASSWORD" \
--project $SERVICE_TENANT \
--email ec2api@example.com \
| grep " id " | get_field 2)
openstack role add \
$ADMIN_ROLE \
--project $SERVICE_TENANT \
--user $EC2API_USER
if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
# Remove nova's ec2 service/endpoint
local endpoint_id=$(openstack endpoint list \
--column "ID" \
--column "Region" \
--column "Service Name" \
| grep " $REGION_NAME " \
| grep " ec2 " | get_field 1)
if [[ -n "$endpoint_id" ]]; then
openstack endpoint delete $endpoint_id
fi
local service_id=$(openstack service list \
-c "ID" -c "Name" \
| grep " ec2 " | get_field 1)
if [[ -n "$service_id" ]]; then
openstack service delete $service_id
fi
EC2API_SERVICE=$(openstack service create \
ec2 \
--type "ec2" \
--description="EC2 Compatibility Layer" \
-f value -c id)
openstack endpoint create \
$EC2API_SERVICE \
--region "$REGION_NAME" \
--publicurl "$EC2API_SERVICE_PROTOCOL://$EC2API_SERVICE_HOST:$EC2API_SERVICE_PORT/" \
--adminurl "$EC2API_SERVICE_PROTOCOL://$EC2API_SERVICE_HOST:$EC2API_SERVICE_PORT/" \
--internalurl "$EC2API_SERVICE_PROTOCOL://$EC2API_SERVICE_HOST:$EC2API_SERVICE_PORT/"
fi
}
function mkdir_chown_stack {
if [[ ! -d "$1" ]]; then
sudo mkdir -p "$1"
fi
sudo chown $STACK_USER "$1"
}
function configure_ec2api_rpc_backend() {
# Configure the rpc service.
iniset_rpc_backend ec2api $EC2API_CONF_FILE DEFAULT
# TODO(ruhe): get rid of this ugly workaround.
inicomment $EC2API_CONF_FILE DEFAULT rpc_backend
# Set non-default rabbit virtual host if required.
if [[ -n "$EC2API_RABBIT_VHOST" ]]; then
iniset $EC2API_CONF_FILE DEFAULT rabbit_virtual_host $EC2API_RABBIT_VHOST
fi
}
function configure_ec2api_networking {
# Use keyword 'public' if ec2api external network was not set.
# If it was set but the network is not exist then
# first available external network will be selected.
local ext_net=${EC2API_EXTERNAL_NETWORK:-'public'}
# Configure networking options for ec2api
if [[ -n "$ext_net" ]]; then
iniset $EC2API_CONF_FILE DEFAULT external_network $ext_net
fi
if [[ ,${ENABLED_SERVICES} =~ ,"q-" ]]; then
iniset $EC2API_CONF_FILE DEFAULT full_vpc_support True
else
iniset $EC2API_CONF_FILE DEFAULT full_vpc_support False
fi
}
# Entry points
# ------------
# configure_ec2api() - Set config files, create data dirs, etc
function configure_ec2api {
mkdir_chown_stack "$EC2API_CONF_DIR"
# Generate ec2api configuration file and configure common parameters.
oslo-config-generator --namespace keystonemiddleware.auth_token \
--namespace ec2api \
--namespace oslo.db \
--namespace oslo.messaging \
> $EC2API_CONF_FILE
cp $EC2API_DIR/etc/ec2api/api-paste.ini $EC2API_CONF_DIR
cleanup_ec2api
iniset $EC2API_CONF_FILE DEFAULT debug $EC2API_DEBUG
iniset $EC2API_CONF_FILE DEFAULT use_syslog $SYSLOG
# ec2api Api Configuration
#-------------------------
# Setup keystone_authtoken section
iniset $EC2API_CONF_FILE keystone_authtoken auth_uri "http://${KEYSTONE_AUTH_HOST}:5000/v2.0"
iniset $EC2API_CONF_FILE keystone_authtoken auth_host $KEYSTONE_AUTH_HOST
iniset $EC2API_CONF_FILE keystone_authtoken auth_port $KEYSTONE_AUTH_PORT
iniset $EC2API_CONF_FILE keystone_authtoken auth_protocol $KEYSTONE_AUTH_PROTOCOL
iniset $EC2API_CONF_FILE keystone_authtoken cafile $KEYSTONE_SSL_CA
iniset $EC2API_CONF_FILE keystone_authtoken admin_tenant_name $SERVICE_TENANT_NAME
iniset $EC2API_CONF_FILE keystone_authtoken admin_user $EC2API_ADMIN_USER
iniset $EC2API_CONF_FILE keystone_authtoken admin_password $SERVICE_PASSWORD
iniset $EC2API_CONF_FILE keystone_authtoken signing_dir $EC2API_KEYSTONE_SIGNING_DIR
iniset $EC2API_CONF_FILE metadata admin_tenant_name $SERVICE_TENANT_NAME
iniset $EC2API_CONF_FILE metadata admin_user $EC2API_ADMIN_USER
iniset $EC2API_CONF_FILE metadata admin_password $SERVICE_PASSWORD
iniset $EC2API_CONF_FILE DEFAULT keystone_url "http://${KEYSTONE_AUTH_HOST}:35357/v2.0"
iniset $EC2API_CONF_FILE DEFAULT region_list "$REGION_NAME"
iniset $EC2API_CONF_FILE DEFAULT s3_port "$S3_SERVICE_PORT"
iniset $EC2API_CONF_FILE DEFAULT s3_host "$SERVICE_HOST"
configure_ec2api_rpc_backend
# configure the database.
iniset $EC2API_CONF_FILE database connection `database_connection_url ec2api`
iniset $EC2API_CONF_FILE database connection_nova `database_connection_url nova`
configure_ec2api_networking
}
# init_ec2api() - Initialize databases, etc.
function init_ec2api() {
# (re)create ec2api database
recreate_database ec2api utf8
$EC2API_BIN_DIR/ec2-api-manage --config-file $EC2API_CONF_FILE db_sync
}
# install_ec2api() - Collect source and prepare
function install_ec2api() {
git_clone $EC2API_REPO $EC2API_DIR $EC2API_BRANCH
# TODO(ruhe): use setup_develop once ec2api requirements match with global-requirement.txt
# both functions (setup_develop and setup_package) are defined at:
# http://git.openstack.org/cgit/openstack-dev/devstack/tree/functions-common
setup_package $EC2API_DIR -e
}
# start_ec2api() - Start running processes, including screen
function start_ec2api() {
screen_it ec2-api "cd $EC2API_DIR && $EC2API_BIN_DIR/ec2-api --config-file $EC2API_CONF_DIR/ec2api.conf"
}
# stop_ec2api() - Stop running processes
function stop_ec2api() {
# Kill the ec2api screen windows
screen -S $SCREEN_NAME -p ec2-api -X kill
}
function cleanup_ec2api() {
# Cleanup keystone signing dir
sudo rm -rf $EC2API_KEYSTONE_SIGNING_DIR
}
# Restore xtrace
$XTRACE
# Local variables:
# mode: shell-script
# End:

View File

@ -28,10 +28,10 @@ from ec2api.openstack.common import log as logging
LOG = logging.getLogger(__name__)
ec2_opts = [
cfg.StrOpt('network_device_mtu',
cfg.IntOpt('network_device_mtu',
default=1500,
help='MTU size to set by DHCP for instances. Corresponds '
'with the network_device_mtu in nova.conf.')
'with the network_device_mtu in ec2api.conf.')
]
CONF = cfg.CONF

View File

@ -4,20 +4,16 @@
# Options defined in oslo.messaging
#
# Use durable queues in amqp. (boolean value)
# Use durable queues in AMQP. (boolean value)
# Deprecated group/name - [DEFAULT]/rabbit_durable_queues
#amqp_durable_queues=false
# Auto-delete queues in amqp. (boolean value)
# Auto-delete queues in AMQP. (boolean value)
#amqp_auto_delete=false
# Size of RPC connection pool. (integer value)
#rpc_conn_pool_size=30
# Modules of exceptions that are permitted to be recreated
# upon receiving exception data from an rpc call. (list value)
#allowed_rpc_exception_modules=oslo.messaging.exceptions,nova.exception,cinder.exception,exceptions
# Qpid broker hostname. (string value)
#qpid_hostname=nova
@ -47,6 +43,10 @@
# Whether to disable the Nagle algorithm. (boolean value)
#qpid_tcp_nodelay=true
# The number of prefetched messages held by receiver. (integer
# value)
#qpid_receiver_capacity=1
# The qpid topology version to use. Version 1 is what was
# originally used by impl_qpid. Version 2 includes some
# backwards-incompatible changes that allow broker federation
@ -56,8 +56,8 @@
#qpid_topology_version=1
# SSL version to use (valid only if SSL enabled). valid values
# are TLSv1, SSLv23 and SSLv3. SSLv2 may be available on some
# distributions. (string value)
# are TLSv1 and SSLv23. SSLv2 and SSLv3 may be available on
# some distributions. (string value)
#kombu_ssl_version=
# SSL key file (valid only if SSL enabled). (string value)
@ -94,7 +94,7 @@
# The RabbitMQ password. (string value)
#rabbit_password=guest
# the RabbitMQ login method (string value)
# The RabbitMQ login method. (string value)
#rabbit_login_method=AMQPLAIN
# The RabbitMQ virtual host. (string value)
@ -117,7 +117,8 @@
# value)
#rabbit_ha_queues=false
# If passed, use a fake RabbitMQ provider. (boolean value)
# Deprecated, use rpc_backend=kombu+memory or rpc_backend=fake
# (boolean value)
#fake_rabbit=false
# ZeroMQ bind address. Should be a wildcard (*), an ethernet
@ -156,15 +157,6 @@
# Heartbeat time-to-live. (integer value)
#matchmaker_heartbeat_ttl=600
# Host to locate redis. (string value)
#host=127.0.0.1
# Use this port to connect to redis host. (integer value)
#port=6379
# Password for Redis server (optional). (string value)
#password=<None>
# Size of RPC greenthread pool. (integer value)
#rpc_thread_pool_size=64
@ -208,7 +200,7 @@
# Directory where the ec2api python module is installed
# (string value)
#pybasedir=/home/apavlov/progmatic/ec2-api
#pybasedir=/home/apavlov/stackforge/ec2-api
# Directory where ec2api binaries are installed (string value)
#bindir=/usr/local/bin
@ -222,9 +214,6 @@
# Options defined in ec2api.service
#
# Enable ssl connections or not (boolean value)
#use_ssl=false
# The IP address on which the EC2 API will listen. (string
# value)
#ec2api_listen=0.0.0.0
@ -232,10 +221,29 @@
# The port on which the EC2 API will listen. (integer value)
#ec2api_listen_port=8788
# Enable ssl connections or not for EC2 API (boolean value)
#ec2api_use_ssl=false
# Number of workers for EC2 API service. The default will be
# equal to the number of CPUs available. (integer value)
#ec2api_workers=<None>
# The IP address on which the metadata API will listen.
# (string value)
#metadata_listen=0.0.0.0
# The port on which the metadata API will listen. (integer
# value)
#metadata_listen_port=8789
# Enable ssl connections or not for EC2 API Metadata (boolean
# value)
#metadata_use_ssl=false
# Number of workers for metadata service. The default will be
# the number of CPUs available. (integer value)
#metadata_workers=<None>
# Maximum time since last check-in for up service (integer
# value)
#service_down_time=60
@ -293,23 +301,12 @@
# Options defined in ec2api.api
#
# The IP address of the EC2 API server (string value)
#base_ec2_host=nova
# The port of the EC2 API server (integer value)
#base_ec2_port=8773
# The protocol to use when connecting to the EC2 API server
# (http, https) (string value)
#base_ec2_scheme=http
# The path prefix used to call the ec2 API server (string
# value)
#base_ec2_path=/services/Cloud
# URL to get token from ec2 request. (string value)
#keystone_url=http://localhost:5000/v2.0
# URL to get token from ec2 request. (string value)
#keystone_ec2_tokens_url=$keystone_url/ec2tokens
# Time in seconds before ec2 timestamp expires (integer value)
#ec2_timestamp_expiry=300
@ -327,6 +324,97 @@
#use_forwarded_for=false
#
# Options defined in ec2api.api.availability_zone
#
# The availability_zone to show internal services under
# (string value)
#internal_service_availability_zone=internal
# IP address of this host (string value)
#my_ip=10.0.0.1
# The IP address of the EC2 API server (string value)
#ec2_host=$my_ip
# The port of the EC2 API server (integer value)
#ec2_port=8788
# The protocol to use when connecting to the EC2 API server
# (http, https) (string value)
#ec2_scheme=http
# The path prefix used to call the ec2 API server (string
# value)
#ec2_path=/
# List of region=fqdn pairs separated by commas (list value)
#region_list=
#
# Options defined in ec2api.api.common
#
# True if server supports Neutron for full VPC access (boolean
# value)
#full_vpc_support=true
#
# Options defined in ec2api.api.dhcp_options
#
# MTU size to set by DHCP for instances. Corresponds with the
# network_device_mtu in ec2api.conf. (integer value)
#network_device_mtu=1500
#
# Options defined in ec2api.api.image
#
# The topic cert nodes listen on (string value)
#cert_topic=cert
# Parent directory for tempdir used for image decryption
# (string value)
#image_decryption_dir=/tmp
# Hostname or IP for OpenStack to use when accessing the S3
# api (string value)
#s3_host=$my_ip
# Port used when accessing the S3 api (integer value)
#s3_port=3333
# Whether to use SSL when talking to S3 (boolean value)
#s3_use_ssl=false
# Whether to affix the tenant id to the access key when
# downloading from S3 (boolean value)
#s3_affix_tenant=false
#
# Options defined in ec2api.api.instance
#
# Return the IP address as private dns hostname in describe
# instances (boolean value)
#ec2_private_dns_show_ip=false
#
# Options defined in ec2api.api.internet_gateway
#
# Name of the external network, which is used to connectVPCs
# to Internet and to allocate Elastic IPs (string value)
#external_network=<None>
#
# Options defined in ec2api.openstack.common.eventlet_backdoor
#
@ -374,7 +462,7 @@
#logging_exception_prefix=%(asctime)s.%(msecs)03d %(process)d TRACE %(name)s %(instance)s
# List of logger=LEVEL pairs. (list value)
#default_log_levels=amqp=WARN,amqplib=WARN,boto=WARN,qpid=WARN,sqlalchemy=WARN,suds=INFO,oslo.messaging=INFO,iso8601=WARN,requests.packages.urllib3.connectionpool=WARN
#default_log_levels=amqp=WARN,amqplib=WARN,boto=WARN,qpid=WARN,sqlalchemy=WARN,suds=INFO,oslo.messaging=INFO,iso8601=WARN,requests.packages.urllib3.connectionpool=WARN,urllib3.connectionpool=WARN,websocket=WARN
# Enables or disables publication of error events. (boolean
# value)
@ -385,11 +473,11 @@
#fatal_deprecations=false
# The format for an instance that is passed with the log
# message. (string value)
# message. (string value)
#instance_format="[instance: %(uuid)s] "
# The format for an instance UUID that is passed with the log
# message. (string value)
# message. (string value)
#instance_uuid_format="[instance: %(uuid)s] "
# The name of a logging configuration file. This file is
@ -421,7 +509,7 @@
#log_dir=<None>
# Use syslog for logging. Existing syslog format is DEPRECATED
# during I, and will chang in J to honor RFC5424. (boolean
# during I, and will change in J to honor RFC5424. (boolean
# value)
#use_syslog=false
@ -703,6 +791,34 @@
# Keystone server. (boolean value)
#check_revocations_for_cached=false
# Hash algorithms to use for hashing PKI tokens. This may be a
# single algorithm or multiple. The algorithms are those
# supported by Python standard hashlib.new(). The hashes will
# be tried in the order given, so put the preferred one first
# for performance. The result of the first hash will be stored
# in the cache. This will typically be set to multiple values
# only while migrating from a less secure algorithm to a more
# secure one. Once all the old tokens are expired this option
# should be set to a single value for better performance.
# (list value)
#hash_algorithms=md5
[matchmaker_redis]
#
# Options defined in oslo.messaging
#
# Host to locate redis. (string value)
#host=127.0.0.1
# Use this port to connect to redis host. (integer value)
#port=6379
# Password for Redis server (optional). (string value)
#password=<None>
[matchmaker_ring]
@ -715,3 +831,95 @@
#ringfile=/etc/oslo/matchmaker_ring.json
[metadata]
#
# Options defined in ec2api.metadata
#
# IP address used by Nova metadata server. (string value)
#nova_metadata_ip=127.0.0.1
# TCP Port used by Nova metadata server. (integer value)
#nova_metadata_port=8775
# Protocol to access nova metadata, http or https (string
# value)
#nova_metadata_protocol=http
# Allow to perform insecure SSL (https) requests to nova
# metadata (boolean value)
#nova_metadata_insecure=false
# Certificate Authority public key (CA cert) file for ssl
# (string value)
#auth_ca_cert=<None>
# Client certificate for nova metadata api server. (string
# value)
#nova_client_cert=
# Private key of client certificate. (string value)
#nova_client_priv_key=
# Admin user (string value)
#admin_user=<None>
# Admin password (string value)
#admin_password=<None>
# Admin tenant name (string value)
#admin_tenant_name=<None>
# Shared secret to sign instance-id request (string value)
#metadata_proxy_shared_secret=
[oslo_messaging_amqp]
#
# Options defined in oslo.messaging
#
# address prefix used when sending to a specific server
# (string value)
#server_request_prefix=exclusive
# address prefix used when broadcasting to all servers (string
# value)
#broadcast_prefix=broadcast
# address prefix when sending to any server in group (string
# value)
#group_request_prefix=unicast
# Name for the AMQP container (string value)
#container_name=<None>
# Timeout for inactive connections (in seconds) (integer
# value)
#idle_timeout=0
# Debug: dump AMQP frames to stdout (boolean value)
#trace=false
# CA certificate PEM file for verifing server certificate
# (string value)
#ssl_ca_file=
# Identifying certificate PEM file to present to clients
# (string value)
#ssl_cert_file=
# Private key PEM file used to sign cert_file certificate
# (string value)
#ssl_key_file=
# Password for decrypting ssl_key_file (if encrypted) (string
# value)
#ssl_key_password=<None>
# Accept clients using either SSL or plain TCP (boolean value)
#allow_insecure_clients=false

View File

@ -324,4 +324,4 @@ sudo rm -rf build ec2_api.egg-info
#recreate database
echo Setuping database
sudo bin/ec2api-db-setup deb
sudo tools/db/ec2api-db-setup deb

View File

@ -21,8 +21,6 @@ classifier =
[files]
packages =
ec2api
scripts =
bin/ec2api-db-setup
[global]
setup-hooks =