From b7302247e3d6078a2903f2c3c37b67fed619a3fb Mon Sep 17 00:00:00 2001 From: Aidan McMahon-Smith Date: Mon, 14 Aug 2023 16:39:34 +0200 Subject: [PATCH 1/2] Add uefi boot support to compose data [RHELDST-18235] From RHEL 8.9 and RHEL 9.3 onwards UEFI will be available. The boot mode must be specified for AMI images to make use of the change. This change adds the boot mode to the metadata parsed in from composes. Data will be used by pubtools-ami and passed to cloudimg --- .../_impl/backend/staged/staged_ami.py | 1 + src/pushsource/_impl/model/ami.py | 6 +++ .../_impl/schema/staged-schema.yaml | 5 ++ tests/baseline/cases/staged-simple-ami-bc.yml | 1 + .../baseline/cases/staged-simple-ami-uefi.yml | 52 +++++++++++++++++++ tests/baseline/cases/staged-simple-ami.yml | 1 + tests/conftest.py | 1 - tests/staged/data/simple_ami/staged.yaml | 1 + .../data/simple_ami_with_bc/staged.yaml | 1 + .../dest1/AWS_IMAGES/fake-image.raw | 0 .../data/simple_ami_with_uefi/staged.yaml | 27 ++++++++++ 11 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 tests/baseline/cases/staged-simple-ami-uefi.yml create mode 100644 tests/staged/data/simple_ami_with_uefi/dest1/AWS_IMAGES/fake-image.raw create mode 100644 tests/staged/data/simple_ami_with_uefi/staged.yaml diff --git a/src/pushsource/_impl/backend/staged/staged_ami.py b/src/pushsource/_impl/backend/staged/staged_ami.py index 255cf8e4..878663e8 100644 --- a/src/pushsource/_impl/backend/staged/staged_ami.py +++ b/src/pushsource/_impl/backend/staged/staged_ami.py @@ -56,6 +56,7 @@ def __push_item(self, leafdir, metadata, entry): "description", "sriov_net_support", "ena_support", + "uefi_support", "public_image", "release_notes", "usage_instructions", diff --git a/src/pushsource/_impl/model/ami.py b/src/pushsource/_impl/model/ami.py index e9323e20..850d5b6b 100644 --- a/src/pushsource/_impl/model/ami.py +++ b/src/pushsource/_impl/model/ami.py @@ -129,6 +129,11 @@ class AmiPushItem(VMIPushItem): ) """``True`` if the image supports Elastic Network Adapter (ENA).""" + uefi_support = attr.ib( + type=bool, default=None, validator=optional(instance_of(bool)) + ) + """``True`` if the image supports UEFI boot.""" + billing_codes = attr.ib( type=AmiBillingCodes, default=None, @@ -199,6 +204,7 @@ def _from_data(cls, data): "description": data["description"], "sriov_net_support": data["sriov_net_support"], "ena_support": data.get("ena_support"), + "uefi_support": data.get("uefi_support"), "billing_codes": AmiBillingCodes._from_data( data.get("billing_codes") or {} ), diff --git a/src/pushsource/_impl/schema/staged-schema.yaml b/src/pushsource/_impl/schema/staged-schema.yaml index f48c12e3..3752b01c 100644 --- a/src/pushsource/_impl/schema/staged-schema.yaml +++ b/src/pushsource/_impl/schema/staged-schema.yaml @@ -97,6 +97,11 @@ definitions: - boolean - "null" + uefi_support: + type: + - boolean + - "null" + billing_codes: $ref: "#/definitions/ami_billing_codes" diff --git a/tests/baseline/cases/staged-simple-ami-bc.yml b/tests/baseline/cases/staged-simple-ami-bc.yml index 1d61c72a..22f1df85 100644 --- a/tests/baseline/cases/staged-simple-ami-bc.yml +++ b/tests/baseline/cases/staged-simple-ami-bc.yml @@ -54,6 +54,7 @@ items: sriov_net_support: simple state: PENDING type: access + uefi_support: null usage_instructions: fake usage instructions user_name: Fake-Username version_title: Fake-Version-Title diff --git a/tests/baseline/cases/staged-simple-ami-uefi.yml b/tests/baseline/cases/staged-simple-ami-uefi.yml new file mode 100644 index 00000000..361a2db5 --- /dev/null +++ b/tests/baseline/cases/staged-simple-ami-uefi.yml @@ -0,0 +1,52 @@ +# A pushsource library testcase. +# +# This file was generated from a template. +# To regenerate, run test_baseline.py with PUSHSOURCE_UPDATE_BASELINE=1. + +# URL of Source to test. +url: "staged:{{ src_dir }}/tests/staged/data/simple_ami_with_uefi" + +# Push items generated from above. +items: +- AmiPushItem: + billing_codes: null + build: null + build_info: null + description: A sample image for testing + dest: + - dest1 + ena_support: true + image_id: null + marketplace_entity_type: null + md5sum: null + name: fake-image.raw + origin: {{ src_dir }}/tests/staged/data/simple_ami_with_uefi + public_image: true + recommended_instance_type: null + region: cn-north-1 + release: + arch: x86_64 + base_product: null + base_version: null + date: 2020-05-11 + product: Fake-Product + respin: 1 + type: ga + variant: Fake-Variant + version: Fake-Version + release_notes: null + root_device: /dev/sda1 + scanning_port: null + security_groups: [] + sha256sum: null + signing_key: null + src: {{ src_dir }}/tests/staged/data/simple_ami_with_uefi/dest1/AWS_IMAGES/fake-image.raw + sriov_net_support: simple + state: PENDING + type: access + uefi_support: true + usage_instructions: null + user_name: null + version_title: null + virtualization: hvm + volume: gp2 diff --git a/tests/baseline/cases/staged-simple-ami.yml b/tests/baseline/cases/staged-simple-ami.yml index 8e6bbe32..5b738006 100644 --- a/tests/baseline/cases/staged-simple-ami.yml +++ b/tests/baseline/cases/staged-simple-ami.yml @@ -44,6 +44,7 @@ items: sriov_net_support: simple state: PENDING type: access + uefi_support: null usage_instructions: null user_name: null version_title: null diff --git a/tests/conftest.py b/tests/conftest.py index 93d2b0f9..e7ea5b93 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -13,7 +13,6 @@ ContainerImageDigestPullSpec, ) - @fixture def fake_errata_tool(): controller = FakeErrataToolController() diff --git a/tests/staged/data/simple_ami/staged.yaml b/tests/staged/data/simple_ami/staged.yaml index ea7e0555..885a44e1 100644 --- a/tests/staged/data/simple_ami/staged.yaml +++ b/tests/staged/data/simple_ami/staged.yaml @@ -21,6 +21,7 @@ payload: root_device: /dev/sda1 sriov_net_support: simple type: access + uefi_support: null virtualization: hvm volume: gp2 public_image: true diff --git a/tests/staged/data/simple_ami_with_bc/staged.yaml b/tests/staged/data/simple_ami_with_bc/staged.yaml index 22661cb0..ec4433b4 100644 --- a/tests/staged/data/simple_ami_with_bc/staged.yaml +++ b/tests/staged/data/simple_ami_with_bc/staged.yaml @@ -35,6 +35,7 @@ payload: root_device: /dev/sda1 sriov_net_support: simple type: access + uefi_support: null virtualization: hvm volume: gp2 billing_codes: diff --git a/tests/staged/data/simple_ami_with_uefi/dest1/AWS_IMAGES/fake-image.raw b/tests/staged/data/simple_ami_with_uefi/dest1/AWS_IMAGES/fake-image.raw new file mode 100644 index 00000000..e69de29b diff --git a/tests/staged/data/simple_ami_with_uefi/staged.yaml b/tests/staged/data/simple_ami_with_uefi/staged.yaml new file mode 100644 index 00000000..32335f76 --- /dev/null +++ b/tests/staged/data/simple_ami_with_uefi/staged.yaml @@ -0,0 +1,27 @@ +header: + version: "0.2" + +payload: + files: + - relative_path: dest1/AWS_IMAGES/fake-image.raw + attributes: + description: "A sample image for testing" + ena_support: true + region: cn-north-1 + release: + arch: x86_64 + base_product: null + base_version: null + date: "20200511" + product: Fake-Product + respin: 1 + type: ga + variant: Fake-Variant + version: Fake-Version + root_device: /dev/sda1 + sriov_net_support: simple + type: access + uefi_support: true + virtualization: hvm + volume: gp2 + public_image: true From de4cff9b843f506827d8a60c37d53a26f3961576 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 15 Aug 2023 09:17:25 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/conftest.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/conftest.py b/tests/conftest.py index e7ea5b93..93d2b0f9 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -13,6 +13,7 @@ ContainerImageDigestPullSpec, ) + @fixture def fake_errata_tool(): controller = FakeErrataToolController()