Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .dev/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ The modules contained in this repository are the following:
* **ddsrouter_docs** (hosted in directory `docs`)
This package contains the user documentation built with sphinx.

* **ddsrouter_yaml_validator** This is an application used for validating DDS Router `yaml` configuration files.

This is the dependency graph of the packages:

```sh
Expand Down
4 changes: 1 addition & 3 deletions .github/docker/ddsrouter/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ RUN pip3 install \
colcon-mixin \
lxml \
vcstool \
GitPython \
pyyaml \
jsonschema
GitPython

WORKDIR /ddsrouter

Expand Down
37 changes: 0 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ environment are provided below. These installation instructions are a summarized
* [CMake](https://cmake.org/), [g++](https://gcc.gnu.org/), [pip](https://pypi.org/project/pip/), [wget](https://www.gnu.org/software/wget/) and [git](https://git-scm.com/)
* [Colcon](https://colcon.readthedocs.io/en/released/) [optional, not required for CMake-only installation]
* [Gtest](https://github.com/google/googletest) [for test only]
* [PyYAML](https://pyyaml.org/) [for YAML Validator only]
* [jsonschema](https://python-jsonschema.readthedocs.io/) [for YAML Validator only]

#### CMake, g++, pip, wget and git

Expand Down Expand Up @@ -98,28 +96,6 @@ compile tests. It is possible to activate them with the opportune [CMake options
[CMake](https://cmake.org/). For a detailed description of the Gtest installation process, please refer to the
[Gtest Installation Guide](https://github.com/google/googletest).

#### PyYAML

[PyYAML](https://pyyaml.org/) is a YAML parser and emitter for Python.
It is used by the DDS-Router YAML Validator for loading the content of configuration files.
Install `pyyaml` by executing the following command:

```bash
pip3 install -U pyyaml
```

#### jsonschema

[jsonschema](https://python-jsonschema.readthedocs.io/) is an implementation of the JSON Schema specification for
Python.
It is used by the DDS-Router YAML Validator for performing validation of configuration files against a given JSON
schema.
Install `jsonschema` by executing the following command:

```bash
pip3 install -U jsonschema
```

### Dependencies

#### Asio and TinyXML2 libraries
Expand Down Expand Up @@ -189,7 +165,6 @@ These packages are:
* `ddsrouter_yaml`: library to configure a DDS Router from a YAML.
* `ddsrouter_tool`: application to execute a DDS Router from a YAML configuration file.
* `ddsrouter_docs`: package to generate the DDS Router documentation using sphinx.
* `ddsrouter_yaml_validator`: application to validate DDS Router YAML configuration files.

> *NOTE:* Those packages could be installed and use independently (according with each package dependency).
In order to compile only a package and its dependencies, use the colcon argument `--packages-up-to <package>`.
Expand All @@ -209,18 +184,6 @@ source <install-path>/setup.bash
./<install-path>/ddsrouter_tool/bin/ddsrouter
```

### Validate a configuration file

To validate a *DDS Router* YAML configuration file, execute the following commands:

```bash
# Source installation
source <install-path>/setup.bash

# Validate a DDS Router configuration file
ddsrouter_yaml_validator --config-file ddsrouter-config.yaml
```

### Testing

By default, *DDS Router* does not compile tests. However, they can be activated by downloading and installing
Expand Down
97 changes: 79 additions & 18 deletions ddsrouter_yaml/src/cpp/YamlReader_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include <set>

#include <ddspipe_participants/configuration/DiscoveryServerParticipantConfiguration.hpp>
#include <ddspipe_participants/configuration/EchoParticipantConfiguration.hpp>
#include <ddspipe_participants/configuration/InitialPeersParticipantConfiguration.hpp>
Expand All @@ -23,6 +25,7 @@
#include <ddspipe_yaml/Yaml.hpp>
#include <ddspipe_yaml/YamlManager.hpp>
#include <ddspipe_yaml/YamlReader.hpp>
#include <ddspipe_yaml/YamlValidator.hpp>

