7 if [ "$1" = "configure" ] || [ "$1" = "reconfigure" ] ; then
8 . /usr/share/debconf/confmodule
10 # We need special handling for Cinder, as it needs 2 endpoints
12 db_get ${PKG_NAME}/register-endpoint
13 if [ "${RET}" = "true" ] ; then
14 # Setup the v1 endpoint
15 db_get ${PKG_NAME}/keystone-ip
16 KEYSTONE_ENDPOINT_IP=`echo ${RET} | egrep '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$'`
17 db_get ${PKG_NAME}/endpoint-ip
18 PKG_ENDPOINT_IP=`echo ${RET} | egrep '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$'`
19 db_get ${PKG_NAME}/region-name
21 db_get ${PKG_NAME}/keystone-project-name
22 KEYSTONE_PROJECT_NAME=${RET}
23 db_get ${PKG_NAME}/keystone-admin-name
24 KEYSTONE_ADMIN_NAME=${RET}
25 db_get ${PKG_NAME}/keystone-admin-password
26 KEYSTONE_ADMIN_PASSWORD=${RET}
28 if [ -n "${KEYSTONE_ENDPOINT_IP}" ] && [ -n "${PKG_ENDPOINT_IP}" ] && [ -n "${REGION_NAME}" ] && [ -n "${KEYSTONE_PROJECT_NAME}" ] && [ -n "${KEYSTONE_ADMIN_NAME}" ] && [ -n "${KEYSTONE_ADMIN_PASSWORD}" ] ; then
29 export OS_PROJECT_DOMAIN_ID=default
30 export OS_USER_DOMAIN_ID=default
31 export OS_TENANT_NAME=${KEYSTONE_PROJECT_NAME}
32 export OS_PROJECT_NAME=${KEYSTONE_PROJECT_NAME}
33 export OS_USERNAME=${KEYSTONE_ADMIN_NAME}
34 export OS_PASSWORD=${KEYSTONE_ADMIN_PASSWORD}
35 export OS_AUTH_URL=http://${KEYSTONE_ENDPOINT_IP}:35357/v3/
36 export OS_IDENTITY_API_VERSION=3
37 export OS_AUTH_VERSION=3
38 export OS_PROJECT_DOMAIN_ID=default
39 export OS_USER_DOMAIN_ID=default
44 SERVICE_DESC="OpenStack Block Storage"
46 SERVICE_URL=/v1/'%(tenant_id)s'
47 echo "Registering service and endpoints for ${SERVICE_NAME} with type ${SERVICE_TYPE} at http://${PKG_ENDPOINT_IP}:${SERVICE_PORT}${SERVICE_URL}"
48 NUM_LINES=$(openstack service list --format=csv | q -d , -H 'SELECT ID FROM - WHERE `Type`="'${SERVICE_TYPE}'"' | wc -l)
49 if [ "${NUM_LINES}" = "0" ] ; then
50 openstack service create --name=${SERVICE_NAME} --description="${SERVICE_DESC}" ${SERVICE_TYPE}
51 openstack endpoint create --region "${REGION_NAME}" ${SERVICE_NAME} public http://${PKG_ENDPOINT_IP}:${SERVICE_PORT}${SERVICE_URL}
52 openstack endpoint create --region "${REGION_NAME}" ${SERVICE_NAME} internal http://${PKG_ENDPOINT_IP}:${SERVICE_PORT}${SERVICE_URL}
53 openstack endpoint create --region "${REGION_NAME}" ${SERVICE_NAME} admin http://${PKG_ENDPOINT_IP}:${SERVICE_PORT}${SERVICE_URL}
58 SERVICE_DESC="OpenStack Block Storage v2"
60 SERVICE_URL=/v2/'%(tenant_id)s'
61 echo "Registering service and endpoints for ${SERVICE_NAME} with type ${SERVICE_TYPE} at http://${PKG_ENDPOINT_IP}:${SERVICE_PORT}${SERVICE_URL}"
62 NUM_LINES=$(openstack service list --format=csv | q -d , -H 'SELECT ID FROM - WHERE `Type`="'${SERVICE_TYPE}'"' | wc -l)
63 if [ "${NUM_LINES}" = "0" ] ; then
64 openstack service create --name=${SERVICE_NAME} --description="${SERVICE_DESC}" ${SERVICE_TYPE}
65 openstack endpoint create --region "${REGION_NAME}" ${SERVICE_NAME} public http://${PKG_ENDPOINT_IP}:${SERVICE_PORT}${SERVICE_URL}
66 openstack endpoint create --region "${REGION_NAME}" ${SERVICE_NAME} internal http://${PKG_ENDPOINT_IP}:${SERVICE_PORT}${SERVICE_URL}
67 openstack endpoint create --region "${REGION_NAME}" ${SERVICE_NAME} admin http://${PKG_ENDPOINT_IP}:${SERVICE_PORT}${SERVICE_URL}
69 # pkgos_register_endpoint_postinst cinder cinder volume "Cinder Volume Service" 8776 /v1/'%(tenant_id)s'
70 # pkgos_register_endpoint_postinst cinder cinderv2 volumev2 "Cinder Volume Service" 8776 /v2/'%(tenant_id)s'
72 echo "Problem in endpoint parameter (IPs or otherwise)."
74 db_unregister ${PKG_NAME}/register-endpoint
76 echo "Will not register "${SERVICE_NAME}" endpoint this time (no user request for it)."
78 db_unregister ${PKG_NAME}/keystone-admin-password