-
Notifications
You must be signed in to change notification settings - Fork 292
Adapt network interfaces sorting #6456
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
base: feature/host-network-device-ordering
Are you sure you want to change the base?
Adapt network interfaces sorting #6456
Conversation
`Network_utils.is_sorted_by_script` checks interface-rename-data dir. When true: Follow the legacy behavior, the new added interface_order field is always None. When false: Use `Network_device_order.sort` to sort the interfaces, store the result in config.interface_order. Signed-off-by: Changlei Li <[email protected]>
Signed-off-by: Changlei Li <[email protected]>
Xapi get interface position from `get_interface_positions`, instead of getting position from "ethx" name. Signed-off-by: Changlei Li <[email protected]>
Some devices like ibft may not be in networkd sort result but need to build pif, network for it. So the devices need be got by `get_all`. Signed-off-by: Changlei Li <[email protected]>
@@ -420,6 +420,18 @@ module Interface_API (R : RPC) = struct | |||
["Get list of all interface names"] | |||
(debug_info_p @-> unit_p @-> returning iface_list_p err) | |||
|
|||
let get_interface_positions = |
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.
Could this be done within Interface.get_all
?
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 prefer to add a new interface to keep the interface function simple and not modify the old one for potential break.
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.
OK. I thought it's would be simpler to include this in the Interface.get_all
from the interface design's point of view. But I'm not sure about this.
Hi @robhoes @psafont @lindig
May I please have your thoughts on this?
BTW, a minor comment on the name: Interface.get_interface_positions
seems a bit redundant. If we are going to use this, how about Interface.get_order
?
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 do prefer the name Interface.get_{positions,order,slots}
, But I would keep the function separate, because they have different semantic meaning. was there only a single user of get_all
?
Pif device name maybe change. Look up device_to_position table to get the new device name in pif refresh. Then update to db. This function is called by pif.scan and resynchronise_pif_params. Signed-off-by: Changlei Li <[email protected]>
When xapi start, networkd config will be reset, see Xapi_pif.start_of_day_best_effort_bring_up. In fact, the interface_order is only maintained by networkd, it shouldn't be cleared. Signed-off-by: Changlei Li <[email protected]>
Signed-off-by: Changlei Li <[email protected]>
- function is_sorted_by_script to val device_renamed_already - reduce nested structure in update config - handle port name update - bring back read inventory to get bridge name Signed-off-by: Changlei Li <[email protected]>
Signed-off-by: Changlei Li <[email protected]>
Signed-off-by: Changlei Li <[email protected]>
c455eb0
to
3b21c30
Compare
- refine n_of_xenbrn_opt by add %! - change back to get_mac when update db feild MAC The mac_table is filtered by physical but pif device may be non physical Signed-off-by: Changlei Li <[email protected]>
This reverts commit 402671f. Signed-off-by: Changlei Li <[email protected]>
- combine sorting on first boot and non first boot in one function - reduce the use of device_already_renamed and make it clear that interface_order is None when device_already_renamed Signed-off-by: Changlei Li <[email protected]>
For the situation if a db pif device's position is not in the position list but can get mac for networkd. There is a mismatch between networkd sort function and dev filesys method. Signed-off-by: Changlei Li <[email protected]>
b694365
to
d95662a
Compare
let choose_network_name_for_pif device pos_opt = | ||
let pos_str = | ||
match pos_opt with None -> "" | Some pos -> Printf.sprintf "[%d]" pos | ||
in | ||
Printf.sprintf "Pool-wide network associated with %s%s" device pos_str |
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 will be user visible, might be worth explaining what that number is:
let choose_network_name_for_pif device pos_opt = | |
let pos_str = | |
match pos_opt with None -> "" | Some pos -> Printf.sprintf "[%d]" pos | |
in | |
Printf.sprintf "Pool-wide network associated with %s%s" device pos_str | |
let choose_network_name_for_pif device pos_opt = | |
let pos_str = | |
match pos_opt with None -> "" | Some pos -> Printf.sprintf "(slot %d)" pos | |
in | |
Printf.sprintf "Pool-wide network associated with %s %s" device pos_str |
Does this rename the existing PIFs? we probably should start picking words for the user-visible concepts, so "slot" might not be the right one.
This PR is the adaption of #6381 in networkd and xapi.
XS8: Keep the legacy behaviour, use host-installer, sort-script to sort and rename the network interfaces to
ethx
.XS9: Use
Network_device_order.sort
to sort the interfaces, store the result in networkdconfig.interface_order
.Compatibility is offered by check the sort-script
interface-rename-data
dir.Add new interface Interface.get_interface_positions to pass interfaces and positions from networkd to xapi.