Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create CLC Ansible Module Base Class #24

Closed
wants to merge 2 commits into from

Conversation

bjfelton
Copy link
Contributor

To simplify module development and cut down on copy-and-paste coding, I've extracted out the common components of all of the existing modules and created a base class. To demonstrate how simply existing modules could be refactored, I've refactored the existing clc_aa_policy module to extend this base class. It eliminates a few hundred lines of code between module and tests while requiring little effort to implement.

@markramach
Copy link

We would love to implement this for obvious reasons. However, Ansible does not support multi-file modules at this time. See ansible/ansible#10274

@bjfelton
Copy link
Contributor Author

bjfelton commented Mar 1, 2016

"Bother," said Pooh

@jufkes jufkes closed this Mar 1, 2016
@AdeMiller
Copy link
Contributor

This was the first thin I thought of when looking at this code. I don't see why Ansible's limitations should prevent this. I would do the following:

  1. Refactor all the shared code into a base class and place this at the foot or head of every file. This would make it far clearer what is shared and what is specific to the file in question.
  2. I would move this class into a separate file and have a simple build step that updated the source files with the latest version. Probably a Python script that replaced everything in between "# BEGIN_BASE" and "#END_BASE" with the contents of the base class.

I think this meets the requirements of Ansible and will get rid of a lot of copy/paste code.

@AdeMiller
Copy link
Contributor

Unless anyone objects I'm about to implement this using a preprocessor build step. This is pretty much the only way we're going to be able to start isolating the Python SDK code by first getting it all in one place and then removing duplicated code and writing better common unit tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants