def export_errata(self, errata_units, progress_callback=None): """ This call looksup each errata unit and its associated rpms and exports the rpms units to the working directory and generates updateinfo xml for exported errata metadata. @param errata_units @type errata_units list of AssociatedUnit @param progress_callback: callback to report progress info to publish_conduit @type progress_callback: function @return tuple of status and list of error messages if any occurred @rtype ({}, [str]) """ summary = {} repo_working_dir = self.repo_working_dir errors = [] errata_progress_status = self.init_progress() if not errata_units: errata_progress_status["state"] = "FINISHED" self.set_progress("errata", errata_progress_status, progress_callback) return summary, errors if 'errata' in self.skip: errata_progress_status["state"] = "SKIPPED" self.set_progress("errata", errata_progress_status, progress_callback) _LOG.info("errata unit type in skip list [%s]; skipping export" % self.skip) return summary, errors errata_progress_status["num_success"] = 0 errata_progress_status["items_left"] = len(errata_units) errata_progress_status["items_total"] = len(errata_units) summary["num_errata_units_exported"] = 0 try: errata_progress_status['state'] = "IN_PROGRESS" self.set_progress("errata", errata_progress_status, progress_callback) updateinfo_path = updateinfo.updateinfo(errata_units, repo_working_dir) if updateinfo_path: repodata_dir = os.path.join(repo_working_dir, "repodata") if not os.path.exists(repodata_dir): _LOG.error("Missing repodata; cannot run modifyrepo") return summary, errors _LOG.debug("Modifying repo for updateinfo") metadata.modify_repo(repodata_dir, updateinfo_path) errata_progress_status["num_success"] = len(errata_units) errata_progress_status["items_left"] = 0 except metadata.ModifyRepoError, mre: details["errors"] = errors msg = "Unable to run modifyrepo to include updateinfo at target location %s; Error: %s" % (repo_working_dir, str(mre)) errors.append(msg) _LOG.error(msg) errata_progress_status['state'] = "FAILED" errata_progress_status["num_success"] = 0 errata_progress_status["items_left"] = len(errata_units) return summary, errors
def _export_errata(self, errata_units, repo_working_dir, progress_callback=None): """ This call looksup each errata unit and its associated rpms and exports the rpms units to the working directory and generates updateinfo xml for exported errata metadata. @param errata_units @type errata_units list of AssociatedUnit @param repo_working_dir: path of where we want the symlink and repodata to reside @type repo_working_dir str @param progress_callback: callback to report progress info to publish_conduit @type progress_callback: function @return tuple of status and list of error messages if any occurred @rtype (bool, [str]) """ errors = [] errata_progress_status = self.init_progress() if not errata_units: return True, [] errata_progress_status["num_success"] = 0 errata_progress_status["items_left"] = len(errata_units) errata_progress_status["items_total"] = len(errata_units) try: errata_progress_status['state'] = "IN_PROGRESS" self.set_progress("errata", errata_progress_status, progress_callback) updateinfo_path = updateinfo.updateinfo(errata_units, repo_working_dir) if updateinfo_path: repodata_dir = os.path.join(repo_working_dir, "repodata") if not os.path.exists(repodata_dir): _LOG.error("Missing repodata; cannot run modifyrepo") return False, [] _LOG.debug("Modifying repo for updateinfo") metadata.modify_repo(repodata_dir, updateinfo_path) errata_progress_status["num_success"] = len(errata_units) errata_progress_status["items_left"] = 0 except metadata.ModifyRepoError, mre: msg = "Unable to run modifyrepo to include updateinfo at target location %s; Error: %s" % (repo_working_dir, str(mre)) errors.append(msg) _LOG.error(msg) errata_progress_status['state'] = "FAILED" errata_progress_status["num_success"] = 0 errata_progress_status["items_left"] = len(errata_units) return False, errors