From f22238e369b7234c5d0d6db536ee5115bb7ce9b4 Mon Sep 17 00:00:00 2001 From: Benny Zlotnik Date: Mon, 28 Aug 2023 12:30:46 +0300 Subject: [PATCH] openstack: block image based VMs We cannot support this currently Signed-off-by: Benny Zlotnik --- .../forklift/openstack/image_format.rego | 18 ------------------ .../forklift/openstack/volume_based.rego | 18 ++++++++++++++++++ ...format_test.rego => volume_based_test.rego} | 12 ++++++------ 3 files changed, 24 insertions(+), 24 deletions(-) delete mode 100644 validation/policies/io/konveyor/forklift/openstack/image_format.rego create mode 100644 validation/policies/io/konveyor/forklift/openstack/volume_based.rego rename validation/policies/io/konveyor/forklift/openstack/{image_format_test.rego => volume_based_test.rego} (76%) diff --git a/validation/policies/io/konveyor/forklift/openstack/image_format.rego b/validation/policies/io/konveyor/forklift/openstack/image_format.rego deleted file mode 100644 index 49101f12c..000000000 --- a/validation/policies/io/konveyor/forklift/openstack/image_format.rego +++ /dev/null @@ -1,18 +0,0 @@ -package io.konveyor.forklift.openstack - -import future.keywords.if - -default has_invalid_image_format = false - -has_invalid_image_format if { - not regex.match(`qcow2|raw`, input.image.diskFormat) -} - -concerns[flag] { - has_invalid_image_format - flag := { - "category": "Critical", - "label": "Unsupported image format detected", - "assessment": "The VM image has a format other than 'qcow2' or 'raw', which is not currently supported by OpenShift Virtualization. The VM disk transfer is likely to fail.", - } -} diff --git a/validation/policies/io/konveyor/forklift/openstack/volume_based.rego b/validation/policies/io/konveyor/forklift/openstack/volume_based.rego new file mode 100644 index 000000000..a5b81c310 --- /dev/null +++ b/validation/policies/io/konveyor/forklift/openstack/volume_based.rego @@ -0,0 +1,18 @@ +package io.konveyor.forklift.openstack + +import future.keywords.if + +default not_volume_based = false + +not_volume_based if { + input.imageID != "" +} + +concerns[flag] { + not_volume_based + flag := { + "category": "Critical", + "label": "Unsupported image format detected", + "assessment": "The VM is not volume based, currently only volume based VMs can be imported.", + } +} diff --git a/validation/policies/io/konveyor/forklift/openstack/image_format_test.rego b/validation/policies/io/konveyor/forklift/openstack/volume_based_test.rego similarity index 76% rename from validation/policies/io/konveyor/forklift/openstack/image_format_test.rego rename to validation/policies/io/konveyor/forklift/openstack/volume_based_test.rego index 12ea6548a..a38c4c09d 100644 --- a/validation/policies/io/konveyor/forklift/openstack/image_format_test.rego +++ b/validation/policies/io/konveyor/forklift/openstack/volume_based_test.rego @@ -1,25 +1,25 @@ package io.konveyor.forklift.openstack -test_with_valid_image_format { +test_image_based_vm { mock_vm := { "name": "test", + "imageID": "b749c132-bb97-4145-b86e-a1751cf75e21", "image": { "id": "b749c132-bb97-4145-b86e-a1751cf75e21", - "diskFormat": "qcow2", }, } results := concerns with input as mock_vm - count(results) == 0 + count(results) == 1 } -test_with_invalid_storage_type { +test_volume_based_vm { mock_vm := { "name": "test", "image": { "id": "b749c132-bb97-4145-b86e-a1751cf75e21", - "diskFormat": "ami", }, + "volumes": [] } results := concerns with input as mock_vm - count(results) == 1 + count(results) == 0 }