Ejemplo n.º 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

    # track updates to determine server update
    updated = False

    for p in self.args.package:

      # parse new and find old
      pn = Package(p)

      print(pn)

      if pn not in t.packages:
        print('warn: package is not defined in template.')
        continue

      # update with new and track
      if t.update_package(pn):
        updated = True

    if not updated:
      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: package(s) updated.')
    return 0
Ejemplo n.º 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

        # track updates to determine server update
        updated = False

        for p in self.args.package:

            # parse new and find old
            pn = Package(p)

            print(pn)

            if pn not in t.packages:
                print('warn: package is not defined in template.')
                continue

            # update with new and track
            if t.update_package(pn):
                updated = True

        if not updated:
            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: package(s) updated.')
        return 0