From f0f3e3bac46c62d99adbbd0b0f1e47706e107f13 Mon Sep 17 00:00:00 2001 From: Dmitry Tantsur Date: Mon, 31 Oct 2016 12:03:56 +0100 Subject: [PATCH] Add an element to configure iBFT network interfaces This allows nodes with remote devices configured via iBFT to be correctly used during Ironic introspection and deployment, at least for non-multipath configurations. The new element is added as a dependency for ironic-agent. Change-Id: If3dac6504d26535593f12e851092065b688ef696 --- .../elements/ibft-interfaces/README.rst | 5 +++ .../elements/ibft-interfaces/element-deps | 4 +++ .../systemd/init-ibft-interfaces.service | 14 +++++++++ .../sysv/init-ibft-interfaces.init | 31 +++++++++++++++++++ .../upstart/init-ibft-interfaces.conf | 16 ++++++++++ .../ibft-interfaces/package-installs.yaml | 1 + .../elements/ibft-interfaces/pkg-map | 13 ++++++++ .../post-install.d/70-init-ibft-interfaces | 22 +++++++++++++ .../static/etc/modules-load.d/ibft.conf | 3 ++ .../usr/local/sbin/init-ibft-interfaces.sh | 22 +++++++++++++ .../elements/ironic-agent/element-deps | 1 + ...init-ibft-interfaces-9458d97dfcecc3ae.yaml | 6 ++++ 12 files changed, 138 insertions(+) create mode 100644 diskimage_builder/elements/ibft-interfaces/README.rst create mode 100644 diskimage_builder/elements/ibft-interfaces/element-deps create mode 100644 diskimage_builder/elements/ibft-interfaces/init-scripts/systemd/init-ibft-interfaces.service create mode 100755 diskimage_builder/elements/ibft-interfaces/init-scripts/sysv/init-ibft-interfaces.init create mode 100644 diskimage_builder/elements/ibft-interfaces/init-scripts/upstart/init-ibft-interfaces.conf create mode 100644 diskimage_builder/elements/ibft-interfaces/package-installs.yaml create mode 100644 diskimage_builder/elements/ibft-interfaces/pkg-map create mode 100755 diskimage_builder/elements/ibft-interfaces/post-install.d/70-init-ibft-interfaces create mode 100644 diskimage_builder/elements/ibft-interfaces/static/etc/modules-load.d/ibft.conf create mode 100755 diskimage_builder/elements/ibft-interfaces/static/usr/local/sbin/init-ibft-interfaces.sh create mode 100644 releasenotes/notes/init-ibft-interfaces-9458d97dfcecc3ae.yaml diff --git a/diskimage_builder/elements/ibft-interfaces/README.rst b/diskimage_builder/elements/ibft-interfaces/README.rst new file mode 100644 index 00000000..f152fa54 --- /dev/null +++ b/diskimage_builder/elements/ibft-interfaces/README.rst @@ -0,0 +1,5 @@ +=============== +ibft-interfaces +=============== + +Initialize network interfaces with information provided through iBFT. diff --git a/diskimage_builder/elements/ibft-interfaces/element-deps b/diskimage_builder/elements/ibft-interfaces/element-deps new file mode 100644 index 00000000..97b6ad5a --- /dev/null +++ b/diskimage_builder/elements/ibft-interfaces/element-deps @@ -0,0 +1,4 @@ +dib-init-system +install-static +package-installs +pkg-map diff --git a/diskimage_builder/elements/ibft-interfaces/init-scripts/systemd/init-ibft-interfaces.service b/diskimage_builder/elements/ibft-interfaces/init-scripts/systemd/init-ibft-interfaces.service new file mode 100644 index 00000000..02eb71f8 --- /dev/null +++ b/diskimage_builder/elements/ibft-interfaces/init-scripts/systemd/init-ibft-interfaces.service @@ -0,0 +1,14 @@ +[Unit] +Description=Initialize iBFT network interfaces +After=network.target +Before=network-online.target +Wants=network-online.target + +[Service] +Type=oneshot +User=root +ExecStart=/usr/local/sbin/init-ibft-interfaces.sh +RemainAfterExit=true + +[Install] +WantedBy=multi-user.target diff --git a/diskimage_builder/elements/ibft-interfaces/init-scripts/sysv/init-ibft-interfaces.init b/diskimage_builder/elements/ibft-interfaces/init-scripts/sysv/init-ibft-interfaces.init new file mode 100755 index 00000000..fa3d9cbf --- /dev/null +++ b/diskimage_builder/elements/ibft-interfaces/init-scripts/sysv/init-ibft-interfaces.init @@ -0,0 +1,31 @@ +#!/bin/sh -e +### BEGIN INIT INFO +# Provides: init-ibft-interfaces +# Required-Start: $local_fs networking +# Required-Stop: $local_fs +# Default-Start: S +# Default-Stop: 0 6 +# X-Start-Before: +# Short-Description: Initialize iBFT interfaces +# Description: Initialize iBFT network interfaces +### END INIT INFO + +NAME=init-ibft-interfaces +INIT_NAME=/etc/init.d/${NAME} +SCRIPT_NAME=/usr/local/sbin/${NAME}.sh + +[ -x $SCRIPT_NAME ] || exit 0 + +case "$1" in + start) + $SCRIPT_NAME + ;; + stop) + ;; + *) + echo "Usage: $INIT_NAME {start|stop}" + exit 1 + ;; +esac + +exit 0 diff --git a/diskimage_builder/elements/ibft-interfaces/init-scripts/upstart/init-ibft-interfaces.conf b/diskimage_builder/elements/ibft-interfaces/init-scripts/upstart/init-ibft-interfaces.conf new file mode 100644 index 00000000..c8b199a2 --- /dev/null +++ b/diskimage_builder/elements/ibft-interfaces/init-scripts/upstart/init-ibft-interfaces.conf @@ -0,0 +1,16 @@ +# init-ibft-interfaces - Initialize iBFT network interfaces + +description "Initialize iBFT network interfaces" + +start on runlevel [2345] +stop on runlevel [!2345] + +respawn +respawn limit 10 5 +umask 022 + +expect stop + +console output + +exec /usr/local/sbin/init-ibft-interfaces.sh diff --git a/diskimage_builder/elements/ibft-interfaces/package-installs.yaml b/diskimage_builder/elements/ibft-interfaces/package-installs.yaml new file mode 100644 index 00000000..7a596e5a --- /dev/null +++ b/diskimage_builder/elements/ibft-interfaces/package-installs.yaml @@ -0,0 +1 @@ +iscsi_package: diff --git a/diskimage_builder/elements/ibft-interfaces/pkg-map b/diskimage_builder/elements/ibft-interfaces/pkg-map new file mode 100644 index 00000000..cb22ea3c --- /dev/null +++ b/diskimage_builder/elements/ibft-interfaces/pkg-map @@ -0,0 +1,13 @@ +{ + "family": { + "redhat": { + "iscsi_package": "iscsi-initiator-utils" + }, + "gentoo": { + "iscsi_package": "sys-block/open-iscsi" + } + }, + "default": { + "iscsi_package": "open-iscsi" + } +} diff --git a/diskimage_builder/elements/ibft-interfaces/post-install.d/70-init-ibft-interfaces b/diskimage_builder/elements/ibft-interfaces/post-install.d/70-init-ibft-interfaces new file mode 100755 index 00000000..d2a6c7a0 --- /dev/null +++ b/diskimage_builder/elements/ibft-interfaces/post-install.d/70-init-ibft-interfaces @@ -0,0 +1,22 @@ +#!/bin/bash + +if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then + set -x +fi +set -eu +set -o pipefail + +case "$DIB_INIT_SYSTEM" in + upstart) + ;; + systemd) + systemctl enable init-ibft-interfaces.service + ;; + sysv) + update-rc.d init-ibft-interfaces.init defaults + ;; + *) + echo "Unsupported init system $DIB_INIT_SYSTEM" + exit 1 + ;; +esac diff --git a/diskimage_builder/elements/ibft-interfaces/static/etc/modules-load.d/ibft.conf b/diskimage_builder/elements/ibft-interfaces/static/etc/modules-load.d/ibft.conf new file mode 100644 index 00000000..43805d41 --- /dev/null +++ b/diskimage_builder/elements/ibft-interfaces/static/etc/modules-load.d/ibft.conf @@ -0,0 +1,3 @@ +iscsi_boot_sysfs +iscsi_ibft +iscsi_tcp diff --git a/diskimage_builder/elements/ibft-interfaces/static/usr/local/sbin/init-ibft-interfaces.sh b/diskimage_builder/elements/ibft-interfaces/static/usr/local/sbin/init-ibft-interfaces.sh new file mode 100755 index 00000000..933e2efd --- /dev/null +++ b/diskimage_builder/elements/ibft-interfaces/static/usr/local/sbin/init-ibft-interfaces.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# dib-lint: disable=dibdebugtrace + +set -eux +set -o pipefail + +# iscsistart is a part of the dependencies, but check just in case. +if ! iscsistart -v; then + echo "iscsistart not found, iBFT devices won't be connected" + exit 1 +fi + +if iscsistart -f; then + if ! iscsistart -N; then + echo "Could not configure iBFT devices" + exit 1 + fi + # Make sure the events for new devices are processed + udevadm settle +else + echo "No iBFT devices to configure, exiting" +fi diff --git a/diskimage_builder/elements/ironic-agent/element-deps b/diskimage_builder/elements/ironic-agent/element-deps index 665e0da3..0f0d86e5 100644 --- a/diskimage_builder/elements/ironic-agent/element-deps +++ b/diskimage_builder/elements/ironic-agent/element-deps @@ -1,4 +1,5 @@ dhcp-all-interfaces +ibft-interfaces install-static no-final-image package-installs diff --git a/releasenotes/notes/init-ibft-interfaces-9458d97dfcecc3ae.yaml b/releasenotes/notes/init-ibft-interfaces-9458d97dfcecc3ae.yaml new file mode 100644 index 00000000..e9428938 --- /dev/null +++ b/releasenotes/notes/init-ibft-interfaces-9458d97dfcecc3ae.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + Adds a new element ``init-ibft-interfaces`` to initialize network + interfaces with configuration provided via iBFT. The new element is now + a dependency of the ``ironic-agent`` element.