Created
May 5, 2015 02:01
-
-
Save ishikawa84g/cce63b0bd643714db7ac to your computer and use it in GitHub Desktop.
keystone_data.sh kilo用
This file contains hidden or 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
#!/bin/bash | |
# ----------- | |
# Defaults | |
# ----------- | |
SERVICE_PROJECT=service | |
ADMIN_PROJECT=admin | |
DEMO_PROJECT=demo | |
ADMIN_ROLE=admin | |
MEMBER_ROLE=_member_ | |
HEAT_STACK_OWNER_ROLE=heat_stack_owner | |
HEAT_STACK_USER_ROLE=heat_stack_user | |
# SERVIVCE PASSWORD | |
ADMIN_PASSWORD=Stackers0 | |
DEMO_PASSWORD=Stackers0 | |
NOVA_PASSWORD=Stackers0 | |
GLANCE_PASSWORD=Stackers0 | |
CINDER_PASSWORD=Stackers0 | |
NEUTRON_PASSWORD=Stackers0 | |
HEAT_PASSWORD=Stackers0 | |
CEILOMETER_PASSWORD=Stackers0 | |
# SERVICE USER | |
ADMIN_USER=admin | |
DEMO_USER=demo | |
NOVA_USER=nova | |
GLANCE_USER=glance | |
CINDER_USER=cinder | |
NEUTRON_USER=neutron | |
HEAT_USER=heat | |
CEILOMETER_USER=ceilometer | |
# E-MAIL ADDRESS | |
[email protected] | |
[email protected] | |
[email protected] | |
[email protected] | |
[email protected] | |
[email protected] | |
[email protected] | |
[email protected] | |
# SERVICE PROTOCOL | |
NOVA_PUBLIC_SERVICE_PROTOCOL=http | |
NOVA_ADMIN_SERVICE_PROTOCOL=http | |
NOVA_INTERNAL_SERVICE_PROTOCOL=http | |
EC2_PUBLIC_SERVICE_PROTOCOL=http | |
EC2_ADMIN_SERVICE_PROTOCOL=http | |
EC2_INTERNAL_SERVICE_PROTOCOL=http | |
GLANCE_PUBLIC_SERVICE_PROTOCOL=http | |
GLANCE_ADMIN_SERVICE_PROTOCOL=http | |
GLANCE_INTERNAL_SERVICE_PROTOCOL=http | |
KEYSTONE_PUBLIC_SERVICE_PROTOCOL=http | |
KEYSTONE_ADMIN_SERVICE_PROTOCOL=http | |
KEYSTONE_INTERNAL_SERVICE_PROTOCOL=http | |
CINDER_PUBLIC_SERVICE_PROTOCOL=http | |
CINDER_ADMIN_SERVICE_PROTOCOL=http | |
CINDER_INTERNAL_SERVICE_PROTOCOL=http | |
NEUTRON_PUBLIC_SERVICE_PROTOCOL=http | |
NEUTRON_ADMIN_SERVICE_PROTOCOL=http | |
NEUTRON_INTERNAL_SERVICE_PROTOCOL=http | |
HEAT_PUBLIC_SERVICE_PROTOCOL=http | |
HEAT_ADMIN_SERVICE_PROTOCOL=http | |
HEAT_INTERNAL_SERVICE_PROTOCOL=http | |
HEAT_CFN_PUBLIC_SERVICE_PROTOCOL=http | |
HEAT_CFN_ADMIN_SERVICE_PROTOCOL=http | |
HEAT_CFN_INTERNAL_SERVICE_PROTOCOL=http | |
CEILOMETER_PUBLIC_SERVICE_PROTOCOL=http | |
CEILOMETER_ADMIN_SERVICE_PROTOCOL=http | |
CEILOMETER_INTERNAL_SERVICE_PROTOCOL=http | |
# SERVICE PORT | |
NOVA_COMPUTE_PORT=8774 | |
EC2_PORT=8773 | |
GLANCE_API_PORT=9292 | |
KEYSTONE_PUBLIC_PORT=5000 | |
KEYSTONE_ADMIN_PORT=35357 | |
CINDER_PORT=8776 | |
NEUTRON_PORT=9696 | |
HEAT_PORT=8004 | |
HEAT_CFN_PORT=8004 | |
CEILOMETER_PORT=8777 | |
# IDENTITY | |
IDENTITY_API_VERSION=3 | |
REGION=regionOne | |
# SERVICE HOST ADDRESS | |
NOVA_PUBLIC_SERVICE_HOST=192.168.56.121 | |
NOVA_ADMIN_SERVICE_HOST=192.168.5.121 | |
NOVA_INTERNAL_SERVICE_HOST=192.168.5.121 | |
EC2_PUBLIC_SERVICE_HOST=192.168.56.121 | |
EC2_ADMIN_SERVICE_HOST=192.168.5.121 | |
EC2_INTERNAL_SERVICE_HOST=192.168.5.121 | |
GLANCE_PUBLIC_SERVICE_HOST=192.168.56.121 | |
GLANCE_ADMIN_SERVICE_HOST=192.168.5.121 | |
GLANCE_INTERNAL_SERVICE_HOST=192.168.5.121 | |
KEYSTONE_PUBLIC_SERVICE_HOST=192.168.56.121 | |
KEYSTONE_ADMIN_SERVICE_HOST=192.168.5.121 | |
KEYSTONE_INTERNAL_SERVICE_HOST=192.168.5.121 | |
CINDER_PUBLIC_SERVICE_HOST=192.168.56.121 | |
CINDER_ADMIN_SERVICE_HOST=192.168.5.121 | |
CINDER_INTERNAL_SERVICE_HOST=192.168.5.121 | |
NEUTRON_PUBLIC_SERVICE_HOST=192.168.56.121 | |
NEUTRON_ADMIN_SERVICE_HOST=192.168.5.121 | |
NEUTRON_INTERNAL_SERVICE_HOST=192.168.5.121 | |
HEAT_PUBLIC_SERVICE_HOST=192.168.56.121 | |
HEAT_ADMIN_SERVICE_HOST=192.168.5.121 | |
HEAT_INTERNAL_SERVICE_HOST=192.168.5.121 | |
HEAT_CFN_PUBLIC_SERVICE_HOST=192.168.56.121 | |
HEAT_CFN_ADMIN_SERVICE_HOST=192.168.5.121 | |
HEAT_CFN_INTERNAL_SERVICE_HOST=192.168.5.121 | |
CEILOMETER_PUBLIC_SERVICE_HOST=192.168.56.121 | |
CEILOMETER_ADMIN_SERVICE_HOST=192.168.5.121 | |
CEILOMETER_INTERNAL_SERVICE_HOST=192.168.5.121 | |
export OS_TOKEN=999888777666 | |
export OS_URL=http://192.168.5.121:35357/v2.0 | |
# OR openstack --os-token $OS_TOKEN --os-url $OS_URL | |
# -------------------------------------- | |
# Functions | |
# -------------------------------------- | |
function get_field { | |
while read data; do | |
if [ "$1" -lt 0 ]; then | |
field="(\$(NF$1))" | |
else | |
field="\$$(($1 + 1))" | |
fi | |
echo "$data" | awk -F'[ \t]*\\|[ \t]*' "{print $field}" | |
done | |
} | |
function create_role { | |
if [ "$#" -eq 1 ]; then | |
openstack role create $1 | |
else | |
echo "Usage: create_role role" | |
exit 1 | |
fi | |
} | |
function create_user { | |
if [ "$#" -eq 4 ]; then | |
openstack user create --project $1 --email $4 --password $3 $2 | |
else | |
echo "Usage: create_user project user password email" | |
exit 1 | |
fi | |
} | |
function create_project { | |
if [ "$#" -eq 1 ]; then | |
openstack project create $1 | |
else | |
echo "Usage: create_project project" | |
exit 1 | |
fi | |
} | |
function add_project_user_role { | |
if [ "$#" -eq 3 ]; then | |
openstack role add --project $1 --user $2 $3 | |
else | |
echo "Usage: add_project_user_role project user role" | |
exit 1 | |
fi | |
} | |
function create_service { | |
if [ "$#" -eq 3 ]; then | |
openstack service create --name $1 --description "$3" $2 | |
else | |
echo "Usage: create_service service type description" | |
exit 1 | |
fi | |
} | |
function create_endpoint { | |
if [ "$#" -eq 5 ]; then | |
openstack endpoint create \ | |
--region $1 \ | |
--publicurl $3 \ | |
--adminurl $4 \ | |
--internalurl $5 \ | |
$2 | |
else | |
echo "Usage: create_endpoint region service publicurl adminurl internalurl" | |
exit 1 | |
fi | |
} | |
# -------------------------------------- | |
# Roles | |
# -------------------------------------- | |
create_role $ADMIN_ROLE | |
create_role $HEAT_STACK_OWNER_ROLE | |
create_role $HEAT_STACK_USER_ROLE | |
#openstack role create $MEMBER_ROLE | |
# -------------------------------------- | |
# Projects | |
# -------------------------------------- | |
create_project $ADMIN_PROJECT | |
create_project $DEMO_PROJECT | |
create_project $SERVICE_PROJECT | |
# -------------------------------------- | |
# Users | |
# -------------------------------------- | |
create_user $ADMIN_PROJECT $ADMIN_USER $ADMIN_PASSWORD $ADMIN_EMAIL | |
create_user $DEMO_PROJECT $DEMO_USER $DEMO_PASSWORD $DEMO_EMAIL | |
# -------------------------------------- | |
# Service Users | |
# -------------------------------------- | |
create_user $SERVICE_PROJECT $NOVA_USER $NOVA_PASSWORD $NOVA_EMAIL | |
create_user $SERVICE_PROJECT $GLANCE_USER $GLANCE_PASSWORD $GLANCE_EMAIL | |
create_user $SERVICE_PROJECT $CINDER_USER $CINDER_PASSWORD $CINDER_EMAIL | |
create_user $SERVICE_PROJECT $NEUTRON_USER $NEUTRON_PASSWORD $NEUTRON_EMAIL | |
create_user $SERVICE_PROJECT $HEAT_USER $HEAT_PASSWORD $HEAT_EMAIL | |
create_user $SERVICE_PROJECT $CEILOMETER_USER $CEILOMETER_PASSWORD $CEILOMETER_EMAIL | |
# -------------------------------------- | |
# Role add | |
# -------------------------------------- | |
add_project_user_role $ADMIN_PROJECT $ADMIN_USER $ADMIN_ROLE | |
add_project_user_role $DEMO_PROJECT $ADMIN_USER $ADMIN_ROLE | |
add_project_user_role $SERVICE_PROJECT $NOVA_USER $ADMIN_ROLE | |
add_project_user_role $SERVICE_PROJECT $GLANCE_USER $ADMIN_ROLE | |
add_project_user_role $SERVICE_PROJECT $CINDER_USER $ADMIN_ROLE | |
add_project_user_role $SERVICE_PROJECT $NEUTRON_USER $ADMIN_ROLE | |
add_project_user_role $SERVICE_PROJECT $HEAT_USER $ADMIN_ROLE | |
add_project_user_role $SERVICE_PROJECT $CEILOMETER_USER $ADMIN_ROLE | |
add_project_user_role $DEMO_PROJECT $DEMO_USER $HEAT_STACK_OWNER_ROLE | |
# -------------------------------------- | |
# Service | |
# -------------------------------------- | |
create_service nova compute "Nova Compute Service" | |
create_service nova21 compute21 "Nova Compute Service V2.1" | |
create_service ec2 ec2 "EC2 Compatibility Layer" | |
create_service glance image "Glance Image Service" | |
create_service keystone identity "Keystone Identity Service" | |
create_service cinder volume "Cinder Volume Service" | |
create_service cinderv2 volumev2 "Cinder Volume Service V2" | |
create_service neutron network "Neutron Service" | |
create_service heat orchestration "Orchestration" | |
create_service heat-cfn cloudformation "Orchestration" | |
create_service ceilometer metering "OpenStack Telemetry Service" | |
# -------------------------------------- | |
# Endpoint | |
# -------------------------------------- | |
# Nova | |
create_endpoint $REGION nova \ | |
"${NOVA_PUBLIC_SERVICE_PROTOCOL}://${NOVA_PUBLIC_SERVICE_HOST}:${NOVA_COMPUTE_PORT}/v2/\$(tenant_id)s" \ | |
"${NOVA_ADMIN_SERVICE_PROTOCOL}://${NOVA_ADMIN_SERVICE_HOST}:${NOVA_COMPUTE_PORT}/v2/\$(tenant_id)s" \ | |
"${NOVA_INTERNAL_SERVICE_PROTOCOL}://${NOVA_INTERNAL_SERVICE_HOST}:${NOVA_COMPUTE_PORT}/v2/\$(tenant_id)s" | |
create_endpoint $REGION nova21 \ | |
"${NOVA_PUBLIC_SERVICE_PROTOCOL}://${NOVA_PUBLIC_SERVICE_HOST}:${NOVA_COMPUTE_PORT}/v2.1/\$(tenant_id)s" \ | |
"${NOVA_ADMIN_SERVICE_PROTOCOL}://${NOVA_ADMIN_SERVICE_HOST}:${NOVA_COMPUTE_PORT}/v2.1/\$(tenant_id)s" \ | |
"${NOVA_INTERNAL_SERVICE_PROTOCOL}://${NOVA_INTERNAL_SERVICE_HOST}:${NOVA_COMPUTE_PORT}/v2.1/\$(tenant_id)s" | |
# EC2 | |
create_endpoint $REGION ec2 \ | |
"${EC2_PUBLIC_SERVICE_PROTOCOL}://${EC2_PUBLIC_SERVICE_HOST}:${EC2_PORT}" \ | |
"${EC2_INTERNAL_SERVICE_PROTOCOL}://${EC2_ADMIN_SERVICE_HOST}:${EC2_PORT}" \ | |
"${EC2_ADMIN_SERVICE_PROTOCOL}://${EC2_INTERNAL_SERVICE_HOST}:${EC2_PORT}" | |
# Glance | |
create_endpoint $REGION glance \ | |
"${GLANCE_PUBLIC_SERVICE_PROTOCOL}://${GLANCE_PUBLIC_SERVICE_HOST}:${GLANCE_API_PORT}" \ | |
"${GLANCE_ADMIN_SERVICE_PROTOCOL}://${GLANCE_INTERNAL_SERVICE_HOST}:${GLANCE_API_PORT}" \ | |
"${GLANCE_INTERNAL_SERVICE_PROTOCOL}://${GLANCE_ADMIN_SERVICE_HOST}:${GLANCE_API_PORT}" | |
# Keystone | |
create_endpoint $REGION keystone \ | |
"${KEYSTONE_PUBLIC_SERVICE_PROTOCOL}://${KEYSTONE_PUBLIC_SERVICE_HOST}:${KEYSTONE_PUBLIC_PORT}/v${IDENTITY_API_VERSION}" \ | |
"${KEYSTONE_ADMIN_SERVICE_PROTOCOL}://${KEYSTONE_INTERNAL_SERVICE_HOST}:${KEYSTONE_ADMIN_PORT}/v${IDENTITY_API_VERSION}" \ | |
"${KEYSTONE_INTERNAL_SERVICE_PROTOCOL}://${KEYSTONE_ADMIN_SERVICE_HOST}:${KEYSTONE_PUBLIC_PORT}/v${IDENTITY_API_VERSION}" | |
# Cinder | |
create_endpoint $REGION cinder \ | |
"${CINDER_PUBLIC_SERVICE_PROTOCOL}://${CINDER_PUBLIC_SERVICE_HOST}:${CINDER_PORT}/v1/\$(tenant_id)s" \ | |
"${CINDER_ADMIN_SERVICE_PROTOCOL}://${CINDER_ADMIN_SERVICE_HOST}:${CINDER_PORT}/v1/\$(tenant_id)s" \ | |
"${CINDER_INTERNAL_SERVICE_PROTOCOL}://${CINDER_INTERNAL_SERVICE_HOST}:${CINDER_PORT}/v1/\$(tenant_id)s" | |
create_endpoint $REGION cinderv2 \ | |
"${CINDER_PUBLIC_SERVICE_PROTOCOL}://${CINDER_PUBLIC_SERVICE_HOST}:${CINDER_PORT}/v2/\$(tenant_id)s" \ | |
"${CINDER_ADMIN_SERVICE_PROTOCOL}://${CINDER_ADMIN_SERVICE_HOST}:${CINDER_PORT}/v2/\$(tenant_id)s" \ | |
"${CINDER_INTERNAL_SERVICE_PROTOCOL}://${CINDER_INTERNAL_SERVICE_HOST}:${CINDER_PORT}/v2/\$(tenant_id)s" | |
# Neutron | |
create_endpoint $REGION neutron \ | |
"${NEUTRON_PUBLIC_SERVICE_PROTOCOL}://${NEUTRON_PUBLIC_SERVICE_HOST}:${NEUTRON_PORT}" \ | |
"${NEUTRON_ADMIN_SERVICE_PROTOCOL}://${NEUTRON_INTERNAL_SERVICE_HOST}:${NEUTRON_PORT}" \ | |
"${NEUTRON_INTERNAL_SERVICE_PROTOCOL}://${NEUTRON_ADMIN_SERVICE_HOST}:${NEUTRON_PORT}" | |
# Heat | |
create_endpoint $REGION orchestration \ | |
"${HEAT_PUBLIC_SERVICE_PROTOCOL}://${HEAT_PUBLIC_SERVICE_HOST}:${HEAT_PORT}" \ | |
"${HEAT_ADMIN_SERVICE_PROTOCOL}://${HEAT_ADMIN_SERVICE_HOST}:${HEAT_PORT}" \ | |
"${HEAT_INTERNAL_SERVICE_PROTOCOL}://${HEAT_INTERNAL_SERVICE_HOST}:${HEAT_PORT}" | |
create_endpoint $REGION cloudformation \ | |
"${HEAT_CFN_PUBLIC_SERVICE_PROTOCOL}://${HEAT_CFN_PUBLIC_SERVICE_HOST}:${HEAT_CFN_PORT}" \ | |
"${HEAT_CFN_ADMIN_SERVICE_PROTOCOL}://${HEAT_CFN_ADMIN_SERVICE_HOST}:${HEAT_CFN_PORT}" \ | |
"${HEAT_CFN_INTERNAL_SERVICE_PROTOCOL}://${HEAT_CFN_INTERNAL_SERVICE_HOST}:${HEAT_CFN_PORT}" | |
# Ceilometer | |
create_endpoint $REGION ceilometer \ | |
"${CEILOMETER_PUBLIC_SERVICE_PROTOCOL}://${CEILOMETER_PUBLIC_SERVICE_HOST}:${CEILOMETER_PORT}/" \ | |
"${CEILOMETER_ADMIN_SERVICE_PROTOCOL}://${CEILOMETER_ADMIN_SERVICE_HOST}:${CEILOMETER_PORT}/" \ | |
"${CEILOMETER_ADMIN_SERVICE_PROTOCOL}://${CEILOMETER_INTERNAL_SERVICE_HOST}:${CEILOMETER_PORT}/" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment