Skip to content

Commit

Permalink
Replace is_rhel8 and is_rhel9 with get_platform function
Browse files Browse the repository at this point in the history
  • Loading branch information
rvykydal committed May 21, 2024
1 parent 8cb666a commit d5b2933
Show file tree
Hide file tree
Showing 16 changed files with 40 additions and 51 deletions.
4 changes: 2 additions & 2 deletions anaconda-conf.ks.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ fi
%post --nochroot

@KSINCLUDE@ scripts-lib.sh
platform="$(get_platform @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@)"

if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ || \
is_rhel9 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then
if [ "${platform}" == "rhel8" ] || [ "${platform}" == "rhel9" ]; then
LOG_MSG="Writing a temporary configuration loaded from"
else
LOG_MSG="Configuration loaded from:"
Expand Down
4 changes: 2 additions & 2 deletions anaconda-modules.ks.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
%post --nochroot

@KSINCLUDE@ scripts-lib.sh
platform="$(get_platform @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@)"

# Get the activated Anaconda DBus modules.
cat /tmp/syslog | grep "Activating service name" | \
grep "org.fedoraproject.Anaconda.Modules" | cut -d"'" -f2 \
| sort > /tmp/generated.out

# Generate the expected output.
if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ || \
is_rhel9 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then
if [ "${platform}" == "rhel8" ] || [ "${platform}" == "rhel9" ]; then
cat > /tmp/expected.out << EOF
org.fedoraproject.Anaconda.Modules.Localization
org.fedoraproject.Anaconda.Modules.Network
Expand Down
3 changes: 2 additions & 1 deletion bindtomac-bridge-2devs-httpks.ks.in
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ check_gui_configurations @KSTEST_NETDEV1@ @KSTEST_NETDEV2@ bridge0 bridge1

@KSINCLUDE@ post-lib-network.sh
@KSINCLUDE@ scripts-lib.sh
platform="$(get_platform @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@)"

# bridge0

Expand Down Expand Up @@ -76,7 +77,7 @@ check_device_config_value bridge1 ONBOOT yes connection autoconnect __NONE

check_device_config_value bridge1_slave_1 ONBOOT yes connection autoconnect __NONE

if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then
if [ "${platform}" == "rhel8" ]; then
# RHEL-8-FAILURE: anaconda does not create default config file for enslaved device in RHEL8
check_config_exists @KSTEST_NETDEV2@ no
else
Expand Down
3 changes: 2 additions & 1 deletion bindtomac-bridge-2devs-pre.ks.in
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ check_gui_configurations @KSTEST_NETDEV1@ @KSTEST_NETDEV2@ bridge0 bridge1

@KSINCLUDE@ post-lib-network.sh
@KSINCLUDE@ scripts-lib.sh
platform="$(get_platform @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@)"

# bridge0

Expand Down Expand Up @@ -76,7 +77,7 @@ check_device_config_value bridge1 ONBOOT yes connection autoconnect __NONE

check_device_config_value bridge1_slave_1 ONBOOT yes connection autoconnect __NONE

if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then
if [ "${platform}" == "rhel8" ]; then
# RHEL-8-FAILURE: anaconda does not create default config file for enslaved device in RHEL8
check_config_exists @KSTEST_NETDEV2@ no
else
Expand Down
3 changes: 2 additions & 1 deletion bindtomac-bridge-httpks.ks.in
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ shutdown
%post --nochroot

@KSINCLUDE@ scripts-lib.sh
platform="$(get_platform @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@)"
@KSINCLUDE@ post-nochroot-lib-network.sh

check_bridge_has_slave_nochroot bridge0 @KSTEST_NETDEV1@ yes
if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then
if [ "${platform}" == "rhel8" ]; then
# RHEL-8-FAILURE: generic "Wired Connection" created in initramfs (ip=dhcp)
# would be edited for @KSTEST_NETDEV1@ in GUI which is not ideal
check_gui_configurations bridge0
Expand Down
6 changes: 4 additions & 2 deletions bond-ks-initramfs.ks.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ network --device bond0 --bootproto dhcp --bondslaves=@KSTEST_NETDEV1@,@KSTEST_NE
# We will copy /root/RESULT to /mnt/sysimage/root/RESULT at the beginning of the %post (--nochroot) checks
@KSINCLUDE@ post-lib-network.sh
@KSINCLUDE@ scripts-lib.sh
platform="$(get_platform @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@)"

if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then
if [ "${platform}" == "rhel8" ]; then
# Ifcfg files for the kickstart configuration are created in initramfs
check_config_exists bond0 yes
check_config_exists bond0_slave_1 yes
Expand Down Expand Up @@ -59,9 +60,10 @@ check_gui_configurations @KSTEST_NETDEV1@ @KSTEST_NETDEV2@ bond0

@KSINCLUDE@ post-lib-network.sh
@KSINCLUDE@ scripts-lib.sh
platform="$(get_platform @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@)"

check_device_config_value bond0 ONBOOT yes connection autoconnect __NONE
if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then
if [ "${platform}" == "rhel8" ]; then
check_device_config_value bond0_slave_1 ONBOOT yes connection autoconnect __NONE
check_device_config_value bond0_slave_1 SLAVE yes connection slave-type bond
check_device_config_value bond0_slave_2 ONBOOT yes connection autoconnect __NONE
Expand Down
3 changes: 2 additions & 1 deletion bridge-2devs-httpks.ks.in
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ check_gui_configurations @KSTEST_NETDEV1@ @KSTEST_NETDEV2@ bridge0 bridge1

@KSINCLUDE@ post-lib-network.sh
@KSINCLUDE@ scripts-lib.sh
platform="$(get_platform @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@)"

# bridge0

Expand Down Expand Up @@ -77,7 +78,7 @@ check_device_config_value bridge1 ONBOOT yes connection autoconnect __NONE

check_device_config_value bridge1_slave_1 ONBOOT yes connection autoconnect __NONE

if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then
if [ "${platform}" == "rhel8" ]; then
# RHEL-8-FAILURE: anaconda does not create default config file for enslaved device in RHEL8
check_config_exists @KSTEST_NETDEV2@ no
else
Expand Down
3 changes: 2 additions & 1 deletion bridge-2devs-pre.ks.in
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ check_gui_configurations @KSTEST_NETDEV1@ @KSTEST_NETDEV2@ bridge0 bridge1

@KSINCLUDE@ post-lib-network.sh
@KSINCLUDE@ scripts-lib.sh
platform="$(get_platform @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@)"

# bridge0

Expand Down Expand Up @@ -76,7 +77,7 @@ check_device_config_value bridge1 ONBOOT yes connection autoconnect __NONE

check_device_config_value bridge1_slave_1 ONBOOT yes connection autoconnect __NONE

if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then
if [ "${platform}" == "rhel8" ]; then
# RHEL-8-FAILURE: anaconda does not create default config file for enslaved device in RHEL8
check_config_exists @KSTEST_NETDEV2@ no
else
Expand Down
3 changes: 2 additions & 1 deletion bridge-2devs.ks.in
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ check_gui_configurations @KSTEST_NETDEV1@ @KSTEST_NETDEV2@ bridge0 bridge1

@KSINCLUDE@ post-lib-network.sh
@KSINCLUDE@ scripts-lib.sh
platform="$(get_platform @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@)"

# bridge0

Expand Down Expand Up @@ -75,7 +76,7 @@ check_device_config_value bridge1 ONBOOT yes connection autoconnect __NONE

check_device_config_value bridge1_slave_1 ONBOOT yes connection autoconnect __NONE

if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then
if [ "${platform}" == "rhel8" ]; then
# RHEL-8-FAILURE: anaconda does not create default config file for enslaved device in RHEL8
check_config_exists @KSTEST_NETDEV2@ no
else
Expand Down
3 changes: 2 additions & 1 deletion bridge-httpks.ks.in
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ shutdown
%post --nochroot

@KSINCLUDE@ scripts-lib.sh
platform="$(get_platform @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@)"
@KSINCLUDE@ post-nochroot-lib-network.sh

