def __init__(self,
                 templatedirelem,
                 indices,
                 testfile_global_overlays,
                 templates_global_overlaylists):
        self._global_overlays = testfile_global_overlays

        self._templates_global_overlaylists = templates_global_overlaylists

        template_suffix = ConfigDictionary().get('etce', 'TEMPLATE_DIRECTORY_SUFFIX')
        
        self._name = templatedirelem.attrib['name']

        self._template_directory_name = '.'.join([self._name, template_suffix])
        
        self._indices = indices
        
        self._relative_path, \
        self._hostname_format = self._read_attributes(templatedirelem)

        # build local overlay chain
        self._template_local_overlays = {}

        for overlayelem in templatedirelem.findall('./overlay'):
            oname = overlayelem.attrib['name']

            oval = overlayelem.attrib['value']

            otype = overlayelem.attrib.get('type', None)

            self._template_local_overlays[oname] = configstrtoval(oval, argtype=otype)

        self._template_local_overlaylists = \
            OverlayListChainFactory().make(templatedirelem.findall('./overlaylist'),
                                           self._indices)
예제 #2
0
    def __init__(self, templatefileelem, indices, testfile_global_overlays,
                 templates_global_overlaylists):

        self._global_overlays = testfile_global_overlays

        self._templates_global_overlaylists = templates_global_overlaylists

        self._name = templatefileelem.attrib['name']

        self._indices = copy.copy(indices)

        self._hostname_format, \
        self._output_file_name = self._read_attributes(templatefileelem)

        # build local overlay chain
        self._template_local_overlays = {}

        for overlayelem in templatefileelem.findall('./overlay'):
            oname = overlayelem.attrib['name']

            oval = overlayelem.attrib['value']

            otype = overlayelem.attrib.get('type', None)

            self._template_local_overlays[oname] = configstrtoval(
                oval, argtype=otype)

        self._template_local_overlaylists = \
            OverlayListChainFactory().make(templatefileelem.findall('./overlaylist'),
                                           self._indices)
예제 #3
0
    def make(self, overlaylistelems, indiceslist):
        valsmap = defaultdict(lambda: {})

        for overlaylistelem in overlaylistelems:
            name = overlaylistelem.attrib['name']

            separator = overlaylistelem.attrib.get('separator', ',')

            values = overlaylistelem.attrib['values'].split(separator)

            # number of indices and vals must agree
            if not len(indiceslist) == len(values):
                err = 'overlaylist error: number of indices (%d) and ' \
                      'number of values (%d) do not match for overlaylist ' \
                      'name "%s"' % (len(indiceslist), len(values), name)
                raise OverlayError(err)

            for index, value in zip(indiceslist, values):
                valsmap[index][name] = configstrtoval(value.strip())

        return valsmap