Add default-node-count role

This patch adds this new role created from:
- validations/default-node-count.yaml

Change-Id: I5d032004585285764b1e6585da03145b3d312d53
Implements: blueprint validation-framework
Signed-off-by: Gael Chamoulaud <gchamoul@redhat.com>
This commit is contained in:
Gael Chamoulaud 2019-02-25 15:08:38 +01:00
parent 6ecfb48553
commit e3be61e336
4 changed files with 86 additions and 0 deletions

View File

@ -0,0 +1,12 @@
---
- hosts: undercloud
vars:
metadata:
name: Verify hypervisor statistics
description: >
This validation checks that the nodes and hypervisor statistics
add up.
groups:
- pre-deployment
roles:
- default-node-count

View File

@ -0,0 +1,27 @@
galaxy_info:
author: TripleO Validations Team
company: Red Hat
license: Apache
min_ansible_version: 2.4
platforms:
- name: CentOS
versions:
- 7
- name: RHEL
versions:
- 7
categories:
- cloud
- baremetal
- system
galaxy_tags: []
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.
dependencies: []

View File

@ -0,0 +1,39 @@
---
- name: Retrieve the hypervisor statistics
set_fact:
statistics: "{{ lookup('nova_hypervisor_statistics', wantlist=True) }}"
- name: Get default role counts
set_fact:
roles_info: "{{ lookup('roles_info', wantlist=True) }}"
- name: Set requested count
set_fact:
requested_count: "{{ roles_info|sum(attribute='count') }}"
- name: Get associated nodes
set_fact:
associated_nodes: "{{ lookup('ironic_nodes', 'associated', wantlist=True) }}"
- name: Get available nodes
set_fact:
available_nodes: "{{ lookup('ironic_nodes', 'provision_state', ['available'], wantlist=True) }}"
- name: Set count of available nodes
set_fact:
available_count: "{{ ((associated_nodes|length) + (available_nodes|length))|int }}"
- name: Fail when requested is more than available
fail:
msg: >
Not enough baremetal nodes - available: {{ available_count }},
requested: {{ requested_count }}
failed_when: requested_count|int > available_count|int
- name: Fail when hypervisor count is less than available count
fail:
msg: >
Only {{ statistics.count }} nodes are exposed to Nova of
{{ available_count }} requests. Check that enough nodes are
in 'available' state with maintenance mode off.
failed_when: statistics.count < available_count|int

View File

@ -0,0 +1,8 @@
---
metadata:
name: Verify hypervisor statistics
description: >
This validation checks that the nodes and hypervisor statistics
add up.
groups:
- pre-deployment