def validate_delete(cls, extension_names, cluster): not_found_extensions = extension_names - set(cluster.extensions) if not_found_extensions: raise errors.CannotFindExtension( "No such extensions to disable: {0}".format(", ".join( sorted(not_found_extensions)))) return list(extension_names)
def validate(cls, data): data = set(super(ExtensionValidator, cls).validate(data)) all_extensions = set(ext.name for ext in get_all_extensions()) not_found_extensions = data - all_extensions if not_found_extensions: raise errors.CannotFindExtension("No such extensions: {0}".format( ", ".join(sorted(not_found_extensions)))) return list(data)
def _get_extension_by_node(call_name, node): all_extensions = {ext.name: ext for ext in get_all_extensions()} for extension in chain(node.extensions, node.cluster.extensions if node.cluster else []): if (extension in all_extensions and call_name in all_extensions[extension].provides): return all_extensions[extension] raise errors.CannotFindExtension("Cannot find extension which provides " "'{0}' call".format(call_name))
def get_extension(name): """Retrieves extension by name :param str name: name of the extension :returns: extension class :raises errors.CannotFindExtension: on non existing extension """ extension = next((ext for ext in get_all_extensions() if ext.name == name), None) if extension is not None: return extension raise errors.CannotFindExtension( "Cannot find extension with name '{0}'".format(name))