How dessertlab/thorfi works
Project type and purpose
• ThorFI is a Python-based, full-stack network fault-injection solution for OpenStack clouds.
• It consists of a front-end REST API (Controller node), per-node injection agents, a CLI client, and database utilities.
• Its goal is to let testers select virtual network resources (networks, subnets, routers, ports, floating IPs), build a fault-injection configuration, and non-intrusively inject network faults (delay, loss, corrupt, duplicate, bottleneck) into tenant virtual networks.
File structure
• Top-level scripts:
• thorfi_client.py: CLI that invokes front-end REST APIs.
• thorfi_frontend_agent.py (in root): front-end REST server listens on TCP port (default 7777).
• injector_agent_app/injector_agent.py: injection agent listens on TCP port (default 11223) on each Compute/Network node.
• Main packages:
• thorfi/: core modules for front-end logic (models, forms, network_utils, workload manager, exceptions).
• injector_agent_app/: REST server and utilities for injecting faults locally (ping, ssh, tc, ip namespace).
• thorfi_db_utils/ & utils/: modules to create, destroy, query the ThorFI database and manage OpenStack projects/users.
• Vendored dependencies in libs/: OpenStack client libraries (keystoneauth1, keystoneclient, nova, neutron, glance, heat) and common utilities (oslo_utils, positional, debtcollector).
• Configuration & templates: config.py, YAML workload definitions (iperf.yaml, jmeter.yaml), JMeter templates.
README for additional insights
• The front-end agent exposes endpoints such as /get_network_topology, /inject_network, /inject_router, etc.
• The front-end uses Keystone for authentication, Neutron/Nova/Glance/Heat clients to discover resources and build thorfi_item_map.
• The injection agents receive fault configurations over TCP, then run Linux ip netns exec ... tc qdisc commands to apply network faults to specific NICs within namespaces.
a. Main components
• ThorFI Client (CLI)
• ThorFI Front-End Agent (REST API server)
• ThorFI Database (via thorfi_db_utils)
• OpenStack Services (Keystone, Neutron, Nova, Glance, Heat)
• Injector Agents (one per Compute/Network node)
• Linux Network Tools (ip, tc)
b. Relationships & interactions
1. Client → Front-End: HTTP(S) REST calls (port 7777)
2. Front-End → OpenStack: Keystone token, Neutron/Nova/Glance/Heat API calls to retrieve tenants, networks, ports, namespaces
3. Front-End → ThorFI DB: create/read test campaigns, store topology, retrieve injection config
4. Front-End → Injector Agents: TCP connections (port 11223) to push per-node, per-NIC fault configurations
5. Injector Agents → Linux kernel: ip netns exec … tc qdisc add … to inject network faults
c. Architectural patterns & design principles
• Micro-service separation: controller vs. per-node agents
• RESTful API for orchestration
• CLI client for scripting & integration
• Isolation of dependencies via vendored libs/
• Clear layering: API layer, orchestration layer, database layer, execution layer
d. Key technologies & libraries
• Python 2.7 scripts, PyInstaller for executables
• python-keystoneclient, python-neutronclient, python-novaclient, python-glanceclient, python-heatclient
• Linux ip & tc userland tools
• Database access via thorfi_db_utils (likely SQLAlchemy or direct SQLite/MySQL calls)