def get_execution_stats(self, exec_id): auth_token = self.authenticate() hdr = {'X-Auth-Token': auth_token} url = Orchconstants().get_st2_executions_get_url(self.server) \ + '/' + exec_id resp = requests.get(url, headers=hdr, verify=False) return (resp.status_code, resp.text)
def authenticate(self): server = self.server url = Orchconstants().get_st2_token_url(server) req = requests.post(url, auth=HTTPBasicAuth(self.username, self.passwd), verify=False) response = req.json() return response['token']
def delete_action(self, id, req_data): auth_token = self.authenticate() url = Orchconstants().get_st2_action_list_url(self.server) + '/' + id hdr = {'X-Auth-Token': auth_token, 'Content-Type': 'application/json'} resp = requests.delete(url, data=json.dumps(req_data), headers=hdr, verify=False) return (resp.status_code, resp.text)
def list_actions(self, pack_name=''): auth_token = self.authenticate() headers = {'X-Auth-Token': auth_token} url = Orchconstants().get_st2_action_list_url(self.server) req = requests.get(url, headers=headers, verify=False) req = req.json() action_dict = {} if pack_name == '': return req else: for elem in req: if elem['runner_type'] != 'mistral-v2': continue if (elem['pack'] != pack_name): continue else: action_dict[elem['ref']] = elem return action_dict
def get_action(self, id, pack_name=''): auth_token = self.authenticate() headers = {'X-Auth-Token': auth_token} url = Orchconstants().get_st2_action_list_url(self.server) + '/' + id response = requests.get(url, headers=headers, verify=False) return response.status_code, response.json()
def delete_action(self, id): auth_token = self.authenticate() url = Orchconstants().get_st2_action_list_url(self.server) + '/' + id hdr = {'X-Auth-Token': auth_token} resp = requests.delete(url, headers=hdr, verify=False) return (resp.status_code, resp.text)