Exemple #1
0
    def run_list(self):
        # fetch all accessible/available templates
        try:
            machines = self.cs.machine_list(
                user=self.args.filter_user,
                name=self.args.filter_name,
                description=self.args.filter_description
            )

        except ServiceException as e:
            print(e)
            return 1

        if len(machines):
            l = TextTable(['[USER:]NAME', 'TITLE'])

            # add table items and print
            for m in machines:
                l.add_row(["{0}:{1}".format(m['username'], m['stub']), m['name']])

            print(l)

            # print summary
            print('\n{0} machine(s) found.'.format(len(machines)))

        else:
            print('0 machines found.')
Exemple #2
0
    def run_list(self):
        # fetch all accessible/available templates
        try:
            machines = self.cs.machine_list(
                user=self.args.filter_user,
                name=self.args.filter_name,
                description=self.args.filter_description)

        except ServiceException as e:
            print(e)
            return 1

        if len(machines):
            l = TextTable(['[USER:]NAME', 'TITLE'])

            # add table items and print
            for m in machines:
                l.add_row(
                    ["{0}:{1}".format(m['username'], m['stub']), m['name']])

            print(l)

            # print summary
            print('\n{0} machine(s) found.'.format(len(machines)))

        else:
            print('0 machines found.')
Exemple #3
0
    def run_list(self):

        # fetch all accessible/available templates
        try:
            templates = self.cs.template_list(
                user=self.args.filter_user,
                name=self.args.filter_name,
                description=self.args.filter_description,
                public=self.args.public_only
            )

        except ServiceException as e:
            logging.exception(e)
            return 1

        if len(templates):
            l = TextTable(header=["[USER:]NAME", "TITLE"])

            # add table items and print
            for t in templates:
                l.add_row(["{0}:{1}".format(t['username'], t['stub']), t['name']])

            print(l)

            # print summary
            print('\n{0} template(s) found.'.format(len(templates)))

        else:
            print('0 templates found.')
Exemple #4
0
    def run_list(self):
        t = Template(self.args.template, user=self.args.username)

        try:
            t = self.cs.template_get(t)

        except ServiceException as e:
            print(e)
            return 1

        packages = list(t.packages_all)
        packages.sort(key=lambda x: x.name)

        if len(packages):
            l = TextTable(header=[
                'PACKAGE', 'EPOCH', 'VERSION', 'RELEASE', 'ARCH', 'ACTION'
            ])

            for p in packages:
                if p.epoch is None:
                    p.epoch = '-'

                if p.version is None:
                    p.version = '-'

                if p.release is None:
                    p.release = '-'

                if p.arch is None:
                    p.arch = '-'

                if p.included:
                    p.action = '+'

                elif p.excluded:
                    p.action = '-'

                elif p.ignored:
                    p.action = '!'

                else:
                    p.action = '?'

                l.add_row(
                    [p.name, p.epoch, p.version, p.release, p.arch, p.action])

            print(l)
            print()

        else:
            print('0 packages defined.')
Exemple #5
0
    def run_list(self):

        # fetch all accessible/available templates
        try:
            templates = self.cs.template_list(
                user=self.args.filter_user,
                name=self.args.filter_name,
                description=self.args.filter_description,
                public=self.args.public_only)

        except ServiceException as e:
            logging.exception(e)
            return 1

        if len(templates):
            l = TextTable(header=["[USER:]NAME", "TITLE", "VERSIONS"])

            # compress versions
            template_versions = {}

            for t in templates:
                un = "{0}:{1}".format(t['username'], t['stub'])

                a = template_versions.get(un, {
                    'name': t['username'],
                    'versions': []
                })
                a['versions'].append(t['version'])

                template_versions[un] = a

            # add table items and print
            for k, v in template_versions.items():
                l.add_row([
                    k, v['name'], ', '.join([
                        x if x is not '' else '*'
                        for x in sorted(v['versions'])
                    ])
                ])

            print(l)

            # print summary
            print('\n{0} template(s) found.'.format(len(templates)))

        else:
            print('0 templates found.')
Exemple #6
0
    def run_list(self):
        t = Template(self.args.template, user=self.args.username)

        try:
            t = self.cs.template_get(t)

        except ServiceException as e:
            print(e)
            return 1

        packages = list(t.packages_all)
        packages.sort(key=lambda x: x.name)

        if len(packages):
            l = TextTable(header=["PACKAGE", "EPOCH", "VERSION", "RELEASE", "ARCH", "ACTION"])

            for p in packages:
                if p.epoch is None:
                    p.epoch = "-"

                if p.version is None:
                    p.version = "-"

                if p.release is None:
                    p.release = "-"

                if p.arch is None:
                    p.arch = "-"

                if p.included:
                    p.action = "+"

                else:
                    p.action = "-"

                l.add_row([p.name, p.epoch, p.version, p.release, p.arch, p.action])

            print(l)
            print()

        else:
            print("0 packages defined.")
Exemple #7
0
    def run_list(self):
        t = Template(self.args.template, user=self.args.username)

        try:
            t = self.cs.template_get(t)

        except ServiceException as e:
            print(e)
            return 1

        repos = list(t.repos_all)
        repos.sort(key=lambda x: x.stub)

        if len(repos):
            l = TextTable(
                header=['REPO', 'NAME', 'PRIORITY', 'COST', 'ENABLED'])

            for r in repos:
                cost = r.cost
                if cost is None:
                    cost = '-'

                priority = '-'
                if priority is None:
                    priority = '-'

                enabled = r.enabled
                if enabled:
                    enabled = 'Y'

                l.add_row([r.stub, r.name, priority, cost, enabled])

            print(l)
            print()

        else:
            print('0 repos defined.')
