def load_tasks(self, cmd, opt_values, pos_args):
        """
        DOIT task list generator
        """
        config = {'verbosity': self.configuration.get('verbosity')}

        dockerfile_list = DockerfileUtility.find_dockerfiles_in_path(
            base_path=self.configuration.get('dockerPath'),
            path_regex=self.configuration.get('docker.pathRegex'),
            image_prefix=self.configuration.get('docker.imagePrefix'),
            whitelist=self.configuration.get('whitelist'),
            blacklist=self.configuration.get('blacklist'),
        )
        dockerfile_list = self.process_dockerfile_list(dockerfile_list)

        #import json,sys;print json.dumps(dockerfile_list, sort_keys=True, indent = 4, separators = (',', ': '));sys.exit(0);

        tasklist = self.generate_task_list(dockerfile_list)

        if not tasklist or len(tasklist) == 0:
            raise Exception('No tasks found')

        tasklist = self.process_tasklist(tasklist)

        return tasklist, config
Beispiel #2
0
    def run_task(self, configuration):
        if self.option('output'):
            configuration.set('imagePath', self.option('output'))

        if Output.VERBOSITY_VERBOSE <= self.output.get_verbosity():
            self.line('<info>ALL :</info> %s' % self.option('all'))
            self.line('<info>output :</info> %s' %
                      configuration.get('imagePath'))
            self.line('<info>format :</info> %s' % self.option('format'))
            self.line('<info>dockerPath :</info> %s' %
                      configuration.get('dockerPath'))
            self.line('<info>filename :</info> %s' % self.option('filename'))
        self.__load_configuration()

        dockerfileList = DockerfileUtility.find_dockerfiles_in_path(
            base_path=configuration.get('dockerPath'),
            path_regex=configuration.get('docker.pathRegex'),
            image_prefix=configuration.get('docker.imagePrefix'),
        )

        for dockerfile in dockerfileList:
            self.__process_dockerfile(dockerfile)

        dia = self.build_graph()
        dia.render()
    def load_tasks(self, cmd, opt_values, pos_args):
        """
        DOIT task list generator
        """
        config = {'verbosity': self.configuration.get('verbosity')}

        dockerfile_list = DockerfileUtility.find_dockerfiles_in_path(
            base_path=self.configuration.get('dockerPath'),
            path_regex=self.configuration.get('docker.pathRegex'),
            image_prefix=self.configuration.get('docker.imagePrefix'),
            whitelist=self.configuration.get('whitelist'),
            blacklist=self.configuration.get('blacklist'),
        )
        dockerfile_list = self.process_dockerfile_list(dockerfile_list)

        #import json,sys;print json.dumps(dockerfile_list, sort_keys=True, indent = 4, separators = (',', ': '));sys.exit(0);

        tasklist = self.generate_task_list(dockerfile_list)

        if not tasklist or len(tasklist) == 0:
            raise Exception('No tasks found')

        tasklist = self.process_tasklist(tasklist)

        return tasklist, config
    def run_task(self, configuration):
        dockerfile_list = DockerfileUtility.find_dockerfiles_in_path(
            base_path=configuration.get('dockerPath'),
            path_regex=configuration.get('docker.pathRegex'),
            image_prefix=configuration.get('docker.imagePrefix'),
            whitelist=configuration.get('whitelist'),
            blacklist=configuration.get('blacklist'),
        )

        image_fail_list = []

        docker_command = self.argument('docker command')

        for dockerfile in dockerfile_list:
            title = dockerfile['image']['fullname']

            print title
            print '~' * len(title)

            if configuration['dryRun']:
                print '  exec: %s' % (docker_command)
            else:

                cmd = [
                    'docker',
                    'run',
                    '-t',
                    '--rm',
                    dockerfile['image']['fullname'],
                    'bash',
                    '-c',
                    '%s' % (' '.join(docker_command))
                ]
                status = Command.execute(cmd)

                if status:
                    print colored(' -> successfull', 'green')
                else:
                    print colored(' -> failed', 'red')
                    image_fail_list.append(dockerfile['image']['fullname'])
            print ''
            print ''

        if len(image_fail_list) >= 1:
            print ''
            print colored(' => failed images (%s):' % (str(len(image_fail_list))), 'red')
            for image in image_fail_list:
                print '   - %s ' % image
            print ''

            return False
        else:
            return True
    def run_task(self, configuration):
        dockerfile_list = DockerfileUtility.find_dockerfiles_in_path(
            base_path=configuration.get('dockerPath'),
            path_regex=configuration.get('docker.pathRegex'),
            image_prefix=configuration.get('docker.imagePrefix'),
            whitelist=configuration.get('whitelist'),
            blacklist=configuration.get('blacklist'),
        )

        image_fail_list = []

        docker_command = self.argument('docker command')

        for dockerfile in dockerfile_list:
            title = dockerfile['image']['fullname']

            print title
            print '~' * len(title)

            if configuration['dryRun']:
                print '  exec: %s' % (docker_command)
            else:

                cmd = [
                    'docker', 'run', '-t', '--rm',
                    dockerfile['image']['fullname'], 'bash', '-c',
                    '%s' % (' '.join(docker_command))
                ]
                status = Command.execute(cmd)

                if status:
                    print colored(' -> successfull', 'green')
                else:
                    print colored(' -> failed', 'red')
                    image_fail_list.append(dockerfile['image']['fullname'])
            print ''
            print ''

        if len(image_fail_list) >= 1:
            print ''
            print colored(
                ' => failed images (%s):' % (str(len(image_fail_list))), 'red')
            for image in image_fail_list:
                print '   - %s ' % image
            print ''

            return False
        else:
            return True
