summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-09-05 11:29:42 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-09-06 07:53:40 -0400
commit9b10ec5537630fb38f8ece6de146e1b884b58ddf (patch)
tree038fcf1517c317afceefd37fe5429428b3b8e38d /src
parentcd7b0b3d40a5a340d5b47819f94a21c9faf23120 (diff)
downloadbcfg2-9b10ec5537630fb38f8ece6de146e1b884b58ddf.tar.gz
bcfg2-9b10ec5537630fb38f8ece6de146e1b884b58ddf.tar.bz2
bcfg2-9b10ec5537630fb38f8ece6de146e1b884b58ddf.zip
improving plugin development docs
Diffstat (limited to 'src')
-rw-r--r--src/lib/Bcfg2/Proxy.py22
-rw-r--r--src/lib/Bcfg2/Server/Plugin.py34
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Probes.py2
3 files changed, 21 insertions, 37 deletions
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])