summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2003-12-23 22:00:56 +0000
committerNarayan Desai <desai@mcs.anl.gov>2003-12-23 22:00:56 +0000
commitdc0b832fd0d9d4b22e721593b2c1bbc70dca7d34 (patch)
tree83394f4510fc2eb6b635dc09ff89dcc507613d4d
parent82a946819810999cdb64f2a87bacfad6ed1dcae4 (diff)
downloadbcfg2-dc0b832fd0d9d4b22e721593b2c1bbc70dca7d34.tar.gz
bcfg2-dc0b832fd0d9d4b22e721593b2c1bbc70dca7d34.tar.bz2
bcfg2-dc0b832fd0d9d4b22e721593b2c1bbc70dca7d34.zip
(Logical change 1.6)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@20 ce84e21b-d406-0410-9b95-82705330c041
-rw-r--r--src/Generator.py41
-rw-r--r--src/Types.py22
2 files changed, 63 insertions, 0 deletions
diff --git a/src/Generator.py b/src/Generator.py
index e69de29bb..ef7fa72e2 100644
--- a/src/Generator.py
+++ b/src/Generator.py
@@ -0,0 +1,41 @@
+#!/usr/bin/env python
+
+class GeneratorError(Exception):
+ pass
+
+class Generator(object):
+ '''This is a class that generators can be subclassed off of.'''
+ __name__ = None
+ __version__ = '$Id: $'
+ __datastore__ = '/tmp/data'
+ __build__ = {}
+
+ def __init__(self):
+ self.data="%s/%s"%(self.__datastore__,self.__name__)
+ print "%s loaded"%(self.__name__)
+
+ def Cron(self):
+ '''Cron defines periodic tasks to maintain data coherence'''
+ pass
+
+ def Build(self,filename,client):
+ '''Build will construct a Config File object for client.'''
+ if self.__build__.has_key(filename):
+ self.__build__[filename](filename,client)
+ else:
+ raise GeneratorError, ("Key",filename)
+
+ def Publish(self,key,value):
+ pass
+
+ def Fetch(self,key):
+ pass
+
+ def GetMetadata(self,client,field):
+ '''GetMetadata returns current metadata file client. Field can be one of:
+ image, tags, bundles'''
+ pass
+
+ def Notify(self,region):
+ '''Generate change notification for region'''
+ pass
diff --git a/src/Types.py b/src/Types.py
index e69de29bb..0e88602df 100644
--- a/src/Types.py
+++ b/src/Types.py
@@ -0,0 +1,22 @@
+#!/usr/bin/env python
+
+from binascii import b2a_base64
+
+class ConfigFile(object):
+ format="<ConfigFile name='%s' owner='%s' group='%s' perms='%s' encoding='%s'>%s</ConfigFile>"
+ def __init__(self,name,owner,group,perms,content,encoding='ascii'):
+ self.name=name
+ self.owner=owner
+ self.group=group
+ self.perms=perms
+ self.content=content
+ self.encoding=encoding
+ if encoding == 'base64':
+ self.xcontent=b2a_base64(content)
+ else:
+ self.xcontent=content
+
+ def XMLSerialize(self):
+ return self.format%(self.name,self.owner,self.group,self.perms,self.encoding,self.xcontent)
+
+