Skip to content

Commit

Permalink
feat: target archictecture as a parameter
Browse files Browse the repository at this point in the history
The default value is x86_64, but it can be overridden. This change
ensures compatibility with older versions.

Signed-off-by: Nestor Acuna Blanco <[email protected]>
  • Loading branch information
nestoracunablanco committed Nov 22, 2024
1 parent d891490 commit 2fbf963
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
5 changes: 0 additions & 5 deletions automation/test-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ namespace="kubevirt"
ocenv="OC"
k8senv="K8s"

if [ "$TARGET" == "centos6" ] && [ "$(uname -m)" == "s390x" ]; then
echo "CentOS 6 does not support s390x."
exit 1
fi

containerdisks_url="docker://quay.io/containerdisks"
legacy_common_templates_disk_url="docker://quay.io/kubevirt/common-templates"
cnv_common_templates_url="docker://quay.io/openshift-cnv/ci-common-templates-images"
Expand Down
15 changes: 11 additions & 4 deletions generate-templates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
hosts: 127.0.0.1
gather_facts: yes
tasks:
- name: Ensure target_arch is defined
assert:
that:
- target_arch is defined
- target_arch in ['x86_64', 's390x']
fail_msg: "Please define the target architecture as either 'x86_64' or 's390x'."

- name: Prepare dist directory
file:
path: "{{ playbook_dir }}/dist/templates"
Expand Down Expand Up @@ -145,7 +152,7 @@
- name: Load CentOS 6 versions
set_fact:
centos6_labels: "{{ lookup('osinfo', 'distro=centos') |map(attribute='short_id') |select('match', '^centos6\\.') |list |sort }}"
when: ansible_architecture != "s390x"
when: target_arch != "s390x"

- name: Generate CentOS 6 templates
template:
Expand All @@ -163,16 +170,16 @@
oslabels: "{{ centos6_labels }}"
osinfoname: "{{ oslabels[0] }}"
cloudusername: centos
when: ansible_architecture != "s390x"
when: target_arch != "s390x"

- name: Load Fedora versions
set_fact:
fedora_labels: "{{ lookup('osinfo', 'distro=fedora') |select('osinfo_active') |map(attribute='short_id') |select('match', '^fedora3[5-9]|^fedora[4-9][0-9]') |list |sort }}"

- name: Load Fedora containerdisk and image urls
set_fact:
fedora_containerdisk_urls: "{{ fedora_containerdisk_urls |default([]) + lookup('osinfo', item) |attr('image_list') |selectattr('architecture', 'eq', ansible_architecture) |selectattr('format', 'eq', 'containerdisk') |map(attribute='url') |map('replace', 'docker://', '') |list }}"
fedora_image_urls: "{{ fedora_image_urls |default([]) + lookup('osinfo', item) |attr('image_list') |selectattr('architecture', 'eq', ansible_architecture) |selectattr('format', 'in', ['raw', 'qcow2']) |map(attribute='url') |list }}"
fedora_containerdisk_urls: "{{ fedora_containerdisk_urls |default([]) + lookup('osinfo', item) |attr('image_list') |selectattr('architecture', 'eq', target_arch) |selectattr('format', 'eq', 'containerdisk') |map(attribute='url') |map('replace', 'docker://', '') |list }}"
fedora_image_urls: "{{ fedora_image_urls |default([]) + lookup('osinfo', item) |attr('image_list') |selectattr('architecture', 'eq', target_arch) |selectattr('format', 'in', ['raw', 'qcow2']) |map(attribute='url') |list }}"
loop: "{{ fedora_labels }}"

- name: Generate Fedora templates
Expand Down
5 changes: 4 additions & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ ALL_META_TEMPLATES=$(wildcard templates/*.yaml)
ALL_PRESETS=$(wildcard presets/*.yaml)
METASOURCES=$(ALL_META_TEMPLATES) $(ALL_PRESETS)

# target architecture
TARGET_ARCH?=x86_64

# Make sure the version is defined
export VERSION=$(shell ./version.sh)
export REVISION=$(shell ./revision.sh)
Expand Down Expand Up @@ -41,7 +44,7 @@ validate-no-offensive-lang:
generate: generate-templates.yaml $(METASOURCES)
# Just build the XML files, no need to export to tarball
make -C osinfo-db/ OSINFO_DB_EXPORT=echo
ansible-playbook generate-templates.yaml
ansible-playbook generate-templates.yaml -e "target_arch=$(TARGET_ARCH)"

update-osinfo-db:
git submodule init
Expand Down
4 changes: 2 additions & 2 deletions templates/fedora.tpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ objects:
kubevirt.io/domain: ${NAME}
kubevirt.io/size: {{ item.flavor }}
spec:
architecture: "{{ 'amd64' if ansible_architecture == 'x86_64' else ansible_architecture }}"
architecture: "{{ 'amd64' if target_arch == 'x86_64' else target_arch }}"
domain:
{% if ansible_architecture != 's390x' %}
{% if target_arch != 's390x' %}
features:
smm:
enabled: true
Expand Down

0 comments on commit 2fbf963

Please sign in to comment.