Skip to content

Commit 7c5264d

Browse files
committed
Provide a script to bootstrap mm devices
See: https://progress.opensuse.org/issues/115418
1 parent 58f720c commit 7c5264d

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed

openqa-prepare-mm-setup

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#!/usr/bin/env perl
2+
# Copyright 2020 SUSE LLC
3+
# SPDX-License-Identifier: GPL-2.0-or-later
4+
use strict;
5+
6+
system("zypper in -y os-autoinst-openvswitch");
7+
system("systemctl enable --now os-autoinst-openvswitch");
8+
9+
my $bridge = 1;
10+
my $openvswitch = "/etc/sysconfig/os-autoinst-openvswitch";
11+
open(file, '>', $openvswitch) or die "Failed to open $openvswitch for writing!";
12+
print file "OS_AUTOINST_USE_BRIDGE=br$bridge";
13+
close(file);
14+
15+
system("ovs-vsctl add-br br$bridge");
16+
print("Added bridge $bridge");
17+
18+
my $bridge_file = "/etc/sysconfig/network/ifcfg-br$bridge";
19+
my $ip = "10.0.2.2/15";
20+
my $config = "
21+
BOOTPROTO='static'
22+
IPADDR='$ip'
23+
STARTMODE='auto'
24+
ZONE=trusted
25+
OVS_BRIDGE='yes'
26+
PRE_UP_SCRIPT=\"wicked:gre_tunnel_preup.sh\"
27+
";
28+
29+
for (my $i = 0; $i < 148; $i++) {
30+
$config .= "OVS_BRIDGE_PORT_DEVICE_$i='tap$i'\n";
31+
32+
my $tapconfig = "
33+
BOOTPROTO='none'
34+
IPADDR=''
35+
NETMASK=''
36+
PREFIXLEN=''
37+
STARTMODE='auto'
38+
TUNNEL='tap'
39+
TUNNEL_SET_GROUP='nogroup'
40+
TUNNEL_SET_OWNER='_openqa-worker'
41+
ZONE=trusted
42+
";
43+
44+
my $tap_file = "/etc/sysconfig/network/ifcfg-tap$i";
45+
open(file, '>', $tap_file) or die "Failed to open $tap_file for writing!";
46+
print file $tapconfig;
47+
close(file);
48+
}
49+
50+
open(file, '>', $bridge_file) or die "Failed to open $bridge_file for writing!";
51+
print file $config;
52+
close(file);
53+
print("Config written!");
54+
55+
my $gre = "/etc/wicked/scripts/gre_tunnel_preup.sh";
56+
open(file, '>', $gre) or die "Failed to open $gre for writing!";
57+
58+
my $gre_config = "
59+
#!/bin/sh
60+
action=\"\$1\"
61+
bridge=\"\$2\"
62+
ovs-vsctl set bridge \$bridge stp_enable=true
63+
";
64+
65+
my %workers = (openqaworker1 => '192.168.112.6',
66+
openqaworker7 => '192.168.112.12',
67+
openqaworker4 => '192.168.112.7',
68+
openqaworker19 => '192.168.112.17',
69+
);
70+
my $device = 0;
71+
my $this_worker = qx(hostname -i);
72+
chomp $this_worker;
73+
hile (my ($worker, $ip) = each %workers) {
74+
# Don't put the machine itself here
75+
if ($this_worker ne $ip) {
76+
$device++;
77+
$gre_config .= "
78+
# $worker
79+
ovs-vsctl --may-exist add-port $bridge gre$device -- set interface gre$device type=gre options:remote_ip=$ip";
80+
}
81+
}
82+
83+
print file $gre_config;
84+
close(file);
85+
system("chmod +x $gre");

0 commit comments

Comments
 (0)