#!/usr/bin/env python

import os

letters = '0123456789abcdef'
share_directory = "%s/%s/share/filemon/" % (os.environ['PSCONFDIR'], os.environ['PSCONFIG'])

nodes = []
nodesFile = open('%s/ippMhpccStorageNodes' % share_directory)
for line in nodesFile:
    nodes.append(line[:-1])
nodesFile.close()

template = ""
templateFile = open('%s/sql/CreateTablesTemplate.sql' % share_directory)
for line in templateFile:
    template = "%s%s" % (template, line)
templateFile.close()

for letter1 in letters:
    for letter2 in letters:
        directory = '%s%s' % (letter1, letter2)
        for node in nodes:
            print template.replace('@HOST@', 
                                   node).replace('@DIRECTORY@', 
                                                 directory)
