Skip to content

Commit

Permalink
add a mechanism for plugin to decide whether it is compatible
Browse files Browse the repository at this point in the history
Signed-off-by: Stepan Blyshchak <stepanb@nvidia.com>
  • Loading branch information
stepanblyschak committed Jan 27, 2021
1 parent 1d4da48 commit d815bb7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion utilities_common/util_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,14 @@ def iter_namespace(ns_pkg):
def register_plugin(self, plugin, root_command):
""" Register plugin in top-level command root_command. """

log.log_debug('registering plugin: {}'.format(plugin.__name__))
name = plugin.__name__
log.log_debug('registering plugin: {}'.format(name))
if hasattr(plugin, 'is_compatible'):
if not plugin.is_compatible():
log.log_error('plugin {} reports that it is not '
'compatible with this version of CLI'.format(name),
also_print_to_console=True)
return
plugin.register(root_command)

# Loads platform specific psuutil module from source
Expand Down

0 comments on commit d815bb7

Please sign in to comment.