1
0
mirror of https://pagure.io/fedora-qa/os-autoinst-distri-fedora.git synced 2024-12-22 02:13:08 +00:00

Use nmcli for static network stuff, not ifcfg files

This should work even if the ifcfg plugin is not present (hi,
CoreOS) or 'predictable' (har) network names are on.

Signed-off-by: Adam Williamson <awilliam@redhat.com>
This commit is contained in:
Adam Williamson 2020-08-21 15:56:44 -07:00
parent 52d52c7062
commit 170ef0733a
3 changed files with 15 additions and 46 deletions

View File

@ -43,21 +43,16 @@ sub setup_tap_static {
# use host's name servers (this is usually going to be correct,
# tests which don't want this can overwrite resolv.conf)
my @dns = get_host_dns();
my $dnstext = '';
for (my $i=0; $i < @dns; $i++) {
my $num = $i + 1;
$dnstext .= "\nDNS" . ${num} . "=" . $dns[$i];
}
# bring up network. DEFROUTE is *vital* here
my $conftext = "DEVICE=eth0\nBOOTPROTO=none\nIPADDR=$ip\nGATEWAY=172.16.2.2\nPREFIX=24\nDEFROUTE=yes\nONBOOT=yes" . $dnstext;
assert_script_run "printf '${conftext}\n' > /etc/sysconfig/network-scripts/ifcfg-eth0";
assert_script_run "systemctl restart NetworkManager.service";
# FIXME workaround for
# https://bugzilla.redhat.com/show_bug.cgi?id=1739148
# remove when that's resolved
script_run 'nmcli con down "Wired connection 1"';
script_run 'nmcli con down "System eth0"';
script_run 'nmcli con up "System eth0"';
my $dnstext = 'ipv4.dns "' . join(", ", @dns) . '"';
# bring up network
# this gets us the name of the first connection in the list,
# which should be what we want
my $connection = script_output "nmcli --fields NAME con show | head -2 | tail -1";
assert_script_run "nmcli con mod '$connection' ipv4.method manual ipv4.addr $ip/24 ipv4.gateway 172.16.2.2 $dnstext";
assert_script_run "nmcli con down '$connection'";
assert_script_run "nmcli con up '$connection'";
# for debugging
assert_script_run "nmcli -t con show '$connection'";
# the above doesn't seem to reliably set up resolv.conf, so...
clone_host_file "/etc/resolv.conf";
}

View File

