summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/Server/Plugins')
-rw-r--r--src/lib/Server/Plugins/Account.py2
-rw-r--r--src/lib/Server/Plugins/Base.py3
-rw-r--r--src/lib/Server/Plugins/Bundler.py3
-rw-r--r--src/lib/Server/Plugins/Hostbase.py4
-rw-r--r--src/lib/Server/Plugins/Metadata.py3
-rw-r--r--src/lib/Server/Plugins/SGenshi.py2
-rw-r--r--src/lib/Server/Plugins/SSHbase.py2
-rw-r--r--src/lib/Server/Plugins/Vhost.py116
8 files changed, 11 insertions, 124 deletions
diff --git a/src/lib/Server/Plugins/Account.py b/src/lib/Server/Plugins/Account.py
index 8599c028a..8cab47b01 100644
--- a/src/lib/Server/Plugins/Account.py
+++ b/src/lib/Server/Plugins/Account.py
@@ -3,7 +3,7 @@ __revision__ = '$Revision$'
import Bcfg2.Server.Plugin
-class Account(Bcfg2.Server.Plugin.Plugin):
+class Account(Bcfg2.Server.Plugin.GeneratorPlugin):
'''This module generates account config files,
based on an internal data repo:
static.(passwd|group|limits.conf) -> static entries
diff --git a/src/lib/Server/Plugins/Base.py b/src/lib/Server/Plugins/Base.py
index 2a849236f..3a06ba641 100644
--- a/src/lib/Server/Plugins/Base.py
+++ b/src/lib/Server/Plugins/Base.py
@@ -5,7 +5,8 @@ import Bcfg2.Server.Plugin
import copy
import lxml.etree
-class Base(Bcfg2.Server.Plugin.Plugin, Bcfg2.Server.Plugin.XMLDirectoryBacked):
+class Base(Bcfg2.Server.Plugin.StructurePlugin,
+ Bcfg2.Server.Plugin.XMLDirectoryBacked):
'''This Structure is good for the pile of independent configs needed for most actual systems'''
__name__ = 'Base'
__version__ = '$Id$'
diff --git a/src/lib/Server/Plugins/Bundler.py b/src/lib/Server/Plugins/Bundler.py
index 597421699..f771d4016 100644
--- a/src/lib/Server/Plugins/Bundler.py
+++ b/src/lib/Server/Plugins/Bundler.py
@@ -3,7 +3,8 @@ __revision__ = '$Revision$'
import copy, lxml.etree, Bcfg2.Server.Plugin
-class Bundler(Bcfg2.Server.Plugin.Plugin, Bcfg2.Server.Plugin.XMLDirectoryBacked):
+class Bundler(Bcfg2.Server.Plugin.StructurePlugin,
+ Bcfg2.Server.Plugin.XMLDirectoryBacked):
'''The bundler creates dependent clauses based on the bundle/translation scheme from bcfg1'''
__name__ = 'Bundler'
__version__ = '$Id$'
diff --git a/src/lib/Server/Plugins/Hostbase.py b/src/lib/Server/Plugins/Hostbase.py
index dcd77f16a..05840f218 100644
--- a/src/lib/Server/Plugins/Hostbase.py
+++ b/src/lib/Server/Plugins/Hostbase.py
@@ -5,7 +5,7 @@ import sys, os
os.environ['DJANGO_SETTINGS_MODULE'] = 'Bcfg2.Server.Hostbase.settings'
from lxml.etree import Element, SubElement
from syslog import syslog, LOG_INFO
-from Bcfg2.Server.Plugin import Plugin, PluginExecutionError, PluginInitError, DirectoryBacked
+from Bcfg2.Server.Plugin import StructurePlugin, PluginExecutionError, PluginInitError, DirectoryBacked
from time import strftime
from sets import Set
from django.template import Context, loader
@@ -37,7 +37,7 @@ import cStringIO
## '''This function is called when underlying data has changed'''
## pass
-class Hostbase(Plugin):
+class Hostbase(StructurePlugin):
'''The Hostbase plugin handles host/network info'''
__name__ = 'Hostbase'
__version__ = '$Id$'
diff --git a/src/lib/Server/Plugins/Metadata.py b/src/lib/Server/Plugins/Metadata.py
index b24dd0c66..f79aa4d03 100644
--- a/src/lib/Server/Plugins/Metadata.py
+++ b/src/lib/Server/Plugins/Metadata.py
@@ -74,7 +74,8 @@ class ProbeSet(Bcfg2.Server.Plugin.EntrySet):
return ret
-class Metadata(Bcfg2.Server.Plugin.Plugin):
+class Metadata(Bcfg2.Server.Plugin.MetadataPlugin,
+ Bcfg2.Server.Plugin.ProbingPlugin):
'''This class contains data for bcfg2 server metadata'''
__version__ = '$Id$'
__author__ = 'bcfg-dev@mcs.anl.gov'
diff --git a/src/lib/Server/Plugins/SGenshi.py b/src/lib/Server/Plugins/SGenshi.py
index 10559733c..bf063b884 100644
--- a/src/lib/Server/Plugins/SGenshi.py
+++ b/src/lib/Server/Plugins/SGenshi.py
@@ -44,7 +44,7 @@ class SGenshiEntrySet(Bcfg2.Server.Plugin.EntrySet):
logger.error("SGenshi: Failed to template file %s" % entry.name)
return ret
-class SGenshi(SGenshiEntrySet, Bcfg2.Server.Plugin.Plugin):
+class SGenshi(SGenshiEntrySet, Bcfg2.Server.Plugin.StructurePlugin):
'''The SGenshi plugin provides templated structures'''
__name__ = 'SGenshi'
__version__ = '$Id$'
diff --git a/src/lib/Server/Plugins/SSHbase.py b/src/lib/Server/Plugins/SSHbase.py
index 005b52988..cdd95181b 100644
--- a/src/lib/Server/Plugins/SSHbase.py
+++ b/src/lib/Server/Plugins/SSHbase.py
@@ -4,7 +4,7 @@ __revision__ = '$Revision$'
import binascii, os, socket
import Bcfg2.Server.Plugin
-class SSHbase(Bcfg2.Server.Plugin.Plugin, Bcfg2.Server.Plugin.DirectoryBacked):
+class SSHbase(Bcfg2.Server.Plugin.GeneratorPlugin, Bcfg2.Server.Plugin.DirectoryBacked):
'''The sshbase generator manages ssh host keys (both v1 and v2)
for hosts. It also manages the ssh_known_hosts file. It can
integrate host keys from other management domains and similarly
diff --git a/src/lib/Server/Plugins/Vhost.py b/src/lib/Server/Plugins/Vhost.py
deleted file mode 100644
index 5c38cd19e..000000000
--- a/src/lib/Server/Plugins/Vhost.py
+++ /dev/null
@@ -1,116 +0,0 @@
-'''
-#-------------------------------------------
-# Script Name: vhost.py
-# Script Version: 1.0
-# Date: 20 July 2005
-# Author: Scott R Behrens
-# Description: opens a request file, genereates a vhost httpd.conf file, and establishes symlinks
-# Revision History:
-# 1.0/<20-7-2005>: orignal version
-# 1.1/<20-7-2005>: now genreates multiple files based on XML document
-# 1.2/<20-8-2005>: generates one file encoded in base64
-# 1.3/<06-9-2005>: cleanup some pylint and style problems
-#-------------------------------------------
-'''
-__revision__ = '$Revision$'
-
-import base64
-from copy import deepcopy
-from lxml.etree import XML, Element, SubElement
-from socket import gethostbyname
-from Bcfg2.Server.Plugin import Plugin, PluginExecutionError, SingleXMLFileBacked
-
-class VhostFile(SingleXMLFileBacked):
- '''The Vhost file contains webserver vhost configuration elements'''
- sitesen = "/etc/apache2/sites-enabled/"
- 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)
- self.http = open('/disks/bcfg2/Vhost/default.httpd', 'r').readlines()
- self.servers = []
- self.vhosts = {}
-
-
- def Index(self):
- '''Build vhost data structures'''
- self.meta = XML(self.data)
- self.servers = [serv.get('name') for serv in self.meta.findall('server')]
- self.vhosts = {}
- for server in self.meta.findall("server"):
- for vhost in server.findall("vhost"):
- name = vhost.get('name')
- self.dispatch[self.sitesav + name] = self.generateSiteFile
- self.vhosts[name] = vhost
-
- def BuildStructures(self, metadata):
- '''Build apache+vhost bundle'''
- if metadata.hostname not in self.servers:
- return []
- output = Element("Bundle", name='apache-vhost', version='2.0')
- for server in self.meta.findall("server"):
- if server.attrib['name'] in metadata.hostname:
- for vhost in server.findall("vhost"):
- name = vhost.get('name')
- SubElement(output, "SymLink", name=self.sitesen+name, to=self.sitesav+name)
- SubElement(output, "ConfigFile", name="/etc/apache2/sites-available/" + name)
- SubElement(output, "ConfigFile", name='/etc/default/apache2')
- for software in self.meta.findall("Software"):
- for child in software.getchildren():
- output.append(deepcopy(child))
- return [output]
-
- def generateApacheDefault(self, entry, metadata):
- '''Build /etc/default/apache2'''
- if metadata.hostname in self.servers:
- entry.text = 'NO_START=0\n'
- else:
- entry.text = 'NO_START=1\n'
- perms = {'owner':'root', 'group':'root', 'perms':'0644'}
- [entry.attrib.__setitem__(key, value) for (key, value) in perms.iteritems()]
-
- def generateApacheSvc(self, entry, metadata):
- '''Enable apache service on webservices, disable on others'''
- if metadata.hostname in self.servers:
- entry.set('status', 'on')
- else:
- entry.set('status', 'off')
-
- def generateSiteFile(self, entry, metadata):
- '''Build site-specific config file for vhost'''
- if metadata.hostname not in self.servers:
- raise PluginExecutionError
- vhostname = entry.get('name')[len(self.sitesav):]
- if not self.vhosts.has_key(vhostname):
- raise PluginExecutionError
-
- if self.vhosts[vhostname].get('root') == "Hostname":
- choice = vhostname
- else:
- choice = gethostbyname(vhostname)
-
- config = ""
- for line in self.http:
- line = line.replace("XXemailXX", self.vhosts[vhostname].get('email'))
- line = line.replace("XXdomainXX", vhostname)
- line = line.replace("XXchoiceXX", choice)
- config += line
- entry.text = base64.encodestring(config)
- perms = {'owner':'root', 'group':'root', 'perms':'0644', 'encoding':'base64'}
- [entry.attrib.__setitem__(key, value) for (key, value) in perms.iteritems()]
-
-class Vhost(Plugin):
- '''This Structure is good for the pile of independent configs needed for most actual systems'''
- __name__ = 'Vhost'
- __version__ = '$Id$'
- __author__ = 'behrens@mcs.anl.gov'
-
- '''Vhost creates independent clauses based on client metadata'''
- def __init__(self, core, datastore):
- Plugin.__init__(self, core, datastore)
- self.Vhost = VhostFile("%s/Vhost/Vhost.xml"%(datastore), self.core.fam)
- self.BuildStructures = self.Vhost.BuildStructures
- self.Entries = self.Vhost.dispatch