Ejemplo n.º 1
0
    def run_add(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

        # default enabled
        if self.args.enabled is None:
            self.args.enabled = True

        r = Repository({
            'stub': self.args.repo,
            'name': self.args.name,
            'baseurl': self.args.baseurl,
            'mirrorlist': self.args.mirrorlist,
            'metalink': self.args.metalink,
            'enabled': self.args.enabled,
            'cost': self.args.cost,
            'priority': self.args.priority,
            'gpgkey': self.args.gpgkey,
            'gpgcheck': self.args.gpgcheck,
            'exclude': self.args.exclude
        })

        t.add_repo(r)

        # push our updated template
        try:
            res = self.cs.template_update(t)

        except ServiceException as e:
            print(e)
            return 1

        print('info: repo added.')
        return 0
Ejemplo n.º 2
0
  def run_add(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

    # default enabled
    if self.args.enabled is None:
      self.args.enabled = True

    r = Repository(
      stub        = self.args.repo,
      name        = self.args.name,
      baseurl     = self.args.baseurl,
      mirrorlist  = self.args.mirrorlist,
      metalink    = self.args.metalink,
      enabled     = self.args.enabled,
      cost        = self.args.cost,
      priority    = self.args.priority,
      gpgkey      = self.args.gpgkey,
      gpgcheck    = self.args.gpgcheck,
      exclude     = self.args.exclude
    )

    t.add_repo(r)

    # push our updated template
    try:
      res = self.cs.template_update(t)

    except ServiceException as e:
      print(e)
      return 1

    print('info: repo added.')
    return 0
Ejemplo n.º 3
0
    def run_add(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

        # default enabled
        if self.args.enabled is None:
            self.args.enabled = True

        r = Repository({
            'stub'       : self.args.repo,
            'name'       : self.args.name,
            'baseurl'    : self.args.baseurl,
            'mirrorlist' : self.args.mirrorlist,
            'metalink'   : self.args.metalink,
            'enabled'    : self.args.enabled,
            'cost'       : self.args.cost,
            'priority'   : self.args.priority,
            'gpgkey'     : self.args.gpgkey,
            'gpgcheck'   : self.args.gpgcheck,
            'exclude'    : self.args.exclude
        })

        t.add_repo(r)

        # push our updated template
        try:
            res = self.cs.template_update(t)

        except ServiceException as e:
            print(e)
            return 1

        print('info: repo added.')
        return 0
Ejemplo n.º 4
0
    def run_add(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

        # default enabled
        if self.args.enabled is None:
            self.args.enabled = True

        r = Repository(stub=self.args.repo,
                       name=self.args.name,
                       baseurl=self.args.baseurl,
                       mirrorlist=self.args.mirrorlist,
                       metalink=self.args.metalink,
                       enabled=self.args.enabled,
                       cost=self.args.cost,
                       priority=self.args.priority,
                       gpgkey=self.args.gpgkey,
                       gpgcheck=self.args.gpgcheck,
                       exclude=self.args.exclude)

        t.add_repo(r)

        # push our updated template
        try:
            res = self.cs.template_update(t)

        except ServiceException as e:
            print(e)
            return 1

        print('info: repo added.')
        return 0
Ejemplo n.º 5
0
    def run_push(self):
        t = Template(self.args.template, user=self.args.username)

        # grab the template we're pushing to
        try:
            t = self.cs.template_get(t)

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

        if self.args.push_clean:
            t.clear()

        if self.args.kickstart is not None:
            logging.info('Parsing kickstart ...')
            t.from_kickstart(self.args.kickstart)

        else:
            # prepare dnf
            logging.info('Analysing system ...')
            db = dnf.Base()
            db.read_all_repos()
            db.read_comps()

            try:
                db.fill_sack()

            except OSError as e:
                pass

            db_list = db.iter_userinstalled()

            if self.args.push_all:
                db_list = db.sack.query().installed()

            # add our user installed packages
            for p in db_list:
                # no need to store versions
                t.add_package(Package(p, evr=False))

            # add only enabled repos
            for r in db.repos.enabled():
                t.add_repo(Repository(r))

        objects = list(t.objects_delta)
        objects.sort(key=lambda x: x.name)

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

        repos = list(t.repos_delta)
        repos.sort(key=lambda x: x.name)

        # describe process for dry runs
        if self.args.dry_run:
            if len(packages) or len(repos):
                print(
                    'The following would be added to the template: {0}'.format(
                        t.name))

                for r in repos:
                    print('  - ' + str(r))

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

                for o in objects:
                    print('  - ' + str(o))

                print()
                print('Summary:')
                print('  - Repo(s): %d' % (len(repos)))
                print('  - Package(s): %d' % (len(packages)))
                print('  - Object(s): %d' % (len(objects)))
                print()

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

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

        if self.args.kickstart is None and not len(packages) and not len(
                repos):
            logging.info('No changes detected, template up to date.')
            return 0

        # push our updated template
        try:
            res = self.cs.template_update(t)

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

        logging.info('Template pushed.')
        return 0
Ejemplo n.º 6
0
    def run_push(self):
        t = Template(self.args.template, user=self.args.username)

        # grab the template we're pushing to
        try:
            t = self.cs.template_get(t)

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

        if self.args.push_clean:
            t.clear()

        if self.args.kickstart is not None:
            logging.info('Parsing kickstart ...')
            t.from_kickstart(self.args.kickstart)

        else:
            # prepare dnf
            logging.info('Analysing system ...')
            db = dnf.Base()
            db.read_all_repos()
            db.read_comps()

            try:
                db.fill_sack()

            except OSError as e:
                pass

            db_list = db.iter_userinstalled()

            if self.args.push_all:
                db_list = db.sack.query().installed()

            # add our user installed packages
            for p in db_list:
                # no need to store versions
                t.add_package(Package(p, evr=False))

            # add only enabled repos
            for r in db.repos.enabled():
                t.add_repo(Repository(r))

        objects = list(t.objects_delta)
        objects.sort(key=lambda x: x.name)

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

        repos = list(t.repos_delta)
        repos.sort(key=lambda x: x.name)

        # describe process for dry runs
        if self.args.dry_run:
            if len(packages) or len(repos):
                print('The following would be added to the template: {0}'.format(t.name))

                for r in repos:
                    print('  - ' + str(r))

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

                for o in objects:
                    print('  - ' + str(o))

                print()
                print('Summary:')
                print('  - Repo(s): %d' % (len(repos)))
                print('  - Package(s): %d' % (len(packages)))
                print('  - Object(s): %d' % (len(objects)))
                print()

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

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

        if self.args.kickstart is None and not len(packages) and not len(repos):
            logging.info('No changes detected, template up to date.')
            return 0

        # push our updated template
        try:
            res = self.cs.template_update(t)

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

        logging.info('Template pushed.')
        return 0