Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweak defaults and configuration #88

Open
wants to merge 4 commits into
base: towards-0.2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ license = "MPL-2.0"
exclude = [ ".github" ]
readme = "README.md"

[[bin]]
name = "print_rotonda_std_doc"
path = "doc/bin/print_rotonda_std_doc.rs"

[workspace.package]
version = "0.2.0-4dev"
edition = "2021"
Expand Down
6 changes: 6 additions & 0 deletions doc/bin/print_rotonda_std_doc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use rotonda::common::roto_runtime::rotonda_roto_runtime;

fn main() {
let runtime = rotonda_roto_runtime().unwrap();
runtime.print_documentation();
}
4 changes: 2 additions & 2 deletions etc/filters.roto → etc/examples/filters.roto.example
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ filter bgp-in(
# information via an encapsulated BGP UPDATE message), this filter-map can act
# on different types as well. Helper methods are provided, e.g.
# 'is_peer_down()' returns true if the message is a BMP PeerDownNotification.
filter-map bmp-in(
filter bmp-in(
output: Log,
bmp: BmpMsg,
prov: Provenance,
Expand Down Expand Up @@ -74,7 +74,7 @@ filter-map bmp-in(
# Filtering purely based on values of attributes (regardless of the individual
# NLRI) can and should be done in the bmp-in/bgp-in filter-maps, as making such
# a decision early on is more efficient.
filter-map rib-in-pre(
filter rib-in-pre(
output: Log,
route: Route,
context: RouteContext,
Expand Down
23 changes: 23 additions & 0 deletions etc/examples/mrt-in.conf.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
roto_script = "filters.roto.example"
log_level = "info"
log_target = "stderr"

http_listen = ["127.0.0.1:8080"]

[units.mrt-in-1]
type = "mrt-in"
filename = "../bview/latest-bview-rrc26"

[units.mrt-in-2]
type = "mrt-in"
filename = "../bview/latest-bview-rrc3"

[units.rib]
type = "rib"
sources = ["mrt-in-1","mrt-in-2"]
rib_type = "Physical"

[targets.null]
type = "null-out"
sources = "rib"

78 changes: 45 additions & 33 deletions etc/rotonda.conf
Original file line number Diff line number Diff line change
@@ -1,63 +1,75 @@
log_level = "info" # "error", "warn", "info", "debug" or "trace"
log_target = "stderr" # "stderr", "file" or "syslog"
log_facility = "daemon" # used if log_target is "syslog"
log_file = "./rotonda.log" # used if log_target is "file"
# Rotonda Configuration
#
# This is an example Rotonda configuration file. It is in TOML format.
# This file has 2 sections: Global settings and Component definitions.
#
# Read more about this configuration format here:
# https://rotonda.readthedocs.io/en/latest/config/


### 1. Global Settings

roto_script = "filters.roto"
log_level = "info" # "error", "warn", "info", "debug" or "trace"
log_target = "stderr" # "stderr", "file" or "syslog"
# log_facility = "daemon" # used if log_target is "syslog"
# log_file = "./rotonda.log" # used if log_target is "file"

# roto_script = "filters.roto"

http_listen = ["0.0.0.0:8080"]


### 2. Component Definitions

## BMP

[units.bmp-in]
type = "bmp-tcp-in"
listen = "0.0.0.0:11019"
http_api_path = "/bmp-routers/"


## BGP

#[units.bgp-in]
#type = "bgp-tcp-in"
#listen = "10.1.0.254:179"
#my_asn = 64512
#my_bgp_id = [10,1,0,254]
#
#[units.bgp-in.peers."10.1.0.1"]
#name = "PeerA"
#remote_asn = []
#protocols = ["Ipv4Unicast", "Ipv4Multicast", "Ipv6Unicast"]
#
#[units.bgp-in.peers."10.1.0.2"]
#name = "PeerB"
#remote_asn = []
#protocols = ["Ipv4Unicast", "Ipv6Unicast"]
# [units.bgp-in]
# type = "bgp-tcp-in"
# listen = "10.1.0.254:179"
# my_asn = 64512
# my_bgp_id = [10,1,0,254]

## MRT
# [units.bgp-in.peers."10.1.0.1"]
# name = "PeerA"
# remote_asn = []
# protocols = ["Ipv4Unicast", "Ipv4Multicast", "Ipv6Unicast"]

#[units.mrt-in]
#type = "mrt-in"
#filename = "path/to/bview.mrt"
# [units.bgp-in.peers."10.1.0.2"]
# name = "PeerB"
# remote_asn = []
# protocols = ["Ipv4Unicast", "Ipv6Unicast"]

## MRT

# [units.mrt-in]
# type = "mrt-in"
# filename = "path/to/bview.mrt"

## RIB

[units.rib]
type = "rib"
rib_type = "Physical"
sources = ["bmp-in"]
#sources = ["bgp-in", "bmp-in", "mrt-in"]

http_api_path = "/rib/"

## Targets
## Null Target

[targets.null]
type = "null-out"
sources = ["rib"]

#[targets.mqtt]
#type = "mqtt-out"
#sources = ["bmp-in", "bgp-in", "rib"]
#destination = "localhost"
#client_id = "rotonda"
## MQTT Target

# [targets.mqtt]
# type = "mqtt-out"
# sources = ["bmp-in", "bgp-in", "rib"]
# destination = "localhost"
# client_id = "rotonda"
75 changes: 75 additions & 0 deletions etc/rotonda.conf.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Rotonda Configuration
#
# This is an example Rotonda configuration file. It is in TOML format.
# This file has 2 sections: Global settings and Component definitions.
#
# Read more about this configuration format here:
# https://rotonda.readthedocs.io/en/latest/config/


### 1. Global Settings

log_level = "info" # "error", "warn", "info", "debug" or "trace"
log_target = "stderr" # "stderr", "file" or "syslog"
# log_facility = "daemon" # used if log_target is "syslog"
# log_file = "./rotonda.log" # used if log_target is "file"

# roto_script = "filters.roto"

http_listen = ["0.0.0.0:8080"]


### 2. Component Definitions

## BMP

[units.bmp-in]
type = "bmp-tcp-in"
listen = "0.0.0.0:11019"
http_api_path = "/bmp-routers/"

## BGP

# [units.bgp-in]
# type = "bgp-tcp-in"
# listen = "10.1.0.254:179"
# my_asn = 64512
# my_bgp_id = [10,1,0,254]

# [units.bgp-in.peers."10.1.0.1"]
# name = "PeerA"
# remote_asn = []
# protocols = ["Ipv4Unicast", "Ipv4Multicast", "Ipv6Unicast"]

# [units.bgp-in.peers."10.1.0.2"]
# name = "PeerB"
# remote_asn = []
# protocols = ["Ipv4Unicast", "Ipv6Unicast"]

## MRT

# [units.mrt-in]
# type = "mrt-in"
# filename = "path/to/bview.mrt"

## RIB

[units.rib]
type = "rib"
rib_type = "Physical"
sources = ["bmp-in"]
http_api_path = "/rib/"

## Null Target

[targets.null]
type = "null-out"
sources = ["rib"]

## MQTT Target

# [targets.mqtt]
# type = "mqtt-out"
# sources = ["bmp-in", "bgp-in", "rib"]
# destination = "localhost"
# client_id = "rotonda"
2 changes: 1 addition & 1 deletion src/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub(crate) mod memory;
pub(crate) mod net;
//pub(crate) mod roto;
pub(crate) mod roto_new;
pub(crate) mod roto_runtime;
pub mod roto_runtime;
pub(crate) mod routecore_extra;
pub(crate) mod status_reporter;
pub(crate) mod unit;
1 change: 1 addition & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const ARG_CONFIG: &str = "config";
/// [`from_arg_matches`](Self::from_arg_matches) will then load the file
/// referenced in the command line and, upon success, return the config.
#[derive(Deserialize)]
#[serde(deny_unknown_fields)]
pub struct Config {
/// Location of the .roto script containing all user defined filters.
pub roto_script: Option<PathBuf>,
Expand Down
15 changes: 5 additions & 10 deletions src/manager.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//! Controlling the entire operation.

use crate::common::file_io::{FileIo, TheFileIo};
use crate::common::file_io::TheFileIo;
//use crate::common::roto::{
// FilterName, LoadErrorKind, RotoError, RotoScriptOrigin, RotoScripts,
//};
use crate::common::roto_new::{rotonda_roto_runtime, FilterName, RotoScripts};
use crate::common::roto_new::{rotonda_roto_runtime, FilterName};
use crate::comms::{
DirectLink, Gate, GateAgent, GraphStatus, Link, DEF_UPDATE_QUEUE_LEN,
};
Expand All @@ -21,9 +21,7 @@ use non_empty_vec::NonEmpty;
use reqwest::Client as HttpClient;
use serde::Deserialize;
use std::collections::HashSet;
use std::ffi::{OsStr, OsString};
use std::ops::Deref;
use std::path::PathBuf;
use std::sync::{Arc, Mutex, RwLock, Weak};
use std::time::{Duration, Instant};
use std::{cell::RefCell, fmt::Display};
Expand Down Expand Up @@ -78,7 +76,7 @@ impl Default for Component {
http_client: Default::default(),
metrics: Default::default(),
http_resources: Default::default(),
roto_scripts: Default::default(),
roto_compiled: Default::default(),
tracer: Default::default(),
ingresses: Default::default(),
}
Expand Down Expand Up @@ -808,7 +806,7 @@ impl Manager {
None => error!("{}", err),
}
Terminate::error()
})
})
}

/// Prepare for spawning.
Expand Down Expand Up @@ -883,16 +881,14 @@ impl Manager {
Ok(())
}


//LH this will replace fn load_roto_scripts eventually
pub fn compile_roto_script(
&mut self,
roto_scripts_path: &Option<std::path::PathBuf>
) -> Result<(), String> {
let path = if let Some(p) = roto_scripts_path {
p
} else {
debug!("no roto scripts path to load filters from");
info!("no roto scripts path to load filters from");
return Ok(());
};

Expand Down Expand Up @@ -2960,7 +2956,6 @@ mod tests {
ConfigFile::new(
toml.as_bytes().to_vec(),
Source::default(),
Default::default(),
).unwrap()
}

Expand Down