-
Notifications
You must be signed in to change notification settings - Fork 107
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
Support specifying mac address without quotation mark #364
Conversation
a5dfe08
to
11e8424
Compare
can you show an example how this is used? What prompted this merge-request, is there an issue that you can link to?
Why does |
The issue: |
Btw, would have been good to link the background information upfront. That doesn't seem a good idea. It allows nonsense like:
which IMO should be rejected as error. Also, if you read https://stackoverflow.com/a/52732369/354393 you'll see that number larger or equal than 60 are treated as carrier to the next digit. So, I would guess that "00:00:00:00:60" is the same as "00:00:00:01:00", which seems very wrong. |
Ah wrong, it doesn't carry over. The link says "Since your other MAC-address, 84:19:14:15:86:58, has a number after the first number that is over 59 (86 that is), it is not considered as a sexagesimal number and is therefore treated literally as a string.". But that seems not something that the role should try to work around. The user has to set the MAC address as string and not the role interpreting integers as hours:minutes:seconds... |
|
Are you absolutely guaranteed that you can always convert a mac address specified like |
the function |
And it is very good suggestion that always remind users to specify the mac address as a string in any of the various ways to specify a string in YAML. |
f06095e
to
1f423c0
Compare
1fca175
to
8859ad1
Compare
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.
Besides the magic number, this PR is breaking the API!
Previously, the unquoted mac address works well when mac address contains [a-f], but your patch change it to raise exception.
Your title says you are supporting unquoted mac address, but the code looks like you are raise exception for it.
For the unquoted mac address containing [a-f], it will not raise an exception, it will work as before. And the code will only support valid unquoted mac address, will raise an exception for invalid unquoted mac address. |
@@ -11,6 +11,9 @@ | |||
from ansible.module_utils.network_lsr.utils import Util # noqa:E501 | |||
|
|||
UINT32_MAX = 0xFFFFFFFF | |||
# a MAC address for type ethernet requires 6 octets | |||
# a MAC address for type infiniband requires 20 octets | |||
MAC_ADDR_OCTETS = [6, 20] |
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 is wrong.
The kernel has no limitation minimum MAC address length.
And the maximum is not 20, but in /usr/include/linux/netdevice.h
:
#define MAX_ADDR_LEN 32 /* Largest hardware address length */
That is 32 octets and 64 hex string characters.
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 reason that I define MAC_ADDR_OCTETS = [6, 20]
is because I saw the validation check here,
https://github.com/linux-system-roles/network/blob/main/module_utils/network_lsr/argument_validator.py#L1483
And in NM,it was also clear indicated,
* ---ifcfg-rh---
* property: mac-address
* variable: HWADDR
* description: IBoIP 20-byte hardware address of the device (in traditional
* hex-digits-and-colons notation).
* Note that for initscripts this is the current MAC address of the device as found
* during ifup. For NetworkManager this is the permanent MAC address. Or in case no
* permanent MAC address exists, the MAC address initially configured on the device.
* example: HWADDR=01:02:03:04:05:06:07:08:09:0A:01:02:03:04:05:06:07:08:09:11
* ---end---
/* ---keyfile---
* property: mac-address
* format: usual hex-digits-and-colons notation
* description: MAC address in traditional hex-digits-and-colons notation
* (e.g. 00:22:68:12:79:A2), or semicolon separated list of 6 bytes (obsolete)
* (e.g. 0;34;104;18;121;162)
* ---end---
223ca16
to
48706ab
Compare
Added commit message to explain why patch is required and how this patch is fixing the issue. |
[citest pending] |
- In yaml, all the string value consists of a series of one-digit or two-digit numbers delimited by colons and all numbers but the first are between 0 and 59, it would be interpreted as a sexagesimal number, and would be converted automatically to the equivalent number of seconds. - The committed patch will guarantee to remediate the yaml's peculiarity and convert back into the mac address specified in the original yaml file. And in case that user specifies arbitrary integer(e.g. `mac:1234`), we introduce `force_len`(e.g. `MAC_ADDR_OCTETS = [6, 20]`) to raise error for invalid integer value. Signed-off-by: Wen Liang <[email protected]>
Pull Request Test Coverage Report for Build 809885115
💛 - Coveralls |
[citest pending] |
[citest bad] |
[citest pending] |
@liangwen12year This PR is still in |
It is still in |
Thank you for your contribution! There was no activity in this pull request recently. To avoid pull requests to pile up, an automated process marked this pull request as stale. It will close this pull request if no further activity occurs. The current policy is available at: https://github.com//linux-system-roles/network/blob/main/.github/stale.yml |
[citest pending] |
any update on this? |
This is currently not a priority, therefore it is just a draft PR. We can revisit this after #363 are handled and the current CI problems are handled. Would you prefer to have the PR closed for now? |
No, this is fine - it is marked as WIP/Draft |
Thank you for your contribution! There was no activity in this pull request recently. To avoid pull requests to pile up, an automated process marked this pull request as stale. It will close this pull request if no further activity occurs. The current policy is available at: https://github.com//linux-system-roles/network/blob/main/.github/stale.yml |
Thank you for your contribution! There was no activity in this pull request recently. To avoid pull requests to pile up, an automated process marked this pull request as stale. It will close this pull request if no further activity occurs. The current policy is available at: https://github.com//linux-system-roles/network/blob/main/.github/stale.yml |
Signed-off-by: Wen Liang [email protected]