Update eos, ios, vyos cliconf plugin (#42300)

* Update eos cliconf plugin methods

*  Refactor eos cliconf plugin
*  Changes in eos module_utils as per cliconf plugin refactor

* Fix unit test and sanity failures

* Fix review comment
This commit is contained in:
Ganesh Nalawade 2018-07-04 19:45:21 +05:30 committed by GitHub
parent 2aa81bf05d
commit c068b88b38
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 444 additions and 299 deletions

View file

@ -26,9 +26,9 @@
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
import json
from ansible.module_utils._text import to_text
from ansible.module_utils.basic import env_fallback, return_values
from ansible.module_utils.network.common.utils import to_list
from ansible.module_utils.connection import Connection, ConnectionError
_DEVICE_CONFIGS = {}
@ -100,26 +100,8 @@ def get_config(module):
def run_commands(module, commands, check_rc=True):
responses = list()
connection = get_connection(module)
try:
outputs = connection.run_commands(commands)
except ConnectionError as exc:
if check_rc:
module.fail_json(msg=to_text(exc))
else:
outputs = exc
for item in to_list(outputs):
try:
item = to_text(item, errors='surrogate_or_strict')
except UnicodeError:
module.fail_json(msg=u'Failed to decode output from %s: %s' % (item, to_text(item)))
responses.append(item)
return responses
return connection.run_commands(commands=commands, check_rc=check_rc)
def load_config(module, commands, commit=False, comment=None):
@ -127,7 +109,6 @@ def load_config(module, commands, commit=False, comment=None):
try:
resp = connection.edit_config(candidate=commands, commit=commit, comment=comment)
resp = json.loads(resp)
except ConnectionError as exc:
module.fail_json(msg=to_text(exc))