Exemple #8
0
    def run_list(self):
        t = Template(self.args.template, user=self.args.username)

        try:
            t = self.cs.template_get(t)

        except ServiceException as e:
            print(e)
            return 1

        repos = list(t.repos_all)
        repos.sort(key=lambda x: x.stub)

        if len(repos):
            l = TextTable(header=['REPO', 'NAME', 'PRIORITY', 'COST', 'ENABLED'])

            for r in repos:
                cost = r.cost
                if cost is None:
                    cost = '-'

                priority = '-'
                if priority is None:
                    priority = '-'

                enabled = r.enabled
                if enabled:
                    enabled = 'Y'

                l.add_row([r.stub, r.name, priority, cost, enabled])

            print(l)
            print()

        else:
            print('0 repos defined.')
Exemple #9
0
    def run_dump(self):
        t = Template(self.args.template, user=self.args.username)

        try:
            t = self.cs.template_get(
                t, resolve_includes=not self.args.no_resolve_includes)

        except ServiceException as e:
            logging.exception(e)
            return 1

        if self.args.kickstart:
            print(t.to_kickstart(resolved=not self.args.no_resolve_includes))
            return 0

        elif self.args.yaml:
            print(
                yaml.dump(
                    t.to_object(resolved=not self.args.no_resolve_includes),
                    indent=4))
            return 0

        elif self.args.json:
            print(
                json.dumps(
                    t.to_object(resolved=not self.args.no_resolve_includes),
                    indent=4,
                    sort_keys=True))
            return 0

        # pretty general information
        print('TEMPLATE: {0} ({1})\n'.format(t.name, t.user))

        if t.description is not None and len(t.description):
            print('Description:\n{0}\n'.format(t.description))

        # pretty print includes
        if len(t.includes):
            l = TextTable(header=['INCLUDE'])
            for i in t.includes:
                l.add_row([i])

            print(l)
            print()

        # pretty print packages
        repos = list(t.repos_all)
        repos.sort(key=lambda x: x.stub)

        if len(repos):
            l = TextTable(header=["REPO", "NAME", "ENABLED", "TEMPLATE"])

            for r in repos:
                cost = r.cost
                if cost is None:
                    cost = '-'

                priority = r.priority
                if priority is None:
                    priority = '-'

                enabled = 'N'
                if r.enabled:
                    enabled = 'Y'

                template = r.template
                if template == t.unv:
                    template = ''

                #l.add_row([r.stub, r.name, priority, cost, enabled])
                l.add_row([r.stub, r.name, enabled, template])

            print(l)
            print()

        # pretty print packages
        packages = list(t.packages_all)
        packages.sort(key=lambda x: x.name)

        if len(packages):
            l = TextTable(header=["PACKAGE", "ACTION", "TEMPLATE"])

            for p in packages:
                if p.included:
                    p.action = '+'

                elif p.excluded:
                    p.action = '-'

                elif p.ignored:
                    p.action = '!'

                else:
                    p.action = '?'

                # no template specified indicates it's part of this template
                if p.template == t.unv:
                    p.template = ''

                l.add_row([p.name, p.action, p.template])

            print(l)
            print()

        return 0
Exemple #10
0
    def run_dump(self):
        t = Template(self.args.template, user=self.args.username)

        try:
            t = self.cs.template_get(t, resolve_includes=not self.args.no_resolve_includes)

        except ServiceException as e:
            logging.exception(e)
            return 1

        if self.args.kickstart:
            print(t.to_kickstart(resolved=not self.args.no_resolve_includes))
            return 0

        elif self.args.yaml:
            print(yaml.dump(t.to_object(resolved=not self.args.no_resolve_includes), indent=4))
            return 0

        elif self.args.json:
            print(json.dumps(t.to_object(resolved=not self.args.no_resolve_includes), indent=4, sort_keys=True))
            return 0

        # pretty general information
        print('TEMPLATE: {0} ({1})\n'.format(t.name, t.user))

        if t.description is not None and len(t.description):
            print('Description:\n{0}\n'.format(t.description))

        # pretty print includes
        if len(t.includes):
            l = TextTable(header=['INCLUDE'])
            for i in t.includes:
                l.add_row([i])

            print(l)
            print()

        # pretty print packages
        repos = list(t.repos_all)
        repos.sort(key=lambda x: x.stub)

        if len(repos):
            l = TextTable(header=["REPO", "NAME", "ENABLED"])

            for r in repos:
                cost = r.cost
                if cost is None:
                    cost = '-'

                priority = r.priority
                if priority is None:
                    priority = '-'

                enabled = 'N'
                if r.enabled:
                    enabled = 'Y'

                #l.add_row([r.stub, r.name, priority, cost, enabled])
                l.add_row([r.stub, r.name, enabled])

            print(l)
            print()

        # pretty print packages
        packages = list(t.packages_all)
        packages.sort(key=lambda x: x.name)

        if len(packages):
            l = TextTable(header=["PACKAGE", "ACTION"])

            for p in packages:
                if p.included:
                    p.action = '+'

                else:
                    p.action = '-'

                l.add_row([p.name, p.action])

            print(l)
            print()

        return 0