Ejemplo n.º 1
0
    def build_image_list(self):
        def process_source_installation(image, section):
            installation = dict()
            # NOTE(jeffrey4l): source is not needed when the type is None
            if self.conf._get('type', self.conf._get_group(section)) is None:
                if image.parent_name is None:
                    LOG.debug('No source location found in section %s',
                              section)
            else:
                installation['type'] = self.conf[section]['type']
                installation['source'] = self.conf[section]['location']
                installation['name'] = section
                if installation['type'] == 'git':
                    installation['reference'] = self.conf[section]['reference']
            return installation

        all_sections = (set(six.iterkeys(self.conf._groups))
                        | set(self.conf.list_all_sections()))

        for path in self.docker_build_paths:
            # Reading parent image name
            with open(os.path.join(path, 'Dockerfile')) as f:
                content = f.read()

            image_name = os.path.basename(path)
            canonical_name = (self.namespace + '/' + self.image_prefix +
                              image_name + ':' + self.tag)
            image = Image(image_name,
                          canonical_name,
                          path,
                          parent_name=content.split(' ')[1].split('\n')[0],
                          logger=make_a_logger(self.conf, image_name))

            if self.install_type == 'source':
                # NOTE(jeffrey4l): register the opts if the section didn't
                # register in the kolla/common/config.py file
                if image.name not in self.conf._groups:
                    self.conf.register_opts(common_config.get_source_opts(),
                                            image.name)
                image.source = process_source_installation(image, image.name)
                for plugin in [
                        match.group(0)
                        for match in (re.search(
                            '^{}-plugin-.+'.format(image.name), section)
                                      for section in all_sections) if match
                ]:
                    try:
                        self.conf.register_opts(
                            common_config.get_source_opts(), plugin)
                    except cfg.DuplicateOptError:
                        LOG.debug('Plugin %s already registered in config',
                                  plugin)
                    image.plugins.append(
                        process_source_installation(image, plugin))

            self.images.append(image)
Ejemplo n.º 2
0
Archivo: build.py Proyecto: maglo/kolla
    def build_image_list(self):
        def process_source_installation(image, section):
            installation = dict()
            # NOTE(jeffrey4l): source is not needed when the type is None
            if self.conf._get('type', self.conf._get_group(section)) is None:
                if image.parent_name is None:
                    LOG.debug('No source location found in section %s',
                              section)
            else:
                installation['type'] = self.conf[section]['type']
                installation['source'] = self.conf[section]['location']
                installation['name'] = section
                if installation['type'] == 'git':
                    installation['reference'] = self.conf[section]['reference']
            return installation

        all_sections = (set(six.iterkeys(self.conf._groups)) |
                        set(self.conf.list_all_sections()))

        for path in self.docker_build_paths:
            # Reading parent image name
            with open(os.path.join(path, 'Dockerfile')) as f:
                content = f.read()

            image_name = os.path.basename(path)
            canonical_name = (self.namespace + '/' + self.image_prefix +
                              image_name + ':' + self.tag)
            image = Image(image_name, canonical_name, path,
                          parent_name=content.split(' ')[1].split('\n')[0],
                          logger=make_a_logger(self.conf, image_name))

            if self.install_type == 'source':
                # NOTE(jeffrey4l): register the opts if the section didn't
                # register in the kolla/common/config.py file
                if image.name not in self.conf._groups:
                    self.conf.register_opts(common_config.get_source_opts(),
                                            image.name)
                image.source = process_source_installation(image, image.name)
                for plugin in [match.group(0) for match in
                               (re.search('^{}-plugin-.+'.format(image.name),
                                          section) for section in
                                all_sections) if match]:
                    try:
                        self.conf.register_opts(
                            common_config.get_source_opts(),
                            plugin
                        )
                    except cfg.DuplicateOptError:
                        LOG.debug('Plugin %s already registered in config',
                                  plugin)
                    image.plugins.append(
                        process_source_installation(image, plugin))

            self.images.append(image)
