-
Notifications
You must be signed in to change notification settings - Fork 212
Add baremetal ABI support for NODES_PLATFORM=baremetal #1922
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
219881f
9d273ed
de47840
22c26e5
fb975ca
f6ca738
dc7a3f1
3f8b16f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,23 @@ if [ -z "${METAL3_DEV_ENV:-}" ]; then | |
|
|
||
| # TODO: remove once Python fixed OpenSSL regression | ||
| sed -i '/name: "{{ packages.centos.common.packages }}"/a\ exclude: "openssl*"' vm-setup/roles/packages_installation/tasks/main.yml | ||
|
|
||
| # Go tarball defaults hardcode linux-amd64; use GOARCH passed as extra var. | ||
| # Upstream fix: https://github.com/metal3-io/metal3-dev-env/pull/1694 | ||
| GO_DEFAULTS="vm-setup/roles/packages_installation/defaults/main.yml" | ||
| if grep -q 'linux-amd64' "${GO_DEFAULTS}"; then | ||
| sed -i 's/go_tarball: "go{{ go_version }}.linux-amd64.tar.gz"/go_tarball: "go{{ go_version }}.linux-{{ GOARCH | default('\''amd64'\'') }}.tar.gz"/' \ | ||
| "${GO_DEFAULTS}" | ||
| fi | ||
|
|
||
| # RHEL 10: genisoimage replaced by xorriso (provides mkisofs), | ||
| # python3-bcrypt not in base repos (soft dep of passlib, not required). | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you have an upstream patch for this problem as well? |
||
| if [[ "${DISTRO}" =~ ^(rhel10|centos10) ]]; then | ||
| PKG_DEFAULTS="vm-setup/roles/packages_installation/defaults/main.yml" | ||
| sed -i '/^ - genisoimage$/d' "${PKG_DEFAULTS}" | ||
| sed -i '/^ - python3-bcrypt$/d' "${PKG_DEFAULTS}" | ||
| fi | ||
|
|
||
| popd | ||
| fi | ||
|
|
||
|
|
@@ -115,8 +132,16 @@ case $DISTRO in | |
| sudo ln -s /usr/bin/python3 /usr/bin/python || true | ||
| PYTHON_DEVEL="python3-devel" | ||
| ;; | ||
| "rhel10"|"centos10") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! |
||
| sudo dnf -y install python3-pip | ||
| if sudo subscription-manager identity > /dev/null 2>&1; then | ||
| sudo subscription-manager repos --enable "codeready-builder-for-rhel-10-$(arch)-rpms" || true | ||
| fi | ||
| sudo ln -s /usr/bin/python3 /usr/bin/python || true | ||
| PYTHON_DEVEL="python3-devel" | ||
| ;; | ||
| *) | ||
| echo -n "CentOS 9 or RHEL 9 required (el8 is no longer supported due to glibc requirements)" | ||
| echo -n "CentOS 9+, RHEL 9+, or compatible required (el8 is no longer supported due to glibc requirements)" | ||
| exit 1 | ||
| ;; | ||
| esac | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -163,6 +163,111 @@ function attach_agent_iso() { | |
|
|
||
| } | ||
|
|
||
| function redfish_curl() { | ||
| local user="$1" password="$2" url="$3" | ||
| shift 3 | ||
| curl -s -u "${user}":"${password}" -k -H 'Content-Type: application/json' "$url" "$@" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you want |
||
| } | ||
|
|
||
| function mount_agent_iso_baremetal() { | ||
| local iso_url="${BAREMETAL_ISO_SERVER}" | ||
| local total_nodes | ||
| total_nodes=$(jq '.nodes | length' "$NODES_FILE") | ||
|
|
||
| for (( i=0; i < total_nodes; i++ )); do | ||
| local address user password scheme system systemurl bmc_base | ||
| address=$(jq -r ".nodes[$i].driver_info.address" "$NODES_FILE") | ||
| user=$(jq -r ".nodes[$i].driver_info.username" "$NODES_FILE") | ||
| password=$(jq -r ".nodes[$i].driver_info.password" "$NODES_FILE") | ||
| local node_name | ||
| node_name=$(jq -r ".nodes[$i].name" "$NODES_FILE") | ||
|
|
||
| if [[ ! $address =~ ^(redfish.*://)(.*)$ ]]; then | ||
| echo "ERROR: Unsupported BMC protocol for node $i ($address) — Redfish required" | ||
| exit 1 | ||
| fi | ||
| scheme="https://" | ||
| system="${BASH_REMATCH[2]}" | ||
| if [[ ${BASH_REMATCH[1]} =~ http: ]]; then | ||
| scheme="http://" | ||
| fi | ||
| systemurl="${scheme}${system}" | ||
| bmc_base="${scheme}${system%%/*}" | ||
|
|
||
| local manager_id vmedia_uri cd_slot | ||
| manager_id=$(redfish_curl "$user" "$password" "${bmc_base}/redfish/v1/Managers" | jq -r '.Members[0]."@odata.id"') | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Going through Managers is deprecated (but still required on HPE AFAIK) |
||
| vmedia_uri="${bmc_base}${manager_id}/VirtualMedia" | ||
| cd_slot=$(redfish_curl "$user" "$password" "$vmedia_uri" | jq -r '.Members[] | select(."@odata.id" | test("[Cc][Dd]|[Dd][Vv][Dd]|2")) | ."@odata.id"' | head -1) | ||
|
|
||
| if [[ -z "$cd_slot" ]]; then | ||
| cd_slot=$(redfish_curl "$user" "$password" "$vmedia_uri" | jq -r '.Members[1]."@odata.id"') | ||
| fi | ||
|
|
||
| local current_image | ||
| current_image=$(redfish_curl "$user" "$password" "${bmc_base}${cd_slot}" | jq -r '.Inserted // false') | ||
| if [[ "$current_image" == "true" ]]; then | ||
| echo "Ejecting existing VirtualMedia from ${node_name}..." | ||
| redfish_curl "$user" "$password" "${bmc_base}${cd_slot}/Actions/VirtualMedia.EjectMedia" \ | ||
| -d '{}' | ||
| sleep 2 | ||
| fi | ||
|
|
||
| echo "Mounting ISO on ${node_name} via ${cd_slot}..." | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If only we had a tool that can manage virtual media for you ;) In all seriousness, don't expect this to work on all hardware. Ironic has 3 or 4 different ways to mount virtual media, as well as some more workarounds. |
||
| redfish_curl "$user" "$password" "${bmc_base}${cd_slot}/Actions/VirtualMedia.InsertMedia" \ | ||
| -d "{\"Image\": \"${iso_url}\", \"Inserted\": true, \"WriteProtected\": true}" | ||
|
|
||
| local inserted | ||
| inserted=$(redfish_curl "$user" "$password" "${bmc_base}${cd_slot}" | jq -r '.Inserted') | ||
| if [[ "$inserted" != "true" ]]; then | ||
| echo "WARNING: VirtualMedia reports Inserted=${inserted} for ${node_name}" | ||
| fi | ||
|
|
||
| redfish_curl "$user" "$password" "$systemurl" -X PATCH \ | ||
| -d '{"Boot": {"BootSourceOverrideTarget": "Cd", "BootSourceOverrideEnabled": "Once"}}' | ||
|
|
||
| redfish_curl "$user" "$password" "$systemurl/Actions/ComputerSystem.Reset" \ | ||
| -d '{"ResetType": "ForceRestart"}' | ||
|
|
||
| echo "Node ${node_name} booting from ISO" | ||
| done | ||
| } | ||
|
|
||
| function eject_agent_iso_baremetal() { | ||
| local total_nodes | ||
| total_nodes=$(jq '.nodes | length' "$NODES_FILE") | ||
|
|
||
| for (( i=0; i < total_nodes; i++ )); do | ||
| local address user password scheme system bmc_base | ||
| address=$(jq -r ".nodes[$i].driver_info.address" "$NODES_FILE") | ||
| user=$(jq -r ".nodes[$i].driver_info.username" "$NODES_FILE") | ||
| password=$(jq -r ".nodes[$i].driver_info.password" "$NODES_FILE") | ||
| local node_name | ||
| node_name=$(jq -r ".nodes[$i].name" "$NODES_FILE") | ||
|
|
||
| if [[ ! $address =~ ^(redfish.*://)(.*)$ ]]; then | ||
| continue | ||
| fi | ||
| scheme="https://" | ||
| system="${BASH_REMATCH[2]}" | ||
| if [[ ${BASH_REMATCH[1]} =~ http: ]]; then | ||
| scheme="http://" | ||
| fi | ||
| bmc_base="${scheme}${system%%/*}" | ||
|
|
||
| local manager_id vmedia_uri cd_slot | ||
| manager_id=$(redfish_curl "$user" "$password" "${bmc_base}/redfish/v1/Managers" | jq -r '.Members[0]."@odata.id"') | ||
| vmedia_uri="${bmc_base}${manager_id}/VirtualMedia" | ||
| cd_slot=$(redfish_curl "$user" "$password" "$vmedia_uri" | jq -r '.Members[] | select(."@odata.id" | test("[Cc][Dd]|[Dd][Vv][Dd]|2")) | ."@odata.id"' | head -1) | ||
|
|
||
| if [[ -z "$cd_slot" ]]; then | ||
| cd_slot=$(redfish_curl "$user" "$password" "$vmedia_uri" | jq -r '.Members[1]."@odata.id"') | ||
| fi | ||
|
|
||
| echo "Ejecting ISO from ${node_name}..." | ||
| redfish_curl "$user" "$password" "${bmc_base}${cd_slot}/Actions/VirtualMedia.EjectMedia" -d '{}' | ||
| done | ||
| } | ||
|
|
||
| function attach_appliance_diskimage() { | ||
| set_file_acl | ||
|
|
||
|
|
@@ -305,6 +410,10 @@ function wait_for_hosts_installed() { | |
| } | ||
|
|
||
| function get_node0_ip() { | ||
| if [[ "${NODES_PLATFORM}" == "baremetal" ]]; then | ||
| echo "${BAREMETAL_IPS%%,*}" | ||
| return | ||
| fi | ||
| # shellcheck disable=SC2059 | ||
| node0_name=$(printf "${MASTER_HOSTNAME_FORMAT}" 0) | ||
| node0_ip=$(sudo virsh net-dumpxml ostestbm | xmllint --xpath "string(//dns[*]/host/hostname[. = '${node0_name}']/../@ip)" -) | ||
|
|
@@ -617,16 +726,29 @@ case "${AGENT_E2E_TEST_BOOT_MODE}" in | |
| fi | ||
| fi | ||
|
|
||
| attach_agent_iso master "$NUM_MASTERS" | ||
| attach_agent_iso worker "$NUM_WORKERS" | ||
| attach_agent_iso arbiter "$NUM_ARBITERS" | ||
|
|
||
| if [[ "${ARCH}" == "aarch64" ]]; then | ||
| wait_for_hosts_installed || echo "WARNING: proceeding with CDROM eject despite host status issues" | ||
| eject_agent_iso master "$NUM_MASTERS" | ||
| eject_agent_iso worker "$NUM_WORKERS" | ||
| eject_agent_iso arbiter "$NUM_ARBITERS" | ||
| echo "aarch64: CDROM media ejected from all VMs" | ||
| if [[ "${NODES_PLATFORM}" == "baremetal" ]]; then | ||
| # Stage the ISO where BAREMETAL_ISO_SERVER can serve it. The ISO is | ||
| # generated under OCP_DIR (relative to dev-scripts), but the HTTP | ||
| # server root may be elsewhere (e.g. WORKING_DIR under nginx). | ||
| iso_file="${OCP_DIR}/agent.$(uname -m).iso" | ||
| if [[ -f "$iso_file" ]]; then | ||
| serve_dir="${WORKING_DIR}/${CLUSTER_NAME}" | ||
| mkdir -p "$serve_dir" | ||
| ln -sf "$(realpath "$iso_file")" "${serve_dir}/agent.$(uname -m).iso" | ||
| fi | ||
| mount_agent_iso_baremetal | ||
| else | ||
| attach_agent_iso master "$NUM_MASTERS" | ||
| attach_agent_iso worker "$NUM_WORKERS" | ||
| attach_agent_iso arbiter "$NUM_ARBITERS" | ||
|
|
||
| if [[ "${ARCH}" == "aarch64" ]]; then | ||
| wait_for_hosts_installed || echo "WARNING: proceeding with CDROM eject despite host status issues" | ||
| eject_agent_iso master "$NUM_MASTERS" | ||
| eject_agent_iso worker "$NUM_WORKERS" | ||
| eject_agent_iso arbiter "$NUM_ARBITERS" | ||
| echo "aarch64: CDROM media ejected from all VMs" | ||
| fi | ||
| fi | ||
|
|
||
| ;; | ||
|
|
@@ -759,6 +881,10 @@ fi | |
|
|
||
| wait_for_cluster_ready | ||
|
|
||
| if [[ "${NODES_PLATFORM}" == "baremetal" ]]; then | ||
| eject_agent_iso_baremetal | ||
| fi | ||
|
|
||
| if [ ! -z "${AGENT_DEPLOY_MCE}" ]; then | ||
| mce_complete_deployment | ||
| fi | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -480,6 +480,37 @@ set -x | |
| # | ||
| #export NODES_PLATFORM=baremetal | ||
|
|
||
| # --- Baremetal ABI (Agent-Based Installation) variables --- | ||
| # These are used when NODES_PLATFORM=baremetal with the agent installer (make agent). | ||
| # All BAREMETAL_* vars except BAREMETAL_ISO_SERVER are auto-generated by | ||
| # the adoption tool (make baremetal-adopt) into config_baremetal_fencing.sh. | ||
|
|
||
| # BAREMETAL_IPS - | ||
| # Comma-separated node IPs, order matches NODES_FILE entries. | ||
| # Required when NODES_PLATFORM=baremetal. | ||
| # | ||
| #export BAREMETAL_IPS="10.1.155.10,10.1.155.11" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If any of these are ABI-specific, could you prefix them with AGENT_? |
||
|
|
||
| # BAREMETAL_API_VIP - | ||
| # API virtual IP for dnsmasq DNS on the provisioning host. | ||
| # Required when NODES_PLATFORM=baremetal. | ||
| # | ||
| #export BAREMETAL_API_VIP="10.1.155.100" | ||
|
|
||
| # BAREMETAL_INGRESS_VIP - | ||
| # Ingress virtual IP. Defaults to BAREMETAL_API_VIP if unset | ||
| # (common for 2-node TNF where API and ingress share a VIP). | ||
| # | ||
| #export BAREMETAL_INGRESS_VIP="10.1.155.101" | ||
|
|
||
| # BAREMETAL_ISO_SERVER - | ||
| # Full HTTP URL where the agent ISO is staged for Redfish VirtualMedia boot. | ||
| # This is the only baremetal var NOT auto-generated by adoption — the user | ||
| # must provide an HTTP server reachable from the BMCs. | ||
| # Required when NODES_PLATFORM=baremetal with agent installer. | ||
| # | ||
| #export BAREMETAL_ISO_SERVER="http://10.1.235.49:8080/agent.x86_64.iso" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At least this one is definitely ABI specific. |
||
|
|
||
| # ENABLE_WORKLOAD_PARTITIONING - | ||
| # Set to any non zero length string value to enable workload partitioning in the install config. | ||
| # | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already merged, maybe update the hash?