Skip to content

Commit

Permalink
bond1 (#57)
Browse files Browse the repository at this point in the history
* Add correct bond to network scripts

* Support multiple bonds

* by default python loops through the keys. so you shouldn't need to use .keys()

* Only put public ip on bond0 for now
  • Loading branch information
nuclearbob authored Aug 8, 2022
1 parent 502d376 commit a6443a6
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 55 deletions.
31 changes: 18 additions & 13 deletions packetnetworking/distros/redhat/bonded.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,28 @@ def build_tasks(self):
self.task_template(
"etc/modprobe.d/bonding.conf", "bonded/etc_modprobe.d_bonding.conf.j2"
)
self.task_template(
"etc/sysconfig/network-scripts/ifcfg-bond0",
"bonded/etc_sysconfig_network-scripts_ifcfg-bond0.j2",
)

if self.ipv4pub:
# Only needed when a public ip is used, otherwise private ip is
# already set and no special routes are needed.
for bond in self.network.bonds:
self.task_template(
"etc/sysconfig/network-scripts/ifcfg-bond0:0",
"bonded/etc_sysconfig_network-scripts_ifcfg-bond0_0.j2",
)
self.task_template(
"etc/sysconfig/network-scripts/route-bond0",
"bonded/etc_sysconfig_network-scripts_route-bond0.j2",
"etc/sysconfig/network-scripts/ifcfg-{}".format(bond),
"bonded/etc_sysconfig_network-scripts_ifcfg-bondX.j2",
fmt={"bond": bond},
)

if self.ipv4pub and bond == "bond0":
# Only needed when a public ip is used, otherwise private ip is
# already set and no special routes are needed.
self.task_template(
"etc/sysconfig/network-scripts/ifcfg-{}:0".format(bond),
"bonded/etc_sysconfig_network-scripts_ifcfg-bondX_0.j2",
fmt={"bond": bond},
)
self.task_template(
"etc/sysconfig/network-scripts/route-{}".format(bond),
"bonded/etc_sysconfig_network-scripts_route-bondX.j2",
fmt={"bond": bond},
)

for i, iface in enumerate(self.network.interfaces):
name = iface["name"]
self.task_template(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
alias bond0 bonding
options bond0 mode={{ net.bonding.mode }} miimon=100 downdelay=200 updelay=200 xmit_hash_policy=layer3+4 lacp_rate=1
{% for bond in net.bonds %}
alias {{ bond }} bonding
options {{ bond }} mode={{ net.bonding.mode }} miimon=100 downdelay=200 updelay=200 xmit_hash_policy=layer3+4 lacp_rate=1
{% endfor %}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
DEVICE={bond}
NAME={bond}
{{% if ip4pub %}}
IPADDR={{{{ ip4pub.address }}}}
NETMASK={{{{ ip4pub.netmask }}}}
GATEWAY={{{{ ip4pub.gateway }}}}
{{% else %}}
IPADDR={{{{ ip4priv.address }}}}
NETMASK={{{{ ip4priv.netmask }}}}
GATEWAY={{{{ ip4priv.gateway }}}}
{{% endif %}}
BOOTPROTO=none
ONBOOT=yes
USERCTL=no
TYPE=Bond
BONDING_OPTS="mode={{{{ net.bonding.mode }}}} miimon=100 downdelay=200 updelay=200"

{{% if ip6pub %}}
IPV6INIT=yes
IPV6ADDR={{{{ ip6pub.address }}}}/{{{{ ip6pub.cidr }}}}
IPV6_DEFAULTGW={{{{ ip6pub.gateway }}}}
{{% endif %}}
{{% for dns in resolvers %}}
DNS{{{{ loop.index }}}}={{{{ dns }}}}
{{% endfor %}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
DEVICE={bond}:0
NAME={bond}:0
IPADDR={{{{ ip4priv.address }}}}
NETMASK={{{{ ip4priv.netmask }}}}
GATEWAY={{{{ ip4priv.gateway }}}}
BOOTPROTO=none
ONBOOT=yes
USERCTL=no
{{% for dns in resolvers %}}
DNS{{{{ loop.index }}}}={{{{ dns }}}}
{{% endfor %}}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
DEVICE={iface}
ONBOOT=yes
HWADDR={{{{ interfaces[{i}].mac }}}}
MASTER=bond0
MASTER={{{{ interfaces[{i}].bond }}}}
SLAVE=yes
BOOTPROTO=none

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{% for subnet in private_subnets %}}
{{{{ subnet }}}} via {{{{ ip4priv.gateway }}}} dev {bond}:0
{{% endfor %}}

0 comments on commit a6443a6

Please sign in to comment.