Ejemplo n.º 3
0
    def build_image_list(self):
        def process_source_installation(image, section):
            installation = dict()
            # NOTE(jeffrey4l): source is not needed when the type is None
            if self.conf._get("type", self.conf._get_group(section)) is None:
                if image.parent_name is None:
                    LOG.debug("No source location found in section %s", section)
            else:
                installation["type"] = self.conf[section]["type"]
                installation["source"] = self.conf[section]["location"]
                installation["name"] = section
                if installation["type"] == "git":
                    installation["reference"] = self.conf[section]["reference"]
            return installation

        for path in self.docker_build_paths:
            # Reading parent image name
            with open(os.path.join(path, "Dockerfile")) as f:
                content = f.read()

            image_name = os.path.basename(path)
            canonical_name = self.namespace + "/" + self.image_prefix + image_name + ":" + self.tag
            image = Image(
                image_name,
                canonical_name,
                path,
                parent_name=content.split(" ")[1].split("\n")[0],
                logger=make_a_logger(self.conf, image_name),
            )

            if self.install_type == "source":
                # NOTE(jeffrey4l): register the opts if the section didn't
                # register in the kolla/common/config.py file
                if image.name not in self.conf._groups:
                    self.conf.register_opts(common_config.get_source_opts(), image.name)
                image.source = process_source_installation(image, image.name)
                for plugin in [
                    match.group(0)
                    for match in (
                        re.search("{}-plugin-.+".format(image.name), section)
                        for section in self.conf.list_all_sections()
                    )
                    if match
                ]:
                    try:
                        self.conf.register_opts(common_config.get_source_opts(), plugin)
                    except cfg.DuplicateOptError:
                        LOG.debug("Plugin %s already registered in config", plugin)
                    image.plugins.append(process_source_installation(image, plugin))

            self.images.append(image)
Ejemplo n.º 4
0
    def build_image_list(self):
        def process_source_installation(image, section):
            installation = dict()
            # NOTE(jeffrey4l): source is not needed when the type is None
            if self.conf._get('type', self.conf._get_group(section)) is None:
                LOG.debug('%s:No source location found', section)
            else:
                installation['type'] = self.conf[section]['type']
                installation['source'] = self.conf[section]['location']
                installation['name'] = section
                if installation['type'] == 'git':
                    installation['reference'] = self.conf[section]['reference']
            return installation

        for path in self.docker_build_paths:
            # Reading parent image name
            with open(os.path.join(path, 'Dockerfile')) as f:
                content = f.read()

            image = dict()
            image['status'] = "unprocessed"
            image['name'] = os.path.basename(path)
            image['fullname'] = self.namespace + '/' + self.image_prefix + \
                image['name'] + ':' + self.tag
            image['path'] = path
            image['parent_name'] = content.split(' ')[1].split('\n')[0]
            if not image['parent_name'].startswith(self.namespace + '/'):
                image['parent'] = None
            image['children'] = list()
            image['plugins'] = list()

            if self.install_type == 'source':
                # NOTE(jeffrey4l): register the opts if the section didn't
                # register in the kolla/common/config.py file
                if image['name'] not in self.conf._groups:
                    self.conf.register_opts(common_config.get_source_opts(),
                                            image['name'])
                image['source'] = process_source_installation(
                    image, image['name'])
                for plugin in [
                        match.group(0) for match in
                    (re.search('{}-plugin-.+'.format(image['name']), section)
                     for section in self.conf.list_all_sections()) if match
                ]:
                    self.conf.register_opts(common_config.get_source_opts(),
                                            plugin)
                    image['plugins'].append(
                        process_source_installation(image, plugin))

            self.images.append(image)
Ejemplo n.º 5
0
    def build_image_list(self):
        def process_source_installation(image, section):
            installation = dict()
            # NOTE(jeffrey4l): source is not needed when the type is None
            if self.conf._get('type', self.conf._get_group(section)) is None:
                LOG.debug('%s:No source location found', section)
            else:
                installation['type'] = self.conf[section]['type']
                installation['source'] = self.conf[section]['location']
                installation['name'] = section
                if installation['type'] == 'git':
                    installation['reference'] = self.conf[section]['reference']
            return installation

        for path in self.docker_build_paths:
            # Reading parent image name
            with open(os.path.join(path, 'Dockerfile')) as f:
                content = f.read()

            image = dict()
            image['status'] = "unprocessed"
            image['name'] = os.path.basename(path)
            image['fullname'] = self.namespace + '/' + self.image_prefix + \
                image['name'] + ':' + self.tag
            image['path'] = path
            image['parent_name'] = content.split(' ')[1].split('\n')[0]
            if not image['parent_name'].startswith(self.namespace + '/'):
                image['parent'] = None
            image['children'] = list()
            image['plugins'] = list()

            if self.install_type == 'source':
                # NOTE(jeffrey4l): register the opts if the section didn't
                # register in the kolla/common/config.py file
                if image['name'] not in self.conf._groups:
                    self.conf.register_opts(common_config.get_source_opts(),
                                            image['name'])
                image['source'] = process_source_installation(image,
                                                              image['name'])
                for plugin in [match.group(0) for match in
                               (re.search('{}-plugin-.+'.format(image['name']),
                                          section) for section in
                               self.conf.list_all_sections()) if match]:
                    self.conf.register_opts(common_config.get_source_opts(),
                                            plugin)
                    image['plugins'].append(
                        process_source_installation(image, plugin))

            self.images.append(image)