-
Notifications
You must be signed in to change notification settings - Fork 23
Holo Guide ‐ Create holo‐vrrp module and skeletal structure
I hope by now it's clear that we are writing an implementation of the VRRP version 2 protocol.
The module that will be managing the project will be called holo-vrrp
. Let's create it:
cargo +nightly new holo-vrrp --lib
Make sure you’re running this from the project’s root directory!
Now that we’ve set up the module, it's time to add the tools we'll need. Dependencies are like the trusty sidekicks of our project—they help us do the heavy lifting.
NOTE: In the holo
project, we manage dependencies a bit differently. Instead of installing them directly in holo-vrrp
, we add them to the root module and then call them from the workspace. If you notice dependencies added with [dependency-name].workspace = true
, that’s why.
Here are the key dependencies we’ll need for holo-vrrp
:
[dependencies]
async-trait.workspace = true
bitflags.workspace = true
bytes.workspace = true
chrono.workspace = true
derive-new.workspace = true
enum-as-inner.workspace = true
ipnetwork.workspace = true
itertools.workspace = true
libc.workspace = true
num-derive.workspace = true
num-traits.workspace = true
rand.workspace = true
serde.workspace = true
serde_json.workspace = true
serde_with.workspace = true
tokio.workspace = true
tracing.workspace = true
yang2.workspace = true
socket2.workspace = true
nix.workspace = true
# local dependencies
holo-northbound = { path = "../holo-northbound" }
holo-protocol = { path = "../holo-protocol" }
holo-utils = { path = "../holo-utils" }
holo-yang = { path = "../holo-yang" }
Most of these are external dependencies fetched from the Cargo repository, but you'll notice a few local dependencies (holo-northbound
, holo-protocol
, holo-utils
, and holo-yang
). These are essential building blocks within our larger holo
suite. We’ll be using them to handle YANG files, protocols, and utilities specific to our project.
With dependencies in place, let’s sketch out the bones of our project. We’re about to create some core files that will form the foundation of our holo-vrrp
module.
Here's how the structure will look:
├── Cargo.toml
├── LICENSE
└── src
├── debug.rs
├── error.rs
├── events.rs
├── instance.rs
├── interface.rs
├── lib.rs
├── network.rs
├── northbound
│ ├── configuration.rs
│ ├── mod.rs
│ ├── notification.rs
│ ├── state.rs
│ └── yang.rs
├── packet.rs
├── southbound.rs
└── tasks.rs
3 directories, 17 files
Looks neat, right? At this stage, the files are still empty. But don't worry—we'll breathe life into them soon enough. For now, let’s just populate our lib.rs
with the necessary module declarations:
// lib.rs
pub mod debug;
pub mod error;
pub mod events;
pub mod instance;
pub mod interface;
pub mod network;
pub mod northbound;
pub mod packet;
pub mod southbound;
pub mod tasks;
And while we’re at it, let’s do the same for northbound/mod.rs
:
// northbound/mod.rs
pub mod configuration;
pub mod notification;
pub mod state;
pub mod yang;
We’ll be adding more content to northbound/mod.rs
as we progress, but for now, let’s take a quick tour of the most important files in this directory.
With our skeleton complete, let us first verify that our project hasn't been broken yet. We do this by running the following command from the project's root directory:
cargo +nightly build
It should build successfully without any errors.
Then we commit our changes, because this is a first step of many, and we would like to document each and every step. So run:
git add .
git commit
When it asks you for a commit message, write the following:
vrrp: initialize the vrrp module.
Created a skeletal file structure
for the vrrp module on the holo
routing suite.
Signed-off-by: My Name <[email protected]>
Replace My Name <[email protected]>
with your specific names. On a sidenote, the commit format above is what we generally use at holo
. Might be important to note for those of you aiming to contribute to the project in future.
And that’s our skeleton! We’ve got the groundwork laid out. We’ll be diving deeper into each file as we progress, but for now, it’s time to start fleshing out the details. Up next, let’s dive into the file structure of our files.
That’s a wrap for setting up our VRRP module. You’ve just laid the foundation for what will become a key piece of the holo routing suite. Keep your eye on the files mentioned above-things are about to get very interesting as we move ahead.
- Architecture
- Management Interfaces
- Developer's Documentation
- Example Topology
- Paul's Practical Guide