From 9b10ec5537630fb38f8ece6de146e1b884b58ddf Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Wed, 5 Sep 2012 11:29:42 -0400 Subject: improving plugin development docs --- src/lib/Bcfg2/Proxy.py | 22 +--------------------- src/lib/Bcfg2/Server/Plugin.py | 34 +++++++++++++++++++--------------- src/lib/Bcfg2/Server/Plugins/Probes.py | 2 +- 3 files changed, 21 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/lib/Bcfg2/Proxy.py b/src/lib/Bcfg2/Proxy.py index 5a5129939..9bd239e26 100644 --- a/src/lib/Bcfg2/Proxy.py +++ b/src/lib/Bcfg2/Proxy.py @@ -299,6 +299,7 @@ class XMLRPCTransport(xmlrpclib.Transport): def request(self, host, handler, request_body, verbose=0): """Send request to server and return response.""" + print "len(request_body) = %s" % len(request_body) try: conn = self.send_request(host, handler, request_body, False) response = conn.getresponse() @@ -331,27 +332,6 @@ class XMLRPCTransport(xmlrpclib.Transport): self.send_content(conn, request_body) return conn - def _get_response(self, fd, length): - # read response from input file/socket, and parse it - recvd = 0 - - p, u = self.getparser() - - while recvd < length: - rlen = min(length - recvd, 1024) - response = fd.read(rlen) - recvd += len(response) - if not response: - break - if self.verbose: - print("body:", repr(response), len(response)) - p.feed(response) - - fd.close() - p.close() - - return u.close() - def ComponentProxy(url, user=None, password=None, key=None, cert=None, ca=None, allowedServerCNs=None, timeout=90, retries=3, delay=1): diff --git a/src/lib/Bcfg2/Server/Plugin.py b/src/lib/Bcfg2/Server/Plugin.py index c6476eb90..80537c200 100644 --- a/src/lib/Bcfg2/Server/Plugin.py +++ b/src/lib/Bcfg2/Server/Plugin.py @@ -168,9 +168,12 @@ class PluginDatabaseModel(object): class Generator(object): - """Generator plugins contribute to literal client configurations.""" + """Generator plugins contribute to literal client + configurations.""" + def HandlesEntry(self, entry, metadata): - """This is the slow path method for routing configuration binding requests.""" + """This is the slow path method for routing configuration + binding requests.""" return False def HandleEntry(self, entry, metadata): @@ -187,20 +190,21 @@ class Structure(object): class Metadata(object): """Signal metadata capabilities for this plugin""" - def add_client(self, client_name): - """Add client.""" - pass + def viz(self, hosts, bundles, key, only_client, colors): + """Create viz str for viz admin mode.""" + return '' - def remove_client(self, client_name): - """Remove client.""" + def set_version(self, client, version): pass - def viz(self, hosts, bundles, key, colors): - """Create viz str for viz admin mode.""" + def set_profile(self, client, profile, address): pass - def _handle_default_event(self, event): - pass + def resolve_client(self, address, cleanup_cache=False): + return address[1] + + def AuthenticateConnection(self, cert, user, password, address): + raise NotImplementedError def get_initial_metadata(self, client_name): raise NotImplementedError @@ -225,13 +229,13 @@ class Connector(object): class Probing(object): """Signal probe capability for this plugin.""" - def GetProbes(self, _): + def GetProbes(self, metadata): """Return a set of probes for execution on client.""" - return [] + raise NotImplementedError - def ReceiveData(self, _, dummy): + def ReceiveData(self, metadata, datalist): """Receive probe results pertaining to client.""" - pass + raise NotImplementedError class Statistics(Plugin): diff --git a/src/lib/Bcfg2/Server/Plugins/Probes.py b/src/lib/Bcfg2/Server/Plugins/Probes.py index 056521ce7..fd80cfbe4 100644 --- a/src/lib/Bcfg2/Server/Plugins/Probes.py +++ b/src/lib/Bcfg2/Server/Plugins/Probes.py @@ -141,7 +141,7 @@ class ProbeSet(Bcfg2.Server.Plugin.EntrySet): for (name, entry) in list(build.items()): probe = lxml.etree.Element('probe') - probe.set('name', name.split('/')[-1]) + probe.set('name', os.path.basename(name)) probe.set('source', self.plugin_name) probe.text = entry.data match = self.bangline.match(entry.data.split('\n')[0]) -- cgit v1.2.3-1-g7c22