Skip to content

Commit

Permalink
answerfile: LACP bonding support
Browse files Browse the repository at this point in the history
Signed-off-by: Yann Dirson <[email protected]>
  • Loading branch information
ydirson committed Jan 23, 2023
1 parent 71321b7 commit 9e3a7b1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
25 changes: 25 additions & 0 deletions answerfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,10 +352,35 @@ def parseFCoEInterface(self):

return results

def parseBonding(self, nethw):
nodes = getElementsByTagName(self.top_node, ['bonding'])
if len(nodes) > 1:
raise AnswerfileException("<bonding> must appear only once")
if nodes:
node = nodes[0]
bond_name = getStrAttribute(node, ['name'], mandatory=True)
if bond_name != "bond0":
raise AnswerfileException("<bonding> name must be 'bond0'")

bond_mode = getStrAttribute(node, ['mode'], mandatory=True)
if bond_mode != "lacp":
raise AnswerfileException("<bonding> mode must be 'lacp'")

bond_members_str = getStrAttribute(node, ['members'], mandatory=True)
bond_members = bond_members_str.split(",")
if len(bond_members) < 2:
raise AnswerfileException("<bonding> members must be at least two")
for member in bond_members:
if member not in nethw:
raise AnswerfileException("<bonding> member %r not in detected NICs" % (member,))

netutil.configure_bonding_interface(nethw, bond_name, bond_mode, bond_members)

def parseInterface(self):
results = {}
node = getElementsByTagName(self.top_node, ['admin-interface'], mandatory=True)[0]
nethw = netutil.scanConfiguration()
self.parseBonding(nethw)

if_name = getStrAttribute(node, ['name'])
if_hwaddr = getStrAttribute(node, ['hwaddr'])
Expand Down
8 changes: 8 additions & 0 deletions doc/answerfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,14 @@ Format of 'source' and 'driver-source'
Specifies additional devices to be included in the local SR.


<bonding name="bond0" mode="lacp" members="eth,eth[,eth]*"/>

Join given ethernet interfaces using LACP bonding. Name of
resulting interface must be "bond0". It can be then be used with

<admin-interface name="bond0"/>


<admin-interface name="eth"/> | <admin-interface hwaddr="mac"/>

Specifies the initial management interface.
Expand Down

0 comments on commit 9e3a7b1

Please sign in to comment.