From 9a4a45f05ab764b7cf31d87ad177e845b573599b Mon Sep 17 00:00:00 2001 From: David Shea Date: Tue, 2 Apr 2019 10:24:45 -0400 Subject: [PATCH] Add a compose type for alibaba. This compose type creates a partitioned disk as a qcow2 file, but with only one partition instead of using a separate /boot. (cherry picked from commit 44e14176bbeacfd5e8ad2447d56dae78faf22d1b) (cherry picked from commit 0f59e576d8ad17847ce5f73e4c746e398ab60510) --- docs/composer-cli.rst | 4 +-- share/composer/alibaba.ks | 45 ++++++++++++++++++++++++++++++++ src/pylorax/api/compose.py | 25 ++++++++++++++++++ tests/cli/test_compose_sanity.sh | 2 +- tests/pylorax/test_server.py | 2 +- 5 files changed, 74 insertions(+), 4 deletions(-) create mode 100644 share/composer/alibaba.ks diff --git a/docs/composer-cli.rst b/docs/composer-cli.rst index bfc2fb4a..a67f9c10 100644 --- a/docs/composer-cli.rst +++ b/docs/composer-cli.rst @@ -41,8 +41,8 @@ keep track of the build. You can also cancel the build if needed. <<<<<<< HEAD The available types of images is displayed by ``composer-cli compose types``. -Currently this consists of: ami, ext4-filesystem, google, hyper-v, live-iso, -openstack, partitioned-disk, qcow2, tar, vhd, vmdk +Currently this consists of: alibaba, ami, ext4-filesystem, google, hyper-v, +live-iso, openstack, partitioned-disk, qcow2, tar, vhd, vmdk Monitor the build status ------------------------ diff --git a/share/composer/alibaba.ks b/share/composer/alibaba.ks new file mode 100644 index 00000000..614fc88a --- /dev/null +++ b/share/composer/alibaba.ks @@ -0,0 +1,45 @@ +# Lorax Composer partitioned disk output kickstart template + +# Firewall configuration +firewall --enabled + +# NOTE: The root account is locked by default +# Network information +network --bootproto=dhcp --onboot=on --activate +# System keyboard +keyboard --xlayouts=us --vckeymap=us +# System language +lang en_US.UTF-8 +# SELinux configuration +selinux --enforcing +# Installation logging level +logging --level=info +# Shutdown after installation +shutdown +# System timezone +timezone US/Eastern +# System bootloader configuration +bootloader --location=mbr + +# Basic services +services --enabled=sshd,cloud-init + +%post +# Remove random-seed +rm /var/lib/systemd/random-seed + +# Clear /etc/machine-id +rm /etc/machine-id +touch /etc/machine-id + +# Remove the rescue kernel and image to save space +rm -f /boot/*-rescue* +%end + +%packages +kernel +selinux-policy-targeted + +cloud-init + +# NOTE lorax-composer will add the blueprint packages below here, including the final %end diff --git a/src/pylorax/api/compose.py b/src/pylorax/api/compose.py index bd458b27..410374d7 100644 --- a/src/pylorax/api/compose.py +++ b/src/pylorax/api/compose.py @@ -873,6 +873,31 @@ def compose_args(compose_type): "app_template": None, "app_file": None, }, + "alibaba": {"make_iso": False, + "make_disk": True, + "make_fsimage": False, + "make_appliance": False, + "make_ami": False, + "make_tar": False, + "make_tar_disk": False, + "make_pxe_live": False, + "make_ostree_live": False, + "make_oci": False, + "make_vagrant": False, + "ostree": False, + "live_rootfs_keep_size": False, + "live_rootfs_size": 0, + "image_size_align": 0, + "image_type": "qcow2", + "qemu_args": [], + "image_name": "disk.qcow2", + "tar_disk_name": None, + "fs_label": "", + "image_only": True, + "app_name": None, + "app_template": None, + "app_file": None, + }, } return _MAP[compose_type] diff --git a/tests/cli/test_compose_sanity.sh b/tests/cli/test_compose_sanity.sh index b335c9bd..f1c84085 100755 --- a/tests/cli/test_compose_sanity.sh +++ b/tests/cli/test_compose_sanity.sh @@ -9,7 +9,7 @@ CLI="${CLI:-./src/bin/composer-cli}" rlJournalStart rlPhaseStartTest "compose types" rlAssertEquals "lists all supported types" \ - "`$CLI compose types | sort | xargs`" "ami ext4-filesystem google hyper-v live-iso openstack partitioned-disk qcow2 tar vhd vmdk" + "`$CLI compose types | sort | xargs`" "alibaba ami ext4-filesystem google hyper-v live-iso openstack partitioned-disk qcow2 tar vhd vmdk" rlPhaseEnd rlPhaseStartTest "compose start" diff --git a/tests/pylorax/test_server.py b/tests/pylorax/test_server.py index 3c3fff2d..3178d22d 100644 --- a/tests/pylorax/test_server.py +++ b/tests/pylorax/test_server.py @@ -859,7 +859,7 @@ class ServerTestCase(unittest.TestCase): data = json.loads(resp.data) self.assertNotEqual(data, None) self.assertEqual(data["status"], False, "Failed to fail to start test compose: %s" % data) - self.assertEqual(data["errors"], [{"id": BAD_COMPOSE_TYPE, "msg": "Invalid compose type (snakes), must be one of ['ami', 'ext4-filesystem', 'google', 'hyper-v', 'live-iso', 'openstack', 'partitioned-disk', 'qcow2', 'tar', 'vhd', 'vmdk']"}], + self.assertEqual(data["errors"], [{"id": BAD_COMPOSE_TYPE, "msg": "Invalid compose type (snakes), must be one of ['alibaba', 'ami', 'ext4-filesystem', 'google', 'hyper-v', 'live-iso', 'openstack', 'partitioned-disk', 'qcow2', 'tar', 'vhd', 'vmdk']"}], "Failed to get errors: %s" % data) def test_compose_03_status_fail(self):