def test_request_content_unit_file_path_no_error(self, mock_root_dir, mock_makedirs): mock_root_dir.return_value = '/var/lib/pulp/content/rpm/' mock_makedirs.return_value = '/var/lib/pulp/content/rpm/name' ContentQueryManager().request_content_unit_file_path( 'rpm', '/name/blah') mock_makedirs.assert_called_once_with('/var/lib/pulp/content/rpm/name')
def test_request_content_unit_file_path_exists(self, mock_root_dir, mock_makedirs): mock_root_dir.return_value = '/var/lib/pulp/content/rpm/' mock_makedirs.side_effect = OSError(errno.EEXIST, os.strerror(errno.EEXIST)) ContentQueryManager().request_content_unit_file_path( 'rpm', '/name/blah') mock_makedirs.assert_called_once_with('/var/lib/pulp/content/rpm/name')
def test_request_content_unit_file_path_random_os_error( self, mock_root_dir, mock_makedirs): mock_root_dir.return_value = '/var/lib/pulp/content/rpm/' mock_makedirs.side_effect = OSError(errno.EACCES, os.strerror(errno.EACCES)) self.assertRaises(OSError, ContentQueryManager().request_content_unit_file_path, 'rpm', '/name/blah') mock_makedirs.assert_called_once_with('/var/lib/pulp/content/rpm/name')
def migrate(*args, **kwargs): """ Looks up rpm unit collection in the db and computes the changelog and filelist data if not already available; If the package path is missing, the fields are defaulted to empty list. """ query_manager = ContentQueryManager() collection = query_manager.get_content_unit_collection(type_id="rpm") ts = rpmUtils.transaction.initReadOnlyTransaction() for rpm_unit in collection.find(): _migrate_unit(rpm_unit, ts, collection) _LOGGER.info( "Migrated rpms to include rpm changelog and filelist metadata")
def _migrate_rpm_unit_repodata(): """ Looks up rpm unit collection in the db and computes the repodata if nto already available; If the package path is missing, the repodata if stored as an empty dict. """ query_manager = ContentQueryManager() collection = query_manager.get_content_unit_collection(type_id="rpm") for rpm_unit in collection.find(): modified = False if "repodata" not in rpm_unit: rpm_unit["repodata"] = get_package_xml(rpm_unit['_storage_path']) modified = True if modified: collection.save(rpm_unit, safe=True)
def _migrate_rpm_unit_repodata(): """ Looks up rpm unit collection in the db and computes the repodata if not already available; If the package path is missing, the repodata if stored as an empty dict. """ query_manager = ContentQueryManager() collection = query_manager.get_content_unit_collection(type_id="rpm") for rpm_unit in collection.find(): if "repodata" not in rpm_unit or not rpm_unit["repodata"]: # if repodata is not in the schema or repodata is empty rpm_unit["repodata"] = metadata.get_package_xml( rpm_unit['_storage_path']) collection.save(rpm_unit, safe=True) _log.info("Migrated rpms to include rpm metadata")
def migrate(*args, **kwargs): """ For each puppet module, calculate a checksum for the source file on the filesystem. """ query_manager = ContentQueryManager() collection = query_manager.get_content_unit_collection( type_id=constants.TYPE_PUPPET_MODULE) for puppet_unit in collection.find(): storage_path = puppet_unit['_storage_path'] checksum = metadata.calculate_checksum(storage_path) puppet_unit['checksum'] = checksum puppet_unit['checksum_type'] = constants.DEFAULT_HASHLIB collection.save(puppet_unit) _log.info("Migrated puppet modules to include checksum")
def test_get_content_unit_collection(self): manager = ContentQueryManager() collection = manager.get_content_unit_collection('deb') self.assertTrue(isinstance(collection, PulpCollection)) self.assertEqual(collection.name, 'units_deb')
def setUp(self): super(TestGetContentUnitIDs, self).setUp() self.manager = ContentQueryManager()
def setUp(self): super(PulpContentTests, self).setUp() database.update_database([TYPE_1_DEF, TYPE_2_DEF]) self.cud_manager = ContentManager() self.query_manager = ContentQueryManager()