How to use the ncclient.xml_.to_xml function in ncclient

To help you get started, we’ve selected a few ncclient examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ansible / ansible / lib / ansible / plugins / netconf / iosxr.py View on Github external
def commit(self, confirmed=False, timeout=None, persist=None, remove_ns=False):
        try:
            resp = self.m.commit(confirmed=confirmed, timeout=timeout, persist=persist)
            if remove_ns:
                response = remove_namespaces(resp)
            else:
                response = resp.data_xml if hasattr(resp, 'data_xml') else resp.xml
            return response
        except RPCError as exc:
            raise Exception(to_xml(exc.xml))
github ansible / ansible / lib / ansible / plugins / netconf / iosxr.py View on Github external
def get(self, filter=None, remove_ns=False):
        if isinstance(filter, list):
            filter = tuple(filter)
        try:
            resp = self.m.get(filter=filter)
            if remove_ns:
                response = remove_namespaces(resp)
            else:
                response = resp.data_xml if hasattr(resp, 'data_xml') else resp.xml
            return response
        except RPCError as exc:
            raise Exception(to_xml(exc.xml))
github ansible / ansible / lib / ansible / plugins / netconf / __init__.py View on Github external
def rpc(self, name):
        """
        RPC to be execute on remote device
        :param name: Name of rpc in string format
        :return: Received rpc response from remote host
        """
        try:
            obj = to_ele(name)
            resp = self.m.rpc(obj)
            return resp.data_xml if hasattr(resp, 'data_xml') else resp.xml
        except RPCError as exc:
            msg = exc.xml
            raise Exception(to_xml(msg))
github alibaba / ansible-provider-docs / lib / ansible / module_utils / network / cloudengine / ce.py View on Github external
def set_nc_config(module, xml_str):
    """ set_config """

    conn = get_nc_connection(module)
    try:
        out = conn.edit_config(target='running', config=xml_str, default_operation='merge',
                               error_option='rollback-on-error')
    finally:
        # conn.unlock(target = 'candidate')
        pass
    return to_string(to_xml(out))
github osrg / ryu / ryu / lib / of_config / capable_switch.py View on Github external
def _find_capable_switch_xml(self, tree):
        return ncclient.xml_.to_xml(self._find_capable_switch(tree))
github frenetic-lang / pyretic / pyretic / vendor / ryu / ryu / lib / of_config / capable_switch.py View on Github external
def _find_capable_switch_xml(self, tree):
        return ncclient.xml_.to_xml(self._find_capable_switch(tree))
github ansible / ansible / lib / ansible / module_utils / network / cloudengine / ce.py View on Github external
def execute_nc_action(module, xml_str):
    """ huawei execute-action """

    conn = get_nc_connection(module)
    response = conn.execute_action(xml_str)
    return to_string(to_xml(response))
github ansible / ansible / lib / ansible / plugins / netconf / ce.py View on Github external
def get(self, *args, **kwargs):
        try:
            if_rpc_reply = kwargs.pop('if_rpc_reply', False)
            if if_rpc_reply:
                return self.m.get(*args, **kwargs).xml
            return self.m.get(*args, **kwargs).data_xml
        except RPCError as exc:
            raise Exception(to_xml(exc.xml))