[doc] Update rule engine document
This commit is contained in:
BIN
doc/source/images/rules_engine_class_model.png
Normal file
BIN
doc/source/images/rules_engine_class_model.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.6 KiB |
23
doc/source/images/src/rules_engine_class_model.txt
Normal file
23
doc/source/images/src/rules_engine_class_model.txt
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
@startuml
|
||||||
|
|
||||||
|
package "common.py" {
|
||||||
|
class "Inspection" {
|
||||||
|
}
|
||||||
|
class "Issue" {
|
||||||
|
}
|
||||||
|
class "Mark" {
|
||||||
|
}
|
||||||
|
class "Error" {
|
||||||
|
}
|
||||||
|
class "Version" {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
package "model.py" {
|
||||||
|
class "Model" {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Inspection --|> Issue
|
||||||
|
|
||||||
|
@enduml
|
||||||
@@ -32,12 +32,12 @@ Rule-based inspection
|
|||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
All rule-based inspections are using pre-defined actions written in python,
|
All rule-based inspections are using pre-defined actions written in python,
|
||||||
currently they are defined in "steps.py" file in the directory:
|
currently they are defined in "steps.py" file in the directory:
|
||||||
``ostack_validator/inspections/lettuce``. They are based on lettuce framework -
|
``ostack_validator/inspections/lettuce``. They are based on lettuce framework -
|
||||||
bdd framework for python.
|
bdd framework for python.
|
||||||
|
|
||||||
Store, extend and reuse rules
|
Store and reuse rules
|
||||||
-----------------------------
|
---------------------
|
||||||
|
|
||||||
First version of Rubick project stores rules to text files and loads them to
|
First version of Rubick project stores rules to text files and loads them to
|
||||||
memory at runtime. You can add your own rules to the set using web UI, and those
|
memory at runtime. You can add your own rules to the set using web UI, and those
|
||||||
@@ -49,14 +49,17 @@ will also support migrating existing rule set to the database.
|
|||||||
You can store your rules wherever you want and add it through the UI or simply
|
You can store your rules wherever you want and add it through the UI or simply
|
||||||
by putting them in text files in directory
|
by putting them in text files in directory
|
||||||
``ostack_validator/inspections/lettuce``.
|
``ostack_validator/inspections/lettuce``.
|
||||||
Rules file must have name in the following format::
|
Rules file must have name in the following format::
|
||||||
|
|
||||||
|
\*.feature
|
||||||
|
|
||||||
\*.feature.
|
|
||||||
|
|
||||||
The main requirement is that all rule conditions and actions in those files must
|
The main requirement is that all rule conditions and actions in those files must
|
||||||
be written in accordance with code of rule steps in
|
be written in accordance with code of rule steps in
|
||||||
``ostack-validator/inspections/lettuce/steps.py``.
|
``ostack-validator/inspections/lettuce/steps.py``.
|
||||||
|
|
||||||
|
Extending rules
|
||||||
|
---------------
|
||||||
|
|
||||||
Also you can extend rules definition by adding your own steps to steps.py. As
|
Also you can extend rules definition by adding your own steps to steps.py. As
|
||||||
an example::
|
an example::
|
||||||
|
|
||||||
@@ -66,7 +69,7 @@ an example::
|
|||||||
name = subst(name)
|
name = subst(name)
|
||||||
value = subst(value)
|
value = subst(value)
|
||||||
|
|
||||||
for nova in [c for c in world.openstack.components if
|
for nova in [c for c in world.openstack.components if
|
||||||
c.name.startswith('nova')]:
|
c.name.startswith('nova')]:
|
||||||
if not nova.config[name] == value:
|
if not nova.config[name] == value:
|
||||||
stop()
|
stop()
|
||||||
@@ -75,15 +78,14 @@ New methods can use 2 classes from the inspections framework:
|
|||||||
``ostack_validator/model.py`` and ``ostack_validator/common.py``. There you can
|
``ostack_validator/model.py`` and ``ostack_validator/common.py``. There you can
|
||||||
find many adapters to OpenStack services configuration data and all additional
|
find many adapters to OpenStack services configuration data and all additional
|
||||||
information collected from OpenStack nodes. After that you can use you brand
|
information collected from OpenStack nodes. After that you can use you brand
|
||||||
new rule in the scenarios as described above.
|
new rule in the scenarios as described above.
|
||||||
|
|
||||||
In ``common.py`` you can find ``Inspection``, ``Issue``, ``Mark``, ``Error`` and
|
In module ``ostack_validator/common.py`` you can find ``Inspection``, ``Issue``,
|
||||||
``Version`` classes for your convenience in rule defining. ``Model.py`` contains
|
``Mark``, ``Error`` and ``Version`` classes for your convenience in rule
|
||||||
Openstack model based on configuration schemas.
|
defining. Module ``model.py`` contains Openstack model based on configuration
|
||||||
|
schemas.
|
||||||
|
|
||||||
putting it in directory ostack_validator/inspections/lettuce with name like
|
.. image:: image/rules_engine_class_model.png
|
||||||
this: *.feature. The main requirement is that all you actions in those files
|
|
||||||
must be written according to the rules in steps.py.
|
|
||||||
|
|
||||||
Default rule sets
|
Default rule sets
|
||||||
-----------------
|
-----------------
|
||||||
|
|||||||
Reference in New Issue
Block a user