Fix deploy and teardown without node enrolment
If the ironic_config field is not present in a node definition, then that node should not be registered with ironic. In this case we also don't need to query glance for images or wait for resources to appear in placement. If nova_flavors is empty, we do not need to register flavors, so no need to install the client or check for OS_USERNAME. Also fixes an issue in the action plugin where it would fail if ironic_config field is not present in a node definition. Finally, in CI deploy/teardown tests, rather than skipping tasks, we now remove the ironic_config field from the node definition, and set nova_flavors to empty, such that we exercise these code paths. Change-Id: I29b42665f1609c99e80f12ab6f3815d0e0918dae Story: 2004412 Task: 28056
This commit is contained in:
parent
6545bf3fa2
commit
6a2fb44a78
@ -156,8 +156,9 @@ class ActionModule(ActionBase):
|
||||
# to count as an 'instance' of the spec.
|
||||
MATCHING_ATTRS = {'type', 'ironic_config'}
|
||||
for spec in specs:
|
||||
if ((all(spec[attr] == node[attr] for attr in MATCHING_ATTRS) and
|
||||
spec['count'] > 0)):
|
||||
if (all(spec.get(attr) == node.get(attr)
|
||||
for attr in MATCHING_ATTRS)
|
||||
and spec['count'] > 0):
|
||||
spec['count'] -= 1
|
||||
return True
|
||||
return False
|
||||
|
@ -10,3 +10,4 @@
|
||||
{{ python_upper_constraints_url }}
|
||||
flavors: "{{ nova_flavors }}"
|
||||
flavors_state: "{{ 'absent' if cmd == 'teardown' else 'present' }}"
|
||||
when: flavors | length > 0
|
||||
|
@ -5,13 +5,6 @@
|
||||
file: "{{ state_file_path }}"
|
||||
name: tenks_state
|
||||
|
||||
- name: Check that OpenStack credentials exist in the environment
|
||||
fail:
|
||||
msg: >
|
||||
$OS_USERNAME was not found in the environment. Ensure the OpenStack
|
||||
credentials exist in your environment, perhaps by sourcing your RC file.
|
||||
when: not lookup('env', 'OS_USERNAME')
|
||||
|
||||
- name: Perform Ironic enrolment for each hypervisor's nodes
|
||||
include_role:
|
||||
name: ironic-enrolment
|
||||
@ -26,3 +19,4 @@
|
||||
loop: "{{ query('dict', tenks_state) }}"
|
||||
loop_control:
|
||||
loop_var: alloc
|
||||
when: ironic_nodes | selectattr('ironic_config', 'defined') | list | length > 0
|
||||
|
@ -15,11 +15,13 @@
|
||||
include_role:
|
||||
name: veth-pair
|
||||
vars:
|
||||
veth_pair_ovs_bridge: "{{ item.1 | bridge_name }}"
|
||||
veth_pair_ovs_link_name: "{{ item.0 | ovs_link_name(item.1) }}"
|
||||
veth_pair_source_link_name: "{{ item.0 | source_link_name(item.1) }}"
|
||||
veth_pair_ovs_bridge: "{{ physnet.1 | bridge_name }}"
|
||||
veth_pair_ovs_link_name: "{{ physnet.0 | ovs_link_name(physnet.1) }}"
|
||||
veth_pair_source_link_name: "{{ physnet.0 | source_link_name(physnet.1) }}"
|
||||
veth_pair_state: "{{ 'absent' if cmd == 'teardown' else 'present' }}"
|
||||
# Loop over each physical network for each node allocated to this host.
|
||||
# Allocations are stored in localhost's vars.
|
||||
loop: >-
|
||||
{{ nodes | subelements('physical_networks') }}
|
||||
loop_control:
|
||||
loop_var: physnet
|
||||
|
@ -1,20 +1,6 @@
|
||||
---
|
||||
- hosts: localhost
|
||||
tasks:
|
||||
- name: Check that OpenStack credentials exist in the environment
|
||||
fail:
|
||||
msg: >
|
||||
$OS_USERNAME was not found in the environment. Ensure the OpenStack
|
||||
credentials exist in your environment, perhaps by sourcing your RC file.
|
||||
when: not lookup('env', 'OS_USERNAME')
|
||||
|
||||
- name: Gather list of OpenStack services
|
||||
command: >-
|
||||
{{ virtualenv_path }}/bin/openstack service list -f json
|
||||
register: service_list_output
|
||||
changed_when: false
|
||||
|
||||
- block:
|
||||
- name: Set default value for expected resources
|
||||
set_fact:
|
||||
tenks_expected_resources: []
|
||||
@ -34,6 +20,20 @@
|
||||
loop_control:
|
||||
loop_var: spec
|
||||
|
||||
- block:
|
||||
- name: Check that OpenStack credentials exist in the environment
|
||||
fail:
|
||||
msg: >
|
||||
$OS_USERNAME was not found in the environment. Ensure the OpenStack
|
||||
credentials exist in your environment, perhaps by sourcing your RC file.
|
||||
when: not lookup('env', 'OS_USERNAME')
|
||||
|
||||
- name: Gather list of OpenStack services
|
||||
command: >-
|
||||
{{ virtualenv_path }}/bin/openstack service list -f json
|
||||
register: service_list_output
|
||||
changed_when: false
|
||||
|
||||
- name: Include the wait-for-resources role
|
||||
include_role:
|
||||
name: wait-for-resources
|
||||
@ -44,3 +44,4 @@
|
||||
{{ python_upper_constraints_url }}
|
||||
# Only attempt to wait for resources when the placement service is running
|
||||
when: service_list_output.stdout | from_json | selectattr('Type', 'equalto', 'placement') | list | length >= 1
|
||||
when: tenks_expected_resources | length > 0
|
||||
|
@ -1,4 +1,11 @@
|
||||
---
|
||||
- name: Check that OpenStack credentials exist in the environment
|
||||
fail:
|
||||
msg: >
|
||||
$OS_USERNAME was not found in the environment. Ensure the OpenStack
|
||||
credentials exist in your environment, perhaps by sourcing your RC file.
|
||||
when: not lookup('env', 'OS_USERNAME')
|
||||
|
||||
# This is useful to get a uniquely generated temporary path.
|
||||
- name: Create temporary file for pip requirements
|
||||
tempfile:
|
||||
|
@ -9,7 +9,7 @@
|
||||
- name: Deploy tenks cluster
|
||||
shell:
|
||||
cmd: >-
|
||||
{{ ansible_playbook_bin }} -vvv --skip-tags openstack
|
||||
{{ ansible_playbook_bin }} -vvv
|
||||
--inventory ansible/inventory
|
||||
--extra-vars=@{{ tenks_overrides_path }}
|
||||
ansible/deploy.yml > {{ logs_dir }}/ansible/tenks-deploy
|
||||
@ -25,7 +25,7 @@
|
||||
- name: Teardown tenks cluster
|
||||
shell:
|
||||
cmd: >-
|
||||
{{ ansible_playbook_bin }} -vvv --skip-tags openstack
|
||||
{{ ansible_playbook_bin }} -vvv
|
||||
--inventory ansible/inventory
|
||||
--extra-vars=@{{ tenks_overrides_path }}
|
||||
ansible/teardown.yml > {{ logs_dir }}/ansible/tenks-teardown
|
||||
|
@ -17,13 +17,8 @@ node_types:
|
||||
specs:
|
||||
- type: type0
|
||||
count: 2
|
||||
ironic_config:
|
||||
resource_class: test-rc
|
||||
network_interface: flat
|
||||
|
||||
nova_flavors:
|
||||
- resource_class: test-rc
|
||||
node_type: type0
|
||||
nova_flavors: []
|
||||
|
||||
physnet_mappings:
|
||||
physnet1: breth1
|
||||
|
Loading…
x
Reference in New Issue
Block a user