1
0
mirror of https://github.com/rancher/os.git synced 2025-08-02 07:24:28 +00:00

add scripts/run --openstack, and use the iso if --cloud-config file.iso

Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>
This commit is contained in:
Sven Dowideit 2017-03-28 16:04:49 +10:00
parent ecdd081c27
commit d4ae014f76
4 changed files with 62 additions and 37 deletions

View File

@ -1,4 +1,4 @@
TARGETS := $(shell ls scripts | grep -vE 'clean|run|help|docs')
TARGETS := $(shell ls scripts | grep -vE 'clean|run|help|docs|release')
.dapper:
@echo Downloading dapper
@ -34,12 +34,18 @@ shell-bind: .dapper
clean:
@./scripts/clean
release: release-build openstack
release-build:
./.dapper release
itest:
./.dapper integration-test 2>&1 | tee dist/itest.log
openstack:
cp dist/artifacts/rancheros.iso scripts/images/openstack/
cd scripts/images/openstack && ../../../.dapper
cp ./scripts/images/openstack/dist/*.img dist/
openstack-run:
qemu-system-x86_64 -curses \

View File

@ -62,10 +62,12 @@ func Main() {
func SaveCloudConfig() error {
log.Debugf("SaveCloudConfig")
// TODO: can't run these here, but it needs to be triggered from here :()
cfg := rancherConfig.LoadConfig()
log.Debugf("init: SaveCloudConfig(pre ApplyNetworkConfig): %#v", cfg.Rancher.Network)
network.ApplyNetworkConfig(cfg)
log.Debugf("datasources that will be consided: %#v", cfg.Rancher.CloudInit.Datasources)
dss := getDatasources(cfg)
if len(dss) == 0 {
log.Errorf("currentDatasource - none found")
@ -74,6 +76,7 @@ func SaveCloudConfig() error {
selectDatasource(dss)
// TODO: can't run these here, but it needs to be triggered from here :()
// Apply any newly detected network config.
cfg = rancherConfig.LoadConfig()
log.Debugf("init: SaveCloudConfig(post ApplyNetworkConfig): %#v", cfg.Rancher.Network)

View File

@ -3,3 +3,4 @@ set -e
cd $(dirname $0)/..
rm -rf build dist bin images/*/build state
rm -rf ./scripts/images/openstack/dist

View File

@ -25,6 +25,9 @@ while [ "$#" -gt 0 ]; do
--pxe)
BOOT_PXE=1
;;
--openstack)
USE_OPENSTACK_IMG=1
;;
--append)
shift 1
QEMU_APPEND="${QEMU_APPEND} $1"
@ -152,16 +155,24 @@ if [ "$QEMU" == "1" ] || [ "$BOOT_ISO" == "1" ] || [ "$BOOT_HD" == "1" ]; then
if [ ! -e ${HD} ]; then
mkdir -p $(dirname ${HD})
if [ ¨$INSTALLED¨ == ¨1¨ ]; then
./scripts/create-installed
if [ "$USE_OPENSTACK_IMG" == "1" ]; then
if [ ! -e "dist/rancheros-openstack.img" ]; then
echo "please build the open stack image first (run make release)."
exit 1
fi
cp dist/rancheros-openstack.img $HD
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}
qemu-img resize ${HD} +10GB
else
qemu-img create -f qcow2 -o size=10G ${HD}
fi
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}
qemu-img resize ${HD} +10GB
else
qemu-img create -f qcow2 -o size=10G ${HD}
fi
fi
fi
fi
@ -180,34 +191,38 @@ if [ "$QIND" != "1" ]; then
CPU="-cpu host"
fi
CCROOT=${BUILD}/cloud-config
rm -rf ${CCROOT}
mkdir -p ${CCROOT}
USER_DATA=${CCROOT}/openstack/latest/user_data
mkdir -p $(dirname ${USER_DATA})
rm -f ${USER_DATA} || :
if [ -n "$CLOUD_CONFIG" ]; then
cat ${CLOUD_CONFIG} > ${USER_DATA}
if [[ "${CLOUD_CONFIG}" == *".iso" ]]; then
CLOUD_CONFIG_DISK="-cdrom ${CLOUD_CONFIG}"
else
echo "#cloud-config" > ${USER_DATA}
echo "ssh_authorized_keys:" >> ${USER_DATA}
echo "- $(<${BASE}/assets/rancher.key.pub)" >> ${USER_DATA}
CCROOT=${BUILD}/cloud-config
rm -rf ${CCROOT}
mkdir -p ${CCROOT}
USER_DATA=${CCROOT}/openstack/latest/user_data
mkdir -p $(dirname ${USER_DATA})
rm -f ${USER_DATA} || :
if [ -n "$CLOUD_CONFIG" ]; then
cat ${CLOUD_CONFIG} > ${USER_DATA}
else
echo "#cloud-config" > ${USER_DATA}
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)
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} \
-device virtio-9p-pci,id=fs0,fsdev=fsdev0,mount_tag=config-2"
;;
esac
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)
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} \
-device virtio-9p-pci,id=fs0,fsdev=fsdev0,mount_tag=config-2"
;;
esac
HOME=${HOME:-/}
fi
@ -251,7 +266,6 @@ elif [ "$BOOT_ISO" == "1" ] ||
[ "$BOOT_HD" == "1" ]; then
if [ "$BOOT_ISO" == "1" ]; then
ISO_OPTS="-boot d -cdrom ./dist/artifacts/rancheros.iso \
${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"
@ -259,6 +273,7 @@ elif [ "$BOOT_ISO" == "1" ] ||
set -x
exec qemu-system-${QEMUARCH} \
${DISPLAY_OPTS} \
${CLOUD_CONFIG_DISK} \
-rtc base=utc,clock=host \
${KVM_ENABLE} \
${CPU} \