cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements
3350
Views
0
Helpful
3
Replies

[Python] Accessing methods of ncclient manager

Hello folks,

 

Can anybody tell me why when I use the manager of ncclient I cant check the method of it using the dot notation.
Here a print screen to illustrate, for example, the methods like "get_config", ""edit_config" exists but it doesn't shows.

 

Is there any other way to check the methods available inside ?

 

Thanks

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
alexstev
Cisco Employee

Here's the GitHub repo and source code for ncclient / manager with all the available operations / methods:
https://github.com/ncclient/ncclient/blob/master/ncclient/manager.py

 

View solution in original post

3 REPLIES 3
alexstev
Cisco Employee

Hello Guilherme,

 

I see you are writing about the auto-complete function of an IDE. I wonder which one you're using. I recreated the core of your code in VS Code and I basically got the same auto-suggestions as you. Well, the 'get_config' and 'edit_config' are missing (see attached image)

 

I tried it in the Atom ID also and the 'get_config' and 'edit_config' are not auto-completion options there either.

 

Something is keeping these two methods from being suggested. I'm not sure why.

alexstev
Cisco Employee

Here's the GitHub repo and source code for ncclient / manager with all the available operations / methods:
https://github.com/ncclient/ncclient/blob/master/ncclient/manager.py

 

View solution in original post

Hey,

 

I just found my answer.

All the operations (get,get_config, etc...) are spicified as a dictionary in the method manager.

With the use of 'help' function of python.

>>> help (manager)
Help on module ncclient.manager in ncclient:

NAME
    ncclient.manager

DESCRIPTION
    This module is a thin layer of abstraction around the library.
    It exposes all core functionality.

<ommited>

DATA
  
    OPERATIONS = {'cancel_commit': <class 'ncclient.operations.edit.Cancel...
    

Then, when we call 'manager.operations' we have them all, it is kind silly.

 

>>> dir(manager.operations)
['CancelCommit', 'CloseSession', 'Commit', 'CopyConfig', 'CreateSubscription', 'DeleteConfig', 'DiscardChanges', 'Dispatch', 'EditConfig', 'GenericRPC', 'Get', 'GetConfig', 'GetReply', 'GetSchema', 'KillSession', 'Lock', 'LockContext', 'MissingCapabilityError', 'OperationError', 'PoweroffMachine', 'RPC', 'RPCError', 'RPCReply', 'RaiseMode', 'RebootMachine', 'TimeoutExpiredError', 'Unlock', 'Validate', '__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'edit', 'errors', 'flowmon', 'lock', 'retrieve', 'rpc', 'session', 'subscribe', 'util']
Create
Recognize Your Peers
Content for Community-Ad