check_bridge_has_slave_nochroot bridge0 @KSTEST_NETDEV1@ yes
if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then
if [ "${platform}" == "rhel8" ]; then
# RHEL-8-FAILURE: generic "Wired Connection" created in initramfs (ip=dhcp)
# would be edited for @KSTEST_NETDEV1@ in GUI which is not ideal
check_gui_configurations bridge0
Expand Down
3 changes: 2 additions & 1 deletion bridge-no-bootopts-net.ks.in
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ check_gui_configurations @KSTEST_NETDEV1@ bridge0

@KSINCLUDE@ post-lib-network.sh
@KSINCLUDE@ scripts-lib.sh
platform="$(get_platform @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@)"

check_device_connected bridge0 yes
check_device_connected @KSTEST_NETDEV1@ yes

if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then
if [ "${platform}" == "rhel8" ]; then
# RHEL-8-FAILURE: in rhel 8 the ifcfg is generated in initramfs by Anaconda
check_device_config_value bridge0_slave_1 BRIDGE bridge0 connection master bridge0
check_device_config_value bridge0_slave_1 BRIDGE bridge0 connection slave-type bridge
Expand Down
3 changes: 2 additions & 1 deletion network-addr-gen-mode.ks.in
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,12 @@ check_gui_configurations @KSTEST_NETDEV1@ @KSTEST_NETDEV2@ @KSTEST_NETDEV3@ @KST

@KSINCLUDE@ post-lib-network.sh
@KSINCLUDE@ scripts-lib.sh
platform="$(get_platform @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@)"

check_device_config_value @KSTEST_NETDEV1@ IPV6_ADDR_GEN_MODE eui64 ipv6 addr-gen-mode eui64
check_connection_setting "@KSTEST_NETDEV1@" ipv6.addr-gen-mode eui64
check_device_config_value @KSTEST_NETDEV2@ IPV6_ADDR_GEN_MODE __NONE ipv6 addr-gen-mode eui64
if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then
if [ "${platform}" == "rhel8" ]; then
# In rhel8 ifcfg from kickstart is generated in initramfs
check_connection_setting "System @KSTEST_NETDEV2@" ipv6.addr-gen-mode default-or-eui64
else
Expand Down
10 changes: 6 additions & 4 deletions network-autoconnections-dhcpall-httpks.ks.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ shutdown
# We will copy /root/RESULT to /mnt/sysimage/root/RESULT at the beginning of the %post (--nochroot) checks
@KSINCLUDE@ post-lib-network.sh
@KSINCLUDE@ scripts-lib.sh
platform="$(get_platform @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@)"

check_config_exists @KSTEST_NETDEV1@ no
if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then
if [ "${platform}" == "rhel8" ]; then
check_config_exists @KSTEST_NETDEV2@ yes
else
check_config_exists @KSTEST_NETDEV2@ no
Expand All @@ -38,7 +39,7 @@ check_device_connected @KSTEST_NETDEV1@ yes
check_device_connected @KSTEST_NETDEV2@ yes
check_device_connected @KSTEST_NETDEV3@ yes

if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then
if [ "${platform}" == "rhel8" ]; then
check_number_of_connections 2
else
# includes "lo" connection
Expand All @@ -47,7 +48,7 @@ fi

check_connection_device "Wired Connection" @KSTEST_NETDEV1@
check_connection_device "Wired Connection" @KSTEST_NETDEV2@
if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then
if [ "${platform}" == "rhel8" ]; then
check_connection_device "System @KSTEST_NETDEV2@"
fi
check_connection_device "Wired Connection" @KSTEST_NETDEV3@
Expand Down Expand Up @@ -76,6 +77,7 @@ check_gui_configurations @KSTEST_NETDEV1@ @KSTEST_NETDEV2@ @KSTEST_NETDEV3@

@KSINCLUDE@ post-lib-network.sh
@KSINCLUDE@ scripts-lib.sh
platform="$(get_platform @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@)"

check_device_config_value @KSTEST_NETDEV1@ ONBOOT yes connection autoconnect __NONE
check_device_config_value @KSTEST_NETDEV2@ ONBOOT yes connection autoconnect __NONE
Expand All @@ -89,7 +91,7 @@ check_device_connected @KSTEST_NETDEV3@ yes
check_connection_device "Wired Connection" @KSTEST_NETDEV2@
check_connection_device @KSTEST_NETDEV2@

