diff --git a/holo-daemon/Cargo.toml b/holo-daemon/Cargo.toml index 8521cb69..4d3f6b8f 100644 --- a/holo-daemon/Cargo.toml +++ b/holo-daemon/Cargo.toml @@ -30,17 +30,17 @@ tracing.workspace = true tracing-subscriber.workspace = true yang2.workspace = true -holo-interface = { path = "../holo-interface" } +holo-interface = { path = "../holo-interface", optional = true } holo-bfd = { path = "../holo-bfd", optional = true } holo-bgp = { path = "../holo-bgp", optional = true } -holo-keychain = { path = "../holo-keychain" } +holo-keychain = { path = "../holo-keychain", optional = true } holo-ldp = { path = "../holo-ldp", optional = true } holo-northbound = { path = "../holo-northbound" } holo-ospf = { path = "../holo-ospf", optional = true } -holo-policy = { path = "../holo-policy" } +holo-policy = { path = "../holo-policy", optional = true } holo-protocol = { path = "../holo-protocol" } holo-rip = { path = "../holo-rip", optional = true } -holo-routing = { path = "../holo-routing" } +holo-routing = { path = "../holo-routing", optional = true } holo-utils = { path = "../holo-utils" } holo-yang = { path = "../holo-yang" } @@ -55,10 +55,32 @@ name = "holod" path = "src/main.rs" [features] -default = ["bfd", "bgp", "ldp", "ospf", "rip"] -bfd = ["holo-bfd"] -bgp = ["holo-bgp"] -ldp = ["holo-ldp"] -ospf = ["holo-ospf"] -rip = ["holo-rip"] +default = [ + # Base components + "interface", + "keychain", + "policy", + "routing", + # Protocols + "bfd", + "bgp", + "ldp", + "ospf", + "rip", +] + +# Base components +interface = ["holo-interface"] +keychain = ["holo-keychain"] +policy = ["holo-policy", "holo-routing"] +routing = ["holo-routing", "holo-interface"] + +# Protocols +bfd = ["holo-bfd", "holo-routing"] +bgp = ["holo-bgp", "holo-routing"] +ldp = ["holo-ldp", "holo-routing"] +ospf = ["holo-ospf", "holo-routing"] +rip = ["holo-rip", "holo-routing"] + +# Other features io_uring = ["tokio-uring"] diff --git a/holo-daemon/src/northbound/core.rs b/holo-daemon/src/northbound/core.rs index e9ce2047..de0100e1 100644 --- a/holo-daemon/src/northbound/core.rs +++ b/holo-daemon/src/northbound/core.rs @@ -16,6 +16,7 @@ use holo_northbound::state::NodeAttributes; use holo_northbound::{ api as papi, CallbackKey, CallbackOp, NbDaemonSender, NbProviderReceiver, }; +use holo_utils::ibus::{IbusReceiver, IbusSender}; use holo_utils::task::TimeoutTask; use holo_utils::{Database, Receiver, Sender, UnboundedReceiver}; use holo_yang::YANG_CTX; @@ -623,43 +624,57 @@ impl Default for ConfirmedCommit { // ===== helper functions ===== // Starts base data providers. +#[allow(unused_mut, unused_variables)] fn start_providers( config: &Config, db: Database, ) -> (NbProviderReceiver, Vec) { let mut providers = Vec::new(); let (provider_tx, provider_rx) = mpsc::unbounded_channel(); - let (ibus_tx, ibus_rx) = broadcast::channel(1024); + let (ibus_tx, ibus_rx): (IbusSender, IbusReceiver) = + broadcast::channel(1024); // Start holo-routing. - let daemon_tx = holo_routing::start( - provider_tx.clone(), - ibus_tx.clone(), - ibus_tx.subscribe(), - db, - config.event_recorder.clone(), - ); - providers.push(daemon_tx); + #[cfg(feature = "routing")] + { + let daemon_tx = holo_routing::start( + provider_tx.clone(), + ibus_tx.clone(), + ibus_tx.subscribe(), + db, + config.event_recorder.clone(), + ); + providers.push(daemon_tx); + } // Start holo-interface. - let daemon_tx = holo_interface::start( - provider_tx.clone(), - ibus_tx.clone(), - ibus_tx.subscribe(), - ); - providers.push(daemon_tx); + #[cfg(feature = "interface")] + { + let daemon_tx = holo_interface::start( + provider_tx.clone(), + ibus_tx.clone(), + ibus_tx.subscribe(), + ); + providers.push(daemon_tx); + } // Start holo-keychain. - let daemon_tx = holo_keychain::start( - provider_tx.clone(), - ibus_tx.clone(), - ibus_tx.subscribe(), - ); - providers.push(daemon_tx); + #[cfg(feature = "keychain")] + { + let daemon_tx = holo_keychain::start( + provider_tx.clone(), + ibus_tx.clone(), + ibus_tx.subscribe(), + ); + providers.push(daemon_tx); + } // Start holo-policy. - let daemon_tx = holo_policy::start(provider_tx, ibus_tx, ibus_rx); - providers.push(daemon_tx); + #[cfg(feature = "policy")] + { + let daemon_tx = holo_policy::start(provider_tx, ibus_tx, ibus_rx); + providers.push(daemon_tx); + } (provider_rx, providers) } diff --git a/holo-daemon/src/northbound/yang.rs b/holo-daemon/src/northbound/yang.rs index 4b92ae84..0649780e 100644 --- a/holo-daemon/src/northbound/yang.rs +++ b/holo-daemon/src/northbound/yang.rs @@ -10,6 +10,7 @@ use holo_northbound::ProviderBase; use holo_yang as yang; use holo_yang::YANG_CTX; +#[allow(dead_code)] fn modules_add(modules: &mut Vec<&'static str>) { modules.extend(P::yang_modules().iter()); } @@ -30,9 +31,16 @@ pub(crate) fn create_context() { } // Add core modules. + #[cfg(feature = "interface")] modules_add::(&mut modules); + + #[cfg(feature = "routing")] modules_add::(&mut modules); + + #[cfg(feature = "keychain")] modules_add::(&mut modules); + + #[cfg(feature = "policy")] modules_add::(&mut modules); // Add protocol modules based on enabled features.