MaatDex
Overview
MaatDex is a Python application designed to fetch and process network topology data from Maat. The application supports saving the fetched data in JSON or CSV format.
Installation
-
Clone the repository:
-
Create a virtual environment and activate it:
-
Install the required dependencies:
Configuration
The configuration file /config.conf contains settings for the API, output paths, and logging. Update this file with the appropriate values for your environment.
Usage
To fetch and process network core link data, run the fetch_data.py script with the required arguments:
Arguments
Required Arguments:
-a,--address: The address of the Maat API.-o,--output: The path to the output file.-f,--format: The output format (json or csv).
Optional Arguments:
--modified: Modifies coordinates of overlapping nodes--only_nodes: Fetches only nodes with geo-coordinates--nmp_database: Enables fetching traffic metrics for NMP (for example VictoriaMetrics) fordevifand enriches output within_bitsandout_bits. Requiresnmp_databasesection inconfig.conf.--nmp_topology: Saves an additional NMP topology file.--cat_links: Category name for links.--cat_sap: Category name for service access points.--cat_sap_interfaces: Category name for service access point interfaces.--cat_interfaces: Category name for interfaces.--cat_nodes: Category name for nodes.--cat_sites: Category name for sites.
Usage Examples
Basic topology fetching in JSON format:
Fetching with coordinate modification:
Fetching only GPS nodes:
Saving in CSV format with custom categories:
python scripts/fetch_data.py -a https://maat.example.com/api -o data.csv -f csv --cat_nodes custom_nodes --cat_links custom_links
Saving Network Map Panel topology:
python scripts/fetch_data.py -a https://maat.example.com/api -f json -o export_data/network_map_panel/topology_for_nmp.json --nmp_topology
Saving Network Map Panel measurements to json format:
python scripts/fetch_data.py -a https://maat.example.com/api -f json -o export_data/network_map_panel/database_for_nmp.json --nmp_database
Application Architecture
Directory Structure
project/
├── api/
│ └── api_client.py # API client for Maat communication
├── config/
│ ├── config_loader.py # Configuration loading
│ └── log_config.py # Logging configuration
├── scripts/
│ ├── fetch_data.py # Main data fetching script
│ ├── process_data.py # Data processing and normalization
│ └── modify_data.py # Data modification
├── utils/
│ ├── file_utils.py # File saving utilities
│ └── metrics_client.py # NMP/VictoriaMetrics client
├── export_data/ # Directory for exported data
│ └── additional_topologies/ # Generated city-based topologies
├── doc/
│ └── images/
│ └── mapgl_data_diagram.png # Data model diagram used in README
├── config.conf # Configuration file
├── requirements.txt # Python dependencies
└── README.md
Modules
api/api_client.pyHandles Maat API communication, connection management, and error handling.scripts/fetch_data.pymain(): Orchestrates fetching, processing, enrichment, and saving.parse_args(): Parses CLI arguments including--nmp_databaseand--nmp_topology.scripts/process_data.pyfetch_network_core_link(): Fetches network link datafetch_nodes_with_gps(): Fetches nodes with GPS coordinatesmodify_coordinates(): Modifies coordinates of overlapping elementsnormalize_polish_chars(): Normalizes Polish diacritical charactersscripts/modify_data.pychecking_vertexb(): Verifies and corrects vertex datachecking_vertexb_for_cities(): Checks vertex data for city groupingutils/file_utils.pysave_as_json(): Saves data in JSON formatsave_as_csv(): Saves data in CSV formatgroup_connections(): Groups connections by citiessave_grouped_topologies(): Saves grouped topologiesenrich_with_traffic_data(): Enriches items with NMP metrics (in_bits,out_bits) bydevifutils/metrics_client.pyclass MetricsClient: VictoriaMetrics client for NMP integrationquery_metric(): Executes PromQL query for a given metric anddevifget_traffic_data(): Returns currentin_bits/out_bitsfor an interfaceconfig/config_loader.pyLoads application configuration (includesnmp_databasesection)config/log_config.pyConfigures application logging
Output Formats
JSON Format
Data is saved as an array of objects with the following fields:
{
"vertexA": "device-1",
"vertexB": "device-2",
"edgeId": "12345678-1234-1234-abcd-abc123def456",
"lon": 16.92516810000000,
"lat": 52.40637400000000,
"devif": "device-1 et-0/0/0",
"bandwidth": 100000000000,
"thickness": 5,
"description": "Network core link",
"city": "Poznań",
"link": "device-1 <-> device-2",
"dst_lng": 19.455020577406692,
"dst_lat": 51.75439257919774
}
CSV Format
CSV columns correspond to JSON fields, with comma separator.
City-Grouped Topologies
The application automatically generates separate JSON files for each city in the export_data/additional_topologies/ directory.
Special Features
- Coordinate Modification: The
--modifiedoption allows automatic separation of overlapping nodes by slightly shifting their geographical coordinates. - Polish Character Normalization: Automatic conversion of Polish diacritical characters to ASCII equivalents for better compatibility.
- City-Based Grouping: Automatic grouping of connections by cities and generation of separate topology files.
Logging
The application uses a logging system with configurable levels. Logs include:
- Data fetching progress information
- API connection errors
- Data issue warnings
- Processed record statistics
Maat Data Model for MaatDex
This section describes the required data model that must exist in the Maat application for proper operation of MaatDex. This model is utilized by MaatDex to export the necessary data for creating network topology visualizations in the Mapgl plugin. The model defines the structure of network elements, their relationships, and the specific requirements for data extraction and processing.

- Link Category (Service)
- Type: Service
- Category:
network.core.link - Description: Main object representing network connection between devices
- SAP Structure: Link MUST contain exactly 2 SAPs in specific order:
serviceRelationship[0]= SAP1 (first geographical point)serviceRelationship[1]= SAP2 (second geographical point)
- Example required relationship:
relationshipType = "ref:network.core.sap" - Order requirement: For link "Poznan - Warszawa":
- SAP1 → device in Poznan
- SAP2 → device in Warszawa
- Service Access Points SAP (Service)
- Type: Service
- Category:
network.core.sap - Order: Maintained according to geographical order of the link
- Example required relationship:
relationshipType = "bref:interface" - Relationship: Each SAP has
resourceRelationshipto interface - Physical Interfaces (Resource)
- Type: Resource
- Category:
interface - @type:
PhysicalResource - Example required relationship:
relationshipType = "bref:device.router" - Relationship with SAP: Each SAP has backward reference to interface
- Speed characteristics:
resourceCharacteristic[name="speed"]in format"100G", "400G", "10G"ONLY format with "G" (not mb, gb, GB) - Logical/Aggregated Interfaces (Resource)
- Type: Resource
- Category:
interface - @type:
LogicalResource - Example required relationship:
relationshipType = "bref:device.router" - Special relationships: Aggregated interface has
resourceRelationshipto twoPhysicalResource - Bandwidth calculation: Sum of speeds of two physical interfaces
- Example:
- Network Devices (Resource)
- Type: Resource
- Category:
device.router - Example required relationship:
relationshipType = "bref:site" - Relationship with interface: Each interface has reference to device
- Geographical relationship: Each device MUST have reference to location
- Site (Resource)
- Type: Resource
- Category:
site - Relationship with device: Each device has reference to location
- Required characteristics:
gps- coordinates in format "latitude;longitude"city- city name
Required Relationships Map
- Link → SAP:
relationshipType = "ref:network.core.sap" - SAP → Interface:
relationshipType = "bref:interface" - Interface → Device:
relationshipType = "bref:device.router" - Device → Site:
relationshipType = "bref:site"
This model ensures full geographical consistency, correct bandwidth calculation for aggregated interfaces, and preservation of point order in network topology with clear definitions of required relationships.