]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Setup both v1 and v2 endpoints.
authorThomas Goirand <thomas@goirand.fr>
Mon, 12 Oct 2015 21:43:48 +0000 (21:43 +0000)
committerThomas Goirand <thomas@goirand.fr>
Mon, 12 Oct 2015 22:19:30 +0000 (22:19 +0000)
debian/changelog
debian/cinder-api.postinst.in

index a7a41940a326b8d62da09cdebaf24b39cea352ae..a880f03351b217211ff56ccfb62934ab26de46f2 100644 (file)
@@ -1,3 +1,9 @@
+cinder (2:7.0.0~rc2-2) experimental; urgency=medium
+
+  * Setup both v1 and v2 endpoints.
+
+ -- Thomas Goirand <zigo@debian.org>  Mon, 12 Oct 2015 21:41:08 +0000
+
 cinder (2:7.0.0~rc2-1) experimental; urgency=medium
 
   * cinder-api depends on python-openstackclient.
index 3868b9ae50f4e5ed906cc09bd1abb3e190c9f5ec..8f72438cda7a0b7f59d7a8b727294b0ccd52176b 100644 (file)
@@ -6,7 +6,58 @@ set -e
 
 if [ "$1" = "configure" ] || [ "$1" = "reconfigure" ] ; then
        . /usr/share/debconf/confmodule
-       pkgos_register_endpoint_postinst cinder cinderv2 volumev2 "Cinder Volume Service" 8776 /v2/'%(tenant_id)s'
+
+       # We need special handling for Cinder, as it needs 2 endpoints
+       PKG_NAME=cinder
+       db_get ${PKG_NAME}/register-endpoint
+       if [ "${RET}" = "true" ] ; then
+               # Setup the v1 endpoint
+               db_get ${PKG_NAME}/keystone-ip
+               KEYSTONE_ENDPOINT_IP=`echo ${RET} | egrep '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$'`
+               db_get ${PKG_NAME}/keystone-auth-token
+               AUTH_TOKEN=${RET}
+               db_get ${PKG_NAME}/endpoint-ip
+               PKG_ENDPOINT_IP=`echo ${RET} | egrep '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$'`
+               db_get ${PKG_NAME}/region-name
+               REGION_NAME=${RET}
+
+               if [ -n "${KEYSTONE_ENDPOINT_IP}" ] && [ -n "${PKG_ENDPOINT_IP}" ] && [ -n "${REGION_NAME}" ] && [ -n "${AUTH_TOKEN}" ] ; then
+                       SERVICE_NAME=cinder
+                       SERVICE_TYPE=volume
+                       SERVICE_DESC="OpenStack Block Storage"
+                       SERVICE_PORT=8776
+                       SERVICE_URL=/v1/'%(tenant_id)s'
+                       echo "Registering service and endpoints for ${SERVICE_NAME} with type ${SERVICE_TYPE} at http://${PKG_ENDPOINT_IP}:${SERVICE_PORT}${SERVICE_URL}"
+                       openstack --os-token ${AUTH_TOKEN} --os-url=http://${KEYSTONE_ENDPOINT_IP}:35357/v2.0/ service create \
+                               --name=${SERVICE_NAME} --description="${SERVICE_DESC}" ${SERVICE_TYPE}
+                       openstack --os-token ${AUTH_TOKEN} --os-url=http://${KEYSTONE_ENDPOINT_IP}:35357/v2.0/ endpoint create \
+                               --region "${REGION_NAME}" \
+                               --publicurl=http://${PKG_ENDPOINT_IP}:${SERVICE_PORT}${SERVICE_URL} \--publicurl=http://${PKG_ENDPOINT_IP}:${SERVICE_PORT}${SERVICE_URL} \
+                               --internalurl=http://${PKG_ENDPOINT_IP}:${SERVICE_PORT}${SERVICE_URL} \
+                               --adminurl=http://${PKG_ENDPOINT_IP}:${SERVICE_PORT}${SERVICE_URL} ${SERVICE_NAME}
+                       SERVICE_NAME=cinderv2
+                       SERVICE_TYPE=volumev2
+                       SERVICE_DESC="OpenStack Block Storage v2"
+                       SERVICE_PORT=8776
+                       SERVICE_URL=/v2/'%(tenant_id)s'
+                       echo "Registering service and endpoints for ${SERVICE_NAME} with type ${SERVICE_TYPE} at http://${PKG_ENDPOINT_IP}:${SERVICE_PORT}${SERVICE_URL}"
+                       openstack --os-token ${AUTH_TOKEN} --os-url=http://${KEYSTONE_ENDPOINT_IP}:35357/v2.0/ service create \
+                               --name=${SERVICE_NAME} --description="${SERVICE_DESC}" ${SERVICE_TYPE}
+                       openstack --os-token ${AUTH_TOKEN} --os-url=http://${KEYSTONE_ENDPOINT_IP}:35357/v2.0/ endpoint create \
+                               --region "${REGION_NAME}" \
+                               --publicurl=http://${PKG_ENDPOINT_IP}:${SERVICE_PORT}${SERVICE_URL} \--publicurl=http://${PKG_ENDPOINT_IP}:${SERVICE_PORT}${SERVICE_URL} \
+                               --internalurl=http://${PKG_ENDPOINT_IP}:${SERVICE_PORT}${SERVICE_URL} \
+                               --adminurl=http://${PKG_ENDPOINT_IP}:${SERVICE_PORT}${SERVICE_URL} ${SERVICE_NAME}
+#                      pkgos_register_endpoint_postinst cinder cinder volume "Cinder Volume Service" 8776 /v1/'%(tenant_id)s'
+#                      pkgos_register_endpoint_postinst cinder cinderv2 volumev2 "Cinder Volume Service" 8776 /v2/'%(tenant_id)s'
+               else
+                       echo "Problem in endpoint parameter (IPs or otherwise)."
+               fi
+               db_unregister ${PKG_NAME}/register-endpoint
+       else
+               echo "Will not register "${SERVICE_NAME}" endpoint this time (no user request for it)."
+       fi
+       db_unregister ${PKG_NAME}/keystone-auth-token
        db_stop
 fi