def sync_plugins_metadata(cls, plugin_ids=None): """Sync metadata for plugins by given ids. If there is not ids all newest plugins will be synced """ if plugin_ids: plugins = PluginCollection.get_by_uids(plugin_ids) else: plugins = PluginCollection.all() for plugin in plugins: plugin_adapter = wrap_plugin(plugin) plugin_adapter.sync_metadata_to_db()
def sync_plugins_metadata(cls, plugin_ids=None): """Sync metadata for plugins by given IDs. If there are no IDs, all newest plugins will be synced. :param plugin_ids: list of plugin IDs :type plugin_ids: list """ if plugin_ids: plugins = PluginCollection.get_by_uids(plugin_ids) else: plugins = PluginCollection.all() for plugin in plugins: plugin_adapter = wrap_plugin(plugin) plugin_adapter.sync_metadata_to_db()
def _install_or_update_or_delete_plugins(cls): """Sync plugins using FS and DB. If plugin: in DB and present on filesystem, it will be updated; in DB and not present on filesystem, it will be removed; not in DB, but present on filesystem, it will be installed """ installed_plugins = {} for plugin in PluginCollection.all(): plugin_adapter = wrap_plugin(plugin) installed_plugins[plugin_adapter.path_name] = plugin for plugin_dir in cls._list_plugins_on_fs(): if plugin_dir in installed_plugins: cls._plugin_update(installed_plugins.pop(plugin_dir)) else: cls._plugin_create(plugin_dir) for deleted_plugin in installed_plugins.values(): cls._plugin_delete(deleted_plugin)
def process_cluster_attributes(cls, cluster, attrs, query=None): if query is None: query = PluginCollection.all() for plugin_db in query: attr_plugin = ClusterAttributesPlugin(plugin_db) attr_plugin.process_cluster_attributes(cluster, attrs)