Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: target archictecture as a parameter #642

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading