Beispiel #1
0
    def run_update(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

        r = t.find_repo(self.args.repo)

        if len(r) != 1:
            print('error: repo is not defined in template.')
            return 1

        r = r[0]
        o = {
            'n': self.args.name,
            'bu': self.args.baseurl,
            'ml': self.args.mirrorlist,
            'ma': self.args.metalink,
            'e': self.args.enabled,
            'c': self.args.cost,
            'p': self.args.priority,
            'gc': self.args.gpgcheck,
            'gk': self.args.gpgkey,
            'sk': self.args.skip,
            'x': self.args.exclude
        }

        o = {k: v for k, v in o.items() if v != None}

        r.parse(o)

        if not t.update_repo(r):
            print('error: no changes detected.')
            return 0

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

        except ServiceException as e:
            print(e)
            return 1

        print('info: repo updated.')
        return 0
Beispiel #2
0
  def run_update(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

    r = t.find_repo(self.args.repo)

    if len(r) != 1:
      print('error: repo is not defined in template.')
      return 1

    r = r[0]
    o = {
      'n':  self.args.name,
      'bu': self.args.baseurl,
      'ml': self.args.mirrorlist,
      'ma': self.args.metalink,
      'e':  self.args.enabled,
      'c':  self.args.cost,
      'p':  self.args.priority,
      'gc': self.args.gpgcheck,
      'gk': self.args.gpgkey,
      'sk': self.args.skip,
      'x':  self.args.exclude
    }

    o = {k: v for k, v in o.items() if v != None}

    r.parse(o)

    if not t.update_repo(r):
      print('error: no changes detected.')
      return 0

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

    except ServiceException as e:
      print(e)
      return 1

    print('info: repo updated.')
    return 0
Beispiel #3
0
    def run_update(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

        r = t.find_repo(self.args.repo)

        if len(r) != 1:
            print('error: repo is not defined in template.')
            return 1

        r = r[0]

        # reset baseurl, metalink and mirrorlist when any are specified
        if self.args.baseurl is not None or self.args.metalink is not None or self.args.mirrorlist is not None:
            r.baseurl = None
            r.mirrorlist = None
            r.metalink = None

        if self.args.baseurl is not None:
            r.baseurl = self.args.baseurl

        if self.args.cost is not None:
            r.cost = self.args.cost

        if self.args.enabled is not None:
            r.enabled = self.args.enabled

        if self.args.gpgcheck is not None:
            r.gpgcheck = self.args.gpgcheck

        if self.args.gpgkey is not None:
            r.gpgkey = self.args.gpgkey

        if self.args.metalink is not None:
            r.metalink = self.args.metalink

        if self.args.mirrorlist is not None:
            r.mirrorlist = self.args.mirrorlist

        if self.args.name is not None:
            r.name = self.args.name

        if self.args.priority is not None:
            r.priority = self.args.priority

        if not t.update_repo(r):
            print('info: no changes detected.')
            return 0

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

        except ServiceException as e:
            print(e)
            return 1

        print('info: repo updated.')
        return 0
Beispiel #4
0
    def run_update(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

        r = t.find_repo(self.args.repo)

        if len(r) != 1:
            print('error: repo is not defined in template.')
            return 1

        r = r[0]

        # reset baseurl, metalink and mirrorlist when any are specified
        if self.args.baseurl is not None or self.args.metalink is not None or self.args.mirrorlist is not None:
            r.baseurl = None
            r.mirrorlist = None
            r.metalink = None

        if self.args.baseurl is not None:
            r.baseurl = self.args.baseurl

        if self.args.cost is not None:
            r.cost = self.args.cost

        if self.args.enabled is not None:
            r.enabled = self.args.enabled

        if self.args.gpgcheck is not None:
            r.gpgcheck = self.args.gpgcheck

        if self.args.gpgkey is not None:
            r.gpgkey = self.args.gpgkey

        if self.args.metalink is not None:
            r.metalink = self.args.metalink

        if self.args.mirrorlist is not None:
            r.mirrorlist = self.args.mirrorlist

        if self.args.name is not None:
            r.name = self.args.name

        if self.args.priority is not None:
            r.priority= self.args.priority

        if not t.update_repo(r):
            print('info: no changes detected.')
            return 0

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

        except ServiceException as e:
            print(e)
            return 1

        print('info: repo updated.')
        return 0