QuestionQ95

VerifiedOperations

Drag and drop the code snippets below into the boxes in the code to enable operational data, and then retrieve interface data. Not all options are used.

Drag & Drop
from ncclient import manager

def get_interface_state(host, port, user, passwd, filename):

    with manager.connect(host, port, user, passwd) as m:

        with open  as f:

            rpc_reply = m.(target='running', config=f.read())

        rpc_reply = m.(filter=('subtree', "<interfaces-state/>"))

    return(rpc_reply)
Explanation

edit_config applies the configuration read from the file to the running datastore. get retrieves both configuration and operational state selected by the subtree filter, including the interfaces-state data; get_config is for configuration datastore retrieval.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!