Add a new compose type for Hyper-V

This is based on the VHD compose type, with the following differences:

  * Use the vhdx format instead of vhd
  * No WALinuxAgent
  * Install hyperv-daemons

The hyperv-daemons are activated through udev rules, so there is no need
to add them to the services line.

(cherry picked from commit 434fe58c28)
(cherry picked from commit 367c2583e4)
This commit is contained in:
David Shea 2019-04-01 13:23:21 -04:00 committed by Brian C. Lane
parent c1628bd171
commit 0220077242
5 changed files with 89 additions and 4 deletions

View File

@ -41,8 +41,8 @@ keep track of the build. You can also cancel the build if needed.
<<<<<<< HEAD <<<<<<< HEAD
The available types of images is displayed by ``composer-cli compose types``. The available types of images is displayed by ``composer-cli compose types``.
Currently this consists of: ami, ext4-filesystem, google, live-iso, openstack, Currently this consists of: ami, ext4-filesystem, google, hyper-v, live-iso,
partitioned-disk, qcow2, tar, vhd, vmdk openstack, partitioned-disk, qcow2, tar, vhd, vmdk
Monitor the build status Monitor the build status
------------------------ ------------------------

60
share/composer/hyper-v.ks Normal file
View File

@ -0,0 +1,60 @@
# Lorax Composer VHD (Azure, Hyper-V) 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 --append="no_timer_check console=ttyS0,115200n8 earlyprintk=ttyS0,115200 rootdelay=300 net.ifnames=0"
# Add platform specific partitions
reqpart --add-boot
# Basic services
services --enabled=sshd,chronyd
%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*
# Add Hyper-V modules into initramfs
cat > /etc/dracut.conf.d/10-hyperv.conf << EOF
add_drivers+=" hv_vmbus hv_netvsc hv_storvsc "
EOF
# Regenerate the intramfs image
dracut -f -v --persistent-policy by-uuid
%end
%addon com_redhat_kdump --disable
%end
%packages
kernel
selinux-policy-targeted
chrony
hyperv-daemons
# NOTE lorax-composer will add the recipe packages below here, including the final %end

View File

@ -848,6 +848,31 @@ def compose_args(compose_type):
"app_template": None, "app_template": None,
"app_file": None, "app_file": None,
}, },
"hyper-v": {"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": "vhdx",
"qemu_args": [],
"image_name": "disk.vhdx",
"tar_disk_name": None,
"fs_label": "",
"image_only": True,
"app_name": None,
"app_template": None,
"app_file": None,
},
} }
return _MAP[compose_type] return _MAP[compose_type]

View File

@ -9,7 +9,7 @@ CLI="${CLI:-./src/bin/composer-cli}"
rlJournalStart rlJournalStart
rlPhaseStartTest "compose types" rlPhaseStartTest "compose types"
rlAssertEquals "lists all supported types" \ rlAssertEquals "lists all supported types" \
"`$CLI compose types | sort | xargs`" "ami ext4-filesystem google live-iso openstack partitioned-disk qcow2 tar vhd vmdk" "`$CLI compose types | sort | xargs`" "ami ext4-filesystem google hyper-v live-iso openstack partitioned-disk qcow2 tar vhd vmdk"
rlPhaseEnd rlPhaseEnd
rlPhaseStartTest "compose start" rlPhaseStartTest "compose start"

View File

@ -859,7 +859,7 @@ class ServerTestCase(unittest.TestCase):
data = json.loads(resp.data) data = json.loads(resp.data)
self.assertNotEqual(data, None) self.assertNotEqual(data, None)
self.assertEqual(data["status"], False, "Failed to fail to start test compose: %s" % data) 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', '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 ['ami', 'ext4-filesystem', 'google', 'hyper-v', 'live-iso', 'openstack', 'partitioned-disk', 'qcow2', 'tar', 'vhd', 'vmdk']"}],
"Failed to get errors: %s" % data) "Failed to get errors: %s" % data)
def test_compose_03_status_fail(self): def test_compose_03_status_fail(self):