summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Reporting/Storage/base.py
blob: 92cc3a68b429389baa5680ff73563ad6ca8392e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""
The base for all Storage backends
"""

import logging 

class StorageError(Exception):
    """Generic StorageError"""
    pass

class StorageImportError(StorageError):
    """Raised when a storage module fails to import"""
    pass

class StorageBase(object):
    """The base for all storages"""

    __rmi__ = ['Ping', 'GetExtra', 'GetCurrentEntry']

    def __init__(self, setup):
        """Do something here"""
        clsname = self.__class__.__name__
        self.logger = logging.getLogger(clsname)
        self.logger.debug("Loading %s storage" % clsname)
        self.setup = setup
        self.encoding = setup['encoding']

    def import_interaction(self, interaction):
        """Import the data into the backend"""
        raise NotImplementedError

    def validate(self):
        """Validate backend storage.  Should be called once when loaded"""
        raise NotImplementedError

    def shutdown(self):
        """Called at program exit"""
        pass

    def Ping(self):
        """Test for communication with reporting collector"""
        return "Pong"

    def GetExtra(self, client):
        """Return a list of extra entries for a client.  Minestruct"""
        raise NotImplementedError

    def GetCurrentEntry(self, client, e_type, e_name):
        """Get the current status of an entry on the client"""
        raise NotImplementedError