ref: bd31e7c59f1fa7ff92ac8c3c1c2f874ba1fe832b cisco/deploy/network/network_up.sh.j2 -rw-r--r-- 972 bytes View raw
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env bash

# Create bridge interface
ip link add {{ net.bridge.name }} type {{ net.bridge.type }}

# Create bond interface
modprobe bonding
ip link add {{ net.cluster.name }} type {{ net.cluster.type }} mode 802.3ad

{% for slave in net.cluster.slaves %}
# Add interface {{ slave }} to the bond
ip link set {{ slave }} down
ip addr flush {{ slave }}
ip link set dev {{ slave }} mtu 1500
ip link set {{ slave }} master {{ net.cluster.name }}

{% endfor %}

# Attach the bond to the bridge
ip link set {{ net.cluster.name }} master {{ net.bridge.name }}

# Configure bond
echo 1 > /sys/class/net/{{ net.cluster.name }}/bonding/lacp_rate
echo 1 > /sys/class/net/{{ net.cluster.name }}/bonding/xmit_hash_policy

# Bring the bond up
ip link set dev {{ net.cluster.name }} up mtu 1500

# Bring the bridge up
ip link set dev {{ net.bridge.name }} up

# Get IP address for bridge
dhclient {{ net.bridge.name }}

# Get IP address for adm
dhclient {{ net.adm.interface }}