@ -1488,7 +1488,6 @@
"settings": {
"BOOTFROM": "c",
"DESKTOP": "gnome",
"GRUB_POSTINSTALL": "net.ifnames=0 biosdevname=0",
"HDD_1": "disk_f%CURRREL%_desktop_4_%ARCH%.img",
"INSTALL": "1",
"NICTYPE": "tap",
@ -1520,7 +1519,6 @@
"settings": {
"BOOTFROM": "c",
"DESKTOP": "gnome",
"GRUB_POSTINSTALL": "net.ifnames=0 biosdevname=0",
"HDD_1": "disk_f%CURRREL%_desktop_4_%ARCH%.img",
"INSTALL": "1",
"NICTYPE": "tap",
@ -1616,7 +1614,7 @@
},
"settings": {
"BOOTFROM": "c",
"GRUB_POSTINSTALL": "net.ifnames=0 biosdevname=0 zezere.url=http://172.16.2.118",
"GRUB_POSTINSTALL": "zezere.url=http://172.16.2.118",
"HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2",
"NICTYPE": "tap",
"PARALLEL_WITH": "iot_zezere_server",
@ -1635,7 +1633,6 @@
},
"settings": {
"BOOTFROM": "c",
"GRUB_POSTINSTALL": "net.ifnames=0 biosdevname=0",
"HDD_1": "disk_f%CURRREL%_support_5_%ARCH%.img",
"NICTYPE": "tap",
"PARALLEL_CANCEL_WHOLE_CLUSTER": "0",
@ -1712,7 +1709,6 @@
},
"settings": {
"BOOTFROM": "c",
"GRUB_POSTINSTALL": "net.ifnames=0 biosdevname=0",
"HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2",
"NICTYPE": "tap",
"POSTINSTALL": "podman",
@ -1730,7 +1726,6 @@
},
"settings": {
"BOOTFROM": "c",
"GRUB_POSTINSTALL": "net.ifnames=0 biosdevname=0",
"HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2",
"NICTYPE": "tap",
"PARALLEL_WITH": "podman",
@ -1752,7 +1747,6 @@
"+HDD_1": "disk_%MACHINE%_cockpit.qcow2",
"+START_AFTER_TEST": "server_cockpit_default",
"BOOTFROM": "c",
"GRUB_POSTINSTALL": "net.ifnames=0 biosdevname=0",
"NICTYPE": "tap",
"PARALLEL_WITH": "server_role_deploy_domain_controller",
"POSTINSTALL": "realmd_join_cockpit freeipa_webui freeipa_password_change freeipa_client",
@ -1770,7 +1764,6 @@
},
"settings": {
"BOOTFROM": "c",
"GRUB_POSTINSTALL": "net.ifnames=0 biosdevname=0",
"HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2",
"NICTYPE": "tap",
"PARALLEL_WITH": "server_role_deploy_domain_controller",
@ -1854,7 +1847,6 @@
},
"settings": {
"BOOTFROM": "c",
"GRUB_POSTINSTALL": "net.ifnames=0 biosdevname=0",
"HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2",
"NICTYPE": "tap",
"PARALLEL_WITH": "server_role_deploy_database_server",
@ -1904,8 +1896,6 @@
"settings": {
"BOOTFROM": "c",
"FREEIPA_REPLICA_CLIENT": "1",
"GRUB": "net.ifnames=0 biosdevname=0",
"GRUB_POSTINSTALL": "net.ifnames=0 biosdevname=0",
"HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2",
"NICTYPE": "tap",
"PARALLEL_WITH": "server_freeipa_replication_replica",
@ -1926,8 +1916,6 @@
"settings": {
"BOOTFROM": "c",
"FREEIPA_REPLICA_MASTER": "1",
"GRUB": "net.ifnames=0 biosdevname=0",
"GRUB_POSTINSTALL": "net.ifnames=0 biosdevname=0",
"HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2",
"NICTYPE": "tap",
"PARALLEL_CANCEL_WHOLE_CLUSTER": "0",
@ -1948,8 +1936,6 @@
"settings": {
"BOOTFROM": "c",
"FREEIPA_REPLICA": "1",
"GRUB": "net.ifnames=0 biosdevname=0",
"GRUB_POSTINSTALL": "net.ifnames=0 biosdevname=0",
"HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2",
"NICTYPE": "tap",
"PARALLEL_CANCEL_WHOLE_CLUSTER": "0",
@ -1990,7 +1976,6 @@
},
"settings": {
"BOOTFROM": "c",
"GRUB_POSTINSTALL": "net.ifnames=0 biosdevname=0",
"HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2",
"NICTYPE": "tap",
"PARALLEL_WITH": "server_remote_logging_server",
@ -2010,7 +1995,6 @@
},
"settings": {
"BOOTFROM": "c",
"GRUB_POSTINSTALL": "net.ifnames=0 biosdevname=0",
"HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2",
"NICTYPE": "tap",
"PARALLEL_CANCEL_WHOLE_CLUSTER": "0",
@ -2030,7 +2014,6 @@
},
"settings": {
"BOOTFROM": "c",
"GRUB_POSTINSTALL": "net.ifnames=0 biosdevname=0",
"HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2",
"NICTYPE": "tap",
"PARALLEL_CANCEL_WHOLE_CLUSTER": "0",
@ -2050,8 +2033,6 @@
},
"settings": {
"BOOTFROM": "c",
"GRUB": "net.ifnames=0 biosdevname=0",
"GRUB_POSTINSTALL": "net.ifnames=0 biosdevname=0",
"HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2",
"NICTYPE": "tap",
"PARALLEL_CANCEL_WHOLE_CLUSTER": "0",
@ -2074,7 +2055,6 @@
},
"settings": {
"BOOTFROM": "c",
"GRUB_POSTINSTALL": "net.ifnames=0 biosdevname=0",
"HDD_1": "disk_f%CURRREL%_support_5_%ARCH%.img",
"NICTYPE": "tap",
"NUMDISKS": "2",
@ -2169,8 +2149,6 @@
"settings": {
"+HDD_1": "disk_f%UP2REL%_server_3_%ARCH%.img",
"BOOTFROM": "c",
"GRUB": "net.ifnames=0 biosdevname=0",
"GRUB_POSTINSTALL": "net.ifnames=0 biosdevname=0",
"NICTYPE": "tap",
"PARALLEL_WITH": "upgrade_2_server_domain_controller",
"POSTINSTALL": "_setup_browser freeipa_webui freeipa_password_change freeipa_client",
@ -2207,8 +2185,6 @@
"settings": {
"+HDD_1": "disk_f%UP2REL%_server_3_%ARCH%.img",
"BOOTFROM": "c",
"GRUB": "net.ifnames=0 biosdevname=0",
"GRUB_POSTINSTALL": "net.ifnames=0 biosdevname=0",
"NICTYPE": "tap",
"PARALLEL_CANCEL_WHOLE_CLUSTER": "0",
"POSTINSTALL": "role_deploy_domain_controller_check",
@ -2304,8 +2280,6 @@
"settings": {
"+HDD_1": "disk_f%UP1REL%_server_3_%ARCH%.img",
"BOOTFROM": "c",
"GRUB": "net.ifnames=0 biosdevname=0",
"GRUB_POSTINSTALL": "net.ifnames=0 biosdevname=0",
"NICTYPE": "tap",
"PARALLEL_WITH": "upgrade_server_domain_controller",
"POSTINSTALL": "_setup_browser freeipa_webui freeipa_password_change freeipa_client",
@ -2343,8 +2317,6 @@
"settings": {
"+HDD_1": "disk_f%UP1REL%_server_3_%ARCH%.img",
"BOOTFROM": "c",
"GRUB": "net.ifnames=0 biosdevname=0",
"GRUB_POSTINSTALL": "net.ifnames=0 biosdevname=0",
"NICTYPE": "tap",
"PARALLEL_CANCEL_WHOLE_CLUSTER": "0",
"POSTINSTALL": "role_deploy_domain_controller_check",

View File

@ -23,8 +23,10 @@ sub run {
}
bypass_1691487;
assert_script_run "printf 'search domain.local\nnameserver ${server_ip}' > /etc/resolv.conf";
assert_script_run "sed -i -e '/^DNS.*/d' /etc/sysconfig/network-scripts/ifcfg-eth0";
assert_script_run "printf '\nDNS1=${server_ip}\n' >> /etc/sysconfig/network-scripts/ifcfg-eth0";
# this gets us the name of the first connection in the list,
# which should be what we want
my $connection = script_output "nmcli --fields NAME con show | head -2 | tail -1";
assert_script_run "nmcli con mod '$connection' ipv4.dns '$server_ip'";
# wait for the server or replica to be ready (do it now just to be
# sure name resolution is working before we proceed)
mutex_lock $server_mutex;