blob: 5b7cbbddcba7b29d3d537200e208a9eb99363897 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
'''This module configures files in a Chiba City specific way'''
__revision__ = '$Revision$'
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'''
pass
class Chiba(Generator):
'''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'
__provides__ = {'ConfigFile':{}}
def __init__(self, core, datastore):
Generator.__init__(self, core, datastore)
self.repo = DirectoryBacked(self.data, self.core.fam)
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'
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
|