summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Generators/Debconf.py
blob: 51f663e1eeab23022082796d63e564b114660e7a (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
'''this generator handles production of client-specific debconf files'''
__revision__ = '$Revision$'

from Bcfg2.Server.Generator import Generator, DirectoryBacked
from elementtree.ElementTree import XML

class Debconf(Generator):
    '''Debconf takes <data>/template.dat and adds entries for
    -> hostname
    -> video driver'''
    __name__ = 'Debconf'
    __version__ = '$Revision$'
    __author__ = 'bcfg-dev@mcs.anl.gov'
    __provides__ = {'ConfigFile':{}}

    probes = [XML('''<probe interpreter='/bin/sh'>lspci|grep VGA</probe>''')]

    def __setup__(self):
        self.repo = DirectoryBacked(self.data, self.core.fam)
        self.xsensed = {}

    def build_config_dat(self, entry, metadata):
        '''build debconf file for client'''
        entry.attrib['owner'] = 'root'
        entry.attrib['group'] = 'root'
        entry.attrib['perms'] = '0600'
        filedata = self.repo.entries['config.dat']
        xdriver = self.xsensed.get(metadata.hostname, "vesa")
        entry.text = filedata % (metadata.hostname, xdriver)

    def get_probes(self, metadata):
        return self.probes