diff --git a/bin/disk-image-create b/bin/disk-image-create index b3d98bfc8..f1ea8eb47 100755 --- a/bin/disk-image-create +++ b/bin/disk-image-create @@ -246,5 +246,12 @@ else # by this point. rm $TMP_IMAGE_PATH fi + +case "$IMAGE_ELEMENT" in + *ironic-agent*) + rm $IMAGE_NAME.$IMAGE_TYPE + ;; +esac + # All done! trap EXIT diff --git a/elements/ironic-agent/README.md b/elements/ironic-agent/README.md new file mode 100644 index 000000000..518f0d683 --- /dev/null +++ b/elements/ironic-agent/README.md @@ -0,0 +1,2 @@ +Build ramdisk with ironic-python-agent. +Works only on Fedora, therefore fedora element is mandatory. diff --git a/elements/ironic-agent/cleanup.d/99-ramdisk-create b/elements/ironic-agent/cleanup.d/99-ramdisk-create new file mode 100755 index 000000000..f9e0c62b4 --- /dev/null +++ b/elements/ironic-agent/cleanup.d/99-ramdisk-create @@ -0,0 +1,20 @@ +#!/bin/bash + +set -eu +set -o pipefail + +[ -n "$TARGET_ROOT" ] + +source $_LIB/img-functions + +WORKDIR=$(pwd) +cd $TARGET_ROOT + +echo "#disabled" > ./tmp/fstab.new +sudo mv ./tmp/fstab.new ./etc/fstab +sudo ln -s ./sbin/init ./ + +sudo find . -path ./sys -prune -o -path ./proc -prune -o -print | sudo cpio -o -H newc | gzip > $WORKDIR/$IMAGE_NAME.initramfs + +select_boot_kernel_initrd $TARGET_ROOT +sudo cp $BOOTDIR/$KERNEL $WORKDIR/$IMAGE_NAME.vmlinuz diff --git a/elements/ironic-agent/element-deps b/elements/ironic-agent/element-deps new file mode 100644 index 000000000..715c11e2f --- /dev/null +++ b/elements/ironic-agent/element-deps @@ -0,0 +1 @@ +source-repositories diff --git a/elements/ironic-agent/element-provides b/elements/ironic-agent/element-provides new file mode 100644 index 000000000..7e20b1dd9 --- /dev/null +++ b/elements/ironic-agent/element-provides @@ -0,0 +1 @@ +ironic-python-agent diff --git a/elements/ironic-agent/install.d/60-ironic-agent-install b/elements/ironic-agent/install.d/60-ironic-agent-install new file mode 100755 index 000000000..94fcd1ef3 --- /dev/null +++ b/elements/ironic-agent/install.d/60-ironic-agent-install @@ -0,0 +1,18 @@ +#!/bin/bash + +set -eu +set -o pipefail + +install-packages python-dev python-pip qemu-utils parted hdparm util-linux genisoimage gcc + +pip install -r /tmp/ironic-python-agent/requirements.txt +pip install /tmp/ironic-python-agent + +sudo echo $'[Unit] +Description=Ironic Python Agent\n +[Service] +ExecStart=/usr/bin/ironic-python-agent +Restart=always +RestartSec=30s\n' > /usr/lib/systemd/system/ironic-python-agent.service + +sudo systemctl enable ironic-python-agent.service diff --git a/elements/ironic-agent/post-install.d/80-ironic-agent b/elements/ironic-agent/post-install.d/80-ironic-agent new file mode 100755 index 000000000..7f4064979 --- /dev/null +++ b/elements/ironic-agent/post-install.d/80-ironic-agent @@ -0,0 +1,17 @@ +#!/bin/bash + +set -eu +set -o pipefail + +install-packages -e python-dev git cloud-init +rm -rf /tmp/ironic-python-agent + +sudo systemctl disable iptables.service + +#configs for additional interfaces +SYSCONFIG_PATH=/etc/sysconfig/network-scripts +for IFACE_NUM in 1 2 +do + sudo cp $SYSCONFIG_PATH/ifcfg-eth0 $SYSCONFIG_PATH/ifcfg-eth$IFACE_NUM + sudo sed -i "s/eth0/eth$IFACE_NUM/g" $SYSCONFIG_PATH/ifcfg-eth$IFACE_NUM +done diff --git a/elements/ironic-agent/source-repository-ironic-agent b/elements/ironic-agent/source-repository-ironic-agent new file mode 100644 index 000000000..b6ecc58a5 --- /dev/null +++ b/elements/ironic-agent/source-repository-ironic-agent @@ -0,0 +1 @@ +agent git /tmp/ironic-python-agent git://git.openstack.org/openstack/ironic-python-agent