diff --git a/heartbeat/openstack-common.sh b/heartbeat/openstack-common.sh index 88ed4ba69..27275e65c 100644 --- a/heartbeat/openstack-common.sh +++ b/heartbeat/openstack-common.sh @@ -1,156 +1,146 @@ -OCF_RESKEY_clouds_yaml_default="$HOME/.config/openstack/clouds.yaml" OCF_RESKEY_openstackcli_default="/usr/bin/openstack" OCF_RESKEY_insecure_default="false" -: ${OCF_RESKEY_clouds_yaml=${OCF_RESKEY_clouds_yaml_default}} : ${OCF_RESKEY_openstackcli=${OCF_RESKEY_openstackcli_default}} : ${OCF_RESKEY_insecure=${OCF_RESKEY_insecure_default}} if ocf_is_true "${OCF_RESKEY_insecure}"; then OCF_RESKEY_openstackcli="${OCF_RESKEY_openstackcli} --insecure" fi common_meta_data() { cat < - -Openstack clouds.yaml config file. - -clouds.yaml config file - - - -Openstack cloud (from ~/.config/openstack/clouds.yaml). +Openstack cloud (from ~/.config/openstack/clouds.yaml or /etc/openstack/clouds.yaml). Cloud from clouds.yaml Openstack credentials as openrc file from api_access/openrc. openrc file Keystone Auth URL Keystone Auth URL Username. Username Password. Password Keystone Project. Keystone Project Keystone User Domain Name. Keystone User Domain Name Keystone Project Domain Name. Keystone Project Domain Name Path to command line tools for openstack. Path to Openstack CLI tool Allow insecure connections Allow insecure connections END } get_config() { - if [ -n "$OCF_RESKEY_clouds_yaml" ]; then - if [ ! -f "$OCF_RESKEY_clouds_yaml" ]; then - ocf_exit_reason "$OCF_RESKEY_clouds_yaml does not exist" - return $OCF_ERR_CONFIGURED - fi - if [ -z "$OCF_RESKEY_cloud" ]; then - ocf_exit_reason "cloud: $OCF_RESKEY_cloud not found in $OCF_RESKEY_clouds_yaml" + if [ -n "$OCF_RESKEY_cloud" ]; then + clouds_yaml="$HOME/.config/openstack/clouds.yaml" + if [ ! -f "$clouds_yaml" ]; then + clouds_yaml="/etc/openstack/clouds.yaml" + fi + if [ ! -f "$clouds_yaml" ]; then + ocf_exit_reason "~/.config/openstack/clouds.yaml and /etc/openstack/clouds.yaml does not exist" return $OCF_ERR_CONFIGURED - fi + fi OCF_RESKEY_openstackcli="${OCF_RESKEY_openstackcli} --os-cloud $OCF_RESKEY_cloud" elif [ -n "$OCF_RESKEY_openrc" ]; then if [ ! -f "$OCF_RESKEY_openrc" ]; then ocf_exit_reason "$OCF_RESKEY_openrc does not exist" return $OCF_ERR_CONFIGURED fi . $OCF_RESKEY_openrc else if [ -z "$OCF_RESKEY_auth_url" ]; then ocf_exit_reason "auth_url not set" return $OCF_ERR_CONFIGURED fi if [ -z "$OCF_RESKEY_username" ]; then ocf_exit_reason "username not set" return $OCF_ERR_CONFIGURED fi if [ -z "$OCF_RESKEY_password" ]; then ocf_exit_reason "password not set" return $OCF_ERR_CONFIGURED fi if [ -z "$OCF_RESKEY_project_name" ]; then ocf_exit_reason "project_name not set" return $OCF_ERR_CONFIGURED fi if [ -z "$OCF_RESKEY_user_domain_name" ]; then ocf_exit_reason "user_domain_name not set" return $OCF_ERR_CONFIGURED fi if [ -z "$OCF_RESKEY_project_domain_name" ]; then ocf_exit_reason " not set" return $OCF_ERR_CONFIGURED fi OCF_RESKEY_openstackcli="${OCF_RESKEY_openstackcli} --os-auth-url $OCF_RESKEY_auth_url" OCF_RESKEY_openstackcli="${OCF_RESKEY_openstackcli} --os-username $OCF_RESKEY_username" OCF_RESKEY_openstackcli="${OCF_RESKEY_openstackcli} --os-password $OCF_RESKEY_password" OCF_RESKEY_openstackcli="${OCF_RESKEY_openstackcli} --os-project-name $OCF_RESKEY_project_name" OCF_RESKEY_openstackcli="${OCF_RESKEY_openstackcli} --os-user-domain-name $OCF_RESKEY_user_domain_name" OCF_RESKEY_openstackcli="${OCF_RESKEY_openstackcli} --os-project-domain-name $OCF_RESKEY_project_domain_name" fi }