USDN vRouter-agent to execute order on each node
Project description
vRouter-agent
Overview
vrouter-agent is a custom pip module built by USDN to handle and execute transaction from customer portal to each node.
Requirements
- python >= 3.10
- vpp >= v20.06
- multichain > v2.3.1
- Fast API > v0.115
- FRR > v8.3
- vrouter > v1.0.6
- poetry > v1.6.1
Development
This project is managed by poetry. Use poetry to install and run script.
curl -sSL https://install.python-poetry.org | python3 -
poetry install
poetry run server
Deployment
Building RPM Package
To build an RPM package for AlmaLinux/RHEL deployment:
# Quick build (from project root)
./build-package.sh
# Or use the build system directly
./build/build.sh
The build system automatically:
- Creates a source tarball
- Builds the RPM package
- Handles Python 3.10+ requirements
- Sets up virtual environment for dependencies
- Configures systemd service integration
For detailed build documentation, see build/README.md.
Installation
# Install the RPM package
sudo dnf install ./dist/RPMS/noarch/vrouter-agent-*.rpm
# Enable and start the service
sudo systemctl enable vrouter-agent
sudo systemctl start vrouter-agent
Run vrouter-agent as a service
vRouter depends on different services. In order to run vrouter-agent, these services must be up and running:
- VPP
- vRouter
- multichaind@{{chain}}. Chain is what defined in the nodecontrol
- FRR
Create service file:
sudo nano /etc/systemd/system/vrouter_agent.service
[Unit]
Description=VRouter Agent Server - API for VRouter tunnel configuration and telemetry monitoring
Requires=multichaind@{{chain}}
After=network.target multichaind@{{chain}} vpp.service vrouter.service
[Service]
Type=simple
ExecStartPre=/usr/local/bin/poetry/bin/poetry install
ExecStart=/usr/local/bin/poetry/bin/poetry run server
Restart=on-failure
RestartSec=30
WorkingDirectory=/opt/vrouter-agent/bin
# Optional: Set environment variables for configuration
# Environment=VRouterAgentHost=0.0.0.0
# Environment=VRouterAgentPort=8000
# Environment=VRouterAgentLogLevel=INFO
# Environment=VRouterAgentLogFile=/var/log/vrouter-agent.log
[Install]
WantedBy=multi-user.target
Note: You can configure the service by:
- Setting environment variables in the service file (as shown above)
- Modifying the
ExecStartline to include command-line arguments:ExecStart=/usr/local/bin/poetry/bin/poetry run server --host 0.0.0.0 --port 9000 --log-level DEBUG
Enable service at boot and start service:
sudo systemctl enable vrouter-agent && sudo systemctl start vrouter-agent
Usage
Command Line Options
The vrouter-agent supports various command-line options for configuration:
usage: vrouter-agent [-h] [--version] [--host HOST] [--port PORT]
[--log-file LOG_FILE] [--log-level {DEBUG,INFO,WARNING,ERROR,CRITICAL}]
VRouter Agent Server - API for VRouter tunnel configuration and telemetry monitoring
options:
-h, --help show this help message and exit
--version, -v Show version and exit
--host HOST Host to bind to (default: 127.0.0.1)
--port PORT, -p PORT Port to bind to (default: 8000)
--log-file LOG_FILE, -l LOG_FILE
Log file path (default: /var/log/vrouter-agent.log)
--log-level {DEBUG,INFO,WARNING,ERROR,CRITICAL}
Log level (default: INFO)
Configuration Options
The vrouter-agent can be configured through:
- Command-line arguments (highest priority)
- Environment variables (medium priority)
- Default values (lowest priority)
Environment Variables
| Variable | Description | Default |
|---|---|---|
VRouterAgentHost |
Server host address | 127.0.0.1 |
VRouterAgentPort |
Server port number | 8000 |
VRouterAgentLogFile |
Log file path | /var/log/vrouter-agent.log |
VRouterAgentLogLevel |
Log level | INFO |
Examples
Basic Usage
# Run with default settings
vrouter-agent
# Show version
vrouter-agent --version
vrouter-agent -v
# Show help
vrouter-agent --help
vrouter-agent -h
Custom Configuration
# Run on specific host and port
vrouter-agent --host 0.0.0.0 --port 9000
# Enable debug logging with custom log file
vrouter-agent --log-level DEBUG --log-file /tmp/vrouter-debug.log
# Combine multiple options
vrouter-agent --host 192.168.1.100 --port 8080 --log-level WARNING --log-file /var/log/custom-vrouter.log
# Using short options
vrouter-agent -p 9000 -l /tmp/vrouter.log
Using Environment Variables
# Set environment variables
export VRouterAgentHost="0.0.0.0"
export VRouterAgentPort="9000"
export VRouterAgentLogLevel="DEBUG"
export VRouterAgentLogFile="/var/log/vrouter-debug.log"
# Run with environment configuration
vrouter-agent
# Override specific settings with command-line args
vrouter-agent --port 8080 # Uses env vars for other settings, but port 8080
Logging
The vrouter-agent uses structured logging with the following features:
- Dual output: Logs to both console (stdout) and file simultaneously
- Log rotation: Automatic log file rotation at 1MB with compression
- Configurable levels: DEBUG, INFO, WARNING, ERROR, CRITICAL
- Structured format: JSON-like format with timestamps, levels, and context
Log Levels
| Level | Description | When to Use |
|---|---|---|
DEBUG |
Detailed diagnostic information | Development and troubleshooting |
INFO |
General operational messages | Production monitoring (default) |
WARNING |
Warning messages for unusual situations | Production monitoring |
ERROR |
Error messages for handled failures | Production monitoring |
CRITICAL |
Critical errors that may cause shutdown | Production monitoring |
Log File Management
- Default location:
/var/log/vrouter-agent.log - Rotation: Automatic at 1MB file size
- Compression: Old logs are compressed as
.zipfiles - Retention: Managed by the logging system
- Permissions: Ensure the user running vrouter-agent has write access to the log directory
Run manually
/usr/local/bin/vrouter-agent
Troubleshooting
Common Issues
-
Permission denied for log file:
# Ensure log directory exists and has proper permissions sudo mkdir -p /var/log sudo chown $(whoami):$(whoami) /var/log/vrouter-agent.log # Or use a different log file location vrouter-agent --log-file /tmp/vrouter-agent.log
-
Port already in use:
# Check what's using the port sudo netstat -tulpn | grep :8000 # Use a different port vrouter-agent --port 8080
-
Service dependencies not running:
# Check required services status sudo systemctl status vpp sudo systemctl status vrouter sudo systemctl status multichaind@<chain-name> # Check logs for more details vrouter-agent --log-level DEBUG
-
Configuration issues:
# Verify configuration with debug logging vrouter-agent --log-level DEBUG --log-file /tmp/debug.log # Check environment variables env | grep VRouterAgent
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vrouter_agent-1.5.3.tar.gz.
File metadata
- Download URL: vrouter_agent-1.5.3.tar.gz
- Upload date:
- Size: 162.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.10.18 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
49b08a7c01814dfb05df849d6103692e1a9753e70fb455cfc24f16212e76a6ee
|
|
| MD5 |
9b20dd94266ff3e4a41846945070b7fc
|
|
| BLAKE2b-256 |
539d1ae56fb2f64b0ff0dab7d0d30c3bd128efa03465bd498be6c3a4c0146860
|
File details
Details for the file vrouter_agent-1.5.3-py3-none-any.whl.
File metadata
- Download URL: vrouter_agent-1.5.3-py3-none-any.whl
- Upload date:
- Size: 216.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.10.18 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9cb3b46c07dbc94fa33bebf58b542d3d998ffb3d570b79e2507930882bc54424
|
|
| MD5 |
8aa9b69517f629381a5907b4b7e7012a
|
|
| BLAKE2b-256 |
00d2e00369f88e337ce23129aa0a0a4c5d401fff63fdd5403cd2b79a4e1156e3
|