Commit 00e219e4 authored by Antoine Millet's avatar Antoine Millet
Browse files

Added Reporter class, simple helper for return state of some commands.

parent 96a76ac9
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -12,6 +12,28 @@ def listed(func):
    func.__listed__ = True
    return func


class Reporter(object):
    '''
    Simple class used to report error, warning and success of command execution.
    '''

    def __init__(self):
        self._reports = {}

    def get_dict(self):
        return self._reports.copy()

    def success(self, oid, message):
        self._reports[oid] = ('success', message)
        
    def warn(self, oid, message):
        self._reports[oid] = ('warn', message)
        
    def error(self, oid, message):
        self._reports[oid] = ('error', message)


class CCHandler(RpcHandler):
    '''
    Base class for handlers of CloudControl server.