Skip to content

Commit 5a0ea34

Browse files
authored
Merge pull request #25 from mcornea/main
Use a new token in terminate_command
2 parents 5a0616f + 932cd73 commit 5a0ea34

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

quads_self_schedule.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,10 @@
101101
{%- set result = [] -%}
102102
{%- for asn in active_assignments.json -%}
103103
{%- set check_cmd = "curl -s https://{}/api/v3/assignments/{} | jq '.validated'".format(quads_api_server, asn.id) -%}
104-
{%- set term_cmd = "curl -s -k -X POST -H 'Authorization: Bearer {}' https://{}/api/v3/assignments/terminate/{} | \
105-
jq".format(quads_token, quads_api_server, asn.id) -%}
104+
{%- set login_cmd = "curl -s -k -X POST -u '{}:{}' https://{}/api/v3/login/ | jq -r '.auth_token'".format(
105+
quads_user_email, quads_password, quads_api_server) -%}
106+
{%- set term_cmd = 'curl -s -k -X POST -H "Authorization: Bearer $({login})" https://{server}/api/v3/assignments/terminate/{id} | jq'.format(
107+
login=login_cmd, server=quads_api_server, id=asn.id) -%}
106108
{%- set _ = asn.update({'check_status_command': check_cmd, 'terminate_command': term_cmd}) -%}
107109
{%- set _ = result.append(asn) -%}
108110
{%- endfor -%}
@@ -239,7 +241,8 @@
239241
ansible.builtin.set_fact:
240242
check_status_command: "curl -s https://{{ quads_api_server }}/api/v3/assignments/{{ assignment_id }} | jq '.validated'"
241243
terminate_command: >-
242-
curl -s -k -X POST -H 'Authorization: Bearer {{ quads_token }}'
244+
curl -s -k -X POST -H "Authorization: Bearer $(curl -s -k -X POST -u '{{ quads_user_email }}:{{ quads_password }}'
245+
https://{{ quads_api_server }}/api/v3/login/ | jq -r '.auth_token')"
243246
https://{{ quads_api_server }}/api/v3/assignments/terminate/{{ assignment_id }} | jq
244247
changed_when: false
245248

0 commit comments

Comments
 (0)