Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 47 additions & 3 deletions agent/06_agent_create_cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,44 @@ function automate_rendezvousIP_selection(){
done
}

function automate_static_networking(){
local node_type=$1
local node_count=$2
local base_ip=80

# Compute IP offset: masters start at 80, workers continue after masters,
# arbiters continue after workers
local offset=0
case "$node_type" in
master) offset=0 ;;
worker) offset=$NUM_MASTERS ;;
arbiter) offset=$(( NUM_MASTERS + NUM_WORKERS )) ;;
esac

local hostname_format
case "$node_type" in
master) hostname_format="$MASTER_HOSTNAME_FORMAT" ;;
worker) hostname_format="$WORKER_HOSTNAME_FORMAT" ;;
arbiter) hostname_format="$ARBITER_HOSTNAME_FORMAT" ;;
esac

for (( n=0; n<node_count; n++ ))
do
name=${CLUSTER_NAME}_${node_type}_${n}
node_ip="192.168.111.$(( base_ip + offset + n ))"
# shellcheck disable=SC2059
node_hostname="$(printf "$hostname_format" "$n")"

sudo virsh screenshot "$name" "${OCP_DIR}/${name}_console_screenshot_before_static_networking.ppm"

echo "Configuring static IP ${node_ip} and hostname ${node_hostname} on ${name}"
./agent/e2e/agent-tui/automate-no-registry-agent-tui-static.sh "$name" "$node_ip" "$node_hostname"

sudo virsh screenshot "$name" "${OCP_DIR}/${name}_console_screenshot_after_static_networking.ppm"
echo "Finished configuring static networking for $name"
done
}

