Remove openstack client from keystone bootstrap
Keystone has merged the rest of thier bootstrap code. Lets take advantage of that. TrivialFix Change-Id: Icfe8a2dca7ae49724fa3290fdfe9fb21b8ba01a2
This commit is contained in:
parent
c5f27aa8a6
commit
215cfc0345
@ -14,12 +14,6 @@ INTERNAL_URL=$6
|
|||||||
PUBLIC_URL=$7
|
PUBLIC_URL=$7
|
||||||
REGION=$8
|
REGION=$8
|
||||||
|
|
||||||
function get_token {
|
|
||||||
unset OS_TOKEN OS_URL
|
|
||||||
OS_TOKEN=$(openstack --os-identity-api-version 3 --os-username "${USERNAME}" --os-password "${PASSWORD}" --os-project-name "${PROJECT}" --os-auth-url "${ADMIN_URL}" token issue 2>&1 | awk '/ id / {print $4}')
|
|
||||||
OS_URL="${ADMIN_URL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function fail_json {
|
function fail_json {
|
||||||
echo '{"failed": true, "msg": "'$1'", "changed": true}'
|
echo '{"failed": true, "msg": "'$1'", "changed": true}'
|
||||||
exit 1
|
exit 1
|
||||||
@ -29,60 +23,26 @@ function exit_json {
|
|||||||
echo '{"failed": false, "changed": '"${changed}"'}'
|
echo '{"failed": false, "changed": '"${changed}"'}'
|
||||||
}
|
}
|
||||||
|
|
||||||
function create_service {
|
|
||||||
if [[ ! $(openstack --os-identity-api-version 3 --os-token "${OS_TOKEN}" --os-url "${OS_URL}" service list 2>&1 | awk '/identity/') ]]; then
|
|
||||||
openstack --os-identity-api-version 3 --os-token "${OS_TOKEN}" --os-url "${OS_URL}" service create identity --name keystone 2>&1 > /dev/null
|
|
||||||
changed="true"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function create_endpoints {
|
|
||||||
endpoints=$(openstack --os-identity-api-version 3 --os-token "${OS_TOKEN}" --os-url "${OS_URL}" endpoint list)
|
|
||||||
if [[ $(echo "${endpoints}" | awk '$6 == "keystone" && $4 == "'"${REGION}"'" && $12 == "admin" {print $14;exit}') != "${ADMIN_URL}" ]]; then
|
|
||||||
openstack --os-identity-api-version 3 --os-token "${OS_TOKEN}" --os-url "${OS_URL}" endpoint create --region "${REGION}" keystone admin "${ADMIN_URL}" 2>&1 > /dev/null
|
|
||||||
changed="true"
|
|
||||||
fi
|
|
||||||
if [[ $(echo "${endpoints}" | awk '$6 == "keystone" && $4 == "'"${REGION}"'" && $12 == "internal" {print $14;exit}') != "${INTERNAL_URL}" ]]; then
|
|
||||||
openstack --os-identity-api-version 3 --os-token "${OS_TOKEN}" --os-url "${OS_URL}" endpoint create --region "${REGION}" keystone internal "${INTERNAL_URL}" 2>&1 > /dev/null
|
|
||||||
changed="true"
|
|
||||||
fi
|
|
||||||
if [[ $(echo "${endpoints}" | awk '$6 == "keystone" && $4 == "'"${REGION}"'" && $12 == "public" {print $14;exit}') != "${PUBLIC_URL}" ]]; then
|
|
||||||
openstack --os-identity-api-version 3 --os-token "${OS_TOKEN}" --os-url "${OS_URL}" endpoint create --region "${REGION}" keystone public "${PUBLIC_URL}" 2>&1 > /dev/null
|
|
||||||
changed="true"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
changed="false"
|
changed="false"
|
||||||
get_token
|
keystone_bootstrap=$(keystone-manage bootstrap --bootstrap-username "${USERNAME}" --bootstrap-password "${PASSWORD}" --bootstrap-project-name "${PROJECT}" --bootstrap-role-name "${ROLE}" --bootstrap-admin-url "${ADMIN_URL}" --bootstrap-internal-url "${INTERNAL_URL}" --bootstrap-public-url "${PUBLIC_URL}" --bootstrap-service-name "keystone" --bootstrap-region-id "${REGION}" 2>&1)
|
||||||
if [[ ! $(openstack --os-identity-api-version 3 --os-token "${OS_TOKEN}" --os-url "${OS_URL}" user list 2>&1 | awk '/'"${USERNAME}"'/') ]]; then
|
if [[ $? != 0 ]]; then
|
||||||
keystone_bootstrap=$(keystone-manage bootstrap --bootstrap-username "${USERNAME}" --bootstrap-password "${PASSWORD}" --bootstrap-project-name "${PROJECT}" --bootstrap-role-name "${ROLE}" 2>&1)
|
fail_json "${keystone_bootstrap}"
|
||||||
if [[ $? != 0 ]]; then
|
|
||||||
fail_json "${keystone_bootstrap}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
changed=$(echo "${keystone_bootstrap}" | awk '
|
|
||||||
/Domain default already exists, skipping creation./ ||
|
|
||||||
/Project '"${PROJECT}"' already exists, skipping creation./ ||
|
|
||||||
/User '"${USERNAME}"' already exists, skipping creation./ ||
|
|
||||||
/Role '"${ROLE}"' exists, skipping creation./ ||
|
|
||||||
/User '"${USERNAME}"' already has '"${ROLE}"' on '"${PROJECT}"'./ {count++}
|
|
||||||
END {
|
|
||||||
if (count == 5) changed="false"; else changed="true"
|
|
||||||
print changed
|
|
||||||
}'
|
|
||||||
)
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
count=0
|
changed=$(echo "${keystone_bootstrap}" | awk '
|
||||||
while [[ ! "${OS_TOKEN}" && "${count}" -lt 5 ]]; do
|
/Domain default already exists, skipping creation./ ||
|
||||||
get_token
|
/Project '"${PROJECT}"' already exists, skipping creation./ ||
|
||||||
((count++))
|
/User '"${USERNAME}"' already exists, skipping creation./ ||
|
||||||
sleep 1
|
/Role '"${ROLE}"' exists, skipping creation./ ||
|
||||||
done
|
/User '"${USERNAME}"' already has '"${ROLE}"' on '"${PROJECT}"'./ ||
|
||||||
if [[ ! "${OS_TOKEN}" ]]; then
|
/Region '"${REGION}"' exists, skipping creation./ ||
|
||||||
fail_json "Unable to retrieve token after 5 attempts"
|
/Skipping admin endpoint as already created/ ||
|
||||||
fi
|
/Skipping internal endpoint as already created/ ||
|
||||||
|
/Skipping public endpoint as already created/ {count++}
|
||||||
|
END {
|
||||||
|
if (count == 9) changed="false"; else changed="true"
|
||||||
|
print changed
|
||||||
|
}'
|
||||||
|
)
|
||||||
|
|
||||||
create_service
|
|
||||||
create_endpoints
|
|
||||||
exit_json
|
exit_json
|
||||||
|
Loading…
Reference in New Issue
Block a user