# arunkumartechstar/ospf_project architecture

> Architecture diagram of the GitHub repository arunkumartechstar/ospf_project, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/arunkumartechstar/ospf_project
- Repository: https://github.com/arunkumartechstar/ospf_project

## Overview

#### Purpose and entry points

This repository automates deployment and validation of an OSPF lab on FRRouting Docker nodes hosted by GNS3. Its operational entry point is `generate_and_push.py`; `generate_and_push_old.py` is a legacy alternative. The main script supports generation-only, deployment, and validation-only modes.

Paths: `generate_and_push.py`, `generate_and_push_old.py`

#### Topology source of truth

The YAML inventory defines routers, interfaces, loopbacks, OSPF networks/areas, and configured container identifiers. It is the intended change boundary for adapting the lab topology without changing automation code.

Path: `inventory/ospf_topology.yaml`

#### Configuration rendering stage

The automation loads the inventory and renders a per-router FRR/vtysh configuration through Jinja2. The template translates topology fields into interface addressing and OSPF configuration; generated artifacts are written as router-specific `.cfg` files.

Paths: `templates/frr_ospf.j2`, `configs/FFR-1.cfg`, `configs/FFR-2.cfg`, `configs/FFR-3.cfg`

#### Container discovery and deployment boundary

The script operates from the GNS3 VM and uses the local Docker CLI as its control-plane boundary. It resolves configured or live GNS3 Docker containers by router/node name, copies rendered configuration into each container’s `/etc/frr/frr.conf`, and configures FRR daemon settings. Docker container IDs are ephemeral across GNS3 restarts, so live discovery is material to reliable deployment.

Path: `generate_and_push.py`

#### FRR process orchestration

Within each target container, deployment ensures zebra and OSPF daemon behavior is compatible with the generated configuration. Zebra must establish interface state before `ospfd`; FRR daemons are explicitly started/restarted against `/etc/frr/frr.conf` rather than relying on image defaults. This is the key runtime boundary between Python automation and the FRRouting control plane.

Paths: `generate_and_push.py`, `templates/frr_ospf.j2`

#### Validation flow

After deployment, the script invokes `vtysh` through Docker to inspect OSPF neighbor adjacencies and learned routes, then tests loopback reachability among routers. Validation can run independently, allowing operators to distinguish configuration rendering/deployment failures from OSPF convergence failures.

Path: `generate_and_push.py`

#### Runtime and infrastructure dependencies

Execution requires Python 3.8+ with PyYAML and Jinja2, Docker available on the GNS3 VM, GNS3 2.2.x topology nodes, and the `frrouting/frr:v8.4.0` image. The designed lab is a three-router, Area 0 triangle; the automation itself is inventory-driven and can target expanded topologies if GNS3 links and inventory remain consistent.

Paths: `requirement.txt`, `inventory/ospf_topology.yaml`

