Skip to content

Commit 8d6342b

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

1 file changed

Lines changed: 86 additions & 0 deletions

File tree

openqa-prepare-mm-setup

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

0 commit comments

Comments
 (0)