def load_schema_for_vo(vo): GENERIC_FALLBACK = 'generic_multi_vo' if config.config_has_section('policy'): try: POLICY = config.config_get('policy', 'package-' + vo, check_config_table=False) + ".schema" except (NoOptionError, NoSectionError): # fall back to old system for now try: POLICY = config.config_get('policy', 'schema', check_config_table=False) except (NoOptionError, NoSectionError): POLICY = GENERIC_FALLBACK POLICY = 'rucio.common.schema.' + POLICY.lower() else: POLICY = 'rucio.common.schema.' + GENERIC_FALLBACK.lower() try: module = importlib.import_module(POLICY) except ImportError: raise exception.PolicyPackageNotFound('Module ' + POLICY + ' not found') schema_modules[vo] = module
def load_permission_for_vo(vo): GENERIC_FALLBACK = 'generic_multi_vo' if config.config_has_section('policy'): try: env_name = 'RUCIO_POLICY_PACKAGE_' + vo.upper() if env_name in environ: POLICY = environ[env_name] + ".permission" else: POLICY = config.config_get('policy', 'package-' + vo) + ".permission" except (NoOptionError, NoSectionError): # fall back to old system for now try: POLICY = config.config_get('policy', 'permission') except (NoOptionError, NoSectionError): POLICY = GENERIC_FALLBACK POLICY = 'rucio.core.permission.' + POLICY.lower() else: POLICY = 'rucio.core.permission.' + GENERIC_FALLBACK.lower() try: module = importlib.import_module(POLICY) except ImportError: raise exception.PolicyPackageNotFound('Module ' + POLICY + ' not found') permission_modules[vo] = module
if config.config_has_section('permission'): try: FALLBACK_POLICY = config.config_get('permission', 'policy') except (NoOptionError, NoSectionError) as error: FALLBACK_POLICY = 'generic' elif config.config_has_section('policy'): try: FALLBACK_POLICY = config.config_get('policy', 'permission') except (NoOptionError, NoSectionError) as error: FALLBACK_POLICY = 'generic' else: FALLBACK_POLICY = 'generic' if config.config_has_section('policy'): try: POLICY = config.config_get('policy', 'package') + ".permission" except (NoOptionError, NoSectionError) as error: # fall back to old system for now POLICY = 'rucio.core.permission.' + FALLBACK_POLICY.lower() else: POLICY = 'rucio.core.permission.generic' try: module = importlib.import_module(POLICY) except (ImportError) as error: raise exception.PolicyPackageNotFound('Module ' + POLICY + ' not found') for i in dir(module): if i[:1] != '_' or i == '_is_root': globals()[i] = getattr(module, i)
# Note that the order of this list is important. As the base metadata plugin module is always first, base key # retrieval and setting will always take precedence over custom plugins, i.e. it is not possible to set a custom key with # the same name as those in the base list. # # Another consequence of this is that if set_metadata() is called with multiple plugins specified, the first to return # True to manages_key() will be used. # METADATA_PLUGIN_MODULES = [] for meta_module_path in METADATA_PLUGIN_MODULE_PATHS: try: base_module = ".".join(meta_module_path.split(".")[:-1]) base_class = meta_module_path.split(".")[-1] metadata_plugin_module = getattr(importlib.import_module(base_module), base_class)() METADATA_PLUGIN_MODULES.append(metadata_plugin_module) except ImportError: raise exception.PolicyPackageNotFound('Module ' + meta_module_path + ' not found') # Set restricted character set for metadata in form character: reason # RESTRICTED_CHARACTERS = { '.': "Used as a delimiter for key and operator (<key>.<operator>) in filtering engine." } def get_metadata(scope, name, plugin="DID_COLUMN", session=None): """ Gets the metadata for a given did from a specified plugin. If [plugin] is set to "all", metadata from all available metadata plugins will be returned, else [plugin] can be used to only return the metadata using a specific plugin.