Enos connection issue (#32895)

* Changes due to connection issues

* Adding changes pertaining to connection issue of Ansible

* Review comments of Kedar

* Adding EOL PyLint issue

* Fixing pep8  and yamlint issues
This commit is contained in:
Anil Kumar Muraleedharan 2017-11-15 02:30:16 +05:30 committed by Nathaniel Case
parent a1517234f6
commit e5b3f60a74
3 changed files with 33 additions and 41 deletions

View file

@ -35,6 +35,7 @@ from ansible.module_utils._text import to_text
from ansible.module_utils.basic import env_fallback, return_values
from ansible.module_utils.network_common import to_list, EntityCollection
from ansible.module_utils.connection import Connection, exec_command
from ansible.module_utils.connection import ConnectionError
_DEVICE_CONFIGS = {}
_CONNECTION = None
@ -75,7 +76,7 @@ def get_connection(module):
global _CONNECTION
if _CONNECTION:
return _CONNECTION
_CONNECTION = Connection(module)
_CONNECTION = Connection(module._socket_path)
context = None
try:
@ -144,8 +145,11 @@ def run_commands(module, commands, check_rc=True):
def load_config(module, config):
conn = get_connection(module)
conn.edit_config(config)
try:
conn = get_connection(module)
conn.edit_config(config)
except ConnectionError as exc:
module.fail_json(msg=to_text(exc))
def get_defaults_flag(module):