From fa8ee89d16b185fbf2b2223e0947e87c119f5ab4 Mon Sep 17 00:00:00 2001 From: rajeshP524 Date: Thu, 22 Dec 2022 12:53:03 +0530 Subject: [PATCH] Add support for the hardware type 'r640' that belongs to different racks This PR adds support for only OSP17 Partially resolves https://github.com/redhat-performance/jetpack/issues/523 --- common.yml | 3 +++ composable_prepare_nic_configs.yml | 14 +++++++++++++ tasks/load_ocpinventory.yml | 27 ++++++++++++++++++++++++++ templates/baremetal_deployment.yaml.j2 | 12 ++++++++++++ 4 files changed, 56 insertions(+) create mode 100644 tasks/load_ocpinventory.yml diff --git a/common.yml b/common.yml index 1a20f49..a2bf5a6 100644 --- a/common.yml +++ b/common.yml @@ -9,6 +9,9 @@ - name: load instackenv file include_tasks: tasks/load_instackenv.yml + - name: load ocpinventory file + include_tasks: tasks/load_ocpinventory.yml + - name: get tn10rt machines list shell: curl http://wiki.scalelab.redhat.com/1029u/ > ~/tn10rt.html diff --git a/composable_prepare_nic_configs.yml b/composable_prepare_nic_configs.yml index 57d656d..b231367 100644 --- a/composable_prepare_nic_configs.yml +++ b/composable_prepare_nic_configs.yml @@ -75,6 +75,20 @@ lab_vars: "{{ (lab_name == 'scale') | ternary(scale, alias) }}" when: lab_name in ['scale', 'alias'] and osp_release|int >= 17 + - name: generic interface names for r640 + set_fact: + machine_ifaces: "{{ machine_ifaces | combine(update_item) }}" + vars: + update_item: "{ 'r640': {{ ['nic1', 'nic2', 'nic3', 'nic4'] }} }" + when: lab_name == "scale" and osp_release|int >= 17 + + - name: generic interface names for r640 + set_fact: + machine_ifaces: "{{ machine_ifaces | combine(update_item) }}" + vars: + update_item: "{ 'r640': {{ ['nic2', 'nic1', 'nic3', 'nic4'] }} }" + when: lab_name == "alias" and osp_release|int >= 17 + - name: set interfaces set_fact: ifaces: "{{ ifaces|default([]) + [ machine_ifaces[item]] }}" diff --git a/tasks/load_ocpinventory.yml b/tasks/load_ocpinventory.yml new file mode 100644 index 0000000..a229207 --- /dev/null +++ b/tasks/load_ocpinventory.yml @@ -0,0 +1,27 @@ +# ocpinventory.json for MAC addresses +--- +- name: Download ocpinventory.json + get_url: + url: "{{ alias.lab_url }}/cloud/{{ cloud_name }}_ocpinventory.json" + dest: ~/ + mode: '0644' + force: yes + when: lab_name == "alias" + +- name: Download ocpinventory.json + get_url: + url: "{{ scale.lab_url }}/cloud/{{ cloud_name }}_ocpinventory.json" + dest: ~/ + mode: '0644' + force: yes + when: lab_name == "scale" + +- name: set fact for ocpinventory file + set_fact: + ocpinventory_file: "~/{{ cloud_name}}_ocpinventory.json" + +- name: read ocpinventory file + set_fact: + ocpinventory_content: "{{ ocpinventory_content }}" + vars: + ocpinventory_content: "{{ lookup('file', '{{ ocpinventory_file }}') | from_json }}" diff --git a/templates/baremetal_deployment.yaml.j2 b/templates/baremetal_deployment.yaml.j2 index 1582afd..5335368 100644 --- a/templates/baremetal_deployment.yaml.j2 +++ b/templates/baremetal_deployment.yaml.j2 @@ -75,6 +75,18 @@ defaults: profile: baremetal{{ node_type }} network_config: +{# workaround for r640's that has different interface namings #} +{% if node_type|string() == "r640" %} + net_config_data_lookup: +{% for i in range(0, ocpinventory_content.nodes | length) %} +{% if node_type|string() in ocpinventory_content.nodes[i].pm_addr|string() %} + node{{ i|int + 1 }}: +{% for j in range(0, ocpinventory_content.nodes[i].mac | length) %} + nic{{ j|int + 1 }}: "{{ ocpinventory_content.nodes[i].mac[j] }}" +{% endfor %} +{% endif %} +{% endfor %} +{% endif %} template: /home/stack/virt/network/vlans/compute_{{ node_type }}.j2 networks: - network: ctlplane