Main entry points: [`generate_and_push.py`](https://github.com/arunkumartechstar/ospf_project/blob/main/generate_and_push.py) (Deployment & validation CLI), [`inventory/ospf_topology.yaml`](https://github.com/arunkumartechstar/ospf_project/blob/main/inventory/ospf_topology.yaml) (OSPF topology inventory), [`templates/frr_ospf.j2`](https://github.com/arunkumartechstar/ospf_project/blob/main/templates/frr_ospf.j2) (FRR config template), [`configs/FFR-1.cfg`](https://github.com/arunkumartechstar/ospf_project/blob/main/configs/FFR-1.cfg) (Per-router FRR configs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_automation["Automation"]
  node_main_script["Deployment &amp; validation CLI<br/>Python entry point"]
  node_legacy_script["Legacy CLI<br/>Python entry point"]
  node_inventory["OSPF topology inventory<br/>YAML source of truth<br/>[ospf_topology.yaml]"]
  node_template["FRR config template<br/>Jinja2 template<br/>[frr_ospf.j2]"]
  node_rendered_configs["Per-router FRR configs<br/>generated artifacts<br/>[FFR-1.cfg]"]
  node_python_deps["Python rendering dependencies<br/>PyYAML + Jinja2<br/>[requirement.txt]"]
  node_validation["vtysh and reachability checks<br/>validation stage"]
end

subgraph group_lab["GNS3 / Docker Lab"]
  node_docker_cli{{"Local Docker CLI<br/>control-plane boundary"}}
  node_gns3_containers["GNS3 FRR containers<br/>Docker nodes<br/>[ospf_topology.yaml]"]
end

subgraph group_frr["FRRouting Runtime"]
  node_frr_config["/etc/frr/frr.conf<br/>container configuration"]
  node_frr_daemons["zebra and ospfd<br/>FRR daemons"]
  node_ospf_control_plane["OSPF adjacencies &amp; routes<br/>routing control plane"]
end

node_operator(("Operator<br/>user"))

node_operator -->|"runs mode"| node_main_script
node_legacy_script -.->|"alternative automation"| node_inventory
node_main_script -->|"loads"| node_inventory
node_main_script -->|"renders with"| node_template
node_python_deps -.->|"supports"| node_main_script
node_inventory -->|"topology fields"| node_template
node_template -->|"produces"| node_rendered_configs
node_main_script -->|"uses"| node_docker_cli
node_inventory -->|"configured node names"| node_docker_cli
node_docker_cli -->|"discovers and targets"| node_gns3_containers
node_rendered_configs -->|"copied into"| node_frr_config
node_docker_cli -->|"deploys"| node_frr_config
node_docker_cli -->|"starts or restarts"| node_frr_daemons
node_frr_config -->|"loaded by"| node_frr_daemons
node_frr_daemons -->|"forms"| node_ospf_control_plane
node_main_script -->|"invokes"| node_validation
node_validation -->|"runs vtysh through"| node_docker_cli
node_validation -->|"verifies"| node_ospf_control_plane

click node_main_script "https://github.com/arunkumartechstar/ospf_project/blob/main/generate_and_push.py"
click node_legacy_script "https://github.com/arunkumartechstar/ospf_project/blob/main/generate_and_push_old.py"
click node_inventory "https://github.com/arunkumartechstar/ospf_project/blob/main/inventory/ospf_topology.yaml"
click node_template "https://github.com/arunkumartechstar/ospf_project/blob/main/templates/frr_ospf.j2"
click node_rendered_configs "https://github.com/arunkumartechstar/ospf_project/blob/main/configs/FFR-1.cfg"
click node_python_deps "https://github.com/arunkumartechstar/ospf_project/blob/main/requirement.txt"
click node_docker_cli "https://github.com/arunkumartechstar/ospf_project/blob/main/generate_and_push.py"
click node_gns3_containers "https://github.com/arunkumartechstar/ospf_project/blob/main/inventory/ospf_topology.yaml"
click node_frr_daemons "https://github.com/arunkumartechstar/ospf_project/blob/main/generate_and_push.py"
click node_validation "https://github.com/arunkumartechstar/ospf_project/blob/main/generate_and_push.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main_script,node_legacy_script,node_inventory,node_template,node_rendered_configs,node_python_deps,node_validation toneBlue
class node_docker_cli,node_gns3_containers toneAmber
class node_frr_config,node_frr_daemons,node_ospf_control_plane toneMint
class node_operator toneNeutral
```

## Components

### Automation

- [Deployment & validation CLI](https://github.com/arunkumartechstar/ospf_project/blob/main/generate_and_push.py): Python entry point · Supports generation-only, deployment, and validation-only modes. · `generate_and_push.py`
- [Legacy CLI](https://github.com/arunkumartechstar/ospf_project/blob/main/generate_and_push_old.py): Python entry point · `generate_and_push_old.py`
- [OSPF topology inventory](https://github.com/arunkumartechstar/ospf_project/blob/main/inventory/ospf_topology.yaml): YAML source of truth · Defines routers, interfaces, loopbacks, areas, and container identifiers. · `inventory/ospf_topology.yaml`
- [FRR config template](https://github.com/arunkumartechstar/ospf_project/blob/main/templates/frr_ospf.j2): Jinja2 template · `templates/frr_ospf.j2`
- [Per-router FRR configs](https://github.com/arunkumartechstar/ospf_project/blob/main/configs/FFR-1.cfg): generated artifacts · `configs/FFR-1.cfg`
- [Python rendering dependencies](https://github.com/arunkumartechstar/ospf_project/blob/main/requirement.txt): PyYAML + Jinja2 · `requirement.txt`
- [vtysh and reachability checks](https://github.com/arunkumartechstar/ospf_project/blob/main/generate_and_push.py): validation stage · Inspects neighbors, learned routes, and loopback reachability. · `generate_and_push.py`

### GNS3 / Docker Lab

- [Local Docker CLI](https://github.com/arunkumartechstar/ospf_project/blob/main/generate_and_push.py): control-plane boundary · Discovers live GNS3 containers and executes deployment commands. · `generate_and_push.py`
- [GNS3 FRR containers](https://github.com/arunkumartechstar/ospf_project/blob/main/inventory/ospf_topology.yaml): Docker nodes · Container IDs are ephemeral across GNS3 restarts. · `inventory/ospf_topology.yaml`

### FRRouting Runtime

- **/etc/frr/frr.conf**: container configuration
- [zebra and ospfd](https://github.com/arunkumartechstar/ospf_project/blob/main/generate_and_push.py): FRR daemons · Zebra interface state is established before ospfd. · `generate_and_push.py`
- **OSPF adjacencies & routes**: routing control plane

### Other components

- **Operator**: user

## Connections

- Operator → Deployment & validation CLI: runs mode
- Legacy CLI → OSPF topology inventory: alternative automation
- Deployment & validation CLI → OSPF topology inventory: loads
- Deployment & validation CLI → FRR config template: renders with
- Python rendering dependencies → Deployment & validation CLI: supports
- OSPF topology inventory → FRR config template: topology fields
- FRR config template → Per-router FRR configs: produces
- Deployment & validation CLI → Local Docker CLI: uses
- OSPF topology inventory → Local Docker CLI: configured node names
- Local Docker CLI → GNS3 FRR containers: discovers and targets
- Per-router FRR configs → /etc/frr/frr.conf: copied into
- Local Docker CLI → /etc/frr/frr.conf: deploys
- Local Docker CLI → zebra and ospfd: starts or restarts
- /etc/frr/frr.conf → zebra and ospfd: loaded by
- zebra and ospfd → OSPF adjacencies & routes: forms
- Deployment & validation CLI → vtysh and reachability checks: invokes
- vtysh and reachability checks → Local Docker CLI: runs vtysh through
- vtysh and reachability checks → OSPF adjacencies & routes: verifies
