Browse Source

Update plumgrid_fabric script to maintain bonded interface configs

- The current script creates a new interface file for the fabric
  interface, which is problematic in bonded interfaces as it removes
  all those configs as well

- The modifcations are now done in place for ip-address netmask etc

Ticket: [CFB-864]

Change-Id: I0704c3c5b394aee22bf7d855fd0469bfb315e95f
Signed-off-by: Javeria Khan <javeriak@plumgrid.com>
Javeria Khan 3 years ago
parent
commit
6dcf7f3b6f
1 changed files with 18 additions and 4 deletions
  1. 18
    4
      deployment_scripts/plumgrid_fabric.sh

+ 18
- 4
deployment_scripts/plumgrid_fabric.sh View File

@@ -17,6 +17,19 @@
17 17
 
18 18
 . /tmp/plumgrid_config
19 19
 
20
+function check_and_replace() {
21
+  local check_line=$1
22
+  local replace_line=$2
23
+  local file=$3
24
+  grep -q "$check_line" $file
25
+  if [[ $? -ne 0 ]]; then
26
+    sed -i "$ a\\$replace_line" $file
27
+  else
28
+    sed -i "s/$check_line.*/$replace_line/g" $file
29
+  fi
30
+  return 0
31
+}
32
+
20 33
 fabric_ip=$(ip addr show br-mgmt | awk '$1=="inet" {print $2}' | awk -F '/' '{print $1}' | awk -F '.' '{print $4}' | head -1)
21 34
 fabric_dev=$(brctl show br-mgmt | awk -F ' ' '{print $4}' | awk 'FNR == 2 {print}' | awk -F '.' '{print $1}')
22 35
 
@@ -38,11 +51,12 @@ fabric_net=$(echo $fabric_network | cut -f2 -d: | cut -f1-3 -d.)
38 51
 ifconfig $fabric_dev $fabric_net.$fabric_ip netmask $fabric_netmask
39 52
 ifconfig $fabric_dev mtu 1580
40 53
 
41
-if [[ -f "/etc/network/interfaces.d/ifcfg-$fabric_dev" ]];then
42
-  rm /etc/network/interfaces.d/ifcfg-$fabric_dev
43
-fi
54
+check_and_replace "iface " "iface $fabric_dev inet static" /etc/network/interfaces.d/ifcfg-$fabric_dev
55
+check_and_replace "address " "address $fabric_net.$fabric_ip" /etc/network/interfaces.d/ifcfg-$fabric_dev
56
+check_and_replace "netmask " "netmask $fabric_netmask" /etc/network/interfaces.d/ifcfg-$fabric_dev
57
+check_and_replace "mtu " "mtu 1580" /etc/network/interfaces.d/ifcfg-$fabric_dev
44 58
 
45
-echo -e "auto $fabric_dev\niface $fabric_dev inet static\naddress $fabric_net.$fabric_ip/24\nmtu 1580" >> /etc/network/interfaces.d/ifcfg-$fabric_dev
59
+sed -i "/bridge_port.*/d" /etc/network/interfaces.d/ifcfg-$fabric_dev
46 60
 
47 61
 grep -q -F "fabric_dev: $fabric_dev" /etc/astute.yaml || echo "fabric_dev: $fabric_dev" >> /etc/astute.yaml
48 62
 

Loading…
Cancel
Save