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

Refactor network operator APIs #817

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
1,228 changes: 1,166 additions & 62 deletions cli/docs/cli.json

Large diffs are not rendered by default.

121 changes: 111 additions & 10 deletions cli/src/cli_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,9 +443,15 @@ fn xxx<'a>(command: CliCommand) -> Option<&'a str> {
CliCommand::NetworkingAddressLotList => Some("system networking address-lot list"),
CliCommand::NetworkingAddressLotCreate => Some("system networking address-lot create"),
CliCommand::NetworkingAddressLotDelete => Some("system networking address-lot delete"),

CliCommand::NetworkingAddressLotBlockList => {
Some("system networking address-lot block list")
}
CliCommand::NetworkingAddressLotBlockAdd => Some("system networking address-lot block add"),
CliCommand::NetworkingAddressLotBlockRemove => {
Some("system networking address-lot block remove")
}

CliCommand::NetworkingLoopbackAddressList => {
Some("system networking loopback-address list")
}
Expand All @@ -456,25 +462,120 @@ fn xxx<'a>(command: CliCommand) -> Option<&'a str> {
Some("system networking loopback-address delete")
}

CliCommand::NetworkingSwitchPortList => Some("system hardware switch-port list"),
CliCommand::NetworkingSwitchPortStatus => Some("system hardware switch-port status"),

// TODO: deprecate?
// how do we go about deprecating commands?
CliCommand::NetworkingSwitchPortApplySettings => {
Some("system hardware switch-port apply-settings")
}
CliCommand::NetworkingSwitchPortClearSettings => {
Some("system hardware switch-port clear-settings")
}
CliCommand::NetworkingSwitchPortList => Some("system hardware switch-port list"),
CliCommand::NetworkingSwitchPortStatus => Some("system hardware switch-port status"),
CliCommand::NetworkingSwitchPortSettingsList => {
Some("system networking switch-port-settings list")

// Use these instead
CliCommand::NetworkingSwitchPortActiveConfigurationView => {
Some("system hardware switch-port active-configuration view")
}
CliCommand::NetworkingSwitchPortActiveConfigurationSet => {
Some("system hardware switch-port active-configuration set")
}
CliCommand::NetworkingSwitchPortActiveConfigurationClear => {
Some("system hardware switch-port active-configuration clear")
}

CliCommand::NetworkingSwitchPortConfigurationList => {
Some("system networking switch-port configuration list")
}
CliCommand::NetworkingSwitchPortConfigurationCreate => {
Some("system networking switch-port configuration create")
}
CliCommand::NetworkingSwitchPortConfigurationDelete => {
Some("system networking switch-port configuration delete")
}
CliCommand::NetworkingSwitchPortConfigurationView => {
Some("system networking switch-port configuration view")
}

CliCommand::NetworkingSwitchPortConfigurationGeometryView => {
Some("system networking switch-port configuration geometry view")
}
CliCommand::NetworkingSwitchPortConfigurationGeometrySet => {
Some("system networking switch-port configuration geometry set")
}

CliCommand::NetworkingSwitchPortConfigurationAddressList => {
Some("system networking switch-port configuration address list")
}
CliCommand::NetworkingSwitchPortConfigurationAddressAdd => {
Some("system networking switch-port configuration address add")
}
CliCommand::NetworkingSwitchPortConfigurationAddressRemove => {
Some("system networking switch-port configuration address remove")
}

CliCommand::NetworkingSwitchPortConfigurationBgpPeerList => {
Some("system networking switch-port configuration bgp peer list")
}
CliCommand::NetworkingSwitchPortConfigurationBgpPeerAdd => {
Some("system networking switch-port configuration bgp peer add")
}
CliCommand::NetworkingSwitchPortConfigurationBgpPeerRemove => {
Some("system networking switch-port configuration bgp peer remove")
}

CliCommand::NetworkingSwitchPortConfigurationRouteList => {
Some("system networking switch-port configuration route list")
}
CliCommand::NetworkingSwitchPortConfigurationRouteAdd => {
Some("system networking switch-port configuration route add")
}
CliCommand::NetworkingSwitchPortConfigurationRouteRemove => {
Some("system networking switch-port configuration route remove")
}

CliCommand::NetworkingSwitchPortConfigurationBgpPeerAllowImportList => {
Some("system networking switch-port configuration bgp peer allow import list")
}
CliCommand::NetworkingSwitchPortConfigurationBgpPeerAllowImportAdd => {
Some("system networking switch-port configuration bgp peer allow import add")
}
CliCommand::NetworkingSwitchPortConfigurationBgpPeerAllowImportRemove => {
Some("system networking switch-port configuration bgp peer allow import remove")
}

CliCommand::NetworkingSwitchPortConfigurationBgpPeerAllowExportList => {
Some("system networking switch-port configuration bgp peer allow export list")
}
CliCommand::NetworkingSwitchPortConfigurationBgpPeerAllowExportAdd => {
Some("system networking switch-port configuration bgp peer allow export add")
}
CliCommand::NetworkingSwitchPortConfigurationBgpPeerAllowExportRemove => {
Some("system networking switch-port configuration bgp peer allow export remove")
}

CliCommand::NetworkingSwitchPortConfigurationBgpPeerCommunityList => {
Some("system networking switch-port configuration bgp peer community list")
}
CliCommand::NetworkingSwitchPortConfigurationBgpPeerCommunityAdd => {
Some("system networking switch-port configuration bgp peer community add")
}
CliCommand::NetworkingSwitchPortConfigurationBgpPeerCommunityRemove => {
Some("system networking switch-port configuration bgp peer community remove")
}

CliCommand::NetworkingSwitchPortConfigurationLinkList => {
Some("system networking switch-port configuration link list")
}
CliCommand::NetworkingSwitchPortSettingsCreate => {
Some("system networking switch-port-settings create")
CliCommand::NetworkingSwitchPortConfigurationLinkCreate => {
Some("system networking switch-port configuration link create")
}
CliCommand::NetworkingSwitchPortSettingsDelete => {
Some("system networking switch-port-settings delete")
CliCommand::NetworkingSwitchPortConfigurationLinkView => {
Some("system networking switch-port configuration link view")
}
CliCommand::NetworkingSwitchPortSettingsView => {
Some("system networking switch-port-settings view")
CliCommand::NetworkingSwitchPortConfigurationLinkDelete => {
Some("system networking switch-port configuration link delete")
}

CliCommand::NetworkingBfdStatus => Some("system networking bfd status"),
Expand Down
36 changes: 18 additions & 18 deletions cli/src/cmd_net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use colored::*;
use futures::TryStreamExt;
use oxide::{
types::{
Address, AddressConfig, BgpAnnounceSetCreate, BgpAnnouncementCreate, BgpPeer,
Address, AddressConfig, BgpAnnounceSetCreate, BgpAnnouncementCreate, BgpPeerCombined,
BgpPeerConfig, BgpPeerStatus, ImportExportPolicy, IpNet, LinkConfigCreate, LinkFec,
LinkSpeed, LldpLinkConfigCreate, Name, NameOrId, Route, RouteConfig,
SwitchInterfaceConfigCreate, SwitchInterfaceKind, SwitchInterfaceKind2, SwitchLocation,
Expand Down Expand Up @@ -148,7 +148,7 @@ impl AuthenticatedCmd for CmdLinkAdd {
}
}
client
.networking_switch_port_settings_create()
.networking_switch_port_configuration_create()
.body(settings)
.send()
.await?;
Expand Down Expand Up @@ -185,7 +185,7 @@ impl AuthenticatedCmd for CmdLinkDel {
current_port_settings(client, &self.rack, &self.switch, &self.port).await?;
settings.links.clear();
client
.networking_switch_port_settings_create()
.networking_switch_port_configuration_create()
.body(settings)
.send()
.await?;
Expand Down Expand Up @@ -443,7 +443,7 @@ impl AuthenticatedCmd for CmdBgpFilter {
}
}
client
.networking_switch_port_settings_create()
.networking_switch_port_configuration_create()
.body(settings)
.send()
.await?;
Expand Down Expand Up @@ -500,7 +500,7 @@ impl AuthenticatedCmd for CmdBgpAuth {
}
}
client
.networking_switch_port_settings_create()
.networking_switch_port_configuration_create()
.body(settings)
.send()
.await?;
Expand Down Expand Up @@ -558,7 +558,7 @@ impl AuthenticatedCmd for CmdBgpLocalPref {
}
}
client
.networking_switch_port_settings_create()
.networking_switch_port_configuration_create()
.body(settings)
.send()
.await?;
Expand Down Expand Up @@ -681,7 +681,7 @@ impl AuthenticatedCmd for CmdStaticRouteSet {
}

client
.networking_switch_port_settings_create()
.networking_switch_port_configuration_create()
.body(settings)
.send()
.await?;
Expand Down Expand Up @@ -747,7 +747,7 @@ impl AuthenticatedCmd for CmdStaticRouteDelete {
}

client
.networking_switch_port_settings_create()
.networking_switch_port_configuration_create()
.body(settings)
.send()
.await?;
Expand Down Expand Up @@ -841,7 +841,7 @@ impl AuthenticatedCmd for CmdAddrAdd {
}
}
client
.networking_switch_port_settings_create()
.networking_switch_port_configuration_create()
.body(settings)
.send()
.await?;
Expand Down Expand Up @@ -892,7 +892,7 @@ impl AuthenticatedCmd for CmdAddrDel {
}
}
client
.networking_switch_port_settings_create()
.networking_switch_port_configuration_create()
.body(settings)
.send()
.await?;
Expand Down Expand Up @@ -1060,7 +1060,7 @@ impl AuthenticatedCmd for CmdBgpPeerSet {
async fn run(&self, client: &Client) -> Result<()> {
let mut settings =
current_port_settings(client, &self.rack, &self.switch, &self.port).await?;
let peer = BgpPeer {
let peer = BgpPeerCombined {
addr: self.addr,
allowed_import: if self.allowed_imports.is_empty() {
ImportExportPolicy::NoFiltering
Expand Down Expand Up @@ -1112,7 +1112,7 @@ impl AuthenticatedCmd for CmdBgpPeerSet {
}
}
client
.networking_switch_port_settings_create()
.networking_switch_port_configuration_create()
.body(settings)
.send()
.await?;
Expand Down Expand Up @@ -1160,7 +1160,7 @@ impl AuthenticatedCmd for CmdBgpPeerDel {
}
}
client
.networking_switch_port_settings_create()
.networking_switch_port_configuration_create()
.body(settings)
.send()
.await?;
Expand Down Expand Up @@ -1210,8 +1210,8 @@ impl AuthenticatedCmd for CmdPortConfig {
for p in &ports {
if let Some(id) = p.port_settings_id {
let config = client
.networking_switch_port_settings_view()
.port(id)
.networking_switch_port_configuration_view()
.configuration(id)
.send()
.await?
.into_inner();
Expand Down Expand Up @@ -1614,7 +1614,7 @@ impl CmdPortStatus {
// modify-write operation.
async fn create_current(settings_id: Uuid, client: &Client) -> Result<SwitchPortSettingsCreate> {
let list = client
.networking_switch_port_settings_list()
.networking_switch_port_configuration_list()
.stream()
.try_collect::<Vec<_>>()
.await?;
Expand All @@ -1627,8 +1627,8 @@ async fn create_current(settings_id: Uuid, client: &Client) -> Result<SwitchPort
.clone();

let current = client
.networking_switch_port_settings_view()
.port(settings_id)
.networking_switch_port_configuration_view()
.configuration(settings_id)
.send()
.await
.unwrap()
Expand Down
Loading
Loading