Beispiel #1
0
    def run_sync(self):
        uuid = self.config.get('machine', 'uuid')
        key = self.config.get('machine', 'key')

        try:
            res = self.cs.machine_sync(uuid, key, template=True)

        except ServiceException as e:
            print(e)
            return 1

        m = Machine(res['template'])
        t = Template(res['template'])

        t.system_prepare()

        # describe process for dry runs
        if self.args.dry_run:
            tx = t.system_transaction()
            packages_install = list(tx.install_set)
            packages_install.sort(key=lambda x: x.name)

            packages_remove = list(tx.remove_set)
            packages_remove.sort(key=lambda x: x.name)
            if len(packages_install) or len(packages_remove):
                print(
                    'The following would be installed to (+) and removed from (-) the system:'
                )

                for p in packages_install:
                    print('  + ' + str(p))

                for p in packages_remove:
                    print('  - ' + str(p))

                print()
                print('Summary:')
                print('  - Package(s): %d' %
                      (len(packages_install) + len(packages_remove)))
                print()

            else:
                print('No system changes required.')

            print('No action peformed during this dry-run.')
            return 0

        # TODO: progress for download, install and removal
        t.to_system_apply(clean=False)

        print('info: machine synced.')

        return 0
Beispiel #2
0
    def run_sync(self):
        uuid = self.config.get('machine', 'uuid')
        key = self.config.get('machine', 'key')

        try:
            res = self.cs.machine_sync(uuid, key, template=True)

        except ServiceException as e:
            print(e)
            return 1

        m = Machine(res['template'])
        t = Template(res['template'])

        t.system_prepare()

        # describe process for dry runs
        if self.args.dry_run:
            tx = t.system_transaction()
            packages_install = list(tx.install_set)
            packages_install.sort(key=lambda x: x.name)

            packages_remove = list(tx.remove_set)
            packages_remove.sort(key=lambda x: x.name)
            if len(packages_install) or len(packages_remove):
                print('The following would be installed to (+) and removed from (-) the system:')

                for p in packages_install:
                    print('  + ' + str(p))

                for p in packages_remove:
                    print('  - ' + str(p))

                print()
                print('Summary:')
                print('  - Package(s): %d' % (len(packages_install)+len(packages_remove)))
                print()

            else:
                print('No system changes required.')

            print('No action peformed during this dry-run.')
            return 0

        # TODO: progress for download, install and removal
        t.to_system_apply(clean=False)

        print('info: machine synced.')

        return 0
Beispiel #3
0
    def run_pull(self):
        # am i effectively root
        if os.geteuid() != 0:
            print('You need to have root privileges to modify the system.')
            return 0

        t = Template(self.args.template, user=self.args.username)

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

        except ServiceException as e:
            print(e)
            return 1

        t.system_prepare(clean=self.args.pull_clean)

        # describe process for dry runs
        if self.args.dry_run:
            tx = t.system_transaction()
            packages_install = list(tx.install_set)
            packages_install.sort(key=lambda x: x.name)

            packages_remove = list(tx.remove_set)
            packages_remove.sort(key=lambda x: x.name)

            if len(packages_install) or len(packages_remove):
                print(
                    'The following would be installed to (+) and removed from (-) the system:'
                )

                for p in packages_install:
                    print('  + ' + str(p))

                for p in packages_remove:
                    print('  - ' + str(p))

                print()
                print('Summary:')
                print('  - Package(s): %d' %
                      (len(packages_install) + len(packages_remove)))
                print()

            else:
                print('No system changes required.')

            print('No action peformed during this dry-run.')
            return 0

        t.system_apply()
Beispiel #4
0
    def run_pull(self):
        # am i effectively root
        if os.geteuid() != 0:
            logging.error('You need to have root privileges to modify the system.')
            return 0

        t = Template(self.args.template, user=self.args.username)

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

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

        t.system_prepare(clean=self.args.pull_clean)

        # describe process for dry runs
        if self.args.dry_run:
            tx = t.system_transaction()
            packages_install = list(tx.install_set)
            packages_install.sort(key=lambda x: x.name)

            packages_remove = list(tx.remove_set)
            packages_remove.sort(key=lambda x: x.name)

            if len(packages_install) or len(packages_remove):
                print('The following would be installed to (+) and removed from (-) the system:')

                for p in packages_install:
                    print('  + ' + str(p))

                for p in packages_remove:
                    print('  - ' + str(p))

                print()
                print('Summary:')
                print('  - Package(s): %d' % (len(packages_install)+len(packages_remove)))
                print()

            else:
                print('No system changes required.')

            logging.info('No action peformed during this dry-run.')
            return 0

        t.system_apply()