From 1a0d953737d9aa9481d484b31f5d07a14435cc8a Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Tue, 18 Dec 2018 15:30:32 +0000 Subject: [PATCH] Support ocata release of ironic In the Ocata release, the physical_network field of ports did not exist. The safest thing to do is to simply ignore it in this case. It is also possible for the local_link_connection fields to not have switch_id, switch_info or port_id attributes, so we now use .get(attr) to avoid an attribute lookup error. Change-Id: Ib4829dbd89fcedc121f493d6af76702421b399f7 TrivialFix --- ansible/roles/ironic-enrolment/tasks/main.yml | 14 ++++++++++++++ ansible/roles/ironic-enrolment/tasks/port.yml | 10 ++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/ansible/roles/ironic-enrolment/tasks/main.yml b/ansible/roles/ironic-enrolment/tasks/main.yml index c9fb3dd..3f44d4c 100644 --- a/ansible/roles/ironic-enrolment/tasks/main.yml +++ b/ansible/roles/ironic-enrolment/tasks/main.yml @@ -26,6 +26,20 @@ until: result is success retries: 3 +- name: Detect ironic API version + command: >- + {{ ironic_virtualenv_path }}/bin/openstack + --os-baremetal-api-version 1.34 + baremetal node list + register: api_version_result + changed_when: false + failed_when: false + +# This is used in port.yml. +- name: Set a fact about whether Ironic supports physical network awareness + set_fact: + supports_port_physnet: "{{ api_version_result.rc == 0 }}" + # This command will return the UUIDs, regardless of whether # ironic_deploy_kernel and ironic_deploy_ramdisk are image UUIDs or names. - name: Get OpenStack deployment image UUIDs diff --git a/ansible/roles/ironic-enrolment/tasks/port.yml b/ansible/roles/ironic-enrolment/tasks/port.yml index a4f4133..1a59818 100644 --- a/ansible/roles/ironic-enrolment/tasks/port.yml +++ b/ansible/roles/ironic-enrolment/tasks/port.yml @@ -40,12 +40,14 @@ command: >- '{{ ironic_virtualenv_path }}/bin/openstack' baremetal port set {{ uuid.stdout }} + {% if supports_port_physnet %} --physical-network '{{ physnet }}' + {% endif %} --local-link-connection switch_id='{{ switch_id }}' --local-link-connection switch_info='{{ bridge }}' --local-link-connection port_id='{{ port_id }}' when: >- - port_attributes.physical_network != physnet or - port_attributes.local_link_connection.switch_id != switch_id or - port_attributes.local_link_connection.switch_info != switch_info or - port_attributes.local_link_connection.port_id != port_id + (supports_port_physnet and port_attributes.physical_network != physnet) or + port_attributes.local_link_connection.get('switch_id') != switch_id or + port_attributes.local_link_connection.get('switch_info') != switch_info or + port_attributes.local_link_connection.get('port_id') != port_id