cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
5639
Views
15
Helpful
4
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

Alex Stevenson
Cisco Employee
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

4 Replies 4

Alex Stevenson
Cisco Employee
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.

Alex Stevenson
Cisco Employee
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

 

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']

Hello Guiherme,

I still have the same problem than you with 'get_config' and 'edit_config' - I cannot see them from connect.manager().

I am using ncclient 0.9.13 on my windows Pycharm machine.

The only time i was able to use those method was from a Ubuntu machine with a different package version 0.6.0-2.1

Did you get a chance to find the right command to get_config and edit_config ? I am stuggling since days now...

If you can share some example, it would be great!

Unfortunately, i am unable to find any information on Internet with this new method.

Thanks, if you can help!

 

 y = ncclient.operations.GetConfig.request(source="running")
TypeError: GetConfig.request() missing 1 required positional argument: 'self'

Z = ncclient.operations.EditConfig.request(target="running", config=netconf_hostname)
TypeError: EditConfig.request() missing 1 required positional argument: 'self'

 

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: