Skip to content
Closed
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
10 changes: 10 additions & 0 deletions cli/docs/cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -4433,6 +4433,16 @@
}
]
},
{
"name": "exported",
"about": "Get BGP exported routes",
"args": [
{
"long": "profile",
"help": "Configuration profile to use for commands"
}
]
},
{
"name": "filter",
"about": "Add a filtering requirement to a BGP session.",
Expand Down
1 change: 1 addition & 0 deletions cli/src/cli_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@ fn xxx<'a>(command: CliCommand) -> Option<&'a str> {
}
CliCommand::NetworkingBgpAnnounceSetList => Some("system networking bgp announce-set list"),
CliCommand::NetworkingBgpImportedRoutesIpv4 => Some("system networking bgp imported ipv4"),
CliCommand::NetworkingBgpExported => Some("system networking bgp exported"),

// Subcommand: disk
CliCommand::DiskList => Some("disk list"),
Expand Down
27 changes: 18 additions & 9 deletions cli/src/cmd_net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use oxide::{
types::{
Address, AddressConfig, BgpAnnounceSetCreate, BgpAnnouncementCreate, BgpPeer,
BgpPeerConfig, BgpPeerStatus, ImportExportPolicy, IpNet, LinkConfigCreate, LinkFec,
LinkSpeed, LldpServiceConfigCreate, Name, NameOrId, Route, RouteConfig,
LinkSpeed, LldpLinkConfigCreate, Name, NameOrId, Route, RouteConfig,
SwitchInterfaceConfigCreate, SwitchInterfaceKind, SwitchInterfaceKind2, SwitchLocation,
SwitchPort, SwitchPortConfigCreate, SwitchPortGeometry, SwitchPortGeometry2,
SwitchPortSettingsCreate,
Expand Down Expand Up @@ -116,10 +116,14 @@ impl AuthenticatedCmd for CmdLinkAdd {
fec: self.fec,
mtu: self.mtu,
speed: self.speed,
//TODO not fully plumbed on the back end yet.
lldp: LldpServiceConfigCreate {
lldp: LldpLinkConfigCreate {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps lldp doesn't need to be a required field?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it doesn't. We can easily construct a disabled Default on the server side.

enabled: false,
lldp_config: None,
link_name: None,
link_description: None,
chassis_id: None,
system_name: None,
system_description: None,
management_ip: None,
},
};
match settings.links.get(PHY0) {
Expand Down Expand Up @@ -1351,13 +1355,17 @@ async fn create_current(settings_id: Uuid, client: &Client) -> Result<SwitchPort
LinkConfigCreate {
autoneg: x.autoneg,
fec: x.fec,
lldp: LldpServiceConfigCreate {
//TODO
enabled: false,
lldp_config: None,
},
mtu: x.mtu,
speed: x.speed,
lldp: LldpLinkConfigCreate {
enabled: false,
link_name: None,
link_description: None,
chassis_id: None,
system_name: None,
system_description: None,
management_ip: None,
},
},
)
})
Expand All @@ -1379,6 +1387,7 @@ async fn create_current(settings_id: Uuid, client: &Client) -> Result<SwitchPort
dst: x.dst.clone(),
gw: x.gw.to_string().parse().unwrap(),
vid: x.vlan_id,
local_pref: None,
})
.collect(),
};
Expand Down
38 changes: 38 additions & 0 deletions cli/src/generated_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ impl<T: CliConfig> Cli<T> {
CliCommand::NetworkingBgpAnnounceSetDelete => {
Self::cli_networking_bgp_announce_set_delete()
}
CliCommand::NetworkingBgpExported => Self::cli_networking_bgp_exported(),
CliCommand::NetworkingBgpMessageHistory => Self::cli_networking_bgp_message_history(),
CliCommand::NetworkingBgpImportedRoutesIpv4 => {
Self::cli_networking_bgp_imported_routes_ipv4()
Expand Down Expand Up @@ -4219,6 +4220,10 @@ impl<T: CliConfig> Cli<T> {
.about("Delete BGP announce set")
}

pub fn cli_networking_bgp_exported() -> clap::Command {
clap::Command::new("").about("Get BGP exported routes")
}

pub fn cli_networking_bgp_message_history() -> clap::Command {
clap::Command::new("")
.arg(
Expand Down Expand Up @@ -6191,6 +6196,9 @@ impl<T: CliConfig> Cli<T> {
self.execute_networking_bgp_announce_set_delete(matches)
.await
}
CliCommand::NetworkingBgpExported => {
self.execute_networking_bgp_exported(matches).await
}
CliCommand::NetworkingBgpMessageHistory => {
self.execute_networking_bgp_message_history(matches).await
}
Expand Down Expand Up @@ -10822,6 +10830,26 @@ impl<T: CliConfig> Cli<T> {
}
}

pub async fn execute_networking_bgp_exported(
&self,
matches: &clap::ArgMatches,
) -> anyhow::Result<()> {
let mut request = self.client.networking_bgp_exported();
self.config
.execute_networking_bgp_exported(matches, &mut request)?;
let result = request.send().await;
match result {
Ok(r) => {
self.config.success_item(&r);
Ok(())
}
Err(r) => {
self.config.error(&r);
Err(anyhow::Error::new(r))
}
}
}

pub async fn execute_networking_bgp_message_history(
&self,
matches: &clap::ArgMatches,
Expand Down Expand Up @@ -13902,6 +13930,14 @@ pub trait CliConfig {
Ok(())
}

fn execute_networking_bgp_exported(
&self,
matches: &clap::ArgMatches,
request: &mut builder::NetworkingBgpExported,
) -> anyhow::Result<()> {
Ok(())
}

fn execute_networking_bgp_message_history(
&self,
matches: &clap::ArgMatches,
Expand Down Expand Up @@ -14499,6 +14535,7 @@ pub enum CliCommand {
NetworkingBgpAnnounceSetList,
NetworkingBgpAnnounceSetUpdate,
NetworkingBgpAnnounceSetDelete,
NetworkingBgpExported,
NetworkingBgpMessageHistory,
NetworkingBgpImportedRoutesIpv4,
NetworkingBgpStatus,
Expand Down Expand Up @@ -14699,6 +14736,7 @@ impl CliCommand {
CliCommand::NetworkingBgpAnnounceSetList,
CliCommand::NetworkingBgpAnnounceSetUpdate,
CliCommand::NetworkingBgpAnnounceSetDelete,
CliCommand::NetworkingBgpExported,
CliCommand::NetworkingBgpMessageHistory,
CliCommand::NetworkingBgpImportedRoutesIpv4,
CliCommand::NetworkingBgpStatus,
Expand Down
33 changes: 26 additions & 7 deletions cli/tests/test_net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ use chrono::prelude::*;
use httpmock::MockServer;
use oxide::types::{
AddressLot, AddressLotBlock, AddressLotBlockResultsPage, AddressLotKind, AddressLotResultsPage,
BgpConfig, BgpConfigResultsPage, BgpPeer, ImportExportPolicy, LinkFec, LinkSpeed, NameOrId,
SwitchPort, SwitchPortAddressConfig, SwitchPortConfig, SwitchPortGeometry2,
SwitchPortLinkConfig, SwitchPortResultsPage, SwitchPortSettings, SwitchPortSettingsView,
BgpConfig, BgpConfigResultsPage, BgpPeer, ImportExportPolicy, LinkFec, LinkSpeed,
LldpLinkConfig, NameOrId, SwitchPort, SwitchPortAddressConfig, SwitchPortConfig,
SwitchPortGeometry2, SwitchPortLinkConfig, SwitchPortResultsPage, SwitchPortSettings,
SwitchPortSettingsView,
};
use oxide_httpmock::MockServerExt;
use uuid::Uuid;
Expand Down Expand Up @@ -161,16 +162,25 @@ fn test_port_config() {
],
groups: Vec::new(),
interfaces: Vec::new(),
link_lldp: Vec::new(),
links: vec![SwitchPortLinkConfig {
autoneg: false,
fec: LinkFec::None,
link_name: String::from("phy0"),
lldp_service_config_id: Uuid::new_v4(),
lldp_link_config_id: Uuid::new_v4(),
mtu: 1500,
port_settings_id: switch1_qsfp0_settings_id,
speed: LinkSpeed::Speed100G,
}],
link_lldp: vec![LldpLinkConfig {
id: Uuid::new_v4(),
enabled: false,
link_name: None,
link_description: None,
chassis_id: None,
system_name: None,
system_description: None,
management_ip: None,
}],
port: SwitchPortConfig {
geometry: SwitchPortGeometry2::Qsfp28x1,
port_settings_id: switch1_qsfp0_settings_id,
Expand Down Expand Up @@ -246,16 +256,25 @@ fn test_port_config() {
],
groups: Vec::new(),
interfaces: Vec::new(),
link_lldp: Vec::new(),
links: vec![SwitchPortLinkConfig {
autoneg: false,
fec: LinkFec::None,
link_name: String::from("phy0"),
lldp_service_config_id: Uuid::new_v4(),
lldp_link_config_id: Uuid::new_v4(),
mtu: 1500,
port_settings_id: switch1_qsfp0_settings_id,
speed: LinkSpeed::Speed100G,
}],
link_lldp: vec![LldpLinkConfig {
id: Uuid::new_v4(),
enabled: false,
link_name: None,
link_description: None,
chassis_id: None,
system_name: None,
system_description: None,
management_ip: None,
}],
port: SwitchPortConfig {
geometry: SwitchPortGeometry2::Qsfp28x1,
port_settings_id: switch1_qsfp0_settings_id,
Expand Down
Loading