-
Notifications
You must be signed in to change notification settings - Fork 1
docs: Fix docstrings of xcp/net/ifrename for Sphinx-autodoc generation
#21
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -119,9 +119,9 @@ commands = | |
| coverage xml -o {envlogdir}/coverage.xml --fail-under {env:XCP_COVERAGE_MIN:78} | ||
| coverage lcov -o {envlogdir}/coverage.lcov | ||
| coverage html -d {envlogdir}/htmlcov | ||
| coverage html -d {envlogdir}/htmlcov-tests --fail-under {env:TESTS_COVERAGE_MIN:96} \ | ||
| coverage html -d {envlogdir}/htmlcov-tests --fail-under {env:TESTS_COVERAGE_MIN:95} \ | ||
| --include="tests/*" | ||
|
Comment on lines
119
to
123
|
||
| diff-cover --compare-branch=origin/master --exclude xcp/dmv.py \ | ||
| diff-cover --compare-branch=origin/master \ | ||
| {env:PY3_DIFFCOVER_OPTIONS} --fail-under {env:DIFF_COVERAGE_MIN:92} \ | ||
| --html-report {envlogdir}/coverage-diff.html \ | ||
| {envlogdir}/coverage.xml | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,6 +39,10 @@ | |
| [out] transactions | ||
| list of string tuples as source and destination names for "ip link set | ||
| name" | ||
|
|
||
| Abbreviations used in this file: | ||
| kname: The kernel name of the network interface (the original name assigned by the kernel). | ||
| tname: The temporary name of the interface, used while renaming interfaces to avoid name conflicts. | ||
| """ | ||
|
|
||
| from __future__ import unicode_literals | ||
|
|
@@ -122,24 +126,32 @@ def __rename_nic(nic, name, transactions, cur_state): | |
| transactions.append((nic.kname, name)) | ||
|
|
||
|
|
||
| def rename_logic( static_rules, | ||
| cur_state, | ||
| last_state, | ||
| old_state ): | ||
| def rename_logic(static_rules, cur_state, last_state, old_state): | ||
|
||
| """ | ||
| Core logic of renaming the current state based on the rules and past state. | ||
|
|
||
| This function assumes all inputs have been suitably sanitised. | ||
| @param static_rules | ||
|
|
||
| Parameters | ||
| ---------- | ||
| static_rules : list[MACPCI] | ||
| List of MACPCI objects representing rules | ||
| @param cur_state | ||
| cur_state : list[MACPCI] | ||
| List of MACPCI objects representing the current state | ||
| @param last_state | ||
| last_state : list[MACPCI] | ||
| List of MACPCI objects representing the last boot state | ||
| @param old_state | ||
| old_state : list[MACPCI] | ||
| List of MACPCI objects representing the old state | ||
| @returns List of tuples... | ||
| @throws AssertionError (Should not be thrown, but better to know about logic | ||
| errors if they occur) | ||
|
|
||
| Returns | ||
| ------- | ||
| list | ||
| List of tuples representing name transactions. | ||
|
|
||
| Raises | ||
| ------ | ||
| AssertionError | ||
| If the current state contains invalid entries. | ||
| """ | ||
|
|
||
| transactions = [] | ||
|
|
@@ -365,26 +377,44 @@ def rename_logic( static_rules, | |
| util.niceformat(cur_state))) | ||
| return transactions | ||
|
|
||
| def rename( static_rules, | ||
| cur_state, | ||
| last_state, | ||
| old_state ): | ||
| def rename(static_rules, cur_state, last_state, old_state): | ||
| """ | ||
| Rename current state based on the rules and past state. | ||
| This function sanitises the input and delegates the renaming logic to | ||
| __rename. | ||
| @param static_rules | ||
|
|
||
| This function: | ||
| - Sanitises the input | ||
| - Delegates the renaming logic to rename_logic() | ||
|
|
||
| Parameters | ||
| ---------- | ||
| static_rules : list[MACPCI] | ||
| List of MACPCI objects representing rules | ||
| @param cur_state | ||
| cur_state : list[MACPCI] | ||
| List of MACPCI objects representing the current state | ||
| @param last_state | ||
| last_state : list[MACPCI] | ||
| List of MACPCI objects representing the last boot state | ||
| @param old_state | ||
| old_state : list[MACPCI] | ||
| List of MACPCI objects representing the old state | ||
|
|
||
| @throws StaticRuleError, CurrentStateError, LastStateError, TypeError | ||
|
|
||
| @returns list of tuples of name changes required | ||
| Returns | ||
| ------- | ||
| list | ||
| List of tuples of name changes required | ||
|
|
||
| Raises | ||
| ------ | ||
| StaticRuleError | ||
| Raised if any of the following conditions are met: | ||
| - A static rule has a kernel name. | ||
| - A static rule has a tname not starting with 'eth'. | ||
| - Duplicate eth names are present in static rules. | ||
| - Duplicate MAC addresses are present in static rules. | ||
| CurrentStateError | ||
| If the current state contains invalid entries. | ||
| LastStateError | ||
| If the last state contains invalid entries. | ||
| TypeError | ||
| If any of the input lists contain objects that are not MACPCI instances. | ||
| """ | ||
|
|
||
| if len(static_rules): | ||
|
|
||
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.
The coverage threshold reduction from 96% to 95% and removal of the
--exclude xcp/dmv.pyexclusion appear unrelated to docstring formatting changes. These changes should be in a separate PR or properly justified in the PR description.