summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2005-09-08 20:59:13 +0000
committerNarayan Desai <desai@mcs.anl.gov>2005-09-08 20:59:13 +0000
commit6f04a3b1b2be669f826fff6908cc1e4345d21923 (patch)
tree30e1178ca9aed6276c40fa06fb137581bc843452
parentb0f8b8570d4786dcb280dca110db3e1226bffceb (diff)
downloadbcfg2-6f04a3b1b2be669f826fff6908cc1e4345d21923.tar.gz
bcfg2-6f04a3b1b2be669f826fff6908cc1e4345d21923.tar.bz2
bcfg2-6f04a3b1b2be669f826fff6908cc1e4345d21923.zip
update to new API
2005/09/08 15:57:29-05:00 anl.gov!desai Rename: src/lib/Server/Generators/Chiba.py -> src/lib/Server/Plugins/Chiba.py (Logical change 1.302) git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@1235 ce84e21b-d406-0410-9b95-82705330c041
-rw-r--r--src/lib/Server/Plugins/Chiba.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/lib/Server/Plugins/Chiba.py b/src/lib/Server/Plugins/Chiba.py
index e69de29bb..110ddc190 100644
--- a/src/lib/Server/Plugins/Chiba.py
+++ b/src/lib/Server/Plugins/Chiba.py
@@ -0,0 +1,40 @@
+'''This module configures files in a Chiba City specific way'''
+__revision__ = '$Revision$'
+
+from socket import gethostbyname, gaierror
+from syslog import syslog, LOG_ERR
+from Bcfg2.Server.Plugin import Plugin, DirectoryBacked, SingleXMLFileBacked, GeneratorError
+
+class ChibaConf(SingleXMLFileBacked):
+ '''This class encapsulates all information needed for all Chiba config ops'''
+ pass
+
+class Chiba(Plugin):
+ '''the Chiba generator builds the following files:
+ -> /etc/fstab
+ -> /etc/network/interfaces
+ -> /etc/dhcpd.conf
+ -> /tftpboot/<node>.lst'''
+
+ __name__ = 'Chiba'
+ __version__ = '$Id$'
+ __author__ = 'bcfg-dev@mcs.anl.gov'
+ Entries = {'ConfigFile':{}}
+
+ def __init__(self, core, datastore):
+ Generator.__init__(self, core, datastore)
+ self.repo = DirectoryBacked(self.data, self.core.fam)
+ self.Entries['ConfigFile']['/etc/network/interfaces'] = self.build_interfaces
+
+ def build_interfaces(self, entry, metadata):
+ '''build network configs for clients'''
+ entry.attrib['owner'] = 'root'
+ entry.attrib['group'] = 'root'
+ entry.attrib['perms'] = '0644'
+ try:
+ myriaddr = gethostbyname("%s-myr" % metadata.hostname)
+ except gaierror:
+ syslog(LOG_ERR, "Failed to resolve %s-myr"% metadata.hostname)
+ raise GeneratorError, ("%s-myr" % metadata.hostname, 'lookup')
+ entry.text = self.repo.entries['interfaces-template'].data % myriaddr
+