From 1c1f97ad70ee716120e3af86d1afbff2aaad4428 Mon Sep 17 00:00:00 2001 From: David Shea Date: Fri, 28 Sep 2018 15:11:09 -0400 Subject: [PATCH] Add a vhd compose type for Azure images This does pretty much the same things as the AMI compose type, but also replaces NetworkManager with the Azure linux agent. (cherry picked from commit e0c236ff3637f35bfff67f64318e37c3c089179b) Resolves: rhbz#1628648 --- docs/composer-cli.rst | 2 +- share/composer/vhd.ks | 47 ++++++++++++++++++++++++++++++++++++ src/pylorax/api/compose.py | 22 +++++++++++++++++ tests/pylorax/test_server.py | 2 +- 4 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 share/composer/vhd.ks diff --git a/docs/composer-cli.rst b/docs/composer-cli.rst index 7e32ca60..fa616dcc 100644 --- a/docs/composer-cli.rst +++ b/docs/composer-cli.rst @@ -41,7 +41,7 @@ keep track of the build. You can also cancel the build if needed. The available types of images is displayed by ``composer-cli compose types``. Currently this consists of: ami, ext4-filesystem, live-iso, partitioned-disk, -qcow2, tar +qcow2, tar, vhd Monitor the build status ------------------------ diff --git a/share/composer/vhd.ks b/share/composer/vhd.ks new file mode 100644 index 00000000..ad0205ba --- /dev/null +++ b/share/composer/vhd.ks @@ -0,0 +1,47 @@ +# Lorax Composer VHD (Azure, Hyper-V) output kickstart template + +# Add a separate /boot partition +part /boot --size=1024 + +# 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 --append="no_timer_check console=ttyS0,115200n8 console=tty1 net.ifnames=0" + +# Basic services +services --enabled=sshd,chronyd,waagent + +%post +# Remove random-seed +rm /var/lib/systemd/random-seed +%end + +%packages +kernel +-dracut-config-rescue + +grub2 + +chrony + +# Uninstall NetworkManager, install WALinuxAgent +-NetworkManager +WALinuxAgent + +# 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 5e522642..df8acbdb 100644 --- a/src/pylorax/api/compose.py +++ b/src/pylorax/api/compose.py @@ -569,6 +569,28 @@ def compose_args(compose_type): "app_template": None, "app_file": None, }, + "vhd": {"make_iso": False, + "make_disk": True, + "make_fsimage": False, + "make_appliance": False, + "make_ami": False, + "make_tar": 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_type": "vpc", + "qemu_args": ["-o", "subformat=fixed,force_size"], + "image_name": "disk.vhd", + "fs_label": "", + "image_only": True, + "app_name": None, + "app_template": None, + "app_file": None, + }, } return _MAP[compose_type] diff --git a/tests/pylorax/test_server.py b/tests/pylorax/test_server.py index 85620fcc..025796e1 100644 --- a/tests/pylorax/test_server.py +++ b/tests/pylorax/test_server.py @@ -808,7 +808,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', 'live-iso', 'partitioned-disk', 'qcow2', 'tar']"}], + self.assertEqual(data["errors"], [{"id": BAD_COMPOSE_TYPE, "msg": "Invalid compose type (snakes), must be one of ['ami', 'ext4-filesystem', 'live-iso', 'partitioned-disk', 'qcow2', 'tar', 'vhd']"}], "Failed to get errors: %s" % data) def test_compose_03_status_fail(self):