Ejemplo n.º 1
0
  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)
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
  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
Ejemplo n.º 4
0
    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
Ejemplo n.º 5
0
    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
Ejemplo n.º 6
0
 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)'
Ejemplo n.º 7
0
 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)'
Ejemplo n.º 8
0
 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
Ejemplo n.º 9
0
 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
Ejemplo n.º 10
0
 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)'