diff --git a/plugins/cliconf/default.py b/plugins/cliconf/default.py index 996303336..5d418d54f 100644 --- a/plugins/cliconf/default.py +++ b/plugins/cliconf/default.py @@ -4,6 +4,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type DOCUMENTATION = """ @@ -18,6 +19,8 @@ import json +from ansible.errors import AnsibleConnectionFailure + from ansible_collections.ansible.netcommon.plugins.plugin_utils.cliconf_base import CliconfBase @@ -31,17 +34,17 @@ def get_device_info(self): device_info = {} device_info["network_os"] = "default" + self._device_info = device_info + return self._device_info def get_config(self, flags=None, format=None): - return self._connection.method_not_found( - "commit is not supported by network_os %s" % self._play_context.network_os - ) + network_os = self.get_device_info()["network_os"] + raise AnsibleConnectionFailure("get_config is not supported by network_os %s" % network_os) def edit_config(self, candidate=None, commit=True, replace=None, comment=None): - return self._connection.method_not_found( - "commit is not supported by network_os %s" % self._play_context.network_os - ) + network_os = self.get_device_info()["network_os"] + raise AnsibleConnectionFailure("edit_config is not supported by network_os %s" % network_os) def get_capabilities(self): result = super(Cliconf, self).get_capabilities() diff --git a/plugins/plugin_utils/cliconf_base.py b/plugins/plugin_utils/cliconf_base.py index e1bc4a334..30b4aa550 100644 --- a/plugins/plugin_utils/cliconf_base.py +++ b/plugins/plugin_utils/cliconf_base.py @@ -17,6 +17,7 @@ # Needed to satisfy PluginLoader's required_base_class from ansible.plugins.cliconf import CliconfBase as CliconfBaseBase + from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import to_list @@ -352,7 +353,7 @@ def commit(self, comment=None): :return: None """ - return self._connection.method_not_found( + raise AnsibleConnectionFailure( "commit is not supported by network_os %s" % self._play_context.network_os ) @@ -365,7 +366,7 @@ def discard_changes(self): :returns: None """ - return self._connection.method_not_found( + raise AnsibleConnectionFailure( "discard_changes is not supported by network_os %s" % self._play_context.network_os )