Skip to content
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

bond1 #57

Merged
merged 5 commits into from
Aug 8, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.keys():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should only be defined on the bond0 interface. otherwise it would define the public ip for both bond0 and bond1 which wouldn't work

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I un-template these files and set them back to just bond0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the better question, will they ever need to be a different bond in the future, or is it okay to just leave them at bond0?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i like that it supports multiple, i think just changing it to if bond == 'bond0' and self.ipv4pub and that should be good enough for now, maybe in the future we'll support more than just that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, can do!

# 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 %}}