Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dns_huaweicloud.sh minor bug fixes #3887

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions dnsapi/dns_huaweicloud.sh
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,27 @@ _get_zoneid() {
fi
_debug "$h"
response=$(_get "${dns_api}/v2/zones?name=${h}")

if _contains "${response}" "id"; then
_debug "Get Zone ID Success."
_zoneid=$(echo "${response}" | _egrep_o "\"id\": *\"[^\"]*\"" | cut -d : -f 2 | tr -d \" | tr -d " ")
printf "%s" "${_zoneid}"
return 0
_debug "$response"
if _contains "${response}" '"id"'; then
zoneidlist=$(echo "${response}" | _egrep_o "\"id\": *\"[^\"]*\"" | cut -d : -f 2 | tr -d \" | tr -d " ")
zonenamelist=$(echo "${response}" | _egrep_o "\"name\": *\"[^\"]*\"" | cut -d : -f 2 | tr -d \" | tr -d " ")
_debug "Return Zone ID(s):"
_debug "${zoneidlist}"
_debug "Return Zone Name(s):"
_debug "${zonenamelist}"
zoneidnum=0
while read -r zonename; do
let zoneidnum++
_debug "Check Zone Name $zonename"
if [[ $zonename == $h. ]]; then
_debug "Get Zone ID Success."
_zoneid=$(echo "${zoneidlist}" | sed -n $zoneidnum"p")
_debug "ZoneID:"$_zoneid
printf "%s" "${_zoneid}"
return 0
fi
done <<< "$zonenamelist"
fi

i=$(_math "$i" + 1)
done
return 1
Expand All @@ -149,7 +162,7 @@ _get_recordset_id() {
export _H1="X-Auth-Token: ${_token}"

response=$(_get "${dns_api}/v2/zones/${_zoneid}/recordsets?name=${_domain}")
if _contains "${response}" "id"; then
if _contains "${response}" '"id"'; then
_id="$(echo "${response}" | _egrep_o "\"id\": *\"[^\"]*\"" | cut -d : -f 2 | tr -d \" | tr -d " ")"
printf "%s" "${_id}"
return 0
Expand Down