def off_parsed(args): """ Handles the appropriate execution of an 'Off' mode request given the provided command line arguments. """ data = { 'application': args.application if args.application else '' } try: result = akrrrestclient.put( '/resources/{0}/off'.format(args.resource), data=data) if result.status_code == 200: message = 'Successfully disabled {0} -> {1}.\n{2}' if args.application and args.resource \ else 'Successfully disabled all applications on {0}.\n{1}' parameters = (args.application, args.resource, result.text) if args.application and args.resource \ else (args.resource, result.text) log.info(message, *parameters) else: log.error( 'something went wrong. {0}:{1}', result.status_code, result.text) except StandardError, e: log.error(''' An error occured while communicating with the REST API. {0}: {1} ''', e.args[0] if len(e.args) > 0 else '', e.args[1] if len(e.args) > 1 else '')
def process_request(request): method = request[0] url = request[1] if method not in RESTCompleter.keywords: raise AssertionError("Invalid method. Please provide a valid method to continue.") if len(url) < 1: raise AssertionError("Must supply a url.") akrrrestclient.get_token() if method == "GET": return akrrrestclient.get(url) elif method == "PUT": return akrrrestclient.put(url) elif method == "POST": return akrrrestclient.post(url) elif method == "DELETE": return akrrrestclient.delete(url)
def process_request(request): method = request[0] url = request[1] if method not in RESTCompleter.keywords: raise AssertionError( "Invalid method. Please provide a valid method to continue.") if len(url) < 1: raise AssertionError("Must supply a url.") akrrrestclient.get_token() if method == 'GET': return akrrrestclient.get(url) elif method == 'PUT': return akrrrestclient.put(url) elif method == 'POST': return akrrrestclient.post(url) elif method == 'DELETE': return akrrrestclient.delete(url)
if msg_body!=msg_body0: print "\n\n"+msg_body print tail_msg, sys.stdout.flush() else: print "\r"+tail_msg, sys.stdout.flush() msg_body0=copy.deepcopy(msg_body) if response_json["data"]["queue"]=="completed_tasks": break #try to update: try: payload={'next_check_time':''} r = akrrrestclient.put('/active_tasks/'+str(task_id), data=payload) except: pass time.sleep(5) ############################################################################################### #analysing the output log("\n\n") log("#"*80) log("Test job is completed analyzing output\n",highlight="ok") r = akrrrestclient.get('/tasks/'+str(task_id)) if r.status_code!=200: logerr("Can not get information about task\n"+ "See full error report below",
if msg_body!=msg_body0: print "\n\n"+msg_body print tail_msg, sys.stdout.flush() else: print "\r"+tail_msg, sys.stdout.flush() msg_body0=copy.deepcopy(msg_body) if response_json["data"]["queue"]=="completed_tasks": break #try to update: try: payload={'next_check_time':''} r = akrrrestclient.put('/active_tasks/'+str(task_id), data=payload) except: pass time.sleep(5) ############################################################################################### #analysing the output log("\n\nTest job is completed analyzing output\n",highlight="ok") r = akrrrestclient.get('/tasks/'+str(task_id)) if r.status_code!=200: logerr("Can not get information about task\n"+ "See full error report below", "AKRR server response:\n"+r.text) exit() completed_tasks=r.json()['data']['data']['completed_tasks'] akrr_xdmod_instanceinfo=r.json()['data']['data']['akrr_xdmod_instanceinfo'] akrr_errmsg=r.json()['data']['data']['akrr_errmsg']