-
Notifications
You must be signed in to change notification settings - Fork 23.8k
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
New module: cnos_vlan and various utility files #21107
Conversation
lib/ansible/module_utils/cnos.py
Outdated
command = command + bgpAFArg1 + " reflection " | ||
elif(bgpAFArg1 == "dampening"): | ||
command = command + bgpAFArg1 + " " | ||
if(bg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI failure due to python 2.4 syntax error:
2017-02-08 01:52:26 Compiling ./lib/ansible/module_utils/cnos.py ...
2017-02-08 01:52:26 File "./lib/ansible/module_utils/cnos.py", line 2829
2017-02-08 01:52:26 with open(errorFile, 'r') as f:
2017-02-08 01:52:26 ^
2017-02-08 01:52:26 SyntaxError: invalid syntax
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have fixed this issue that was reported by shippable in cnos.py and have updated the branch. We have not used shippable yet, but have just enabled our repo to have shippable check it, however, still trying to figure out a simple shippable.yml file to have it scan our Python files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can run the tests locally using docker, rather than using Shippable. Take a look at the integration test documentation.
I'm not able to determine if there is an issue that needs to be fixed based on the check that has failed. Can you help me understand? |
I think I found the error now... |
@dkasak See http://docs.ansible.com/ansible/dev_guide/developing_modules_python3.html#exceptions for using |
@dkasberg this PR contains the following merge comits: Please rebase your branch to remove these commits. |
We have several modules that share the same set of options so we were advised to move all of them to ansible\lib\ansible\utils\module_docs_fragments\cnos.py. This module has no options specific to it. All the options are defined in the module_docs_fragments\cnos.py. Please advise how to proceed. Should we move all the common options back into each of the individual module so this passes the 'ansible_doc' check in Shippable? |
Additional comment to the above. As I mentioned all options for this module have been moved to module_utils since they are in common with all our other modules, but we do have other variables that need to be input to the module. Refer to our documentation from our release last January in the link below As you can see we have an Options section there but also section called "Overloaded Variables". How do we accommodate this in Ansible's documentation guidelines? Should we convert them to the Options format? If that is the case, it may be difficult for the user to understand the various ways to input these variables.... FYI, we will be changing the documentation on our website once our modules are included in the Ansible product. |
Had to dig (I'll update the docs) |
help/index.jsp?topic=%2Fcom.lenovo.switchmgt.ansible.doc%2Fansible_for_ | ||
cnos.html) | ||
version_added: "2.3" | ||
Options: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change to:
options: {}
cnos.html) | ||
version_added: "2.3" | ||
Options: | ||
- The following is a table depicting how the overloaded variables are used |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From here to the end of the DOCUMENTAION block needs deleting
@@ -48,6 +48,8 @@ | |||
cnos.html) | |||
version_added: "2.3" | |||
Options: | |||
{} | |||
|
|||
- The following is a table depicting how the overloaded variables are used |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These other lines will not end up in the documentation, so I believe they need removing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you talking about all the lines starting with:
"- The following is a table....
to where the EXAMPLE section starts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. The script that generates the HTML will only look at that the sections defined in docs.ansible.com/ansible/dev_guide/developing_modules_documenting.html
This module uses SSH to manage network device configuration. | ||
The results of the operation can be viewed in results directory. | ||
To know more about this module from Lenovo and customizing them for your | ||
use cases, please visit our [User Guide](http://systemx.lenovofiles.com/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm stuck trying to fix this error reported by this check: 'ansible-doc cnos_vlan' gundalow suggested using: But this fails as well. |
It looks like you specified |
CI failure due to module validation failure:
|
Merged :) |
retVal = "" | ||
command = "interface " | ||
newPrompt = prompt | ||
if(interfaceArg1 == "port-aggregation"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are many examples of this throughout this PR, however 2 things here:
- The parentheses are not needed
- There should be a space between
if
and(
My personal opinion, is that where unnecessary, such as in this example, the parentheses should be removed.
def interfaceLevel2Config( | ||
obj, deviceType, prompt, timeout, interfaceL2Arg1, interfaceL2Arg2, | ||
interfaceL2Arg3, interfaceL2Arg4, interfaceL2Arg5, interfaceL2Arg6, | ||
interfaceL2Arg7): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, all of the args should be indented to the same level as interfaceL2Arg7
Also, I'm not a fan of these variables. They seem pretty poorly named.
This applies throughout the codebase
# EOM | ||
|
||
|
||
def interfaceLevel2Config( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function, is really untestable. On a McCabe complexity scale, this is a 207, which means it contains at least 207 branches of code that would need to be independently tested. Generally speaking, in most scenarios, something below a 10-12 on a McCabe complexity is preferred.
My recommendation, is that this function needs to be split up, into many smaller functions.
outputfile=./results/test_vlan_{{ inventory_hostname }}_output.txt | ||
vlanArg1='{{item.vlanArg1}}' vlanArg2='{{item.vlanArg2}}' | ||
vlanArg3='{{item.vlanArg3}}' | ||
with_items: "{{test_vlan_data1}}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I can see here, these EXAMPLES are not valid YAML, and would not be operational if someone were to copy paste them.
They should be laid out in pure/full YAML such as:
- name: Test Vlan - Create a vlan, name it
cnos_vlan:
host: "{{ inventory_hostname }}"
username: "{{ hostvars[inventory_hostname]['username'] }}"
First module: cnos_vlan and various utility files. First 1 of 17 CNOS modules
ISSUE TYPE
COMPONENT NAME
cnos_vlan module
ANSIBLE VERSION
SUMMARY