Beispiel #6
0
    def init_docker_image_list(self, docker_image=False):
        """
        Init and build list of available docker images
        """
        if docker_image:
            self.docker_image_list.append(docker_image)
        else:
            dockerfile_list = DockerfileUtility.find_dockerfiles_in_path(
                base_path=self.configuration.get('dockerPath'),
                path_regex=self.configuration.get('docker.pathRegex'),
                image_prefix=self.configuration.get('docker.imagePrefix'),
                whitelist=self.configuration.get('whitelist'),
                blacklist=self.configuration.get('blacklist'),
            )

            for image in dockerfile_list:
                self.docker_image_list.append(image['image']['fullname'])
    def init_docker_image_list(self, docker_image=False):
        """
        Init and build list of available docker images
        """
        if docker_image:
            self.docker_image_list.append(docker_image)
        else:
            dockerfile_list = DockerfileUtility.find_dockerfiles_in_path(
                base_path=self.configuration.get('dockerPath'),
                path_regex=self.configuration.get('docker.pathRegex'),
                image_prefix=self.configuration.get('docker.imagePrefix'),
                whitelist=self.configuration.get('whitelist'),
                blacklist=self.configuration.get('blacklist'),
            )

            for image in dockerfile_list:
                self.docker_image_list.append(image['image']['fullname'])
    def run_task(self, configuration):
        if self.option('output'):
            configuration.set('imagePath', self.option('output'))

        if Output.VERBOSITY_VERBOSE <= self.output.get_verbosity():
            self.line('<info>ALL :</info> %s' % self.option('all'))
            self.line('<info>output :</info> %s' % configuration.get('imagePath'))
            self.line('<info>format :</info> %s' % self.option('format'))
            self.line('<info>dockerPath :</info> %s' % configuration.get('dockerPath'))
            self.line('<info>filename :</info> %s' % self.option('filename'))
        self.__load_configuration()

        dockerfileList = DockerfileUtility.find_dockerfiles_in_path(
            base_path=configuration.get('dockerPath'),
            path_regex=configuration.get('docker.pathRegex'),
            image_prefix=configuration.get('docker.imagePrefix'),
        )

        for dockerfile in dockerfileList:
            self.__process_dockerfile(dockerfile)

        dia = self.build_graph()
        dia.render()