Now we using ncclient netconf lib to develop huawei datacenter switch ansible module;
But we hope our switch ansible module will be ansible core module, and I think it’s better that ansible do not need to add new dependency library.
Now we using ncclient netconf lib to develop huawei datacenter switch ansible module;
But we hope our switch ansible module will be ansible core module, and I think it’s better that ansible do not need to add new dependency library.
Hi Jacky,
Deeper integration with netconf is on the roadmap for Ansible 2.3. There is already a module that works with netconf documents for calling the edit-config rpc. See here. http://docs.ansible.com/ansible/netconf_config_module.html
HTH,
Peter
Hi Peter,
Thanks for the answer.
I find that the current ansible version does not include netconf_config module.
And Junos modules using the below code “try” to depend other python lib, we will using the same style to resolve the third party lib dependency question. If we expect HUAWEI data center switch modules will be ansible core modules. Does it work ok?
try: import jxmlease |
|
HAS_JXMLEASE = True |
|
except ImportError: |
|
HAS_JXMLEASE = False |
The idea with that snippet is to fail gracefully if the module isn’t installed, either displaying a user-readable error (please install library-name to use this module) or, if reasonable, fall back to some other functionality. You’ll notice further down, that the Netconf class (but not the Cli class) has the following snippet
if not HAS_JXMLEASE:
raise NetworkError(
msg='jxmlease is required but does not appear to be installed. ’
)
‘It can be installed using
pip install jxmlease
’
This handles the actual issue without throwing an ImportError at the user, and gives them a concrete suggestion at a solution. This is only for Netconf, as Cli does not depend on jxmlease, and therefore should not be gated by that lib.