restconf_config module (#51971)

* Add restconf_config module

* Try to do the right thing when given partial paths

* Add PATCH

* Delete should not require content

* Non-JSON exceptions need raising, too

* Let ConnectionError objects pass through exec_jsonrpc
This commit is contained in:
Nathaniel Case 2019-03-04 08:27:18 -05:00 committed by GitHub
commit d5aabd02ba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 196 additions and 12 deletions

View file

@ -8,6 +8,7 @@ import json
import traceback
from ansible.module_utils._text import to_text
from ansible.module_utils.connection import ConnectionError
from ansible.module_utils.six import binary_type
from ansible.utils.display import Display
@ -42,6 +43,10 @@ class JsonRpcServer(object):
else:
try:
result = rpc_method(*args, **kwargs)
except ConnectionError as exc:
display.vvv(traceback.format_exc())
error = self.error(code=exc.code, message=to_text(exc))
response = json.dumps(error)
except Exception as exc:
display.vvv(traceback.format_exc())
error = self.internal_error(data=to_text(exc, errors='surrogate_then_replace'))