function check_assisted_install_UI(){
local rendezvousIP
rendezvousIP=$(getRendezvousIP)
Expand Down Expand Up @@ -838,9 +876,15 @@ case "${AGENT_E2E_TEST_BOOT_MODE}" in
echo "aarch64: CDROM media ejected from all VMs"
fi

automate_rendezvousIP_selection master "$NUM_MASTERS"
automate_rendezvousIP_selection worker "$NUM_WORKERS"
automate_rendezvousIP_selection arbiter "$NUM_ARBITERS"
if [[ "${AGENT_ISO_NO_REGISTRY_STATIC_NETWORKING:-false}" == "true" ]]; then
automate_static_networking master "$NUM_MASTERS"
automate_static_networking worker "$NUM_WORKERS"
automate_static_networking arbiter "$NUM_ARBITERS"
else
automate_rendezvousIP_selection master "$NUM_MASTERS"
automate_rendezvousIP_selection worker "$NUM_WORKERS"
automate_rendezvousIP_selection arbiter "$NUM_ARBITERS"
fi

check_assisted_install_UI

Expand Down
8 changes: 8 additions & 0 deletions agent/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,17 @@ if [ "${AGENT_E2E_TEST_BOOT_MODE}" == "ISO_NO_REGISTRY" ] ; then
if [[ -z "${NETWORKING_MODE}" ]]; then
export NETWORKING_MODE="DHCP"
fi
# When true, static IPs are configured via nmtui in the TUI
# instead of using DHCP addresses
export AGENT_ISO_NO_REGISTRY_STATIC_NETWORKING=${AGENT_ISO_NO_REGISTRY_STATIC_NETWORKING:-false}
fi

function getRendezvousIP() {
# When static networking is configured via TUI, the rendezvous IP is known
if [[ "${AGENT_ISO_NO_REGISTRY_STATIC_NETWORKING:-false}" == "true" ]]; then
echo "192.168.111.80"
return
fi
if [[ "${NODES_PLATFORM}" == "baremetal" ]]; then
echo "${AGENT_BAREMETAL_IPS%%,*}"
return
Expand Down
165 changes: 165 additions & 0 deletions agent/e2e/agent-tui/automate-no-registry-agent-tui-static.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
#!/bin/bash

SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../../../" && pwd )"
source "$SCRIPTDIR/common.sh"
source "$SCRIPTDIR/agent/common.sh"
source "$SCRIPTDIR/agent/e2e/agent-tui/utils.sh"

set +x

node_name=$1
node_ip=$2
node_hostname=$3

# The following commands send key presses through "virsh send-key" to interact
# with agent-tui and nmtui to configure static networking.

#
# Phase 1: Navigate from TUI first screen to nmtui
# The TUI first screen has: Rendezvous IP field, <Save rendezvous IP>,
# <This is the rendezvous node>, and <Configure Network> at the bottom.
#
pressDown "Navigate to <Configure Network>" 3 "$node_name"
pressEnter "Select '<Configure Network>'" "" "$node_name"

#
# Phase 2: Add a new Ethernet connection with static IP in nmtui
# Creating a NEW connection (rather than editing the existing one) ensures
# a new .nmconnection file is created with a birth time after agent-tui start.
# This triggers the --copy-network flag in coreos-installer, which preserves
# the static networking config into the installed system.
#
# nmtui opens with: "Edit a connection", "Activate a connection",
# "Set system hostname", "Radio" (4.16+), "Quit"
#
pressEnter "Select 'Edit a connection'" "" "$node_name"

# Tab from connection list to <Add> button.
# Connection list is one widget; Tab goes to buttons: <Add>, <Edit>, <Delete>, <Back>
pressTab "Goto <Add> button" 1 "$node_name"
pressEnter "Select '<Add>' button" "" "$node_name"

# New Connection type dialog: DSL is selected by default.
# Navigate down to Ethernet, then tab past <Cancel> to <Create> and confirm.
pressDown "Select Ethernet" 1 "$node_name"
pressTab "Goto <Cancel> button" 1 "$node_name"
pressTab "Goto <Create> button" 1 "$node_name"
pressEnter "Create new Ethernet connection" "" "$node_name"

# Edit Connection form opens with cursor on Profile name field.
# Leave default profile name, tab to Device field and enter interface name.
pressTab "Goto Device field" 1 "$node_name"
pressKeys "Enter device name" "enp2s0" "$node_name"

# Tab past ETHERNET <Show>, 802.1X SECURITY <Show> to IPv4 <Automatic>
pressTab "Goto IPv4 CONFIGURATION mode" 3 "$node_name"
pressEnter "Open IPv4 mode selector" "" "$node_name"
# Modes are: Disabled, Automatic, Link-Local, Manual
# From Automatic, Manual is two DOWNs
pressDown "Select Manual" 2 "$node_name"
pressEnter "Confirm Manual" "" "$node_name"

# After selecting Manual, expand <Show> to reveal address fields.
# From the mode selector, <Show> is the next tab stop.
pressTab "Goto <Show>" 1 "$node_name"
pressEnter "Expand IPv4 details" "" "$node_name"

# Tab to the Addresses <Add...> field and enter the static IP.
pressTab "Goto Addresses <Add...>" 1 "$node_name"
pressEnter "Activate Addresses field" "" "$node_name"
pressKeys "Enter static IP address" "${node_ip}/24" "$node_name"

# Tab past <Remove> and <Add...> to Gateway field
pressTab "Goto Gateway field" 3 "$node_name"
pressKeys "Enter gateway" "192.168.111.1" "$node_name"

# Tab to DNS servers <Add...> field
pressTab "Goto DNS servers <Add...>" 1 "$node_name"
pressEnter "Activate DNS servers field" "" "$node_name"
pressKeys "Enter DNS server" "192.168.111.1" "$node_name"

# Tab to <OK> button
# From DNS servers, tab past: <Remove>, <Add...>, Search domains <Add...>,
# Routing (No custom routes) <Edit...>,
# [ ] Never use this network for default route,
# [ ] Ignore automatically obtained routes,
# [ ] Ignore automatically obtained DNS parameters,
# [ ] Require IPv4 addressing for this connection,
# IPv6 CONFIGURATION <Automatic> <Show>,
# [X] Automatically connect, [X] Available to all users,
# <Cancel>, <OK>
pressTab "Goto <OK> button" 14 "$node_name"
pressEnter "Select '<OK>' button" "" "$node_name"

#
# Phase 3: Activate the new static connection
# After OK we're back at the connection list. Go Back to main menu,
# then activate the new connection (which deactivates the old DHCP one).
#
pressTab "Goto <Back> button" 4 "$node_name"
pressEnter "Select '<Back>' button" "" "$node_name"
pressDown "Select 'Activate a connection'" 1 "$node_name"
pressEnter "Select 'Activate a connection' menu item" "" "$node_name"
# Activate a connection list layout:
# Ethernet (enp1s0)
# Wired connection 1 <- cursor starts here
# Ethernet (enp2s0)
# * Wired connection 2 <- active DHCP (DOWN 1)
# Ethernet connection 1 <- our new static (DOWN 2)
# Navigate down 2 to our new static connection and activate it.
# NM auto-deactivates the old DHCP connection on the same device.
pressDown "Select 'Ethernet connection 1'" 2 "$node_name"
pressEnter "Activate new static connection" "" "$node_name"
sleep 3

#
# Phase 4: Set system hostname in nmtui
# After "Activate a connection" Back, we're at the main menu.
# Menu items: "Edit a connection", "Activate a connection" (cursor here),
# "Set system hostname", "Radio" (4.16+), "Quit"
#
pressTab "Goto <Back> button" 2 "$node_name"
pressEnter "Select '<Back>' button" "" "$node_name"
pressDown "Select 'Set system hostname'" 1 "$node_name"
pressEnter "Select 'Set system hostname' menu item" "" "$node_name"

# Clear any existing hostname and enter the new one.
# The dialog has: hostname text field, <Cancel>, <OK>.
# Press End to ensure cursor is at end of any existing text,
# then Ctrl+U to clear the line.
pressKey "Goto end of hostname field" KEY_END 1 "$node_name"
echo "Clear hostname field"
sudo virsh send-key "$node_name" KEY_LEFTCTRL KEY_U
sleep 1
pressKeys "Enter hostname" "$node_hostname" "$node_name"

# Tab past <Cancel> to <OK> and confirm
pressTab "Goto <OK> button" 2 "$node_name"
pressEnter "Confirm hostname" "" "$node_name"

#
# Phase 5: Exit nmtui back to TUI first screen
# After setting hostname, we're back at the main menu on "Set system hostname".
# From here: "Radio" is 1 down, "Quit" is 2 down.
#
pressDown "Select Quit" 2 "$node_name"
pressEnter "Select 'Quit' menu item" "" "$node_name"
pressEsc "Esc from network tree view" 2 "$node_name"
sleep 3

# Wait for TUI checks to update after network reconfiguration
sleep 10

#
# Phase 6: Save rendezvous IP on the TUI first screen
# After returning from nmtui, cursor is back on the Rendezvous IP field.
# All nodes enter the same rendezvous IP. The rendezvous node recognizes
# the IP as its own; other nodes use it to find the rendezvous.
#
rendezvousIP=$(getRendezvousIP)
pressKeys "Entering rendezvous IP address" "$rendezvousIP" "$node_name"
# After typing in the text field, the first TAB is absorbed, so we need
# 2 TABs to reach <Save rendezvous IP>: 1 absorbed + 1 to <Save>
pressTab "Goto <Save rendezvous IP>" 2 "$node_name"
pressEnter "" "" "$node_name"
pressEnter "Save and Continue" "" "$node_name"
12 changes: 8 additions & 4 deletions agent/e2e/agent-tui/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function pressKey() {
echo "$msg"
fi

local node_name=$4
local node_name=${4:-}
for i in $(seq 1 "$numReps"); do
_pressKey "$keyCode" "$node_name"
done
Expand All @@ -46,19 +46,19 @@ function pressEnter() {
}

function pressTab() {
pressKey "$1" KEY_TAB "$2"
pressKey "$1" KEY_TAB "$2" "${3:-}"
}

function pressDown() {
pressKey "$1" KEY_DOWN "$2" "$3"
}

function pressBackspace() {
pressKey "$1" KEY_BACKSPACE "$2"
pressKey "$1" KEY_BACKSPACE "$2" "${3:-}"
}

function pressEsc() {
pressKey "$1" KEY_ESC "$2"
pressKey "$1" KEY_ESC "$2" "${3:-}"
}

function pressKeys(){
Expand All @@ -85,6 +85,10 @@ function pressKeys(){
c="DOT"
elif [[ $c =~ [':'] ]]; then
c="LEFTSHIFT KEY_SEMICOLON"
elif [[ $c =~ ['/'] ]]; then
c="SLASH"
elif [[ $c == '-' ]]; then
c="MINUS"
fi

local keyCode="KEY_"$c
Expand Down
8 changes: 8 additions & 0 deletions config_example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,14 @@ set -x
# As the size of the ISO increases in future, increase the expected ISO size accordingly.
# export AGENT_OVE_ISO_SIZE=40

# AGENT_ISO_NO_REGISTRY_STATIC_NETWORKING controls whether the ISO_NO_REGISTRY
# test configures static networking on each node via the TUI (nmtui) instead of
# using DHCP. When set to 'true', the TUI automation script will navigate nmtui
# to configure a static IP on each node before proceeding with rendezvous IP
# selection. Static IPs are assigned starting at 192.168.111.80 (rendezvous node),
# incrementing by 1 for each additional node.
# Requires: AGENT_E2E_TEST_BOOT_MODE=ISO_NO_REGISTRY
# export AGENT_ISO_NO_REGISTRY_STATIC_NETWORKING=true

# Uncomment and set the following value to "true" to enable a test scenario
# where the DNS is disabled on the hosts by setting its IP address to an incorrect value.
Expand Down