find cloud-init on cdrom by label

Signed-off-by: Avi Deitcher <avi@deitcher.net>
This commit is contained in:
Avi Deitcher
2020-04-24 11:23:51 +03:00
parent 0b488d805e
commit 3678adeca8
492 changed files with 194724 additions and 12 deletions

View File

@@ -0,0 +1,16 @@
#!/bin/sh
set -x
function failed {
printf "metadata test suite FAILED\n" >&1
exit 1
}
DEVICE=/dev/sdb
[ -f /run/config/provider ] || failed
[ "$(cat /run/config/provider)" = "CDROM ${DEVICE}" ] || failed
[ -f /run/config/userdata ] || failed
grep -q supersecret /run/config/userdata || failed
printf "metadata test suite PASSED\n" >&1

View File

@@ -0,0 +1,12 @@
#!/bin/sh
# script to generate the iso image we use here
set -ex
apk --update add cdrkit >&2
# generate our cdrom image
cd /tmp;
{ echo instance-id: iid-local01; echo local-hostname: cloudimg; } > meta-data
printf '{"file1": {"perm": "0644","content": "abcdefg"}, "file2": {"perm": "0700", "content": "supersecret"}}' > user-data
genisoimage -output - -volid cidata -joliet -rock user-data meta-data

View File

@@ -0,0 +1,32 @@
#!/bin/sh
# SUMMARY: Check that the userdata is found and read when on a cidata partition
# LABELS:
# REPEAT:
set -ex
# Source libraries. Uncomment if needed/defined
#. "${RT_LIB}"
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
NAME=metadata
DISK=disk.img
clean_up() {
rm -rf ${NAME}-* ${DISK}
}
trap clean_up EXIT
# Test code goes here
# generate our cdrom image
ISOFILE=/tmp/cidata.iso
docker run -i --rm -v $(pwd)/geniso.sh:/geniso.sh:ro alpine:3.11 /geniso.sh > ${ISOFILE}
linuxkit build -format kernel+initrd -name ${NAME} test.yml
RESULT="$(linuxkit run -disk file=${DISK},size=32M -disk file=${ISOFILE} ${NAME})"
echo "${RESULT}"
echo "${RESULT}" | grep -q "suite PASSED"
exit 0

View File

@@ -0,0 +1,25 @@
kernel:
image: linuxkit/kernel:5.4.30
cmdline: "console=ttyS0 console=ttyAMA0"
init:
- linuxkit/init:7195dc244cd92af01fd0895fd204249a6114c5e2
- linuxkit/runc:f79954950022fea76b8b6f10de58cb48e4fb3878
onboot:
- name: metadata
image: linuxkit/metadata:dc5bcfa45946053145391ceabe33729c8b9507a1
- name: test
image: alpine:3.11
binds:
- /check.sh:/check.sh
- /run:/run
command: ["sh", "./check.sh"]
- name: poweroff
image: linuxkit/poweroff:06dd4e46c62fbe79123a028835c921f80e4855d3
command: ["/bin/sh", "/poweroff.sh", "10"]
files:
- path: check.sh
source: ./check.sh
trust:
org:
- linuxkit
- library