Exemplo n.º 1
0
    def _dispatch(self, method, args):
        """Overridden method so that SimpleXMLRPCServer will
        resolve methods through this method rather than through
        inspection.

        @param method: marshalled method name from XMLRPC.
        @param args: marshalled arguments from XMLRPC.
        """

        # Only deal with method names that start with "Async."
        if not method.startswith(self.method_prefix):
            return maestro_api_error(['MESSAGE_METHOD_UNKNOWN', method])

        # Lookup synchronous version of the method
        synchronous_method_name = method[len(self.method_prefix):]
        if synchronous_method_name not in self.method_map:
            return maestro_api_error(['MESSAGE_METHOD_UNKNOWN', method])

        method = self.method_map[synchronous_method_name]

        # Check that we've got enough arguments before issuing a task ID.
        needed = argcounts[method.api]
        if len(args) != needed:
            return maestro_api_error([
                'MESSAGE_PARAMETER_COUNT_MISMATCH',
                self.method_prefix + method.api, needed,
                len(args)
            ])

        # Validate the session before proceeding
        session = args[0]
        if not auth_manager().is_session_valid(session):
            return maestro_api_error(['SESSION_INVALID', session])

        # create and execute the task, and return task_uuid
        return_type = getattr(method, 'return_type', None)
        task_uuid = MaestroTaskManager.create_task(method, args,
                                                   synchronous_method_name,
                                                   return_type,
                                                   synchronous_method_name,
                                                   session)
        return maestro_api_success(task_uuid)
Exemplo n.º 2
0
    def _dispatch(self, method, args):
        """Overridden method so that SimpleXMLRPCServer will
        resolve methods through this method rather than through
        inspection.

        @param method: marshalled method name from XMLRPC.
        @param args: marshalled arguments from XMLRPC.
        """

        # Only deal with method names that start with "Async."
        if not method.startswith(self.method_prefix):
            return maestro_api_error(['MESSAGE_METHOD_UNKNOWN', method])

        # Lookup synchronous version of the method
        synchronous_method_name = method[len(self.method_prefix):]
        if synchronous_method_name not in self.method_map:
            return maestro_api_error(['MESSAGE_METHOD_UNKNOWN', method])
        
        method = self.method_map[synchronous_method_name]

        # Check that we've got enough arguments before issuing a task ID.
        needed = argcounts[method.api]
        if len(args) != needed:
            return maestro_api_error(['MESSAGE_PARAMETER_COUNT_MISMATCH',
                                  self.method_prefix + method.api, needed,
                                  len(args)])

        # Validate the session before proceeding
        session = args[0]
        if not auth_manager().is_session_valid(session):
            return maestro_api_error(['SESSION_INVALID', session])

        # create and execute the task, and return task_uuid
        return_type = getattr(method, 'return_type', None)
        task_uuid = MaestroTaskManager.create_task(method, args,
                                                synchronous_method_name,
                                                return_type,
                                                synchronous_method_name,
                                                session)
        return maestro_api_success(task_uuid)
Exemplo n.º 3
0
 def task_get_by_name_label(self, session, name):
     return maestro_api_success(MaestroTaskManager.get_tasks_by_name(name))
Exemplo n.º 4
0
 def task_get_record(self, session, task_ref):
     task = MaestroTaskManager.get_task(task_ref)
     return maestro_api_success(task.get_record())
Exemplo n.º 5
0
 def task_get_all(self, session):
     tasks = MaestroTaskManager.get_all_tasks()
     return maestro_api_success(tasks)
Exemplo n.º 6
0
 def task_get_error_info(self, session, task_ref):
     task = MaestroTaskManager.get_task(task_ref)
     return maestro_api_success(task.error_info)
Exemplo n.º 7
0
 def task_get_progress(self, session, task_ref):
     task = MaestroTaskManager.get_task(task_ref)
     return maestro_api_success(task.progress)
Exemplo n.º 8
0
 def task_get_name_description(self, session, task_ref):
     task = MaestroTaskManager.get_task(task_ref)
     return maestro_api_success(task.name_description)
Exemplo n.º 9
0
 def task_get_by_name_label(self, session, name):
     return maestro_api_success(MaestroTaskManager.get_tasks_by_name(name))
Exemplo n.º 10
0
 def task_get_record(self, session, task_ref):
     task = MaestroTaskManager.get_task(task_ref)
     return maestro_api_success(task.get_record())
Exemplo n.º 11
0
 def task_get_all(self, session):
     tasks = MaestroTaskManager.get_all_tasks()
     return maestro_api_success(tasks)
Exemplo n.º 12
0
 def task_get_error_info(self, session, task_ref):
     task = MaestroTaskManager.get_task(task_ref)
     return maestro_api_success(task.error_info)
Exemplo n.º 13
0
 def task_get_progress(self, session, task_ref):
     task = MaestroTaskManager.get_task(task_ref)
     return maestro_api_success(task.progress)
Exemplo n.º 14
0
 def task_get_name_description(self, session, task_ref):
     task = MaestroTaskManager.get_task(task_ref)
     return maestro_api_success(task.name_description)