Refresh sample_data.sh

This patch refresh the sample_data.sh file to satisfy the newest
OpenStack.
It includes:
1. Remove ec2 which has been removed from Nova already.
2. Remove Cinder V1 which has been removed as well.
3. Add the missing cinder user.
4. Add nova v2.1, cinder v2 and v3 support.
5. Change tenant_id to project_id

Change-Id: I792dfcd058c169c69a8ed82d04aafc8d53649087
This commit is contained in:
wangxiyuan 2017-12-11 15:25:14 +08:00
parent cfbc2aa30b
commit 098279129b
1 changed files with 48 additions and 56 deletions

View File

@ -25,15 +25,12 @@
# Disable creation of endpoints by setting DISABLE_ENDPOINTS environment variable. # Disable creation of endpoints by setting DISABLE_ENDPOINTS environment variable.
# Use this with the Catalog Templated backend. # Use this with the Catalog Templated backend.
# #
# A EC2-compatible credential is created for the admin user and # Project User Roles
# placed in etc/ec2rc.
#
# Tenant User Roles
# ------------------------------------------------------- # -------------------------------------------------------
# demo admin admin # demo admin admin
# service glance service # service glance service
# service nova service # service nova service
# service ec2 service # service cinder service
# service swift service # service swift service
# service neutron service # service neutron service
@ -51,7 +48,7 @@ type openstack >/dev/null 2>&1 || {
ADMIN_PASSWORD=${ADMIN_PASSWORD:-secret} ADMIN_PASSWORD=${ADMIN_PASSWORD:-secret}
NOVA_PASSWORD=${NOVA_PASSWORD:-${SERVICE_PASSWORD:-nova}} NOVA_PASSWORD=${NOVA_PASSWORD:-${SERVICE_PASSWORD:-nova}}
GLANCE_PASSWORD=${GLANCE_PASSWORD:-${SERVICE_PASSWORD:-glance}} GLANCE_PASSWORD=${GLANCE_PASSWORD:-${SERVICE_PASSWORD:-glance}}
EC2_PASSWORD=${EC2_PASSWORD:-${SERVICE_PASSWORD:-ec2}} CINDER_PASSWORD=${CINDER_PASSWORD:-${SERVICE_PASSWORD:-cinder}}
SWIFT_PASSWORD=${SWIFT_PASSWORD:-${SERVICE_PASSWORD:-swiftpass}} SWIFT_PASSWORD=${SWIFT_PASSWORD:-${SERVICE_PASSWORD:-swiftpass}}
NEUTRON_PASSWORD=${NEUTRON_PASSWORD:-${SERVICE_PASSWORD:-neutron}} NEUTRON_PASSWORD=${NEUTRON_PASSWORD:-${SERVICE_PASSWORD:-neutron}}
@ -61,15 +58,13 @@ CONTROLLER_INTERNAL_ADDRESS=${CONTROLLER_INTERNAL_ADDRESS:-localhost}
TOOLS_DIR=$(cd $(dirname "$0") && pwd) TOOLS_DIR=$(cd $(dirname "$0") && pwd)
KEYSTONE_CONF=${KEYSTONE_CONF:-/etc/keystone/keystone.conf} KEYSTONE_CONF=${KEYSTONE_CONF:-/etc/keystone/keystone.conf}
if [[ -r "$KEYSTONE_CONF" ]]; then if [[ ! -r "$KEYSTONE_CONF" ]]; then
EC2RC="$(dirname "$KEYSTONE_CONF")/ec2rc" if [[ -r "$TOOLS_DIR/../etc/keystone.conf" ]]; then
elif [[ -r "$TOOLS_DIR/../etc/keystone.conf" ]]; then # assume git checkout
# assume git checkout KEYSTONE_CONF="$TOOLS_DIR/../etc/keystone.conf"
KEYSTONE_CONF="$TOOLS_DIR/../etc/keystone.conf" else
EC2RC="$TOOLS_DIR/../etc/ec2rc" KEYSTONE_CONF=""
else fi
KEYSTONE_CONF=""
EC2RC="ec2rc"
fi fi
# Extract some info from Keystone's configuration file # Extract some info from Keystone's configuration file
@ -124,10 +119,10 @@ openstack role add --user nova \
--project service \ --project service \
service service
openstack user create ec2 --project service \ openstack user create cinder --project service \
--password "${EC2_PASSWORD}" --password "${CINDER_PASSWORD}"
openstack role add --user ec2 \ openstack role add --user cinder \
--project service \ --project service \
service service
@ -148,31 +143,55 @@ openstack role add --user neutron \
# #
# Nova service # Nova service
# #
openstack service create --name=nova_legacy \
--description="Nova Compute Service (Legacy 2.0)" \
compute_legacy
if [[ -z "$DISABLE_ENDPOINTS" ]]; then
openstack endpoint create --region RegionOne \
compute public "http://$CONTROLLER_PUBLIC_ADDRESS:8774/v2/\$(project_id)s"
openstack endpoint create --region RegionOne \
compute admin "http://$CONTROLLER_ADMIN_ADDRESS:8774/v2/\$(project_id)s"
openstack endpoint create --region RegionOne \
compute internal "http://$CONTROLLER_INTERNAL_ADDRESS:8774/v2/\$(project_id)s"
fi
openstack service create --name=nova \ openstack service create --name=nova \
--description="Nova Compute Service" \ --description="Nova Compute Service" \
compute compute
if [[ -z "$DISABLE_ENDPOINTS" ]]; then if [[ -z "$DISABLE_ENDPOINTS" ]]; then
openstack endpoint create --region RegionOne \ openstack endpoint create --region RegionOne \
compute public "http://$CONTROLLER_PUBLIC_ADDRESS:8774/v2/\$(tenant_id)s" compute public "http://$CONTROLLER_PUBLIC_ADDRESS:8774/v2.1"
openstack endpoint create --region RegionOne \ openstack endpoint create --region RegionOne \
compute admin "http://$CONTROLLER_ADMIN_ADDRESS:8774/v2/\$(tenant_id)s" compute admin "http://$CONTROLLER_ADMIN_ADDRESS:8774/v2.1"
openstack endpoint create --region RegionOne \ openstack endpoint create --region RegionOne \
compute internal "http://$CONTROLLER_INTERNAL_ADDRESS:8774/v2/\$(tenant_id)s" compute internal "http://$CONTROLLER_INTERNAL_ADDRESS:8774/v2.1"
fi fi
# #
# Volume service # Volume service
# #
openstack service create --name=volume \ openstack service create --name=cinderv2 \
--description="Cinder Volume Service" \ --description="Cinder Volume Service V2" \
volume volumev2
if [[ -z "$DISABLE_ENDPOINTS" ]]; then if [[ -z "$DISABLE_ENDPOINTS" ]]; then
openstack endpoint create --region RegionOne \ openstack endpoint create --region RegionOne \
volume public "http://$CONTROLLER_PUBLIC_ADDRESS:8776/v1/\$(tenant_id)s" volume public "http://$CONTROLLER_PUBLIC_ADDRESS:8776/v2/\$(project_id)s"
openstack endpoint create --region RegionOne \ openstack endpoint create --region RegionOne \
volume admin "http://$CONTROLLER_ADMIN_ADDRESS:8776/v1/\$(tenant_id)s" volume admin "http://$CONTROLLER_ADMIN_ADDRESS:8776/v2/\$(project_id)s"
openstack endpoint create --region RegionOne \ openstack endpoint create --region RegionOne \
volume internal "http://$CONTROLLER_INTERNAL_ADDRESS:8776/v1/\$(tenant_id)s" volume internal "http://$CONTROLLER_INTERNAL_ADDRESS:8776/v2/\$(project_id)s"
fi
openstack service create --name=cinderv3 \
--description="Cinder Volume Service V3" \
volumev3
if [[ -z "$DISABLE_ENDPOINTS" ]]; then
openstack endpoint create --region RegionOne \
volume public "http://$CONTROLLER_PUBLIC_ADDRESS:8776/v3/\$(project_id)s"
openstack endpoint create --region RegionOne \
volume admin "http://$CONTROLLER_ADMIN_ADDRESS:8776/v3/\$(project_id)s"
openstack endpoint create --region RegionOne \
volume internal "http://$CONTROLLER_INTERNAL_ADDRESS:8776/v3/\$(project_id)s"
fi fi
# #
@ -190,21 +209,6 @@ if [[ -z "$DISABLE_ENDPOINTS" ]]; then
image internal "http://$CONTROLLER_INTERNAL_ADDRESS:9292" image internal "http://$CONTROLLER_INTERNAL_ADDRESS:9292"
fi fi
#
# EC2 service
#
openstack service create --name=ec2 \
--description="EC2 Compatibility Layer" \
ec2
if [[ -z "$DISABLE_ENDPOINTS" ]]; then
openstack endpoint create --region RegionOne \
ec2 public "http://$CONTROLLER_PUBLIC_ADDRESS:8773/services/Cloud"
openstack endpoint create --region RegionOne \
ec2 admin "http://$CONTROLLER_ADMIN_ADDRESS:8773/services/Admin"
openstack endpoint create --region RegionOne \
ec2 internal "http://$CONTROLLER_INTERNAL_ADDRESS:8773/services/Cloud"
fi
# #
# Swift service # Swift service
# #
@ -213,11 +217,11 @@ openstack service create --name=swift \
object-store object-store
if [[ -z "$DISABLE_ENDPOINTS" ]]; then if [[ -z "$DISABLE_ENDPOINTS" ]]; then
openstack endpoint create --region RegionOne \ openstack endpoint create --region RegionOne \
object-store public "http://$CONTROLLER_PUBLIC_ADDRESS:8080/v1/AUTH_\$(tenant_id)s" object-store public "http://$CONTROLLER_PUBLIC_ADDRESS:8080/v1/AUTH_\$(project_id)s"
openstack endpoint create --region RegionOne \ openstack endpoint create --region RegionOne \
object-store admin "http://$CONTROLLER_ADMIN_ADDRESS:8080/v1" object-store admin "http://$CONTROLLER_ADMIN_ADDRESS:8080/v1"
openstack endpoint create --region RegionOne \ openstack endpoint create --region RegionOne \
object-store internal "http://$CONTROLLER_INTERNAL_ADDRESS:8080/v1/AUTH_\$(tenant_id)s" object-store internal "http://$CONTROLLER_INTERNAL_ADDRESS:8080/v1/AUTH_\$(project_id)s"
fi fi
# #
@ -234,15 +238,3 @@ if [[ -z "$DISABLE_ENDPOINTS" ]]; then
openstack endpoint create --region RegionOne \ openstack endpoint create --region RegionOne \
network internal "http://$CONTROLLER_INTERNAL_ADDRESS:9696" network internal "http://$CONTROLLER_INTERNAL_ADDRESS:9696"
fi fi
# create ec2 creds and parse the secret and access key returned
ADMIN_USER=$(openstack user show admin -f value -c id)
RESULT=$(openstack ec2 credentials create --project service --user $ADMIN_USER)
ADMIN_ACCESS=`echo "$RESULT" | grep access | awk '{print $4}'`
ADMIN_SECRET=`echo "$RESULT" | grep secret | awk '{print $4}'`
# write the secret and access to ec2rc
cat > $EC2RC <<EOF
ADMIN_ACCESS=$ADMIN_ACCESS
ADMIN_SECRET=$ADMIN_SECRET
EOF