def _check_and_log_response(self, resp): """Checks scheduler return status, raises Error in case of unexpected response. Arguments: resp -- scheduler response object. Raises Error in case of unexpected response status. """ message = format_response(resp) if resp.responseCode == ResponseCode.OK: log.debug(message) else: raise self.Error(message)
def _get_tasks(self, query): """Gets tasks directly via SchedulerProxy. Arguments: query -- TaskQuery instance. Returns a list of tasks. """ try: resp = self._scheduler.getTasksWithoutConfigs(query) except IOError as e: log.error('IO Exception during scheduler call: %s' % e) return [] tasks = [] if resp.responseCode == ResponseCode.OK: tasks = resp.result.scheduleStatusResult.tasks log.debug(format_response(resp)) return tasks
def get_tasks(self, instance_ids=None): """Gets tasks from the scheduler. Arguments: instance_ids -- optional list of instance IDs to query for. Returns a list of tasks. """ log.debug("Querying instance statuses: %s" % instance_ids) try: resp = self._scheduler.getTasksWithoutConfigs(self._query_factory(instance_ids)) except IOError as e: log.error("IO Exception during scheduler call: %s" % e) return [] tasks = [] if resp.responseCode == ResponseCode.OK: tasks = resp.result.scheduleStatusResult.tasks log.debug(format_response(resp)) return tasks
def get_tasks(self, instance_ids=None): """Gets tasks from the scheduler. Arguments: instance_ids -- optional list of instance IDs to query for. Returns a list of tasks. """ log.debug('Querying instance statuses: %s' % instance_ids) try: resp = self._scheduler.getTasksWithoutConfigs( self._query_factory(instance_ids)) except IOError as e: log.error('IO Exception during scheduler call: %s' % e) return [] tasks = [] if resp.responseCode == ResponseCode.OK: tasks = resp.result.scheduleStatusResult.tasks log.debug(format_response(resp)) return tasks
def test_format_response_with_details(self): resp = Response(responseCode=ResponseCode.ERROR, details=[ResponseDetail(message='Error')]) formatted = base.format_response(resp) assert formatted == 'Response from scheduler: ERROR (message: Error)'
def _get_tasks(self, task_query): resp = self._scheduler.getTasksWithoutConfigs(task_query) log.info(format_response(resp)) if resp.responseCode != ResponseCode.OK: return [] return resp.result.scheduleStatusResult.tasks
def test_format_response_with_message(self): resp = Response(responseCode=ResponseCode.ERROR, messageDEPRECATED='Error') formatted = base.format_response(resp) assert formatted == 'Response from scheduler: ERROR (message: Error)'