From 9355a535e71407911332c228a382ee592452f5e7 Mon Sep 17 00:00:00 2001 From: Dan Sneddon Date: Tue, 9 Jun 2015 10:50:07 -0700 Subject: Automate selection of active bond slave This change selects an interface to be the active slave in a bond with active/passive characteristics. If one of the interfaces is marked as primary, it will be the active slave. If none of the interfaces are marked, the interface with the lowest alphanumeric value will be chosen. For instance em2 comes before em3. Co-Authored-By: Dan Prince Change-Id: Ic9b4e8c68b788b98a19ea33a76c9210a80deabeb --- os_net_config/objects.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'os_net_config/objects.py') diff --git a/os_net_config/objects.py b/os_net_config/objects.py index 65bdd3b..ea9c11c 100644 --- a/os_net_config/objects.py +++ b/os_net_config/objects.py @@ -338,6 +338,10 @@ class OvsBond(_BaseOpts): self.primary_interface_name = member.primary_interface_name else: self.primary_interface_name = member.name + if not self.primary_interface_name: + bond_members = list(self.members) + bond_members.sort(key=lambda x: x.name) + self.primary_interface_name = bond_members[0].name @staticmethod def from_json(json): -- cgit 1.2.3-korg