diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2004-12-20 17:07:40 +0000 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2004-12-20 17:07:40 +0000 |
commit | 6cfcc21b8ed084391dc11b7946f546458c424a8d (patch) | |
tree | 52bdf59e6cd939b4f0e2eef2eaa9a1a721f3d181 | |
parent | ec16583886d8b89363c825a746c10d34a04e6052 (diff) | |
download | bcfg2-6cfcc21b8ed084391dc11b7946f546458c424a8d.tar.gz bcfg2-6cfcc21b8ed084391dc11b7946f546458c424a8d.tar.bz2 bcfg2-6cfcc21b8ed084391dc11b7946f546458c424a8d.zip |
add error handling
(Logical change 1.171)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@747 ce84e21b-d406-0410-9b95-82705330c041
-rw-r--r-- | src/lib/Server/Generators/Chiba.py | 62 |
1 files changed, 8 insertions, 54 deletions
diff --git a/src/lib/Server/Generators/Chiba.py b/src/lib/Server/Generators/Chiba.py index 6f442cbe7..5b7cbbddc 100644 --- a/src/lib/Server/Generators/Chiba.py +++ b/src/lib/Server/Generators/Chiba.py @@ -1,8 +1,8 @@ '''This module configures files in a Chiba City specific way''' __revision__ = '$Revision$' -from re import compile as regcompile -from Bcfg2.Server.Generator import Generator, DirectoryBacked, SingleXMLFileBacked +from socket import gethostbyname, gaierror +from Bcfg2.Server.Generator import Generator, DirectoryBacked, SingleXMLFileBacked, GeneratorError class ChibaConf(SingleXMLFileBacked): '''This class encapsulates all information needed for all Chiba config ops''' @@ -20,65 +20,19 @@ class Chiba(Generator): __author__ = 'bcfg-dev@mcs.anl.gov' __provides__ = {'ConfigFile':{}} - mayor = regcompile("\$MAYOR") - def __init__(self, core, datastore): Generator.__init__(self, core, datastore) self.repo = DirectoryBacked(self.data, self.core.fam) - self.__provides__['ConfigFile']['/etc/fstab'] = self.build_fstab - - def get_mayor(self, node): - '''Get mayor for node''' - if 'ccn' in node: - return 'cct%sm.mcs.anl.gov' % ((int(node[3:]) / 32) + 1) - elif 'ccviz' in node: - return 'cct10m.mcs.anl.gov' - elif 'ccsto' in node: - return 'cct9m.mcs.anl.gov' - else: - return 'ccprez.mcs.anl.gov' - - def build_fstab(self, entry, metadata): - '''build fstab for chiba nodes''' - node = metadata.hostname.split('.')[0] - mayor = self.get_mayor(node) - - if 'ccn' in node: - nodeclass = 'compute' - elif 'ccviz' in node: - nodeclass = 'compute' - elif 'ccsto' in node: - nodeclass = 'storage' - elif 'cct' in node: - nodeclass = 'mayor' - elif 'ccfs' in node: - nodeclass = 'fs' - else: - raise KeyError, node - - entry.attrib['owner'] = 'root' - entry.attrib['group'] = 'root' - entry.attrib['perms'] = '0644' - fsdata = self.repo.entries["fstab_%s" % (nodeclass)] - entry.text = self.mayor.sub(mayor, fsdata) + self.__provides__['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' - entry.text = self.repo.entries['iface-template'] - # add more here later - - def build_dhcpd(self, entry, metadata): - '''build dhcpd.conf for server(s)''' - pass + try: + myriaddr = gethostbyname("%s-myr" % metadata.hostname) + except gaierror: + raise GeneratorError, ("%s-myr" % metadata.hostname, 'lookup') + entry.text = self.repo.entries['interfaces-template'].data % myriaddr - def build_tftp(self, entry, metadata): - '''build tftp files for client netboot''' - mayor = self.get_mayor(metadata.hostname.split('.')[0]) - kvers = '2.4.26' - root = '/dev/sda2' - data = self.repo.entries['tftp-template'] - entry.text = data % ( kvers, root, mayor, kvers, kvers, root, mayor, kvers) - entry.attrib.update({'owner':'root', 'group':'root', 'perms':'0600'}) |