From 2fb7651b60d98ae184d699714735e09be8441547 Mon Sep 17 00:00:00 2001 From: Sven Dowideit Date: Thu, 16 Feb 2017 23:12:40 +0000 Subject: [PATCH 1/2] Failing test for cloud-config on iso Signed-off-by: Sven Dowideit --- scripts/run | 38 +++++++++++++++++++++++++++----------- tests/cloud_init_test.go | 10 ++++++++++ 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/scripts/run b/scripts/run index 5b6f2618..36e96fe2 100755 --- a/scripts/run +++ b/scripts/run @@ -42,6 +42,12 @@ while [ "$#" -gt 0 ]; do exit 1 fi ;; + --cloud-config-iso) + CLOUD_CONFIG_FORMAT="iso" + ;; + --cloud-config-fat) + CLOUD_CONFIG_FORMAT="fat" + ;; --second-drive) SECOND_DRIVE=1 ;; @@ -76,7 +82,7 @@ while [ "$#" -gt 0 ]; do AUTOFORMAT=1 ;; --console) - # use the bios console, not serial (lets you see syslinux) + # use the bios console, not serial (lets you see syslinux) CONSOLEDISPLAY=1 ;; --installed) @@ -131,13 +137,13 @@ if [ "$QEMU" == "1" ] || [ "$BOOT_ISO" == "1" ] || [ "$BOOT_HD" == "1" ]; then if [ ¨$INSTALLED¨ == ¨1¨ ]; then ./scripts/create-installed else - if [ "$AUTOFORMAT" == "1" ]; then - echo "boot2docker, please format-me" | cat - /dev/zero | head -c 5242880 > format-flag.txt # 5M - qemu-img convert -f raw format-flag.txt -O qcow2 ${HD} + if [ "$AUTOFORMAT" == "1" ]; then + echo "boot2docker, please format-me" | cat - /dev/zero | head -c 5242880 > format-flag.txt # 5M + qemu-img convert -f raw format-flag.txt -O qcow2 ${HD} qemu-img resize ${HD} +10GB - else - qemu-img create -f qcow2 -o size=10G ${HD} - fi + else + qemu-img create -f qcow2 -o size=10G ${HD} + fi fi fi @@ -170,6 +176,18 @@ if [ "$QIND" != "1" ]; then echo "ssh_authorized_keys:" >> ${USER_DATA} echo "- $(<${BASE}/assets/rancher.key.pub)" >> ${USER_DATA} fi + case $CLOUD_CONFIG_FORMAT in + iso) + mkisofs -R -V config-2 -o ${BASE}/state/configdrive.iso ${CCROOT} + CLOUD_CONFIG_DISK="-cdrom ${BASE}/state/configdrive.iso" + ;; + fat) + ;; + *) + CLOUD_CONFIG_DISK="-fsdev local,security_model=passthrough,readonly,id=fsdev0,path=${CCROOT} \ + -device virtio-9p-pci,id=fs0,fsdev=fsdev0,mount_tag=config-2" + ;; + esac HOME=${HOME:-/} fi @@ -203,8 +221,7 @@ if [ "$QEMU" == "1" ]; then $(eval "${hd["$ARCH"]} ${HD}") \ ${SECOND_DRIVE_ENABLE} \ -smp 1 \ - -fsdev local,security_model=passthrough,readonly,id=fsdev0,path=${CCROOT} \ - -device virtio-9p-pci,id=fs0,fsdev=fsdev0,mount_tag=config-2 \ + ${CLOUD_CONFIG_DISK} \ -fsdev local,security_model=none,id=fsdev1,path=${HOME} \ -device virtio-9p-pci,id=fs1,fsdev=fsdev1,mount_tag=home \ ${QEMU_ARGS} \ @@ -214,8 +231,7 @@ elif [ "$BOOT_ISO" == "1" ] || [ "$BOOT_HD" == "1" ]; then if [ "$BOOT_ISO" == "1" ]; then ISO_OPTS="-boot d -cdrom ./dist/artifacts/rancheros.iso \ - -fsdev local,security_model=passthrough,readonly,id=fsdev0,path=${CCROOT} \ - -device virtio-9p-pci,id=fs0,fsdev=fsdev0,mount_tag=config-2 \ + ${CLOUD_CONFIG_DISK} \ -fsdev local,security_model=none,id=fsdev1,path=${HOME} \ -device virtio-9p-pci,id=fs1,fsdev=fsdev1,mount_tag=home " echo "----- $ISO_OPTS" diff --git a/tests/cloud_init_test.go b/tests/cloud_init_test.go index a04d0d05..756a4254 100644 --- a/tests/cloud_init_test.go +++ b/tests/cloud_init_test.go @@ -18,3 +18,13 @@ EOF s.CheckCall(c, "sudo ros config get rancher.log | grep true") } + +func (s *QemuSuite) TestIsoCloudConfig(c *C) { + runArgs := []string{ + "--fresh", + "--cloud-config-iso", + } + s.RunQemuWith(c, runArgs...) + + s.CheckCall(c, `ls .ssh/authorized_keys`) +} From 69be7de1c409f3e3447a1d5ec019a849bb3e64fe Mon Sep 17 00:00:00 2001 From: Sven Dowideit Date: Wed, 22 Feb 2017 03:46:54 +0000 Subject: [PATCH 2/2] Fix ISO based cloud-config drive Signed-off-by: Sven Dowideit --- cmd/cloudinitsave/cloudinitsave.go | 6 +++++- scripts/run | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/cloudinitsave/cloudinitsave.go b/cmd/cloudinitsave/cloudinitsave.go index 4b1f17ec..75050031 100644 --- a/cmd/cloudinitsave/cloudinitsave.go +++ b/cmd/cloudinitsave/cloudinitsave.go @@ -81,7 +81,11 @@ func MountConfigDrive() error { return mount.Mount(configDevName, configDevMountPoint, "9p", "trans=virtio,version=9p2000.L") } - return mount.Mount(configDev, configDevMountPoint, "iso9660,vfat", "") + fsType, err := util.GetFsType(configDev) + if err != nil { + return err + } + return mount.Mount(configDev, configDevMountPoint, fsType, "ro") } func UnmountConfigDrive() error { diff --git a/scripts/run b/scripts/run index 36e96fe2..5e19514a 100755 --- a/scripts/run +++ b/scripts/run @@ -182,6 +182,8 @@ if [ "$QIND" != "1" ]; then CLOUD_CONFIG_DISK="-cdrom ${BASE}/state/configdrive.iso" ;; fat) + echo "TODO: implement a vfat formated qemu img & copy the config files into it" + exit 1 ;; *) CLOUD_CONFIG_DISK="-fsdev local,security_model=passthrough,readonly,id=fsdev0,path=${CCROOT} \