|
@ -3265,16 +3265,38 @@ get_all_relations () { |
|
|
providers=() |
|
|
providers=() |
|
|
providers_def=() |
|
|
providers_def=() |
|
|
array_read-0 providers providers_def < <(_get_charm_providing "$relation_name" "${service_list[@]}") |
|
|
array_read-0 providers providers_def < <(_get_charm_providing "$relation_name" "${service_list[@]}") |
|
|
|
|
|
|
|
|
|
|
|
## select first provider that is not a stub |
|
|
|
|
|
new_providers=() |
|
|
|
|
|
new_providers_def=() |
|
|
|
|
|
while [[ "${#providers[@]}" != 0 ]]; do |
|
|
|
|
|
provider="${providers[0]}" |
|
|
|
|
|
provider_def="${providers_def[0]}" |
|
|
|
|
|
providers=("${providers[@]:1}") |
|
|
|
|
|
providers_def=("${providers_def[@]:1}") |
|
|
|
|
|
type="$(get_service_type "$provider")" || true |
|
|
|
|
|
[ "$type" == "stub" ] && continue |
|
|
|
|
|
new_providers+=("$provider") |
|
|
|
|
|
new_providers_def+=("$provider_def") |
|
|
|
|
|
done |
|
|
|
|
|
providers=("${new_providers[@]}") |
|
|
|
|
|
providers_def=("${new_providers_def[@]}") |
|
|
|
|
|
|
|
|
if [ "${#providers[@]}" == 0 ]; then |
|
|
if [ "${#providers[@]}" == 0 ]; then |
|
|
err "Summoning a ${DARKBLUE}$relation_name${NORMAL} provider failed: none were found in charm store." |
|
|
err "Summoning a ${DARKBLUE}$relation_name${NORMAL} provider failed: none were found in charm store." |
|
|
return 1 |
|
|
return 1 |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
if [ "${#providers[@]}" -gt 1 ]; then |
|
|
if [ "${#providers[@]}" -gt 1 ]; then |
|
|
|
|
|
## if there are multiple providers (for instance |
|
|
|
|
|
## sql-database), there are some case where other |
|
|
|
|
|
## services will also summon a more specific |
|
|
|
|
|
## postgres-database, that will solve our |
|
|
|
|
|
## constraint. So we'd rather pass (and requeue) |
|
|
if [ -z "${summon_requeued[$service/$relation_name]}" ]; then |
|
|
if [ -z "${summon_requeued[$service/$relation_name]}" ]; then |
|
|
debug "Auto-summon ${DARKYELLOW}$service${NORMAL}" \ |
|
|
debug "Auto-summon ${DARKYELLOW}$service${NORMAL}" \ |
|
|
"--${DARKBLUE}$relation_name${NORMAL}--> ($DARKYELLOW""${providers[@]}""$NORMAL)"\ |
|
|
"--${DARKBLUE}$relation_name${NORMAL}--> ($DARKYELLOW""${providers[@]}""$NORMAL)"\ |
|
|
"(> 1 provider). Requeing." |
|
|
|
|
|
|
|
|
"(> 1 provider). Requeuing." |
|
|
summon+=("$service" "$relation_name" "$relation_def") ## re-queue it |
|
|
summon+=("$service" "$relation_name" "$relation_def") ## re-queue it |
|
|
summon_requeued["$service/$relation_name"]=1 |
|
|
summon_requeued["$service/$relation_name"]=1 |
|
|
continue |
|
|
continue |
|
|