Last active
August 29, 2015 14:05
-
-
Save therandomsecurityguy/a0a5e18308df54dbe841 to your computer and use it in GitHub Desktop.
Keystone sample data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# Modified from https://github.com/openstack/keystone/blob/master/tools/sample_data.sh | |
# Copyright 2013 OpenStack Foundation | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); you may | |
# not use this file except in compliance with the License. You may obtain | |
# a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Int and Ext host IP address | |
HOST_IP=controller.putyourowndomainhere.com | |
EXT_HOST_IP=controller.putyourowndomainhere.com | |
# MySQL def | |
MYSQL_USER=keystoneUser | |
MYSQL_DATABASE=keystone | |
MYSQL_HOST=$HOST_IP | |
MYSQL_PASSWORD=keystonePass | |
# Keystone definitions | |
KEYSTONE_REGION=RegionOne | |
export SERVICE_TOKEN=ADMIN | |
export SERVICE_ENDPOINT="http://${HOST_IP}:35357/v2.0" | |
while getopts "u:D:p:m:K:R:E:T:vh" opt; do | |
case $opt in | |
u) | |
MYSQL_USER=$OPTARG | |
;; | |
D) | |
MYSQL_DATABASE=$OPTARG | |
;; | |
p) | |
MYSQL_PASSWORD=$OPTARG | |
;; | |
m) | |
MYSQL_HOST=$OPTARG | |
;; | |
K) | |
MASTER=$OPTARG | |
;; | |
R) | |
KEYSTONE_REGION=$OPTARG | |
;; | |
E) | |
export SERVICE_ENDPOINT=$OPTARG | |
;; | |
T) | |
export SERVICE_TOKEN=$OPTARG | |
;; | |
v) | |
set -x | |
;; | |
h) | |
cat <<EOF | |
Usage: $0 [-m mysql_hostname] [-u mysql_username] [-D mysql_database] [-p mysql_password] | |
[-K keystone_master ] [ -R keystone_region ] [ -E keystone_endpoint_url ] | |
[ -T keystone_token ] | |
Add -v for verbose mode, -h to display this message. | |
EOF | |
exit 0 | |
;; | |
\?) | |
echo "Unknown option -$OPTARG" >&2 | |
exit 1 | |
;; | |
:) | |
echo "Option -$OPTARG requires an argument" >&2 | |
exit 1 | |
;; | |
esac | |
done | |
if [ -z "$KEYSTONE_REGION" ]; then | |
echo "Keystone region not set. Please set with -R option or set KEYSTONE_REGION variable." >&2 | |
missing_args="true" | |
fi | |
if [ -z "$SERVICE_TOKEN" ]; then | |
echo "Keystone service token not set. Please set with -T option or set SERVICE_TOKEN variable." >&2 | |
missing_args="true" | |
fi | |
if [ -z "$SERVICE_ENDPOINT" ]; then | |
echo "Keystone service endpoint not set. Please set with -E option or set SERVICE_ENDPOINT variable." >&2 | |
missing_args="true" | |
fi | |
if [ -z "$MYSQL_PASSWORD" ]; then | |
echo "MySQL password not set. Please set with -p option or set MYSQL_PASSWORD variable." >&2 | |
missing_args="true" | |
fi | |
if [ -n "$missing_args" ]; then | |
exit 1 | |
fi | |
keystone service-create --name nova --type compute --description 'OpenStack Compute Service' | |
keystone service-create --name cinder --type volume --description 'OpenStack Volume Service' | |
keystone service-create --name glance --type image --description 'OpenStack Image Service' | |
keystone service-create --name keystone --type identity --description 'OpenStack Identity Service' | |
keystone service-create --name ec2 --type ec2 --description 'OpenStack EC2 Service' | |
keystone service-create --name neutron --type network --description 'OpenStack Networking Service' | |
keystone service-create --name swift --type object-store --description='OpenStack Storage Service' | |
keystone service-create --name ceilometer --type metering --description='OpenStack Metering Service' | |
keystone service-create --name heat --type orchestration --description 'Heat Orchestration API' | |
keystone service-create --name heat-cfn --type cloudformation --description 'Heat CloudFormation API' | |
create_endpoint () { | |
case $1 in | |
compute) | |
keystone endpoint-create --region $KEYSTONE_REGION --service-id $2 --publicurl 'http://'"$EXT_HOST_IP"':8774/v2/$(tenant_id)s' --adminurl 'http://'"$HOST_IP"':8774/v2/$(tenant_id)s' --internalurl 'http://'"$HOST_IP"':8774/v2/$(tenant_id)s' | |
;; | |
volume) | |
keystone endpoint-create --region $KEYSTONE_REGION --service-id $2 --publicurl 'http://'"$EXT_HOST_IP"':8776/v1/$(tenant_id)s' --adminurl 'http://'"$HOST_IP"':8776/v1/$(tenant_id)s' --internalurl 'http://'"$HOST_IP"':8776/v1/$(tenant_id)s' | |
;; | |
image) | |
keystone endpoint-create --region $KEYSTONE_REGION --service-id $2 --publicurl 'http://'"$EXT_HOST_IP"':9292/v2' --adminurl 'http://'"$HOST_IP"':9292/v2' --internalurl 'http://'"$HOST_IP"':9292/v2' | |
;; | |
identity) | |
keystone endpoint-create --region $KEYSTONE_REGION --service-id $2 --publicurl 'http://'"$EXT_HOST_IP"':5000/v2.0' --adminurl 'http://'"$HOST_IP"':35357/v2.0' --internalurl 'http://'"$HOST_IP"':5000/v2.0' | |
;; | |
ec2) | |
keystone endpoint-create --region $KEYSTONE_REGION --service-id $2 --publicurl 'http://'"$EXT_HOST_IP"':8773/services/Cloud' --adminurl 'http://'"$HOST_IP"':8773/services/Admin' --internalurl 'http://'"$HOST_IP"':8773/services/Cloud' | |
;; | |
network) | |
keystone endpoint-create --region $KEYSTONE_REGION --service-id $2 --publicurl 'http://'"$EXT_HOST_IP"':9696' --adminurl 'http://'"$HOST_IP"':9696' --internalurl 'http://'"$HOST_IP"':9696' | |
;; | |
object-store) | |
keystone endpoint-create --region $KEYSTONE_REGION --service-id $2 --publicurl 'http://'"$EXT_HOST_IP"':8080/v1/AUTH_$(tenant_id)s' --adminurl 'http://'"$HOST_IP"':8080/v1' --internalurl 'http://'"$HOST_IP"':8080/v1/AUTH_$(tenant_id)s' | |
;; | |
metering) | |
keystone endpoint-create --region $KEYSTONE_REGION --service_id $2 --publicurl 'http://'"$EXT_HOST_IP"':8777' --adminurl 'http://'"$HOST_IP"':8777' --internalurl 'http://'"$HOST_IP"':8777' | |
;; | |
orchestration) | |
keystone endpoint-create --region $KEYSTONE_REGION --service-id $2 --publicurl 'http://'"$EXT_HOST_IP"':8004/v1/$(tenant_id)s' --adminurl 'http://'"$HOST_IP"':8004/v1/$(tenant_id)s' --internalurl 'http://'"$HOST_IP"':8004/v1/$(tenant_id)s' | |
;; | |
cloudformation) | |
keystone endpoint-create --region $KEYSTONE_REGION --service-id $2 --publicurl 'http://'"$EXT_HOST_IP"':8000/v1' --adminurl 'http://'"$HOST_IP"':8000/v1' --internalurl 'http://'"$HOST_IP"':8000/v1' | |
esac | |
} | |
for i in compute volume image object-store identity ec2 network object-store metering orchestration cloudformation; do | |
id=`mysql -h "$MYSQL_HOST" -u "$MYSQL_USER" -p"$MYSQL_PASSWORD" "$MYSQL_DATABASE" -ss -e "SELECT id FROM service WHERE type='"$i"';"` || exit 1 | |
create_endpoint $i $id | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment