# How to develop network core module by netconf to config huawei datacenter switch

**URL:** <https://forum.ansible.com/t/how-to-develop-network-core-module-by-netconf-to-config-huawei-datacenter-switch/22682>\
**Category:** Ansible Developer\
**Created:** [September 30, 2016, 3:53am UTC](https://forum.ansible.com/t/how-to-develop-network-core-module-by-netconf-to-config-huawei-datacenter-switch/22682 "2016-09-30T03:53:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jacky.gao2016](https://avatars.discourse-cdn.com/v4/letter/j/e9bcb4/32.png) [@jacky.gao2016](https://forum.ansible.com/u/jacky.gao2016)\
**Post date:** [September 30, 2016, 3:53am UTC](https://forum.ansible.com/t/how-to-develop-network-core-module-by-netconf-to-config-huawei-datacenter-switch/22682/1 "2016-09-30T03:53:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![psprygada](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@psprygada](https://forum.ansible.com/u/psprygada)\
**Post date:** [October 4, 2016, 9:13pm UTC](https://forum.ansible.com/t/how-to-develop-network-core-module-by-netconf-to-config-huawei-datacenter-switch/22682/2 "2016-10-04T21:13:28Z")

</div>

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](http://docs.ansible.com/ansible/netconf_config_module.html)

HTH,  
Peter

---

<div class="post-metadata">

**Author:** ![jacky.gao2016](https://avatars.discourse-cdn.com/v4/letter/j/e9bcb4/32.png) [@jacky.gao2016](https://forum.ansible.com/u/jacky.gao2016)\
**Post date:** [October 18, 2016, 2:57am UTC](https://forum.ansible.com/t/how-to-develop-network-core-module-by-netconf-to-config-huawei-datacenter-switch/22682/3 "2016-10-18T02:57:14Z")

</div>

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

 |

---

<div class="post-metadata">

**Author:** ![Nate\_Case](https://avatars.discourse-cdn.com/v4/letter/n/ccd318/32.png) [@Nate\_Case](https://forum.ansible.com/u/Nate_Case)\
**Post date:** [October 19, 2016, 3:48pm UTC](https://forum.ansible.com/t/how-to-develop-network-core-module-by-netconf-to-config-huawei-datacenter-switch/22682/4 "2016-10-19T15:48:09Z")

</div>

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.
