-
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
b427fcc
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,15 @@ 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 | ||
|
|
||
| # RHEL 10: genisoimage replaced by xorriso (provides mkisofs), | ||
| # python3-bcrypt not in base repos (soft dep of passlib, not required). | ||
| 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 +124,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,116 @@ function attach_agent_iso() { | |
|
|
||
| } | ||
|
|
||
| function redfish_curl() { | ||
| local user="$1" password="$2" url="$3" | ||
| shift 3 | ||
| curl -sf -u "${user}":"${password}" -k -H 'Content-Type: application/json' "$url" "$@" | ||
| } | ||
|
|
||
| # Mounts the agent ISO via Redfish VirtualMedia on each baremetal node. | ||
| # Currently tested on HPE iLO; other vendors may need Ironic's boot interface | ||
| # for vendor-specific VirtualMedia quirks. | ||
| function mount_agent_iso_baremetal() { | ||
| local iso_url="${AGENT_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%%/*}" | ||
|
|
||
| # VirtualMedia via Managers — deprecated in Redfish spec, but required on HPE iLO. | ||
| 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)
Contributor
Author
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. Correct — our test hardware is HPE e920t (iLO), where Managers is the only path to VirtualMedia. Added a comment noting the deprecation and HPE requirement. |
||
| 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 '{}' || true | ||
| 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.
Contributor
Author
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. Fair point. This is currently tested on HPE iLO only — added a comment scoping it. Ironic's |
||
| 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%%/*}" | ||
|
|
||
| # VirtualMedia via Managers — see mount_agent_iso_baremetal(). | ||
| 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 '{}' || true | ||
| done | ||
| } | ||
|
|
||
| function attach_appliance_diskimage() { | ||
| set_file_acl | ||
|
|
||
|
|
@@ -305,6 +415,10 @@ function wait_for_hosts_installed() { | |
| } | ||
|
|
||
| function get_node0_ip() { | ||
| if [[ "${NODES_PLATFORM}" == "baremetal" ]]; then | ||
| echo "${AGENT_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 +731,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 AGENT_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 +886,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 | ||
|
|
||
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.
Do you have an upstream patch for this problem as well?
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.
No upstream patch yet —
genisoimageandpython3-bcryptare still in metal3-dev-env's defaults at the pinned hash. Will file an upstream PR.