if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then
if [ "${platform}" == "rhel8" ]; then
check_number_of_connections 4
else
# includes "lo" connection
Expand Down
10 changes: 6 additions & 4 deletions network-autoconnections-httpks.ks.in
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ shutdown
# We will copy /root/RESULT to /mnt/sysimage/root/RESULT at the beginning of the %post (--nochroot) checks
@KSINCLUDE@ post-lib-network.sh
@KSINCLUDE@ scripts-lib.sh
platform="$(get_platform @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@)"
# Note: up to RHEL8.2 the file was created by dracut network module
# check_config_exists @KSTEST_NETDEV1@ yes
check_config_exists @KSTEST_NETDEV1@ no
# In RHEL8 ifcfg files are created from kickstart already in initramfs
if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then
if [ "${platform}" == "rhel8" ]; then
check_config_exists @KSTEST_NETDEV2@ yes
else
check_config_exists @KSTEST_NETDEV2@ no
Expand All @@ -40,7 +41,7 @@ check_config_exists @KSTEST_NETDEV3@ no

check_device_connected @KSTEST_NETDEV1@ yes
check_connection_device @KSTEST_NETDEV1@ @KSTEST_NETDEV1@
if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then
if [ "${platform}" == "rhel8" ]; then
check_connection_device "System @KSTEST_NETDEV2@"
fi

Expand All @@ -53,7 +54,7 @@ check_connection_setting "@KSTEST_NETDEV1@" 802-3-ethernet.mac-address --
detect_nm_has_autoconnections_off
nm_has_autoconnections_off=$?
if [[ $nm_has_autoconnections_off -eq 0 ]]; then
if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then
if [ "${platform}" == "rhel8" ]; then
check_number_of_connections 2
else
# includes "lo" connection
Expand Down Expand Up @@ -94,6 +95,7 @@ check_gui_configurations @KSTEST_NETDEV1@ @KSTEST_NETDEV2@ @KSTEST_NETDEV3@

@KSINCLUDE@ post-lib-network.sh
@KSINCLUDE@ scripts-lib.sh
platform="$(get_platform @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@)"

check_device_config_value @KSTEST_NETDEV1@ ONBOOT yes connection autoconnect __NONE
check_device_config_value @KSTEST_NETDEV2@ ONBOOT yes connection autoconnect __NONE
Expand All @@ -103,7 +105,7 @@ detect_nm_has_autoconnections_off
nm_has_autoconnections_off=$?
if [[ $nm_has_autoconnections_off -eq 0 ]]; then
check_device_config_value @KSTEST_NETDEV3@ ONBOOT no connection autoconnect false
if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then
if [ "${platform}" == "rhel8" ]; then
check_number_of_connections 3
else
# includes "lo" connection
Expand Down
4 changes: 2 additions & 2 deletions repo-install.ks.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ repo --name=test05 --baseurl=EMPTY_REPO_URL --includepkgs=p1,p2 --excludepkgs=p3
%post

@KSINCLUDE@ scripts-lib.sh
platform="$(get_platform @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@)"

# Define patterns for repo options.
if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ || \
is_rhel9 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then
if [ "${platform}" == "rhel8" ] || [ "${platform}" == "rhel9" ]; then
cost='^cost=25$'
sslverify='^sslverify=0$'
includepkgs='^includepkgs=p1,p2$'
Expand Down
26 changes: 0 additions & 26 deletions scripts-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,3 @@ function get_platform {

echo ${platform}
}


# is_rhel8 KSTESTS_OS_NAME KSTESTS_OS_VERSION
# Are we testing rhel 8 (based on the name and version detected from boot.iso) ?
function is_rhel8 {
local os_name=$1
local os_version=$2
if [ "$(get_platform ${os_name} ${os_version})" == "rhel8" ] ; then
return 0
else
return 1
fi
}


# is_rhel9 KSTESTS_OS_NAME KSTESTS_OS_VERSION
# Are we testing rhel 9 (based on the name and version detected from boot.iso) ?
function is_rhel9 {
local os_name=$1
local os_version=$2
if [ "$(get_platform ${os_name} ${os_version})" == "rhel9" ] ; then
return 0
else
return 1
fi
}

0 comments on commit d5b2933

Please sign in to comment.