[PKG-Openstack-devel] [PATCH] Allow to use '.../endpoint-host' instead of '.../endpoint-ip'.

Turbo Fredriksson turbo at bayour.com
Mon Jul 4 13:59:51 UTC 2016


I have (will have) my Control nodes clustered and have a
round-robin DNS entry for my control node(s). The primary
might be done, so I'd like to be able to use the RR entry
to connect to my [current] control node.

---
 pkgos_func |   29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/pkgos_func b/pkgos_func
index ff87ee0..9cfe925 100644
--- a/pkgos_func
+++ b/pkgos_func
@@ -648,7 +648,7 @@ pkgos_register_endpoint_config () {
 # Example: pkgos_register_endpoint_postinst glance glance image "Glance Image Service" 9292 /v1
 # To be used in: postinst
 pkgos_register_endpoint_postinst () {
-       local PKG_NAME SERVICE_NAME SERVICE_TYPE SERVICE_DESC SERVICE_PORT SERVICE_URL KEYSTONE_ENDPOINT_IP AUTH_TOKEN PKG_ENDPOINT_IP REGION_NAME PKG_SERVICE_ID
+       local PKG_NAME SERVICE_NAME SERVICE_TYPE SERVICE_DESC SERVICE_PORT SERVICE_URL KEYSTONE_ENDPOINT_IP AUTH_TOKEN PKG_ENDPOINT PKG_ENDPOINT_IP PKG_ENDPOINT_HOST REGION_NAME PKG_SERVICE_ID
        PKG_NAME=${1}
        SERVICE_NAME=${2}
        SERVICE_TYPE=${3}
@@ -662,14 +662,19 @@ pkgos_register_endpoint_postinst () {
                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}/endpoint-ip
-               PKG_ENDPOINT_IP=`echo ${RET} | egrep '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$'`
+               if [ -n "${RET}" ]; then
+                       PKG_ENDPOINT=`echo ${RET} | egrep '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$'`
+               else
+                       db_get ${PKG_NAME}/endpoint-host
+                       PKG_ENDPOINT="${RET}"
+               fi
                db_get ${PKG_NAME}/region-name
                REGION_NAME=${RET}

                if db_get ${PKG_NAME}/keystone-auth-token ; then
                        AUTH_TOKEN=${RET}
-                       if [ -n "${KEYSTONE_ENDPOINT_IP}" ] && [ -n "${PKG_ENDPOINT_IP}" ] && [ -n "${REGION_NAME}" ] && [ -n "${AUTH_TOKEN}" ] ; then
-                               echo "Registering service and endpoints for ${SERVICE_NAME} with type ${SERVICE_TYPE} at http://${PKG_ENDPOINT_IP}:${SERVICE_PORT}${SERVICE_URL}"
+                       if [ -n "${KEYSTONE_ENDPOINT_IP}" ] && [ -n "${PKG_ENDPOINT}" ] && [ -n "${REGION_NAME}" ] && [ -n "${AUTH_TOKEN}" ] ; then
+                               echo "Registering service and endpoints for ${SERVICE_NAME} with type ${SERVICE_TYPE} at http://${PKG_ENDPOINT}:${SERVICE_PORT}${SERVICE_URL}"
                                NUM_LINES=$(openstack --os-token ${AUTH_TOKEN} --os-url=http://${KEYSTONE_ENDPOINT_IP}:35357/v3/ --os-domain-name default --os-identity-api-version=3 service list --format=csv | q -d , -H 'SELECT ID FROM - WHERE `Type`="'${SERVICE_TYPE}'"' | wc -l)
                                if [ "${NUM_LINES}" = "0" ] ; then
                                        openstack --os-token ${AUTH_TOKEN} --os-url=http://${KEYSTONE_ENDPOINT_IP}:35357/v3/ --os-domain-name default --os-identity-api-version=3 service create \
@@ -677,15 +682,15 @@ pkgos_register_endpoint_postinst () {

                                        openstack --os-token ${AUTH_TOKEN} --os-url=http://${KEYSTONE_ENDPOINT_IP}:35357/v3/ --os-domain-name default --os-identity-api-version=3 endpoint create \
                                                --region "${REGION_NAME}" \
-                                               ${SERVICE_NAME} public http://${PKG_ENDPOINT_IP}:${SERVICE_PORT}${SERVICE_URL}
+                                               ${SERVICE_NAME} public http://${PKG_ENDPOINT}:${SERVICE_PORT}${SERVICE_URL}

                                        openstack --os-token ${AUTH_TOKEN} --os-url=http://${KEYSTONE_ENDPOINT_IP}:35357/v3/ --os-domain-name default --os-identity-api-version=3 endpoint create \
                                                --region "${REGION_NAME}" \
-                                               ${SERVICE_NAME} internal http://${PKG_ENDPOINT_IP}:${SERVICE_PORT}${SERVICE_URL}
+                                               ${SERVICE_NAME} internal http://${PKG_ENDPOINT}:${SERVICE_PORT}${SERVICE_URL}

                                        openstack --os-token ${AUTH_TOKEN} --os-url=http://${KEYSTONE_ENDPOINT_IP}:35357/v3/ --os-domain-name default --os-identity-api-version=3 endpoint create \
                                                --region "${REGION_NAME}" \
-                                               ${SERVICE_NAME} admin http://${PKG_ENDPOINT_IP}:${SERVICE_PORT}${SERVICE_URL}
+                                               ${SERVICE_NAME} admin http://${PKG_ENDPOINT}:${SERVICE_PORT}${SERVICE_URL}
                                else
                                        echo "Service already registered: skipping service endpoint creation. Will skip service endpoint creation."
                                fi
@@ -700,8 +705,8 @@ pkgos_register_endpoint_postinst () {
                        db_get ${PKG_NAME}/keystone-admin-password
                        KEYSTONE_ADMIN_PASSWORD=${RET}

-                       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
-                               echo "Registering service and endpoints for ${SERVICE_NAME} with type ${SERVICE_TYPE} at http://${PKG_ENDPOINT_IP}:${SERVICE_PORT}${SERVICE_URL}"
+                       if [ -n "${KEYSTONE_ENDPOINT_IP}" ] && [ -n "${PKG_ENDPOINT}" ] && [ -n "${REGION_NAME}" ] && [ -n "${KEYSTONE_PROJECT_NAME}" ] && [ -n "${KEYSTONE_ADMIN_NAME}" ]  && [ -n "${KEYSTONE_ADMIN_PASSWORD}" ]; then
+                               echo "Registering service and endpoints for ${SERVICE_NAME} with type ${SERVICE_TYPE} at http://${PKG_ENDPOINT}:${SERVICE_PORT}${SERVICE_URL}"
                                export OS_PROJECT_DOMAIN_ID=default
                                export OS_USER_DOMAIN_ID=default

                                export OS_TENANT_NAME=${KEYSTONE_PROJECT_NAME}
@@ -717,9 +722,9 @@ pkgos_register_endpoint_postinst () {
                                NUM_LINES=$(OS_PASSWORD=${KEYSTONE_ADMIN_PASSWORD} openstack service list --format=csv | q -d , -H 'SELECT ID FROM - WHERE `Type`="'${SERVICE_TYPE}'"' | wc -l)
                                if [ "${NUM_LINES}" = "0" ] ; then
                                        openstack service create --name=${SERVICE_NAME} --description="${SERVICE_DESC}" ${SERVICE_TYPE}
-                                       openstack endpoint create --region "${REGION_NAME}" ${SERVICE_NAME} public   http://${PKG_ENDPOINT_IP}:${SERVICE_PORT}${SERVICE_URL}
-                                       openstack endpoint create --region "${REGION_NAME}" ${SERVICE_NAME} internal http://${PKG_ENDPOINT_IP}:${SERVICE_PORT}${SERVICE_URL}
-                                       openstack endpoint create --region "${REGION_NAME}" ${SERVICE_NAME} admin    http://${PKG_ENDPOINT_IP}:${SERVICE_PORT}${SERVICE_URL}
+                                       openstack endpoint create --region "${REGION_NAME}" ${SERVICE_NAME} public   http://${PKG_ENDPOINT}:${SERVICE_PORT}${SERVICE_URL}
+                                       openstack endpoint create --region "${REGION_NAME}" ${SERVICE_NAME} internal http://${PKG_ENDPOINT}:${SERVICE_PORT}${SERVICE_URL}
+                                       openstack endpoint create --region "${REGION_NAME}" ${SERVICE_NAME} admin    http://${PKG_ENDPOINT}:${SERVICE_PORT}${SERVICE_URL}
                                else
                                        echo "Service already registered: skipping service endpoint creation."
                                fi
--
1.7.10.4





More information about the Openstack-devel mailing list