Added pciid match support#375
Conversation
Signed-off-by: Fatih USTA <fatihusta86@gmail.com>
Signed-off-by: Fatih USTA <fatihusta86@gmail.com>
Signed-off-by: Fatih USTA <fatihusta86@gmail.com>
|
Sorry, this is taking much longer than anticipated. I like the idea of having |
slyon
left a comment
There was a problem hiding this comment.
My apologies, this PR fell through the cracks. I've now done an initial high-level round of review, as this is touching quite some core parts of Netplan and the original issue seems to be fixed as of recently (#503).
Please let me know if you're still interested in driving this forward, so I can do a more detailed review and talk to our architect about the new YAML schema.
|
|
||
| NETPLAN_PUBLIC gboolean | ||
| netplan_netdef_match_interface(const NetplanNetDefinition* netdef, const char* name, const char* mac, const char* driver_name); | ||
| netplan_netdef_match_interface(const NetplanNetDefinition* netdef, const char* name, const char* mac, const char* driver_name, const char* pciid); |
There was a problem hiding this comment.
todo: We cannot just change public API like this, but would rather need to introduce a new netplan_netdef_match_interface2() function. Keeping the original function backwards compatible.
| char* driver; | ||
| char* mac; | ||
| char* original_name; | ||
| char* pciid; |
There was a problem hiding this comment.
todo: This has the potential of breaking ABI and we'd need to move the new field to the very end of the netplan_net_definition struct, e.g. called match_pciid.
| - **pciid** (scalar) – since **0.107** | ||
|
|
||
| > The PCI ID, corresponding to the `ID_PATH` udev properity. (`0000:98:00.1`) | ||
| > Matching on pci id is *only* supported with networkd. | ||
| > `udevadm info /sys/class/net/DEVICE_NAME` |
There was a problem hiding this comment.
nitpick (non-blocking): Version needs to be bumped.
question: Also, is there any possibility of doing the same for the NetworkManager backend? The match stanza is a very central piece of Netplan's configuration and we should try not to diverge between the backends here.
| {"driver", YAML_NO_NODE, {.variable=handle_match_driver}}, | ||
| {"macaddress", YAML_SCALAR_NODE, {.generic=handle_netdef_mac}, netdef_offset(match.mac)}, | ||
| {"name", YAML_SCALAR_NODE, {.generic=handle_netdef_id}, netdef_offset(match.original_name)}, | ||
| {"pciid", YAML_SCALAR_NODE, {.generic=handle_netdef_str}, netdef_offset(match.pciid)}, |
There was a problem hiding this comment.
todo: We'd probably want to have a more specific handler here, that validates the input string is an actual PCI ID.
| self.assert_nm(None) | ||
| self.assert_nm_udev(NM_UNMANAGED % 'lom1' + NM_UNMANAGED_MAC % '11:22:33:44:55:66') | ||
|
|
||
| def test_eth_match_by_pciid_rename(self): |
There was a problem hiding this comment.
nitpick: Thanks for providing some test cases! I'd love to see an integration test along the lines of tests/integration/ethernets.py:test_rename_interfaces(), too (if possible).
| return link.get('addr', '') | ||
|
|
||
|
|
||
| def get_interface_pciid(interface): # pragma: nocover (covered in autopkgtest) |
There was a problem hiding this comment.
question: Can we apply some test-mocking to get this net method covered by unit tests?
Description
Netplan doesn't match mac address of ethernet when using bond. So member ethernet doesn't up.
This PR fixes ethernet up problem, but still prints warning message(below).
I try to add PCI ID match support for better renaming to the ethernet.
Checklist
make checksuccessfully.make check-coverage).Also may fixes this issue: https://bugs.launchpad.net/netplan/+bug/1608447