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
This commit is contained in:
parent
bdbd55a324
commit
7456102348
|
@ -53,3 +53,4 @@ ChangeLog
|
||||||
*~
|
*~
|
||||||
.*.swp
|
.*.swp
|
||||||
.*sw?
|
.*sw?
|
||||||
|
doc/source/validations-*.rst
|
||||||
|
|
10
README.rst
10
README.rst
|
@ -37,8 +37,7 @@ Prep
|
||||||
Validations that are run on a fresh machine *before* the undercloud is
|
Validations that are run on a fresh machine *before* the undercloud is
|
||||||
installed.
|
installed.
|
||||||
|
|
||||||
- `undercloud-ram.yaml`: Verify the undercloud fits the RAM requirements
|
.. include:: validations-prep.rst
|
||||||
- `undercloud-cpu.yaml`: Verify undercloud fits the CPU core requirements
|
|
||||||
|
|
||||||
Pre Introspection
|
Pre Introspection
|
||||||
~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~
|
||||||
|
@ -46,19 +45,22 @@ Pre Introspection
|
||||||
Validations that are run when the undercloud is ready to perform hardware
|
Validations that are run when the undercloud is ready to perform hardware
|
||||||
introspection.
|
introspection.
|
||||||
|
|
||||||
- `undercloud-ram.yaml`: Verify the undercloud fits the RAM requirements
|
.. include:: validations-pre-introspection.rst
|
||||||
- `undercloud-cpu.yaml`: Verify undercloud fits the CPU core requirements
|
|
||||||
|
|
||||||
Pre Deployment
|
Pre Deployment
|
||||||
~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Validation that are run right before deploying the overcloud.
|
Validation that are run right before deploying the overcloud.
|
||||||
|
|
||||||
|
.. include:: validations-pre-deployment.rst
|
||||||
|
|
||||||
Post Deployment
|
Post Deployment
|
||||||
~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Validations that are run after the overcloud deployment finished.
|
Validations that are run after the overcloud deployment finished.
|
||||||
|
|
||||||
|
.. include:: validations-post-deployment.rst
|
||||||
|
|
||||||
|
|
||||||
Writing Validations
|
Writing Validations
|
||||||
-------------------
|
-------------------
|
||||||
|
|
|
@ -23,6 +23,7 @@ sys.path.insert(0, os.path.abspath('../..'))
|
||||||
extensions = [
|
extensions = [
|
||||||
'sphinx.ext.autodoc',
|
'sphinx.ext.autodoc',
|
||||||
#'sphinx.ext.intersphinx',
|
#'sphinx.ext.intersphinx',
|
||||||
|
'generate_validation_list',
|
||||||
'oslosphinx'
|
'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…
Reference in New Issue