@@ -41,8 +41,8 @@ use nexus_db_queries::db::identity::Resource;
4141use nexus_db_queries:: db:: lookup:: ImageLookup ;
4242use nexus_db_queries:: db:: lookup:: ImageParentLookup ;
4343use nexus_db_queries:: db:: model:: Name ;
44- use nexus_types:: external_api:: views:: SiloQuotas ;
4544use nexus_types:: external_api:: views:: Utilization ;
45+ use nexus_types:: external_api:: { shared:: BfdStatus , views:: SiloQuotas } ;
4646use nexus_types:: identity:: AssetIdentityMetadata ;
4747use omicron_common:: api:: external:: http_pagination:: data_page_params_for;
4848use omicron_common:: api:: external:: http_pagination:: marker_for_name;
@@ -270,6 +270,10 @@ pub(crate) fn external_api() -> NexusApiDescription {
270270 api. register ( networking_bgp_announce_set_list) ?;
271271 api. register ( networking_bgp_announce_set_delete) ?;
272272
273+ api. register ( networking_bfd_enable) ?;
274+ api. register ( networking_bfd_disable) ?;
275+ api. register ( networking_bfd_status) ?;
276+
273277 api. register ( utilization_view) ?;
274278
275279 // Fleet-wide API operations
@@ -3380,6 +3384,68 @@ async fn networking_bgp_announce_set_delete(
33803384 apictx. external_latencies . instrument_dropshot_handler ( & rqctx, handler) . await
33813385}
33823386
3387+ /// Enable a BFD session.
3388+ #[ endpoint {
3389+ method = POST ,
3390+ path = "/v1/system/networking/bfd-enable" ,
3391+ tags = [ "system/networking" ] ,
3392+ } ]
3393+ async fn networking_bfd_enable (
3394+ rqctx : RequestContext < Arc < ServerContext > > ,
3395+ session : TypedBody < params:: BfdSessionEnable > ,
3396+ ) -> Result < HttpResponseUpdatedNoContent , HttpError > {
3397+ let apictx = rqctx. context ( ) ;
3398+ let handler = async {
3399+ let nexus = & apictx. nexus ;
3400+ let opctx = crate :: context:: op_context_for_external_api ( & rqctx) . await ?;
3401+ opctx. authorize ( authz:: Action :: ListChildren , & authz:: FLEET ) . await ?;
3402+ nexus. bfd_enable ( & opctx, session. into_inner ( ) ) . await ?;
3403+ Ok ( HttpResponseUpdatedNoContent { } )
3404+ } ;
3405+ apictx. external_latencies . instrument_dropshot_handler ( & rqctx, handler) . await
3406+ }
3407+
3408+ /// Disable a BFD session.
3409+ #[ endpoint {
3410+ method = POST ,
3411+ path = "/v1/system/networking/bfd-disable" ,
3412+ tags = [ "system/networking" ] ,
3413+ } ]
3414+ async fn networking_bfd_disable (
3415+ rqctx : RequestContext < Arc < ServerContext > > ,
3416+ session : TypedBody < params:: BfdSessionDisable > ,
3417+ ) -> Result < HttpResponseUpdatedNoContent , HttpError > {
3418+ let apictx = rqctx. context ( ) ;
3419+ let handler = async {
3420+ let nexus = & apictx. nexus ;
3421+ let opctx = crate :: context:: op_context_for_external_api ( & rqctx) . await ?;
3422+ opctx. authorize ( authz:: Action :: ListChildren , & authz:: FLEET ) . await ?;
3423+ nexus. bfd_disable ( & opctx, session. into_inner ( ) ) . await ?;
3424+ Ok ( HttpResponseUpdatedNoContent { } )
3425+ } ;
3426+ apictx. external_latencies . instrument_dropshot_handler ( & rqctx, handler) . await
3427+ }
3428+
3429+ /// Get BFD status.
3430+ #[ endpoint {
3431+ method = GET ,
3432+ path = "/v1/system/networking/bfd-status" ,
3433+ tags = [ "system/networking" ] ,
3434+ } ]
3435+ async fn networking_bfd_status (
3436+ rqctx : RequestContext < Arc < ServerContext > > ,
3437+ ) -> Result < HttpResponseOk < Vec < BfdStatus > > , HttpError > {
3438+ let apictx = rqctx. context ( ) ;
3439+ let handler = async {
3440+ let nexus = & apictx. nexus ;
3441+ let opctx = crate :: context:: op_context_for_external_api ( & rqctx) . await ?;
3442+ opctx. authorize ( authz:: Action :: ListChildren , & authz:: FLEET ) . await ?;
3443+ let status = nexus. bfd_status ( & opctx) . await ?;
3444+ Ok ( HttpResponseOk ( status) )
3445+ } ;
3446+ apictx. external_latencies . instrument_dropshot_handler ( & rqctx, handler) . await
3447+ }
3448+
33833449// Images
33843450
33853451/// List images
0 commit comments