summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Swartzlander <ben@swartzlander.org>2017-01-30 10:26:54 -0500
committerBen Swartzlander <ben@swartzlander.org>2017-01-30 19:09:43 +0000
commitcadc0ee3912c6095247f3006dd356070bbf7c8aa (patch)
treebf4ca17f22acb2acff2d498156a59beb9702071d
parentd341b73a9ac9c6c25312fe01e49cd394058cd95b (diff)
Create a config drive to test the metadata code
Because it's not possible to test the metadata service code in an easy way, create a config drive ISO image for test purposes. Also speed up the metadata code to not block while waiting for the metadata service and to exit quickly when there is no config drive CD present. Change-Id: If6a5565825b67de58715e3d2de1cbf69b7f9e551
Notes
Notes (review): Code-Review+2: Mark Sturdevant <mark.sturdevant@ibm.com> Code-Review+2: Tom Barron <tpb@dyncloud.net> Workflow+1: Tom Barron <tpb@dyncloud.net> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Wed, 08 Feb 2017 03:09:18 +0000 Reviewed-on: https://review.openstack.org/426811 Project: openstack/manila-test-image Branch: refs/heads/master
-rw-r--r--README4
-rwxr-xr-xcommon-files/etc/init.d/S99metadata4
-rw-r--r--conf/busybox.config6
-rwxr-xr-xtest-image.sh28
4 files changed, 30 insertions, 12 deletions
diff --git a/README b/README
index 2d819b6..18228cf 100644
--- a/README
+++ b/README
@@ -23,7 +23,7 @@ On Ubuntu:
23 build-essential gcc-multilib 23 build-essential gcc-multilib
24 # For test/dev 24 # For test/dev
25 sudo apt-get -y install bison flex texinfo gettext ncurses-dev sshpass \ 25 sudo apt-get -y install bison flex texinfo gettext ncurses-dev sshpass \
26 qt-sdk qemu-kvm 26 qt-sdk qemu-kvm genisoimage
27 27
28On Fedora: 28On Fedora:
29 29
@@ -32,7 +32,7 @@ On Fedora:
32 make glibc-devel.i686 32 make glibc-devel.i686
33 # For test/dev 33 # For test/dev
34 sudo dnf -y install bison flex texinfo gettext ncurses-devel sshpass \ 34 sudo dnf -y install bison flex texinfo gettext ncurses-devel sshpass \
35 qt-devel qemu-kvm 35 qt-devel qemu-kvm genisoimage
36 36
37== Building the images == 37== Building the images ==
38 38
diff --git a/common-files/etc/init.d/S99metadata b/common-files/etc/init.d/S99metadata
index cef1ad2..b3f2b8b 100755
--- a/common-files/etc/init.d/S99metadata
+++ b/common-files/etc/init.d/S99metadata
@@ -22,7 +22,7 @@ json_metadata() {
22} 22}
23 23
24check_cd() { 24check_cd() {
25 [ -b /dev/sr0 ] || return 25 blkid /dev/sr0 | grep config-2 > /dev/null || return
26 mkdir /tmp/cd 26 mkdir /tmp/cd
27 if mount /dev/sr0 /tmp/cd ; then 27 if mount /dev/sr0 /tmp/cd ; then
28 json_metadata /tmp/cd >> authorized_keys 28 json_metadata /tmp/cd >> authorized_keys
@@ -37,5 +37,5 @@ chmod 700 .
37[ -f authorized_keys ] || touch authorized_keys 37[ -f authorized_keys ] || touch authorized_keys
38chmod 600 authorized_keys 38chmod 600 authorized_keys
39 39
40check_net
41check_cd 40check_cd
41check_net &
diff --git a/conf/busybox.config b/conf/busybox.config
index 49c5611..521f411 100644
--- a/conf/busybox.config
+++ b/conf/busybox.config
@@ -572,8 +572,8 @@ CONFIG_FEATURE_MOUNT_OTHERTAB=y
572CONFIG_UEVENT=y 572CONFIG_UEVENT=y
573# CONFIG_ACPID is not set 573# CONFIG_ACPID is not set
574# CONFIG_FEATURE_ACPID_COMPAT is not set 574# CONFIG_FEATURE_ACPID_COMPAT is not set
575# CONFIG_BLKID is not set 575CONFIG_BLKID=y
576# CONFIG_FEATURE_BLKID_TYPE is not set 576CONFIG_FEATURE_BLKID_TYPE=y
577CONFIG_DMESG=y 577CONFIG_DMESG=y
578CONFIG_FEATURE_DMESG_PRETTY=y 578CONFIG_FEATURE_DMESG_PRETTY=y
579# CONFIG_FBSET is not set 579# CONFIG_FBSET is not set
@@ -658,7 +658,7 @@ CONFIG_FEATURE_VOLUMEID_NTFS=y
658CONFIG_FEATURE_VOLUMEID_OCFS2=y 658CONFIG_FEATURE_VOLUMEID_OCFS2=y
659CONFIG_FEATURE_VOLUMEID_REISERFS=y 659CONFIG_FEATURE_VOLUMEID_REISERFS=y
660CONFIG_FEATURE_VOLUMEID_ROMFS=y 660CONFIG_FEATURE_VOLUMEID_ROMFS=y
661# CONFIG_FEATURE_VOLUMEID_SQUASHFS is not set 661CONFIG_FEATURE_VOLUMEID_SQUASHFS=y
662CONFIG_FEATURE_VOLUMEID_SYSV=y 662CONFIG_FEATURE_VOLUMEID_SYSV=y
663CONFIG_FEATURE_VOLUMEID_UDF=y 663CONFIG_FEATURE_VOLUMEID_UDF=y
664CONFIG_FEATURE_VOLUMEID_XFS=y 664CONFIG_FEATURE_VOLUMEID_XFS=y
diff --git a/test-image.sh b/test-image.sh
index 9d92b76..c26d111 100755
--- a/test-image.sh
+++ b/test-image.sh
@@ -1,12 +1,30 @@
1#!/bin/sh 1#!/bin/sh
2 2
3CONFIG_DIR=/tmp/configdir
4CONFIG_ISO=/tmp/configdrive.iso
5TEST_IMG=/tmp/client-test.qcow2
6
7# Create config-drive ISO
8mkdir -p $CONFIG_DIR/ec2/2009-04-04
9(
10 echo -n '{"public-keys": {"0": {"openssh-key": "'
11 cat ~/.ssh/id_rsa.pub | tr -d '\n'
12 echo -n '\\n"}}}'
13) > $CONFIG_DIR/ec2/2009-04-04/meta-data.json
14mkisofs -R -V config-2 -o $CONFIG_ISO $CONFIG_DIR 2> /dev/null
15rm -rf $CONFIG_DIR
16
17# Create temporary overlay
18qemu-img create -f qcow2 -b $(pwd)/client.qcow2 $TEST_IMG
19
20# Test the image
3KVM=kvm 21KVM=kvm
4if ! which $KVM 2> /dev/null ; then 22if ! which $KVM 2> /dev/null ; then
5 KVM=qemu-kvm 23 KVM=qemu-kvm
6fi 24fi
7
8qemu-img create -f qcow2 -b client.qcow2 client-test.qcow2
9$KVM -m 64 -monitor none -nographic \ 25$KVM -m 64 -monitor none -nographic \
10 -drive file=client-test.qcow2,if=virtio,format=qcow2 \ 26 -drive file=$TEST_IMG,if=virtio,format=qcow2 \
11 -netdev user,id=net0 -device virtio-net-pci,netdev=net0 27 -netdev user,id=net0 -device virtio-net-pci,netdev=net0 \
12rm client-test.qcow2 28 -cdrom $CONFIG_ISO
29
30rm $TEST_IMG $CONFIG_ISO