@@ -41,6 +41,7 @@ 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:: shared:: BfdStatus ;
4445use omicron_common:: api:: external:: http_pagination:: data_page_params_for;
4546use omicron_common:: api:: external:: http_pagination:: marker_for_name;
4647use omicron_common:: api:: external:: http_pagination:: marker_for_name_or_id;
@@ -273,6 +274,10 @@ pub(crate) fn external_api() -> NexusApiDescription {
273274 api. register ( networking_bgp_announce_set_list) ?;
274275 api. register ( networking_bgp_announce_set_delete) ?;
275276
277+ api. register ( networking_bfd_enable) ?;
278+ api. register ( networking_bfd_disable) ?;
279+ api. register ( networking_bfd_status) ?;
280+
276281 api. register ( utilization_view) ?;
277282
278283 // Fleet-wide API operations
@@ -3489,6 +3494,68 @@ async fn networking_bgp_announce_set_delete(
34893494 apictx. external_latencies . instrument_dropshot_handler ( & rqctx, handler) . await
34903495}
34913496
3497+ /// Enable a BFD session.
3498+ #[ endpoint {
3499+ method = POST ,
3500+ path = "/v1/system/networking/bfd-enable" ,
3501+ tags = [ "system/networking" ] ,
3502+ } ]
3503+ async fn networking_bfd_enable (
3504+ rqctx : RequestContext < Arc < ServerContext > > ,
3505+ session : TypedBody < params:: BfdSessionEnable > ,
3506+ ) -> Result < HttpResponseUpdatedNoContent , HttpError > {
3507+ let apictx = rqctx. context ( ) ;
3508+ let handler = async {
3509+ let nexus = & apictx. nexus ;
3510+ let opctx = crate :: context:: op_context_for_external_api ( & rqctx) . await ?;
3511+ opctx. authorize ( authz:: Action :: ListChildren , & authz:: FLEET ) . await ?;
3512+ nexus. bfd_enable ( & opctx, session. into_inner ( ) ) . await ?;
3513+ Ok ( HttpResponseUpdatedNoContent { } )
3514+ } ;
3515+ apictx. external_latencies . instrument_dropshot_handler ( & rqctx, handler) . await
3516+ }
3517+
3518+ /// Disable a BFD session.
3519+ #[ endpoint {
3520+ method = POST ,
3521+ path = "/v1/system/networking/bfd-disable" ,
3522+ tags = [ "system/networking" ] ,
3523+ } ]
3524+ async fn networking_bfd_disable (
3525+ rqctx : RequestContext < Arc < ServerContext > > ,
3526+ session : TypedBody < params:: BfdSessionDisable > ,
3527+ ) -> Result < HttpResponseUpdatedNoContent , HttpError > {
3528+ let apictx = rqctx. context ( ) ;
3529+ let handler = async {
3530+ let nexus = & apictx. nexus ;
3531+ let opctx = crate :: context:: op_context_for_external_api ( & rqctx) . await ?;
3532+ opctx. authorize ( authz:: Action :: ListChildren , & authz:: FLEET ) . await ?;
3533+ nexus. bfd_disable ( & opctx, session. into_inner ( ) ) . await ?;
3534+ Ok ( HttpResponseUpdatedNoContent { } )
3535+ } ;
3536+ apictx. external_latencies . instrument_dropshot_handler ( & rqctx, handler) . await
3537+ }
3538+
3539+ /// Get BFD status.
3540+ #[ endpoint {
3541+ method = GET ,
3542+ path = "/v1/system/networking/bfd-status" ,
3543+ tags = [ "system/networking" ] ,
3544+ } ]
3545+ async fn networking_bfd_status (
3546+ rqctx : RequestContext < Arc < ServerContext > > ,
3547+ ) -> Result < HttpResponseOk < Vec < BfdStatus > > , HttpError > {
3548+ let apictx = rqctx. context ( ) ;
3549+ let handler = async {
3550+ let nexus = & apictx. nexus ;
3551+ let opctx = crate :: context:: op_context_for_external_api ( & rqctx) . await ?;
3552+ opctx. authorize ( authz:: Action :: ListChildren , & authz:: FLEET ) . await ?;
3553+ let status = nexus. bfd_status ( & opctx) . await ?;
3554+ Ok ( HttpResponseOk ( status) )
3555+ } ;
3556+ apictx. external_latencies . instrument_dropshot_handler ( & rqctx, handler) . await
3557+ }
3558+
34923559// Images
34933560
34943561/// List images
0 commit comments