Skip to content

Commit

Permalink
replace ctrl_ip with du_fqdn for calling management plane APIs (#248)
Browse files Browse the repository at this point in the history
* replace ctrl_ip with du_fqdn for calling management plane APIs

* add the deauth role to us du_fqdn, fix multi-region support to use the correct fqdn
  • Loading branch information
Jeremy Brooks authored Nov 19, 2019
1 parent 5c0fad3 commit 16471bc
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion pf9-express
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ service_id=`curl -X GET -H "X-Auth-Token: ${token}" https://${du_url}/keystone/v
region_url=`curl -X GET -H "X-Auth-Token: ${token}" https://${du_url}/keystone/v3/endpoints?service_id=${service_id} 2>/dev/null | jq --arg du_region "${du_region}" '.endpoints[] | select(.region_id==$du_region and .interface=="public")' | jq '.url' | awk '{print substr($0,2,length($0)-9)}' | cut -d '/' -f3`

## assign/validate ctrl_ip from config file and resolve IP for ctrl_hostname
ctrl_hostname=${du_url}
ctrl_hostname=${region_url}
tmp_ip=$(ping -c 1 ${region_url} | grep PING | cut -d ' ' -f3)
ctrl_ip=${tmp_ip:1:((${#tmp_ip}-2))}

Expand Down
4 changes: 2 additions & 2 deletions roles/k8s-cluster-attach/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
- debug: msg="TOKEN = {{api_token.stdout.strip()}}"

- block:
- debug: msg="URI = https://{{ctrl_ip}}/qbert/v1/clusters/{{cluster_uuid}}/attach"
- debug: msg="URI = https://{{du_fqdn}}/qbert/v1/clusters/{{cluster_uuid}}/attach"
- debug: msg="BODY = {{host_id.stdout.strip()}}"

- name: "Attaching to Cluster : UUID = {{cluster_uuid}}"
uri:
url: "https://{{ctrl_ip}}/qbert/v1/clusters/{{cluster_uuid}}/attach"
url: "https://{{du_fqdn}}/qbert/v1/clusters/{{cluster_uuid}}/attach"
method: POST
body: "['{{host_id.stdout.strip()}}']"
body_format: json
Expand Down
2 changes: 1 addition & 1 deletion roles/map-role/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@

- name: "Assigning Role - {{rolename}}"
uri:
url: "https://{{ctrl_ip}}/resmgr/v1/hosts/{{host_id.stdout.strip()}}/roles/{{rolename}}"
url: "https://{{du_fqdn}}/resmgr/v1/hosts/{{host_id.stdout.strip()}}/roles/{{rolename}}"
method: PUT
body: "{{role_json.stdout.strip()}}"
body_format: json
Expand Down
10 changes: 5 additions & 5 deletions roles/pf9-deauth/files/wait_for_agent_deauth.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ basedir=$(dirname $0)
TIMEOUT=900

usage() {
echo -e "usage: `basename $0` <ctrl_ip> <host_id> <admin_user> <admin_password>"
echo -e "usage: `basename $0` <du_fqdn> <host_id> <admin_user> <admin_password>"
exit 1
}

Expand All @@ -18,13 +18,13 @@ assert() {

## validate commandline
if [ $# -lt 4 ]; then usage; fi
ctrl_ip=${1}
du_fqdn=${1}
host_id=${2}
admin_user=${3}
admin_password=${4}

## set auth url
auth_url=https://${ctrl_ip}/keystone/v3
auth_url=https://${du_fqdn}/keystone/v3

####################################################################################################
# Get Keystone Token
Expand All @@ -42,11 +42,11 @@ start_time=`date +%s`
elapsedTime=0
while [ ${elapsedTime} -lt ${TIMEOUT} ]; do
http_status=$(curl --write-out %{http_code} --output /dev/null --silent -k -H "Content-Type: application/json" -H "X-Auth-Token: ${token}" \
https://${ctrl_ip}/resmgr/v1/hosts/${host_id})
https://${du_fqdn}/resmgr/v1/hosts/${host_id})

if [ ${http_status} -eq 200 ]; then
role_status=$(curl -k -H "Content-Type: application/json" -H "X-Auth-Token: ${token}" \
https://${ctrl_ip}/resmgr/v1/hosts/${host_id} 2>/dev/null | python -m json.tool | grep role_status)
https://${du_fqdn}/resmgr/v1/hosts/${host_id} 2>/dev/null | python -m json.tool | grep role_status)
if [ -n "${role_status}" ]; then
role_status=$(echo ${role_status} | cut -d : -f2 | sed -e 's/\"//g' | sed -e 's/,//g' | sed -e 's/ //g')
fi
Expand Down
4 changes: 2 additions & 2 deletions roles/pf9-deauth/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

- name: delete host from resmgr database
uri:
url: "https://{{ctrl_ip}}/resmgr/v1/hosts/{{host_id.stdout.strip()}}"
url: "https://{{du_fqdn}}/resmgr/v1/hosts/{{host_id.stdout.strip()}}"
method: DELETE
validate_certs: False
headers:
Expand All @@ -29,7 +29,7 @@
- debug: var=uri_result

- name: wait for deauthorization to complete
script: "files/wait_for_agent_deauth.sh {{ctrl_ip}} {{host_id.stdout.strip()}} {{du_username}} \'{{du_password}}\'"
script: "files/wait_for_agent_deauth.sh {{du_fqdn}} {{host_id.stdout.strip()}} {{du_username}} \'{{du_password}}\'"
register: waitfor_agent
- debug: var=waitfor_agent

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ TIMEOUT=900
flag_k8s=0

usage() {
echo -e "usage: `basename $0` <ctrl_ip> <host_id> <admin_user> <admin_password>"
echo -e "usage: `basename $0` <du_fqdn> <host_id> <admin_user> <admin_password>"
exit 1
}

Expand All @@ -19,7 +19,7 @@ assert() {

## validate commandline
if [ $# -lt 4 ]; then usage; fi
ctrl_ip=${1}
du_fqdn=${1}
host_id=${2}
admin_user=${3}
admin_password=${4}
Expand All @@ -32,7 +32,7 @@ if [ $# -eq 5 -a "${5}" == "k8s" ]; then
fi

## set auth url
auth_url=https://${ctrl_ip}/keystone/v3
auth_url=https://${du_fqdn}/keystone/v3

####################################################################################################
# Get Keystone Token
Expand All @@ -51,7 +51,7 @@ start_time=`date +%s`
elapsedTime=0
while [ ${elapsedTime} -lt ${TIMEOUT} ]; do
role_status=$(curl -k -H "Content-Type: application/json" -H "X-Auth-Token: ${token}" \
https://${ctrl_ip}/resmgr/v1/hosts/${host_id} 2>/dev/null | python -m json.tool | grep role_status)
https://${du_fqdn}/resmgr/v1/hosts/${host_id} 2>/dev/null | python -m json.tool | grep role_status)
if [ -n "${role_status}" ]; then
role_status=$(echo ${role_status} | cut -d : -f2 | sed -e 's/\"//g' | sed -e 's/,//g' | sed -e 's/ //g')
fi
Expand Down
4 changes: 2 additions & 2 deletions roles/wait-for-convergence/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
flags: ""
when: flags is undefined
- debug: var=flags
- debug: msg="running wait_for_agent_convergence.sh {{ctrl_ip}} {{host_id.stdout.strip()}} {{du_username}} ******** <{{flags}}>"
- debug: msg="running wait_for_agent_convergence.sh {{du_fqdn}} {{host_id.stdout.strip()}} {{du_username}} ******** <{{flags}}>"

- name: wait for pf9-hostagent to converge
script: "files/wait_for_agent_convergence.sh {{ctrl_ip}} {{host_id.stdout.strip()}} {{du_username}} \'{{du_password}}\' {{flags}}"
script: "files/wait_for_agent_convergence.sh {{du_fqdn}} {{host_id.stdout.strip()}} {{du_username}} \'{{du_password}}\' {{flags}}"
register: waitfor_agent

- debug: var=waitfor_agent
Expand Down

0 comments on commit 16471bc

Please sign in to comment.