summaryrefslogtreecommitdiffstats
path: root/generators/fstab.py
blob: bc5535b4d654a5cd11c67b76a23fdfc8121cb5ae (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
39
40
41
42
43
44
45
#!/usr/bin/env python

from re import compile

from Generator import Generator
from GeneratorUtils import DirectoryBacked
from Types import ConfigFile

class fstab(Generator):
    __name__ = 'fstab'
    __version__ = '$Id$'
    __author__ = 'bcfg-dev@mcs.anl.gov'

    mayor = compile("\$MAYOR")

    def __setup__(self):
        self.repo = DirectoryBacked(self.data, self.core.fam)
        self.__provides__ = {'ConfigFile':{'/etc/fstab':self.build_fstab}}

    def build_fstab(self,name,metadata):
        node = metadata.hostname.split('.')[0]
        if 'ccn' in node:
            nodeclass = 'compute'
            mayor = 'cct%sm.mcs.anl.gov'%((int(node[3:]) / 32) + 1)
        elif 'ccviz' in node:
            nodeclass = 'compute'
            mayor = 'cct10m.mcs.anl.gov'
        elif 'ccsto' in node:
            nodeclass = 'storage'
            mayor = 'cct9m.mcs.anl.gov'
        elif 'cct' in node:
            nodeclass = 'mayor'
            mayor = 'ccprez.mcs.anl.gov'
        elif 'ccfs' in node:
            nodeclass = 'fs'
            mayor = 'ccprez.mcs.anl.gov'
        else:
            raise KeyError,client

        fsname = "fstab_%s"%(nodeclass)
        fsdata = self.repo.entries[fsname].data

        return ConfigFile('/etc/fstab','root','root','0644',self.mayor.sub(mayor,fsdata))