diff --git a/lib/ansible/plugins/netconf/__init__.py b/lib/ansible/plugins/netconf/__init__.py index 9605877642d..518fbee300c 100644 --- a/lib/ansible/plugins/netconf/__init__.py +++ b/lib/ansible/plugins/netconf/__init__.py @@ -103,9 +103,11 @@ class NetconfBase(with_metaclass(ABCMeta, object)): :name: Name of rpc in string format""" try: obj = to_ele(to_bytes(name, errors='surrogate_or_strict')) - return self.m.rpc(obj).data_xml + resp = self.m.rpc(obj) + return resp.data_xml if hasattr(resp, 'data_xml') else resp.xml except RPCError as exc: - raise Exception(to_xml(exc.xml)) + msg = exc.data_xml if hasattr(exc, 'data_xml') else exc.xml + raise Exception(to_xml(msg)) @ensure_connected def get_config(self, *args, **kwargs): @@ -113,7 +115,8 @@ class NetconfBase(with_metaclass(ABCMeta, object)): :source: name of the configuration datastore being queried :filter: specifies the portion of the configuration to retrieve (by default entire configuration is retrieved)""" - return self.m.get_config(*args, **kwargs).data_xml + resp = self.m.get_config(*args, **kwargs) + return resp.data_xml if hasattr(resp, 'data_xml') else resp.xml @ensure_connected def get(self, *args, **kwargs): @@ -121,7 +124,8 @@ class NetconfBase(with_metaclass(ABCMeta, object)): *filter* specifies the portion of the configuration to retrieve (by default entire configuration is retrieved) """ - return self.m.get(*args, **kwargs).data_xml + resp = self.m.get(*args, **kwargs) + return resp.data_xml if hasattr(resp, 'data_xml') else resp.xml @ensure_connected def edit_config(self, *args, **kwargs): @@ -135,7 +139,8 @@ class NetconfBase(with_metaclass(ABCMeta, object)): :error_option: if specified must be one of { `"stop-on-error"`, `"continue-on-error"`, `"rollback-on-error"` } The `"rollback-on-error"` *error_option* depends on the `:rollback-on-error` capability. """ - return self.m.edit_config(*args, **kwargs).xml + resp = self.m.edit_config(*args, **kwargs) + return resp.data_xml if hasattr(resp, 'data_xml') else resp.xml @ensure_connected def validate(self, *args, **kwargs): @@ -143,7 +148,8 @@ class NetconfBase(with_metaclass(ABCMeta, object)): :source: is the name of the configuration datastore being validated or `config` element containing the configuration subtree to be validated """ - return self.m.validate(*args, **kwargs).xml + resp = self.m.validate(*args, **kwargs) + return resp.data_xml if hasattr(resp, 'data_xml') else resp.xml @ensure_connected def copy_config(self, *args, **kwargs): @@ -152,27 +158,31 @@ class NetconfBase(with_metaclass(ABCMeta, object)): :source: is the name of the configuration datastore to use as the source of the copy operation or `config` element containing the configuration subtree to copy :target: is the name of the configuration datastore to use as the destination of the copy operation""" - return self.m.copy_config(*args, **kwargs).xml + resp = self.m.copy_config(*args, **kwargs) + return resp.data_xml if hasattr(resp, 'data_xml') else resp.xml @ensure_connected def lock(self, *args, **kwargs): """Allows the client to lock the configuration system of a device. *target* is the name of the configuration datastore to lock """ - return self.m.lock(*args, **kwargs).xml + resp = self.m.lock(*args, **kwargs) + return resp.data_xml if hasattr(resp, 'data_xml') else resp.xml @ensure_connected def unlock(self, *args, **kwargs): """Release a configuration lock, previously obtained with the lock operation. :target: is the name of the configuration datastore to unlock """ - return self.m.unlock(*args, **kwargs).xml + resp = self.m.unlock(*args, **kwargs) + return resp.data_xml if hasattr(resp, 'data_xml') else resp.xml @ensure_connected def discard_changes(self, *args, **kwargs): """Revert the candidate configuration to the currently running configuration. Any uncommitted changes are discarded.""" - return self.m.discard_changes(*args, **kwargs).xml + resp = self.m.discard_changes(*args, **kwargs) + return resp.data_xml if hasattr(resp, 'data_xml') else resp.xml @ensure_connected def commit(self, *args, **kwargs): @@ -186,23 +196,27 @@ class NetconfBase(with_metaclass(ABCMeta, object)): :confirmed: whether this is a confirmed commit :timeout: specifies the confirm timeout in seconds """ - return self.m.commit(*args, **kwargs).xml + resp = self.m.commit(*args, **kwargs) + return resp.data_xml if hasattr(resp, 'data_xml') else resp.xml @ensure_connected def validate(self, *args, **kwargs): """Validate the contents of the specified configuration. :source: name of configuration data store""" - return self.m.validate(*args, **kwargs).xml + resp = self.m.validate(*args, **kwargs) + return resp.data_xml if hasattr(resp, 'data_xml') else resp.xml @ensure_connected def get_schema(self, *args, **kwargs): """Retrieves the required schema from the device """ - return self.m.get_schema(*args, **kwargs).xml + resp = self.m.get_schema(*args, **kwargs) + return resp.data_xml if hasattr(resp, 'data_xml') else resp.xml @ensure_connected def locked(self, *args, **kwargs): - return self.m.locked(*args, **kwargs) + resp = self.m.locked(*args, **kwargs) + return resp.data_xml if hasattr(resp, 'data_xml') else resp.xml @abstractmethod def get_capabilities(self):