def test_plugins_are_inherited_from_base(self):
     self.assertTrue(
         all(
             (
                 issubclass(p, base.CinderMigrationPlugin)
                 for p in extensions.available_extensions(base.CinderMigrationPlugin, OS_STORAGE_PLUGINS)
             )
         )
     )
Exemple #2
0
def get_copier_class(name=None):
    """
    Returns the copier by its name or default copier if name is None

    :param name: Name of copier or None
    :return: A copier's class
    """
    name = name or CONF.migrate.copy_backend
    copiers = extensions.available_extensions(BaseCopier,
                                              'cloudferry.lib.copy_engines')
    for copier in copiers:
        if copier.get_name() == name:
            return copier
    raise CopierNotFound(name)
Exemple #3
0
def get_cinder_backend(context):
    """:returns: instance of cinder plugin"""

    cloud = context.position
    storage_config = context.config['{cloud}_storage'.format(cloud=cloud)]
    configured_backend = storage_config.backend

    for plugin in extensions.available_extensions(base.CinderMigrationPlugin,
                                                  __name__):
        if configured_backend.lower() == plugin.PLUGIN_NAME:
            return plugin.from_context(context)

    msg = ("Invalid cinder plugin '{plugin}' specified in "
           "config".format(plugin=configured_backend))
    raise InvalidCinderPluginError(msg)
Exemple #4
0
def get_cinder_backend(context):
    """:returns: instance of cinder plugin"""

    cloud = context.position
    storage_config = context.config['{cloud}_storage'.format(cloud=cloud)]
    configured_backend = storage_config.backend

    for plugin in extensions.available_extensions(base.CinderMigrationPlugin,
                                                  __name__):
        if configured_backend.lower() == plugin.PLUGIN_NAME:
            return plugin.from_context(context)

    msg = ("Invalid cinder plugin '{plugin}' specified in "
           "config".format(plugin=configured_backend))
    raise InvalidCinderPluginError(msg)
Exemple #5
0
    def init_tasks(self, init):
        with open(self.path_tasks) as tasks_file:
            tasks_file = yaml.load(tasks_file)
            actions = {}
            for path in tasks_file['paths']:
                actions.update({e.__name__: e
                                for e in extensions.available_extensions(
                                    action.Action, path)})

            tasks = {}
            for task in tasks_file['tasks']:
                args = tasks_file['tasks'][task][1:]
                if args and isinstance(args[-1], dict):
                    args_map = args[-1]
                    args = args[:-1]
                else:
                    args_map = {}
                tasks[task] = actions[tasks_file['tasks'][task][0]](init,
                                                                    *args,
                                                                    **args_map)
            self.tasks = tasks
Exemple #6
0
    def init_tasks(self, init):
        with open(self.path_tasks) as tasks_file:
            tasks_file = yaml.load(tasks_file)
            actions = {}
            for path in tasks_file['paths']:
                actions.update({e.__name__: e
                                for e in extensions.available_extensions(
                                    action.Action, path)})

            tasks = {}
            for task in tasks_file['tasks']:
                args = tasks_file['tasks'][task][1:]
                if args and isinstance(args[-1], dict):
                    args_map = args[-1]
                    args = args[:-1]
                else:
                    args_map = {}
                tasks[task] = actions[tasks_file['tasks'][task][0]](init,
                                                                    *args,
                                                                    **args_map)
            self.tasks = tasks
 def test_returns_list(self):
     self.assertIsInstance(extensions.available_extensions(base.CinderMigrationPlugin, OS_STORAGE_PLUGINS), list)