def get_check_plugin(plugin_name: CheckPluginName) -> Optional[CheckPlugin]: """Returns the registered check plugin Management plugins may be created on the fly. """ plugin = registered_check_plugins.get(plugin_name) if plugin is not None or not plugin_name.is_management_name(): return plugin # create management board plugin on the fly: non_mgmt_plugin = registered_check_plugins.get(plugin_name.create_host_name()) if non_mgmt_plugin is not None: return management_plugin_factory(non_mgmt_plugin) return None
def _validate_service_name(plugin_name: CheckPluginName, service_name: str) -> None: if not isinstance(service_name, str): raise TypeError("service_name must be str, got %r" % (service_name,)) if not service_name: raise ValueError("service_name must not be empty") if service_name.count(ITEM_VARIABLE) not in (0, 1): raise ValueError("service_name must contain %r at most once" % ITEM_VARIABLE) if plugin_name.is_management_name() is not service_name.startswith(MANAGEMENT_DESCR_PREFIX): raise ValueError( "service name and description inconsistency: Please neither have your plugins " "name start with %r, nor the description with %r. In the rare case that you want to " "implement a check plugin explicitly designed for management boards (and nothing else)," " you must do both of the above." % (CheckPluginName.MANAGEMENT_PREFIX, MANAGEMENT_DESCR_PREFIX))