Developing plugin for Aerohive wireless access points - need another set of eyes

I am in need of some guidance on developing a plugin for Aerohive wireless access points. I feel like I am very close to making this all work, but I am stuck and would appreciate any assistance that you can provide. I have included all of the .py files as well as error output from the execution of my playbook.

Here’s what I’ve done so far:

*disclaimer, I chose the ios.py files simply due to the fact that interacting with the cli on the APs is very similar to interacting with the Cisco cli

  1. Copied the ios.py files in the action, cliconf, and terminal plugin directories and renamed them to hiveos.py. I have heavily modified the contents of the files essentially doing find/replace on ios for hiveos
  2. In the module_utils/network directory I created a hiveos directory and added a copy of ios.py (renamed to hiveos.py) and init.py files - again, lots of find/replace on ios for hiveos.
  3. In the base.yml file I added hiveos to the NETWORK_GROUP_MODULES default list
  4. Copied ios_facts.py and init.py into /modules/network/hiveos and renamed to hiveos_facts.py. Heavily modified to get hiveos specific info.
  5. Created a playbook that executes the hiveos_facts module against an AP.
  6. Now I’m stuck

Essentially what happens is Ansible connects to the AP and logs in successfully. It changes the console page length to 0 and then bombs.

There are two spots so far that I don’t understand how they work in the original ios_facts.py files:

  1. In the file located at /module_utils/network/ios there is the following:
    .
    .
    from ansible.module_utils.basic import env_fallback, return_values
    .
    .
    When I ran my playbook it bombed saying that return_values can’t be imported. I went in and looked at the basic.py file to see what return_values was doing and I can’t find it anywhere. I’m using VS Code as my Python IDE and flake8 is saying that return_values is imported but unused (even in the original, unmodified ios.py file). When I run ios_facts (instead of hiveos_facts) everything works - Ansible doesn’t bomb in this module.

  2. In the file located at /module_utils/network/hiveos there is the following:
    .
    .
    capabilities = Connection(module._socket_path).get_capabilities()
    .
    .
    When I run my playbook it bombs at this spot. I went and looked at the connection.py file and, again, I don’t see any function called get_capabilities(). Again, the ios_facts module has no issues with this. I can’t find any information on what exactly this is supposed to be pulling back from the device.

Thanks for any assistance you can provide.

Dennis

I’m running my ansible host on CentOS 7
[root@localhost ansible]# ansible --version
ansible 2.8.2
config file = /root/ansible/ansible.cfg
configured module search path = [u’/root/.ansible/plugins/modules’, u’/usr/share/ansible/plugins/modules’]
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.5 (default, Jun 20 2019, 20:27:34) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]

(attachments)

hiveos-plugin.zip (24.5 KB)

Dennis,

I think it’s great you’re working on this. I am a long time Aerohive user and these modules would be very handy.

Starting with the IOS modules as a base brings along a lot of extra cruft you won’t need. Those are the oldest modules and require the most work arounds due to variations between versions of IOS. HiveOS is much cleaner (mainly because it’s a newer OS) and should not need nearly as much code.

I would look at the EdgeOS and VyOS plugins and modules as much simpler and cleaner examples to follow.

I pared down the attached plugins and managed to get them working. This may be a better starting point for you (though I’m sure there is still a lot more refinement that can take place).

Have a look at this article on Developing network_cli Platforms. It provides a good overview of the pieces needed for new platforms. Also look at network connection plugins in the developer docs.

Dennis,

Developing network modules and plugins is much more challenging than standard modules and plugins due to all the moving parts. But once you get the terminal and cliconf plugins ironed out, it becomes much easier to focus on the logic involved in specific modules.

I would start with hiveos_facts and hiveos_command modules. From there you could create a generic hiveos_config module that looks for lines in the config, or you could create modules like hiveos_ssid, hiveos_radio_profile, hiveos_user, hiveos_group, hiveos_user_profile, etc. that take parameters and ensure the necessary config is set on the device without forcing the user to know the specific command syntax.

You can always reach out in ansible-devel or #ansible-network on IRC for more help, or we can continue the discussion here. Whatever is easiest for you.