4
# Script to configure the switch to be a single or dual vlan
5
# Copyright (C) 2016 Canonical Ltd.
7
# Authors: Gary MacKenzie <gary.mackenzie@canonical.com>
9
# This program is free software: you can redistribute it and/or modify
10
# it under the terms of the GNU General Public License as published by
11
# the Free Software Foundation, version 3 of the License.
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU General Public License for more details.
18
# You should have received a copy of the GNU General Public License
19
# along with this program. If not, see <http://www.gnu.org/licenses/>.
22
# Get OrangeBox number
25
OB=`hostname | cut -c 10-`
26
BYTE1=$(echo $OB | cut -c 1)
27
BYTE2=$(echo $OB | cut -c 2-)
29
# Parse the variables for the OrangeBox number to eliminate any zero's at the beginning of the number.
36
# Set the network subnet variables
44
echo "Usage: ./network_mode.sh mode
46
-s|--single-network Configure primary and secondary interfaces on nodes 1-10 on a single VLAN
47
-d|--dual-network Configure secondary interfaces on ndoes 1-10 on a second VLAN"
54
ARGS=`getopt -o sd --long single-network,dual-network -- "$@"`
71
*) echo "Usage: ./network_mode.sh mode
73
-s|--single-network Configure primary and secondary interfaces on nodes 1-10 on a single VLAN
74
-d|--dual-network Configure secondary interfaces on ndoes 1-10 on a second VLAN"
79
if [ "$SINGLENETWORK" -eq 1 ];
81
echo "Configuring for 1 Network mode..."
82
ssh -o "StrictHostKeyChecking no" admin@172.27.$PLUS1.254 /interface ethernet set master-port=ether2-master-local 4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23
85
echo "All ports configured for 1 network mode"
86
ssh -o "StrictHostKeyChecking no" admin@172.27.$PLUS1.254 /beep
87
#Get Orangebox number from the hostname and place into the configuration file
88
obnum=`hostname | cut -c 10- -`
89
echo "orangebox_number=${obnum}" > /etc/orange-box.conf
91
# Get interface names of the 3 interfaces on node0 since in Xenial they aren't ethX anymore
92
# An array is declared and the interface names are placed into the array to be used later on
96
vlanid=$(maas admin vlans read 1 |grep id |grep -v vid | awk -F, '{print $1}'|awk '{print $2}')
97
sub_net="172.27.${ob_number}.0/23"
99
# Configure first usb interface for fabric-1 and proper subnet
102
for nodenum in {01..10}
106
interface=$(maas admin nodes read hostname=node${nodenum}ob${ob_number} |grep enx | cut -d '"' -f4)
107
echo "Interface read $interface"
108
system_id=$(maas admin nodes read hostname=node${nodenum}ob${ob_number} |grep system_id | cut -d'"' -f4)
109
maas admin machine update $system_id cpu_count=4
110
maas admin interface update $system_id $interface vlan=$vlanid
111
maas admin interface link-subnet $system_id $interface mode=auto subnet="$sub_net"
116
if [ "$DUALNETWORK" -eq 1 ];
118
echo "Configuring for 2 Network mode..."
119
ssh -o "StrictHostKeyChecking no" admin@172.27.$PLUS1.254 /interface ethernet set master-port=ether2-master-local 4,6,8,10,12,14,16,18,20,22
121
ssh -o "StrictHostKeyChecking no" admin@172.27.$PLUS1.254 /interface ethernet set master-port=ether1-master-local 5,7,9,11,13,15,17,19,21,23
124
echo "All ports configured for 2 network mode"
125
ssh -o "StrictHostKeyChecking no" admin@172.27.$PLUS1.254 /beep
126
#Get Orangebox number from the hostname and place into the configuration file
127
obnum=`hostname | cut -c 10- -`
128
echo "orangebox_number=${obnum}" > /etc/orange-box.conf
130
# Get interface names of the 3 interfaces on node0 since in Xenial they aren't ethX anymore
131
# An array is declared and the interface names are placed into the array to be used later on
135
vlanid=$(maas admin vlans read 2 |grep id |grep -v vid | awk -F, '{print $1}'|awk '{print $2}')
136
sub_net="172.27.`expr ${ob_number} + 2`.0/23"
138
# Configure first usb interface for fabric-1 and proper subnet
141
for nodenum in {01..10}
145
interface=$(maas admin nodes read hostname=node${nodenum}ob${ob_number} |grep enx | cut -d '"' -f4)
146
echo "Interface read $interface"
147
system_id=$(maas admin nodes read hostname=node${nodenum}ob${ob_number} |grep system_id | cut -d'"' -f4)
148
maas admin machine update $system_id cpu_count=4
149
maas admin interface update $system_id $interface vlan=$vlanid
150
maas admin interface link-subnet $system_id $interface mode=auto subnet="$sub_net"
152
echo "MAAS re-adjusted the nodes to work with dual vlan"