mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 22:02:50 +00:00
Fix ios and vyos cliconf edit_config return type (#41896)
* Fix ios and vyos cliconf edit_config return type Modify cliconf edit_config api to return a json string with diff and response received from remote host for ios and vyos. * Doc change
This commit is contained in:
@@ -206,9 +206,13 @@ class CliconfBase(with_metaclass(ABCMeta, object)):
|
||||
:param diff: Boolean flag to indicate if configuration that is applied on remote host should
|
||||
generated and returned in response or not
|
||||
:param comment: Commit comment provided it is supported by remote host
|
||||
:return: Returns a tuple, the first entry of tupe is configuration diff if diff flag is enable else
|
||||
it is None. Second entry is the list of response received from remote host on executing
|
||||
configuration commands.
|
||||
:return: Returns a json string with contains configuration applied on remote host, the returned
|
||||
response on executing configuration commands and platform relevant data.
|
||||
{
|
||||
"diff": "",
|
||||
"response": []
|
||||
}
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
@@ -125,6 +125,7 @@ class Cliconf(CliconfBase):
|
||||
|
||||
@enable_mode
|
||||
def edit_config(self, candidate=None, commit=True, replace=False, diff=False, comment=None):
|
||||
resp = {}
|
||||
if not candidate:
|
||||
raise ValueError("must provide a candidate config to load")
|
||||
|
||||
@@ -154,7 +155,9 @@ class Cliconf(CliconfBase):
|
||||
if diff:
|
||||
diff_config = candidate
|
||||
|
||||
return diff_config, results[1:-1]
|
||||
resp['diff'] = diff_config
|
||||
resp['response'] = results[1:-1]
|
||||
return json.dumps(resp)
|
||||
|
||||
def get(self, command=None, prompt=None, answer=None, sendonly=False):
|
||||
if not command:
|
||||
|
||||
@@ -61,6 +61,7 @@ class Cliconf(CliconfBase):
|
||||
return out
|
||||
|
||||
def edit_config(self, candidate=None, commit=True, replace=False, diff=False, comment=None):
|
||||
resp = {}
|
||||
if not candidate:
|
||||
raise ValueError('must provide a candidate config to load')
|
||||
|
||||
@@ -98,7 +99,9 @@ class Cliconf(CliconfBase):
|
||||
else:
|
||||
self.discard_changes()
|
||||
|
||||
return diff_config, results[1:]
|
||||
resp['diff'] = diff_config
|
||||
resp['response'] = results[1:]
|
||||
return json.dumps(resp)
|
||||
|
||||
def get(self, command=None, prompt=None, answer=None, sendonly=False):
|
||||
if not command:
|
||||
|
||||
Reference in New Issue
Block a user