Merge ~ma-brothier/cloud-init:interfaces-order into cloud-init:master
Proposed by
Marc-Aurele Brothier
Status: | Merged |
---|---|
Approved by: | Scott Moser |
Approved revision: | 0f705cce22f6028431b8593171369f98a98497c5 |
Merged at revision: | 543e25cda6235d18adb6485e4266944d59e1979d |
Proposed branch: | ~ma-brothier/cloud-init:interfaces-order |
Merge into: | cloud-init:master |
Diff against target: |
63 lines (+26/-1) 2 files modified
cloudinit/net/__init__.py (+12/-1) tests/unittests/test_net.py (+14/-0) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Scott Moser | Approve | ||
Server Team CI bot | continuous-integration | Approve | |
Review via email: mp+324535@code.launchpad.net |
Description of the change
Natural sort order of interfaces
The code deciding which interface to choose as the default to request the IP address through DHCP does not sort the interfaces correctly. On Ubuntu Xenial images for example, the interfaces are named ens1, ens2, ens3..., ens11, ... depending on the pci bus address. The python sorting will list 'ens11' before 'ens3' for example despite the fact that 'ens3' should be before 'ens11'.
This patch address this issue and sort the interface names according to a human sorting.
To post a comment you must log in.
Marc,
This looks good. Some comments... they're all minor, and should be explained more in HACKING.rst cloudinit. readthedocs. io/en/latest/ topics/ hacking. html
http://
a.) change description to be
Summary
<blank line>
Description
b.) lets go ahead and just keep the function in a net/__init__.py rather than putting it in util. And name it _natural_ sort_key( ). At some point if someone else needs such a function we can move it to util.
c.) a unit test would be good. Just add something to tests/unittests /test_net. py to test your _natural_key_sort. Also realize you can (and do) get interfaces named 'enp0s25' (as I have on this system).
d.) You'll need to sign the contributors agreement (see HACKING.rst). Please feel free to ping me if you have any questions.
e.) Thanks!
d.) Thanks!