summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Reporting/Transport/base.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/Bcfg2/Reporting/Transport/base.py')
-rw-r--r--src/lib/Bcfg2/Reporting/Transport/base.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/lib/Bcfg2/Reporting/Transport/base.py b/src/lib/Bcfg2/Reporting/Transport/base.py
new file mode 100644
index 000000000..8488d0e46
--- /dev/null
+++ b/src/lib/Bcfg2/Reporting/Transport/base.py
@@ -0,0 +1,45 @@
+"""
+The base for all server -> collector Transports
+"""
+
+import os.path
+import logging
+
+class TransportError(Exception):
+ """Generic TransportError"""
+ pass
+
+class TransportImportError(TransportError):
+ """Raised when a transport fails to import"""
+ pass
+
+class TransportBase(object):
+ """The base for all transports"""
+
+ def __init__(self, setup):
+ """Do something here"""
+ clsname = self.__class__.__name__
+ self.logger = logging.getLogger(clsname)
+ self.logger.debug("Loading %s transport" % clsname)
+ self.data = os.path.join(setup['repo'], clsname.split()[-1])
+ self.setup = setup
+ self.timeout = 2
+
+ def start_monitor(self, collector):
+ """Called to start monitoring"""
+ raise NotImplementedError
+
+ def store(self, hostname, payload):
+ raise NotImplementedError
+
+ def fetch(self):
+ raise NotImplementedError
+
+ def shutdown(self):
+ """Called at program exit"""
+ pass
+
+ def rpc(self, method, *args, **kwargs):
+ """Send a request for data to the collector"""
+ raise NotImplementedError
+