Autogenerate the list of existing validations

Instead of having to manually update the README every time we add a new
validation or update the name of an existing one (potentially causing
merge conflicts on the way), this generates list of existing validations
from their metadata automatically.

So when we add a new validation, it will be added to the docs
automatically based on its name and groups.

Change-Id: Ib5d227d090624ff8844abb5e3fd53c002635705b
changes/78/352278/2
Tomas Sedovic 6 years ago
parent bdbd55a324
commit 7456102348
  1. 1
      .gitignore
  2. 10
      README.rst
  3. 1
      doc/source/conf.py
  4. 45
      generate_validation_list.py

1
.gitignore vendored

@ -53,3 +53,4 @@ ChangeLog
*~
.*.swp
.*sw?
doc/source/validations-*.rst

@ -37,8 +37,7 @@ Prep
Validations that are run on a fresh machine *before* the undercloud is
installed.
- `undercloud-ram.yaml`: Verify the undercloud fits the RAM requirements
- `undercloud-cpu.yaml`: Verify undercloud fits the CPU core requirements
.. include:: validations-prep.rst
Pre Introspection
~~~~~~~~~~~~~~~~~
@ -46,19 +45,22 @@ Pre Introspection
Validations that are run when the undercloud is ready to perform hardware
introspection.
- `undercloud-ram.yaml`: Verify the undercloud fits the RAM requirements
- `undercloud-cpu.yaml`: Verify undercloud fits the CPU core requirements
.. include:: validations-pre-introspection.rst
Pre Deployment
~~~~~~~~~~~~~~
Validation that are run right before deploying the overcloud.
.. include:: validations-pre-deployment.rst
Post Deployment
~~~~~~~~~~~~~~~
Validations that are run after the overcloud deployment finished.
.. include:: validations-post-deployment.rst
Writing Validations
-------------------

@ -23,6 +23,7 @@ sys.path.insert(0, os.path.abspath('../..'))
extensions = [
'sphinx.ext.autodoc',
#'sphinx.ext.intersphinx',
'generate_validation_list',
'oslosphinx'
]

@ -0,0 +1,45 @@
# -*- coding: utf-8 -*-
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from glob import glob
from os import path
import six
import yaml
def metadata(validation, metadata_name):
return validation['vars']['metadata'][metadata_name]
def setup(app):
# Seed it with the known groups:
groups = set(('prep', 'pre-introspection',
'pre-deployment', 'post-deployment'))
validations = {}
for validation_path in glob('validations/*.yaml'):
with open(validation_path) as f:
loaded_validation = yaml.safe_load(f.read())[0]
for group in metadata(loaded_validation, 'groups'):
groups.add(group)
validations[path.basename(validation_path)] = loaded_validation
for group in groups:
validations_in_group = [(filename, validation) for filename, validation
in six.iteritems(validations)
if group in metadata(validation, 'groups')]
entries = ["* ``{}``: {}".format(name, metadata(validation, 'name'))
for name, validation in sorted(validations_in_group)]
with open('doc/source/validations-{}.rst'.format(group), 'w') as f:
f.write("\n".join(entries))
Loading…
Cancel
Save