#include <ddspipe_core/configuration/DdsPipeConfiguration.hpp>
#include <ddspipe_core/configuration/MonitorConfiguration.hpp>
Expand All @@ -34,6 +37,20 @@ namespace eprosima {
namespace ddspipe {
namespace yaml {

template <>
bool YamlValidator::validate<core::MonitorConfiguration>(
const Yaml& yml,
const YamlReaderVersion& /* version */)
{
// The method is rewritten to provide a specific validation of the DDS Router's MonitorConfiguration:
// i.e. the DDS Router's MonitorConfiguration doesn't have a status.
static const std::set<TagType> tags{
MONITOR_DOMAIN_TAG,
MONITOR_TOPICS_TAG};

return YamlValidator::validate_tags(yml, tags);
}

template <>
void YamlReader::fill(
ddsrouter::core::SpecsConfiguration& object,
Expand All @@ -57,7 +74,7 @@ void YamlReader::fill(
// Optional Topic QoS
if (is_tag_present(yml, SPECS_QOS_TAG))
{
fill<core::types::TopicQoS>(object.topic_qos, get_value_in_tag(yml, SPECS_QOS_TAG), version);
object.topic_qos = YamlReader::get<core::types::TopicQoS>(yml, SPECS_QOS_TAG, version);
core::types::TopicQoS::default_topic_qos.set_value(object.topic_qos);
}

Expand Down Expand Up @@ -95,6 +112,34 @@ void YamlReader::fill(
}
}

template <>
bool YamlValidator::validate<ddsrouter::core::SpecsConfiguration>(
const Yaml& yml,
const YamlReaderVersion& /* version */)
{
static const std::set<TagType> tags{
NUMBER_THREADS_TAG,
REMOVE_UNUSED_ENTITIES_TAG,
SPECS_QOS_TAG,
DISCOVERY_TRIGGER_TAG,
LOG_CONFIGURATION_TAG,
MONITOR_TAG};

return YamlValidator::validate_tags(yml, tags);
}

template <>
ddsrouter::core::SpecsConfiguration YamlReader::get<ddsrouter::core::SpecsConfiguration>(
const Yaml& yml,
const YamlReaderVersion version)
{
YamlValidator::validate<ddsrouter::core::SpecsConfiguration>(yml, version);

ddsrouter::core::SpecsConfiguration object;
fill<ddsrouter::core::SpecsConfiguration>(object, yml, version);
return object;
}

template <>
ddsrouter::core::types::ParticipantKind YamlReader::get(
const Yaml& yml,
Expand Down Expand Up @@ -190,21 +235,14 @@ void YamlReader::fill(
// Get optional routes
if (YamlReader::is_tag_present(yml, ROUTES_TAG))
{
YamlReader::fill<core::RoutesConfiguration>(
object.routes,
YamlReader::get_value_in_tag(yml, ROUTES_TAG),
version);
object.routes = YamlReader::get<core::RoutesConfiguration>(yml, ROUTES_TAG, version);
}

/////
// Get optional topic routes
if (YamlReader::is_tag_present(yml, TOPIC_ROUTES_TAG))
{
// get list, and parse each element as above
YamlReader::fill<core::TopicRoutesConfiguration>(
object.topic_routes,
YamlReader::get_value_in_tag(yml, TOPIC_ROUTES_TAG),
version);
object.topic_routes = YamlReader::get<core::TopicRoutesConfiguration>(yml, TOPIC_ROUTES_TAG, version);
}

/////
Expand All @@ -221,6 +259,9 @@ core::DdsPipeConfiguration YamlReader::get<core::DdsPipeConfiguration>(
const Yaml& yml,
const YamlReaderVersion version)
{
// The DdsPipeConfiguration's fields don't correspond to a YAML section and, therefore, can't be validated.
// Instead, they are validated in the methods above (most of them in the DdsRouterConfiguration).

core::DdsPipeConfiguration object;
fill<core::DdsPipeConfiguration>(object, yml, version);
return object;
Expand Down Expand Up @@ -250,6 +291,7 @@ void YamlReader::fill(
{
ddsrouter::core::types::ParticipantKind kind =
YamlReader::get<ddsrouter::core::types::ParticipantKind>(conf, PARTICIPANT_KIND_TAG, version);

object.participants_configurations.insert(
{
kind,
Expand All @@ -262,10 +304,9 @@ void YamlReader::fill(
// Get optional specs configuration
if (YamlReader::is_tag_present(yml, SPECS_TAG))
{
YamlReader::fill<ddsrouter::core::SpecsConfiguration>(
object.advanced_options,
YamlReader::get_value_in_tag(yml, SPECS_TAG),
version);
object.advanced_options = get<ddsrouter::core::SpecsConfiguration>(YamlReader::get_value_in_tag(yml,
SPECS_TAG),
version);
}

// DDS Pipe Configuration
Expand All @@ -286,18 +327,38 @@ void YamlReader::fill(
// Get optional xml configuration
if (YamlReader::is_tag_present(yml, XML_TAG))
{
YamlReader::fill<participants::XmlHandlerConfiguration>(
object.xml_configuration,
YamlReader::get_value_in_tag(yml, XML_TAG),
version);
object.xml_configuration = YamlReader::get<participants::XmlHandlerConfiguration>(yml, XML_TAG, version);
}
}

template <>
DDSPIPE_YAML_DllAPI
bool YamlValidator::validate<ddsrouter::core::DdsRouterConfiguration>(
const Yaml& yml,
const YamlReaderVersion& /* version */)
{
static const std::set<TagType> tags{
VERSION_TAG,
COLLECTION_PARTICIPANTS_TAG,
XML_TAG,
ALLOWLIST_TAG,
BLOCKLIST_TAG,
BUILTIN_TAG,
ROUTES_TAG,
TOPIC_ROUTES_TAG,
TOPICS_TAG,
SPECS_TAG};

return YamlValidator::validate_tags(yml, tags);
}

template <>
ddsrouter::core::DdsRouterConfiguration YamlReader::get<ddsrouter::core::DdsRouterConfiguration>(
const Yaml& yml,
const YamlReaderVersion version)
{
YamlValidator::validate<ddsrouter::core::DdsRouterConfiguration>(yml, version);

ddsrouter::core::DdsRouterConfiguration object;
fill<ddsrouter::core::DdsRouterConfiguration>(object, yml, version);
return object;
Expand Down
1 change: 0 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
Participant </rst/user_manual/participants/participant>
/rst/user_manual/configuration
/rst/user_manual/wan_configuration
/rst/user_manual/yaml_validator
/rst/user_manual/user_manual_glossary


Expand Down
36 changes: 0 additions & 36 deletions docs/rst/developer_manual/installation/sources/linux.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ installed in the system:
* :ref:`cmake_gcc_pip_wget_git_sl`
* :ref:`colcon_install` [optional]
* :ref:`gtest_sl` [for test only]
* :ref:`py_yaml` [for YAML Validator only]
* :ref:`json_schema` [for YAML Validator only]


.. _cmake_gcc_pip_wget_git_sl:
Expand Down Expand Up @@ -104,40 +102,6 @@ Use the following command to download the code:

git clone --branch release-1.12.0 https://github.com/google/googletest src/googletest-distribution


.. _py_yaml:

PyYAML
^^^^^^

`PyYAML <https://pyyaml.org/>`_ is a YAML parser and emitter for Python.

It is used by the DDS-Router :ref:`yaml_validator` for loading the content of configuration files.

Install ``pyyaml`` by executing the following command:

.. code-block:: bash

pip3 install -U pyyaml


.. _json_schema:

jsonschema
^^^^^^^^^^

`jsonschema <https://python-jsonschema.readthedocs.io/>`_ is an implementation of the JSON Schema specification for
Python.

It is used by the DDS-Router :ref:`yaml_validator` for performing validation of configuration files against a given
JSON schema.

Install ``jsonschema`` by executing the following command:

.. code-block:: bash

pip3 install -U jsonschema

.. _dependencies:

Dependencies
Expand Down
36 changes: 0 additions & 36 deletions docs/rst/developer_manual/installation/sources/windows.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ installed in the system:
* :ref:`windows_sources_cmake_pip3_wget_git`
* :ref:`windows_sources_colcon_install` [optional]
* :ref:`windows_sources_gtest` [for test only]
* :ref:`windows_py_yaml` [for YAML Validator only]
* :ref:`windows_json_schema` [for YAML Validator only]

.. _windows_sources_visual_studio:

Expand Down Expand Up @@ -127,40 +125,6 @@ or refer to the
`Gtest Installation Guide <https://github.com/google/googletest>`_ for a detailed description of the Gtest installation
process.


.. _windows_py_yaml:

PyYAML
^^^^^^

`PyYAML <https://pyyaml.org/>`_ is a YAML parser and emitter for Python.

It is used by the DDS-Router :ref:`yaml_validator` for loading the content of configuration files.

Install ``pyyaml`` by executing the following command:

.. code-block:: bash

pip3 install -U pyyaml


.. _windows_json_schema:

jsonschema
^^^^^^^^^^

`jsonschema <https://python-jsonschema.readthedocs.io/>`_ is an implementation of the JSON Schema specification for
Python.

It is used by the DDS-Router :ref:`yaml_validator` for performing validation of configuration files against a given
JSON schema.

Install ``jsonschema`` by executing the following command:

.. code-block:: bash

pip3 install -U jsonschema

.. _windows_sources_dependencies:

Dependencies
Expand Down
2 changes: 1 addition & 1 deletion docs/rst/notes/previous_versions/v0.4.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Version v0.4.0

This release includes the following **features**:

* New :ref:`yaml_validator`, a simple tool to assert the correctness of DDS Router configuration files.
* New *Yaml Validator*, a simple tool to assert the correctness of DDS Router configuration files.
* New :ref:`user_manual_user_interface_version_argument` to show the current version of DDS Router.

This release includes the following **improvementes**:
Expand Down
2 changes: 0 additions & 2 deletions docs/rst/spelling_wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ gMock
Gtest
guid
IPv
jsonschema
kubernetes
localhost
metatraffic
Expand All @@ -41,7 +40,6 @@ Requiredness
runtime
scalable
utils
validator
Vulcanexus
wget
yaml
Loading
Loading