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 21, 2023
1 parent 1090f60 commit 6fb1d16
Show file tree
Hide file tree
Showing 2 changed files with 14 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
7 changes: 5 additions & 2 deletions plugins/plugin_utils/cliconf_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from __future__ import absolute_import, division, print_function


__metaclass__ = type

from abc import abstractmethod
Expand All @@ -16,8 +17,10 @@

# 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


try:
from scp import SCPClient

Expand Down Expand Up @@ -350,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 @@ -363,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 6fb1d16

Please sign in to comment.