Skip to content

Commit

Permalink
Fix some holes in default cliconf
Browse files Browse the repository at this point in the history
  • Loading branch information
Qalthos committed Jul 24, 2023
1 parent 8873ef7 commit b621fa6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
15 changes: 9 additions & 6 deletions plugins/cliconf/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from __future__ import absolute_import, division, print_function


__metaclass__ = type

DOCUMENTATION = """
Expand All @@ -18,6 +19,8 @@

import json

from ansible.errors import AnsibleConnectionFailure

from ansible_collections.ansible.netcommon.plugins.plugin_utils.cliconf_base import CliconfBase


Expand All @@ -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()
Expand Down
5 changes: 3 additions & 2 deletions plugins/plugin_utils/cliconf_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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
)

Expand All @@ -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
)

Expand Down

0 comments on commit b621fa6

Please sign in to comment.