def get_extensions_urls(): """Method is used to retrieve the data about handlers and urls from extensions and convert them into web.py consumable format. :returns: dict in the next format: {'urls': (r'/url/', 'ClassName'), 'handlers': [{ 'class': ClassName, 'name': 'ClassName'}]} """ urls = [] handlers = [] for extension in get_all_extensions(): for url in extension.urls: # TODO(eli): handler name should be extension specific # not to have problems when several extensions use # the same name for handler classes. # Should be done as a part of blueprint: # https://blueprints.launchpad.net/fuel/+spec # /volume-manager-refactoring handler_name = url['handler'].__name__ handlers.append({'class': url['handler'], 'name': handler_name}) urls.extend((url['uri'], handler_name)) return {'urls': urls, 'handlers': handlers}
def get_extensions_urls(): """Method is used to retrieve the data about handlers and urls from extensions and convert them into web.py consumable format. :returns: dict in the next format: {'urls': (r'/url/', 'ClassName'), 'handlers': [{ 'class': ClassName, 'name': 'ClassName'}]} """ urls = [] handlers = [] for extension in get_all_extensions(): for url in extension.urls: # TODO(eli): handler name should be extension specific # not to have problems when several extensions use # the same name for handler classes. # Should be done as a part of blueprint: # https://blueprints.launchpad.net/fuel/+spec # /volume-manager-refactoring handler_name = url['handler'].__name__ handlers.append({ 'class': url['handler'], 'name': handler_name}) urls.extend((url['uri'], handler_name)) return {'urls': urls, 'handlers': handlers}
def do_upgrade_head_extensions(): from nailgun.extensions import get_all_extensions for extension in get_all_extensions(): if extension.alembic_migrations_path(): config = make_alembic_config_from_extension(extension) do_alembic_command('upgrade', config, 'head')
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 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 data
def action_extensions(params): from nailgun.logger import logger from nailgun.db.migration import action_migrate_alembic_extension from nailgun.extensions import get_all_extensions for extension in get_all_extensions(): if extension.alembic_migrations_path(): logger.info("Running command for extension {0}".format(extension.full_name())) action_migrate_alembic_extension(params, extension=extension) else: logger.info("Extension {0} does not have migrations. " "Skipping...".format(extension.full_name()))
def action_extensions(params): from nailgun.logger import logger from nailgun.db.migration import action_migrate_alembic_extension from nailgun.extensions import get_all_extensions for extension in get_all_extensions(): if extension.alembic_migrations_path(): logger.info('Running command for extension {0}'.format( extension.full_name())) action_migrate_alembic_extension(params, extension=extension) else: logger.info('Extension {0} does not have migrations. ' 'Skipping...'.format(extension.full_name()))
def GET(self): """:returns: JSONized list of available extensions. :http: * 200 (OK) """ return [ext().to_dict() for ext in get_all_extensions()]