def process_main(self, item=None): """ Link the unit to the content directory and the package_dir :param unit: The unit to process :type unit: pulp.server.db.model.NonMetadataPackage """ unit = item source_path = unit._storage_path relative_path = unit.filename destination_path = os.path.join(self.get_working_dir(), relative_path) plugin_misc.create_symlink(source_path, destination_path) filename = unit.name + '-' + unit.version + '-' + unit.release + '.' + unit.arch + '.json' path = os.path.join(self.get_working_dir(), filename) metadata_dict = unit.create_legacy_metadata_dict() # The repodata is large, and can get re-generated during upload, so we leave it out here. metadata_dict.pop('repodata', None) dict_to_write = { 'unit_key': unit.unit_key, 'unit_metadata': metadata_dict } with open(path, 'w') as f: json.dump(dict_to_write, f)
def process_unit(self, unit): """ Link the unit to the content directory and the package_dir :param unit: The unit to process :type unit: pulp.plugins.model.Unit """ source_path = unit.storage_path relative_path = util.get_relpath_from_unit(unit) destination_path = os.path.join(self.get_working_dir(), relative_path) self._create_symlink(source_path, destination_path) filename = unit.unit_key['name'] + '-' + unit.unit_key['version'] + '-' + \ unit.unit_key['release'] + '.' + unit.unit_key['arch'] + '.json' path = os.path.join(self.get_working_dir(), filename) # Remove all keys that start with an underscore, like _id and _ns for key_to_remove in filter(lambda key: key[0] == '_', unit.metadata.keys()): unit.metadata.pop(key_to_remove) # repodata will be regenerated on import, so remove it as well if 'repodata' in unit.metadata: unit.metadata.pop('repodata') dict_to_write = {'unit_key': unit.unit_key, 'unit_metadata': unit.metadata} with open(path, 'w') as f: json.dump(dict_to_write, f)
def process_unit(self, unit): # Remove unnecessary keys, like _id for key_to_remove in filter(lambda key: key[0] == '_', unit.metadata.keys()): unit.metadata.pop(key_to_remove) errata_dict = { 'unit_key': unit.unit_key, 'unit_metadata': unit.metadata } json_file_path = os.path.join(self.get_working_dir(), unit.unit_key['id'] + '.json') with open(json_file_path, 'w') as f: json.dump(errata_dict, f)
def process_main(self, item=None): """ :param item: the errata unit to process :type item: pulp_rpm.plugins.db.models.Errata """ unit = item errata_dict = { 'unit_key': unit.unit_key, 'unit_metadata': unit.create_legacy_metadata_dict() } json_file_path = os.path.join(self.get_working_dir(), unit.errata_id + '.json') with open(json_file_path, 'w') as f: json.dump(errata_dict, f)
def process_main(self, item=None): """ Link the unit to the content directory and the package_dir :param unit: The unit to process :type unit: pulp.server.db.model.NonMetadataPackage """ unit = item source_path = unit._storage_path relative_path = unit.filename destination_path = os.path.join(self.get_working_dir(), relative_path) plugin_misc.create_symlink(source_path, destination_path) filename = unit.name + '-' + unit.version + '-' + unit.release + '.' + unit.arch + '.json' path = os.path.join(self.get_working_dir(), filename) metadata_dict = unit.create_legacy_metadata_dict() # The repodata is large, and can get re-generated during upload, so we leave it out here. metadata_dict.pop('repodata', None) dict_to_write = {'unit_key': unit.unit_key, 'unit_metadata': metadata_dict} with open(path, 'w') as f: json.dump(dict_to_write, f)