in deploy/ansible/action_plugins/public_api.py [0:0]
def login(self, oauthServerUrl, apiEndpoint):
self._address = oauthServerUrl
self._client.client_cert, cert_temp_file = self.create_temp_file_from_encrypted(
self.get_full_path("cert_file.pem")
)
self._client.client_key, key_temp_file = self.create_temp_file_from_encrypted(
self.get_full_path("key_file")
)
status, headers, data = self.post("")
try:
if status in [200, 201, 204, 206]:
token = data.get("access_token")
self._address = apiEndpoint
if token is not None:
self._headers["Authorization"] = "Bearer " + token
else:
raise AnsibleActionFail(
"Unable to fetch CAL token. Exit code %s" % status
)
finally:
# Clean up temporary files
if self.get_full_path("cert_file.pem"):
os.remove(self.get_full_path("cert_file.pem"))
if self.get_full_path("key_file"):
os.remove(self.get_full_path("key_file"))
self._client.client_cert = None
self._client.client_key = None