Merge "Fix deploy and teardown without node enrolment"
This commit is contained in:
commit
48b4ef0353
|
@ -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,38 +1,38 @@
|
|||
---
|
||||
- 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: Set default value for expected resources
|
||||
set_fact:
|
||||
tenks_expected_resources: []
|
||||
|
||||
- name: Gather list of OpenStack services
|
||||
command: >-
|
||||
{{ virtualenv_path }}/bin/openstack service list -f json
|
||||
register: service_list_output
|
||||
changed_when: false
|
||||
- name: Build list of expected resources
|
||||
# takes the form: [{ resource_class: CUSTOM_TEST_RC, amount: 2, traits: [] }, ]
|
||||
vars:
|
||||
resource:
|
||||
amount: "{{ spec.count | int }}" # this gets converted back to a string
|
||||
resource_class: "{{ 'CUSTOM_' ~ spec.ironic_config.resource_class | upper | replace('-', '_') }}"
|
||||
traits: "{{ spec.ironic_config.traits | default([])}}"
|
||||
set_fact:
|
||||
tenks_expected_resources: >-
|
||||
{{ tenks_expected_resources + [resource] }}
|
||||
loop: "{{ specs }}"
|
||||
when: "'ironic_config' in spec"
|
||||
loop_control:
|
||||
loop_var: spec
|
||||
|
||||
- block:
|
||||
- name: Set default value for expected resources
|
||||
set_fact:
|
||||
tenks_expected_resources: []
|
||||
- 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: Build list of expected resources
|
||||
# takes the form: [{ resource_class: CUSTOM_TEST_RC, amount: 2, traits: [] }, ]
|
||||
vars:
|
||||
resource:
|
||||
amount: "{{ spec.count | int }}" # this gets converted back to a string
|
||||
resource_class: "{{ 'CUSTOM_' ~ spec.ironic_config.resource_class | upper | replace('-', '_') }}"
|
||||
traits: "{{ spec.ironic_config.traits | default([])}}"
|
||||
set_fact:
|
||||
tenks_expected_resources: >-
|
||||
{{ tenks_expected_resources + [resource] }}
|
||||
loop: "{{ specs }}"
|
||||
when: "'ironic_config' in spec"
|
||||
loop_control:
|
||||
loop_var: spec
|
||||
- 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:
|
||||
|
@ -42,5 +42,6 @@
|
|||
wait_for_resources_venv: "{{ virtualenv_path }}"
|
||||
wait_for_resources_python_upper_constraints_url: >-
|
||||
{{ 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
|
||||
# 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…
Reference in New Issue