def update_update_candidates(self, account, remote_host, packages_add, packages_remove): """ Add and/or remove packages from the update_candidates table. """ c = self._get_computer_from_account(account) if type(packages_add) != list or type(packages_remove) != list: raise InvalidParamsFault('update_update_candidates') # First remove the packages. for name in packages_remove: package = c.update_candidates.get_by(name=name) if package: package.delete() package.flush() # Now add the new ones. for p in packages_add: if type(p) != dict or not 'name' in p or not 'version' in p: raise InvalidParamsFault('update_update_candidates') name = p['name'] version = p['version'] package = UpdateCandidates(computer=c, name=name, version=version) package.save() package.flush() self._increment_table_version(c, 'update_candidates')
def set_update_candidates(self, account, remote_host, update_candidates): """ Remove old update candidates and set new ones. """ c = self._get_computer_from_account(account) delete_all(c.update_candidates) if type(update_candidates) != list: raise InvalidParamsFault('set_update_candidates') for uc in update_candidates: if type(uc) != dict or not 'name' in uc or not 'version' in uc: raise InvalidParamsFault('set_update_candidates') name = c['name'] version = c['version'] u = UpdateCandidates(computer=c, name=name, version=version) u.save() u.flush()