summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2005-12-06 18:50:52 +0000
committerNarayan Desai <desai@mcs.anl.gov>2005-12-06 18:50:52 +0000
commit592d406208fb387fc14b5ec2663804d9f6a22a49 (patch)
tree5a263a9e5144956b18460f91a62880beaf9450fa /src
parentccc99edf650eb11671792245efeb812a76ab0fd1 (diff)
downloadbcfg2-592d406208fb387fc14b5ec2663804d9f6a22a49.tar.gz
bcfg2-592d406208fb387fc14b5ec2663804d9f6a22a49.tar.bz2
bcfg2-592d406208fb387fc14b5ec2663804d9f6a22a49.zip
Re-add daemonize support to the server
Fix some pylint errors Add better error handling for function calls Add mesh-mode support for sshbase git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@1612 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src')
-rw-r--r--src/lib/Server/Component.py4
-rw-r--r--src/lib/Server/Plugins/Cfg.py10
-rw-r--r--src/lib/Server/Plugins/Pkgmgr.py2
-rw-r--r--src/lib/Server/Plugins/SSHbase.py7
-rw-r--r--src/lib/Server/Plugins/TCheetah.py7
-rw-r--r--src/lib/Server/Plugins/Vhost.py2
-rw-r--r--src/sbin/Bcfg2Server18
7 files changed, 39 insertions, 11 deletions
diff --git a/src/lib/Server/Component.py b/src/lib/Server/Component.py
index 57d0e1d89..d24f6576f 100644
--- a/src/lib/Server/Component.py
+++ b/src/lib/Server/Component.py
@@ -142,6 +142,10 @@ class Component(SSL.SSLServer,
response = dumps(response, methodresponse=1)
except Fault, fault:
response = dumps(fault)
+ except TypeError, t:
+ syslog(LOG_ERR, "Client %s called function %s with wrong argument count" %
+ (address[0], method))
+ response = dumps(Fault(4, t.args[0]))
except:
(trace, val, trb) = exc_info()
syslog(LOG_ERR, "Unexpected failure in handler")
diff --git a/src/lib/Server/Plugins/Cfg.py b/src/lib/Server/Plugins/Cfg.py
index c04c2e029..953401e7a 100644
--- a/src/lib/Server/Plugins/Cfg.py
+++ b/src/lib/Server/Plugins/Cfg.py
@@ -191,11 +191,13 @@ class ConfigFileEntry(object):
[entry.attrib.__setitem__(x,y) for (x,y) in self.metadata.iteritems()]
if self.paranoid:
entry.attrib['paranoid'] = 'true'
- try:
- entry.text = filedata
- except:
+ if entry.attrib['encoding'] == 'base64':
entry.text = b2a_base64(filedata)
- entry.attrib['encoding'] = 'base64'
+ else:
+ try:
+ entry.text = filedata
+ except:
+ syslog(LOG_ERR, "Failed to marshall file %s. Mark it as base64" % (entry.get('name')))
class Cfg(Plugin):
'''This generator in the configuration file repository for bcfg2'''
diff --git a/src/lib/Server/Plugins/Pkgmgr.py b/src/lib/Server/Plugins/Pkgmgr.py
index f3b3aa144..5ce31750c 100644
--- a/src/lib/Server/Plugins/Pkgmgr.py
+++ b/src/lib/Server/Plugins/Pkgmgr.py
@@ -84,7 +84,7 @@ class Pkgmgr(Plugin):
pkglist = self.pkgdir["%s.xml" % metadata.hostname]
if pkglist.packages.has_key(pkgname):
pkginfo = pkglist.packages[pkgname]
- [entry.attrib.__setitem__(x, pkginfo[x]) for x in pkginfo]
+ [entry.attrib.__setitem__(field, pkginfo[field]) for field in pkginfo]
return
elif not self.pkgdir.entries.has_key("%s.xml" % metadata.image):
self.LogError("Pkgmgr: no package index for image %s" % metadata.image)
diff --git a/src/lib/Server/Plugins/SSHbase.py b/src/lib/Server/Plugins/SSHbase.py
index 1d378f1f2..cc93cc1c3 100644
--- a/src/lib/Server/Plugins/SSHbase.py
+++ b/src/lib/Server/Plugins/SSHbase.py
@@ -50,6 +50,13 @@ class SSHbase(Plugin):
prefix + '/etc/ssh/ssh_host_key':self.build_hk,
prefix + '/etc/ssh/ssh_host_key.pub':self.build_hk}}
self.ipcache = {}
+ self.__rmi__ = ['GetPubKeys']
+
+ def GetPubKeys(self, client):
+ '''Export public key data'''
+ if not hasattr(self, 'static_skn'):
+ self.cache_skn()
+ return self.static_skn
def get_ipcache_entry(self, client):
'''build a cache of dns results'''
diff --git a/src/lib/Server/Plugins/TCheetah.py b/src/lib/Server/Plugins/TCheetah.py
index f39ebbad0..1ebdb6c94 100644
--- a/src/lib/Server/Plugins/TCheetah.py
+++ b/src/lib/Server/Plugins/TCheetah.py
@@ -60,11 +60,6 @@ class TCheetah(Plugin):
'''Dispatch fetch calls to the correct object'''
self.entries[entry.get('name')].BuildFile(entry, metadata)
- def MapName(self, name):
- '''MapName finds the object corresponding to a particular file
- the DirShadow MapName method maps filenames literally'''
- return name
-
def HandleEvent(self, event):
'''Unified FAM event handler for DirShadow'''
#print "got event %s %s %s" % ( event.code2str(), event.filename, event.requestID)
@@ -72,7 +67,7 @@ class TCheetah(Plugin):
if event.filename[0] == '/':
return
epath = "".join([self.data, self.handles[event.requestID], event.filename])
- identifier = self.MapName(epath[len(self.data):])
+ identifier = epath[len(self.data):]
if action in ['exists', 'created']:
if isdir(epath):
self.AddDirectoryMonitor(epath[len(self.data):])
diff --git a/src/lib/Server/Plugins/Vhost.py b/src/lib/Server/Plugins/Vhost.py
index 43c1b8ca5..5c38cd19e 100644
--- a/src/lib/Server/Plugins/Vhost.py
+++ b/src/lib/Server/Plugins/Vhost.py
@@ -26,6 +26,7 @@ class VhostFile(SingleXMLFileBacked):
sitesav = "/etc/apache2/sites-available/"
def __init__(self, name, fam):
+ self.meta = Element('dummy')
self.dispatch = {'ConfigFile':{'/etc/default/apache2':self.generateApacheDefault},
'Service':{'apache2':self.generateApacheSvc}}
SingleXMLFileBacked.__init__(self, name, fam)
@@ -33,6 +34,7 @@ class VhostFile(SingleXMLFileBacked):
self.servers = []
self.vhosts = {}
+
def Index(self):
'''Build vhost data structures'''
self.meta = XML(self.data)
diff --git a/src/sbin/Bcfg2Server b/src/sbin/Bcfg2Server
index 8b2423355..d8e224369 100644
--- a/src/sbin/Bcfg2Server
+++ b/src/sbin/Bcfg2Server
@@ -17,6 +17,7 @@ from xmlrpclib import Fault
from socket import gethostbyaddr, herror
from lxml.etree import XML, Element, tostring
from M2Crypto.SSL import SSLError
+import os, sys
def dgetopt(arglist, opt, vopt):
'''parse options into a dictionary'''
@@ -174,6 +175,23 @@ if __name__ == '__main__':
ssetup = dgetopt(argv[1:], options, doptions)
if not ssetup['configfile']:
ssetup['configfile'] = '/etc/bcfg2.conf'
+ if ssetup['daemon']:
+ if os.fork() != 0:
+ os._exit(0)
+ os.setsid() # Create new session
+ pid = os.fork()
+ if pid != 0:
+ pidfile = open(ssetup['daemon'], "w")
+ pidfile.write("%i" % pid)
+ pidfile.close()
+ os._exit(0)
+ os.chdir("/")
+ os.umask(0)
+ null = open("/dev/null", "w+")
+ os.dup2(null.fileno(), sys.__stdin__.fileno())
+ os.dup2(null.fileno(), sys.__stdout__.fileno())
+ os.dup2(null.fileno(), sys.__stderr__.fileno())
+
s = Bcfg2(ssetup)
while not s.shut:
try: