diff --git a/nexus/src/app/address_lot.rs b/nexus/src/app/address_lot.rs index 766258fc3b..199730638b 100644 --- a/nexus/src/app/address_lot.rs +++ b/nexus/src/app/address_lot.rs @@ -34,7 +34,7 @@ impl AddressLot { AddressLot { datastore } } - pub fn address_lot_lookup<'a>( + pub fn lookup<'a>( &'a self, opctx: &'a OpContext, address_lot: NameOrId, @@ -53,7 +53,7 @@ impl AddressLot { } } - pub(crate) async fn address_lot_create( + pub(crate) async fn create( &self, opctx: &OpContext, params: params::AddressLotCreate, @@ -63,7 +63,7 @@ impl AddressLot { self.datastore.address_lot_create(opctx, ¶ms).await } - pub(crate) async fn address_lot_delete( + pub(crate) async fn delete( &self, opctx: &OpContext, address_lot_lookup: &lookup::AddressLot<'_>, @@ -73,7 +73,7 @@ impl AddressLot { self.datastore.address_lot_delete(opctx, &authz_address_lot).await } - pub(crate) async fn address_lot_list( + pub(crate) async fn list( &self, opctx: &OpContext, pagparams: &PaginatedBy<'_>, @@ -82,7 +82,7 @@ impl AddressLot { self.datastore.address_lot_list(opctx, pagparams).await } - pub(crate) async fn address_lot_block_list( + pub(crate) async fn block_list( &self, opctx: &OpContext, address_lot: &lookup::AddressLot<'_>, diff --git a/nexus/src/app/allow_list.rs b/nexus/src/app/allow_list.rs index dbe6b1331a..ffa36ae5ed 100644 --- a/nexus/src/app/allow_list.rs +++ b/nexus/src/app/allow_list.rs @@ -35,10 +35,7 @@ impl SourceIpAllowList { } /// Fetch the allowlist of source IPs that can reach user-facing services. - pub async fn allow_list_view( - &self, - opctx: &OpContext, - ) -> Result { + pub async fn view(&self, opctx: &OpContext) -> Result { self.datastore .allow_list_view(opctx) .await @@ -46,7 +43,7 @@ impl SourceIpAllowList { } /// Upsert the allowlist of source IPs that can reach user-facing services. - pub async fn allow_list_upsert( + pub async fn upsert( &self, opctx: &OpContext, remote_addr: IpAddr, diff --git a/nexus/src/app/bfd.rs b/nexus/src/app/bfd.rs index 3bb9a1e423..fee88afd26 100644 --- a/nexus/src/app/bfd.rs +++ b/nexus/src/app/bfd.rs @@ -55,7 +55,7 @@ impl Bfd { Ok(mg_client) } - pub async fn bfd_enable( + pub async fn enable( &self, opctx: &OpContext, session: params::BfdSessionEnable, @@ -73,7 +73,7 @@ impl Bfd { Ok(()) } - pub async fn bfd_disable( + pub async fn disable( &self, opctx: &OpContext, session: params::BfdSessionDisable, @@ -91,7 +91,7 @@ impl Bfd { Ok(()) } - pub async fn bfd_status( + pub async fn status( &self, _opctx: &OpContext, ) -> Result, Error> { diff --git a/nexus/src/app/bgp.rs b/nexus/src/app/bgp.rs index b82f6f27cb..21ee2580cb 100644 --- a/nexus/src/app/bgp.rs +++ b/nexus/src/app/bgp.rs @@ -33,7 +33,7 @@ impl Bgp { ) -> Bgp { Bgp { log, datastore, internal_resolver } } - pub async fn bgp_config_set( + pub async fn config_set( &self, opctx: &OpContext, config: ¶ms::BgpConfigCreate, @@ -43,7 +43,7 @@ impl Bgp { Ok(result) } - pub async fn bgp_config_get( + pub async fn config_get( &self, opctx: &OpContext, name_or_id: NameOrId, @@ -52,7 +52,7 @@ impl Bgp { self.datastore.bgp_config_get(opctx, &name_or_id).await } - pub async fn bgp_config_list( + pub async fn config_list( &self, opctx: &OpContext, pagparams: &PaginatedBy<'_>, @@ -61,7 +61,7 @@ impl Bgp { self.datastore.bgp_config_list(opctx, pagparams).await } - pub async fn bgp_config_delete( + pub async fn config_delete( &self, opctx: &OpContext, sel: ¶ms::BgpConfigSelector, @@ -71,7 +71,7 @@ impl Bgp { Ok(result) } - pub async fn bgp_create_announce_set( + pub async fn create_announce_set( &self, opctx: &OpContext, announce: ¶ms::BgpAnnounceSetCreate, @@ -82,7 +82,7 @@ impl Bgp { Ok(result) } - pub async fn bgp_announce_list( + pub async fn announce_list( &self, opctx: &OpContext, sel: ¶ms::BgpAnnounceSetSelector, @@ -91,7 +91,7 @@ impl Bgp { self.datastore.bgp_announce_list(opctx, sel).await } - pub async fn bgp_delete_announce_set( + pub async fn delete_announce_set( &self, opctx: &OpContext, sel: ¶ms::BgpAnnounceSetSelector, @@ -101,7 +101,7 @@ impl Bgp { Ok(result) } - pub async fn bgp_peer_status( + pub async fn peer_status( &self, opctx: &OpContext, ) -> ListResultVec { @@ -162,7 +162,7 @@ impl Bgp { Ok(result) } - pub async fn bgp_message_history( + pub async fn message_history( &self, opctx: &OpContext, sel: ¶ms::BgpRouteSelector, @@ -205,7 +205,7 @@ impl Bgp { Ok(result) } - pub async fn bgp_imported_routes_ipv4( + pub async fn imported_routes_ipv4( &self, opctx: &OpContext, sel: ¶ms::BgpRouteSelector, diff --git a/nexus/src/app/certificate.rs b/nexus/src/app/certificate.rs index c4ea38a844..f40595cf14 100644 --- a/nexus/src/app/certificate.rs +++ b/nexus/src/app/certificate.rs @@ -43,7 +43,7 @@ impl Certificate { ) -> Certificate { Certificate { datastore, background_tasks, silo, opctx_external_authn } } - pub fn certificate_lookup<'a>( + pub fn lookup<'a>( &'a self, opctx: &'a OpContext, certificate: &'a NameOrId, @@ -57,7 +57,7 @@ impl Certificate { } } - pub(crate) async fn certificate_create( + pub(crate) async fn create( &self, opctx: &OpContext, params: params::CertificateCreate, @@ -82,7 +82,7 @@ impl Certificate { // name(s)). let silo_fq_dns_names = self .silo - .silo_fq_dns_names(&self.opctx_external_authn, authz_silo.id()) + .fq_dns_names(&self.opctx_external_authn, authz_silo.id()) .await?; let kind = params.service; @@ -109,7 +109,7 @@ impl Certificate { } } - pub(crate) async fn certificates_list( + pub(crate) async fn list( &self, opctx: &OpContext, pagparams: &PaginatedBy<'_>, @@ -117,7 +117,7 @@ impl Certificate { self.datastore.certificate_list_for(opctx, None, pagparams, true).await } - pub(crate) async fn certificate_delete( + pub(crate) async fn delete( &self, opctx: &OpContext, certificate_lookup: lookup::Certificate<'_>, diff --git a/nexus/src/app/crucible.rs b/nexus/src/app/crucible.rs index b999f38dec..6e6140cb3e 100644 --- a/nexus/src/app/crucible.rs +++ b/nexus/src/app/crucible.rs @@ -80,7 +80,7 @@ impl Crucible { Crucible { datastore, reqwest_client } } - fn crucible_agent_client_for_dataset( + fn agent_client_for_dataset( &self, dataset: &db::model::Dataset, ) -> CrucibleAgentClient { @@ -93,10 +93,7 @@ impl Crucible { /// Return if the Crucible agent is expected to be there and answer Nexus: /// true means it's gone, and the caller should bail out of the /// ProgenitorOperationRetry loop. - async fn crucible_agent_gone_check( - &self, - dataset_id: Uuid, - ) -> Result { + async fn agent_gone_check(&self, dataset_id: Uuid) -> Result { let on_in_service_physical_disk = self.datastore.dataset_physical_disk_in_service(dataset_id).await?; @@ -110,7 +107,7 @@ impl Crucible { dataset: &db::model::Dataset, region: &db::model::Region, ) -> Result { - let client = self.crucible_agent_client_for_dataset(dataset); + let client = self.agent_client_for_dataset(dataset); let dataset_id = dataset.id(); let Ok(extent_count) = u32::try_from(region.extent_count()) else { @@ -136,7 +133,7 @@ impl Crucible { let create_region = || async { let region = match ProgenitorOperationRetry::new( || async { client.region_create(®ion_request).await }, - || async { self.crucible_agent_gone_check(dataset_id).await }, + || async { self.agent_gone_check(dataset_id).await }, ) .run(log) .await @@ -211,20 +208,20 @@ impl Crucible { /// Returns a Ok(Some(Region)) if a region with id {region_id} exists, /// Ok(None) if it does not (a 404 was seen), and Err otherwise. - async fn maybe_get_crucible_region( + async fn maybe_get_region( &self, log: &Logger, dataset: &db::model::Dataset, region_id: Uuid, ) -> Result, Error> { - let client = self.crucible_agent_client_for_dataset(dataset); + let client = self.agent_client_for_dataset(dataset); let dataset_id = dataset.id(); let result = ProgenitorOperationRetry::new( || async { client.region_get(&RegionId(region_id.to_string())).await }, - || async { self.crucible_agent_gone_check(dataset_id).await }, + || async { self.agent_gone_check(dataset_id).await }, ) .run(log) .await; @@ -253,13 +250,13 @@ impl Crucible { } } - async fn get_crucible_region_snapshots( + async fn get_region_snapshots( &self, log: &Logger, dataset: &db::model::Dataset, region_id: Uuid, ) -> Result { - let client = self.crucible_agent_client_for_dataset(dataset); + let client = self.agent_client_for_dataset(dataset); let dataset_id = dataset.id(); let result = ProgenitorOperationRetry::new( @@ -268,7 +265,7 @@ impl Crucible { .region_get_snapshots(&RegionId(region_id.to_string())) .await }, - || async { self.crucible_agent_gone_check(dataset_id).await }, + || async { self.agent_gone_check(dataset_id).await }, ) .run(log) .await; @@ -293,20 +290,20 @@ impl Crucible { } /// Send a region deletion request - async fn request_crucible_region_delete( + async fn request_region_delete( &self, log: &Logger, dataset: &db::model::Dataset, region_id: Uuid, ) -> Result<(), Error> { - let client = self.crucible_agent_client_for_dataset(dataset); + let client = self.agent_client_for_dataset(dataset); let dataset_id = dataset.id(); let result = ProgenitorOperationRetry::new( || async { client.region_delete(&RegionId(region_id.to_string())).await }, - || async { self.crucible_agent_gone_check(dataset_id).await }, + || async { self.agent_gone_check(dataset_id).await }, ) .run(log) .await; @@ -335,14 +332,14 @@ impl Crucible { } /// Send a running snapshot deletion request - async fn request_crucible_running_snapshot_delete( + async fn request_running_snapshot_delete( &self, log: &Logger, dataset: &db::model::Dataset, region_id: Uuid, snapshot_id: Uuid, ) -> Result<(), Error> { - let client = self.crucible_agent_client_for_dataset(dataset); + let client = self.agent_client_for_dataset(dataset); let dataset_id = dataset.id(); let result = ProgenitorOperationRetry::new( @@ -354,7 +351,7 @@ impl Crucible { ) .await }, - || async { self.crucible_agent_gone_check(dataset_id).await }, + || async { self.agent_gone_check(dataset_id).await }, ) .run(log) .await; @@ -384,14 +381,14 @@ impl Crucible { } /// Send a snapshot deletion request - async fn request_crucible_snapshot_delete( + async fn request_snapshot_delete( &self, log: &Logger, dataset: &db::model::Dataset, region_id: Uuid, snapshot_id: Uuid, ) -> Result<(), Error> { - let client = self.crucible_agent_client_for_dataset(dataset); + let client = self.agent_client_for_dataset(dataset); let dataset_id = dataset.id(); let result = ProgenitorOperationRetry::new( @@ -403,7 +400,7 @@ impl Crucible { ) .await }, - || async { self.crucible_agent_gone_check(dataset_id).await }, + || async { self.agent_gone_check(dataset_id).await }, ) .run(log) .await; @@ -433,7 +430,7 @@ impl Crucible { } /// Call out to a Crucible agent to delete a region - async fn delete_crucible_region( + async fn delete_region( &self, log: &Logger, dataset: &db::model::Dataset, @@ -444,7 +441,7 @@ impl Crucible { // existed. This can occur if an `ensure_all_datasets_and_regions` // partially fails. - match self.maybe_get_crucible_region(log, dataset, region_id).await { + match self.maybe_get_region(log, dataset, region_id).await { Ok(Some(_)) => { // region found, proceed with deleting } @@ -473,7 +470,7 @@ impl Crucible { // deleted. Request the deletion (which is idempotent), then wait for // the appropriate state change. - self.request_crucible_region_delete(log, dataset, region_id).await?; + self.request_region_delete(log, dataset, region_id).await?; // Wait until the region is deleted @@ -481,7 +478,7 @@ impl Crucible { backoff::retry_policy_internal_service_aggressive(), || async { let region = match self - .maybe_get_crucible_region(log, dataset, region_id) + .maybe_get_region(log, dataset, region_id) .await { Ok(None) => Err(BackoffError::Permanent( @@ -553,7 +550,7 @@ impl Crucible { }) } - async fn delete_crucible_running_snapshot_impl( + async fn delete_running_snapshot_impl( &self, log: &Logger, dataset: &db::model::Dataset, @@ -562,7 +559,7 @@ impl Crucible { ) -> Result<(), Error> { // request running snapshot deletion - self.request_crucible_running_snapshot_delete( + self.request_running_snapshot_delete( log, dataset, region_id, @@ -575,7 +572,7 @@ impl Crucible { backoff::retry_notify( backoff::retry_policy_internal_service_aggressive(), || async { - let response = match self.get_crucible_region_snapshots( + let response = match self.get_region_snapshots( log, dataset, region_id, @@ -677,18 +674,17 @@ impl Crucible { }) } - pub async fn delete_crucible_snapshot( + pub async fn delete_snapshot( &self, log: &Logger, dataset: &db::model::Dataset, region_id: Uuid, snapshot_id: Uuid, ) -> Result<(), Error> { - self.delete_crucible_snapshot_impl(log, dataset, region_id, snapshot_id) - .await + self.delete_snapshot_impl(log, dataset, region_id, snapshot_id).await } - async fn delete_crucible_snapshot_impl( + async fn delete_snapshot_impl( &self, log: &Logger, dataset: &db::model::Dataset, @@ -711,19 +707,14 @@ impl Crucible { "snapshot_id" => %snapshot_id, ); - self.request_crucible_snapshot_delete( - log, - dataset, - region_id, - snapshot_id, - ) - .await?; + self.request_snapshot_delete(log, dataset, region_id, snapshot_id) + .await?; backoff::retry_notify( backoff::retry_policy_internal_service_aggressive(), || async { let response = match self - .get_crucible_region_snapshots(log, dataset, region_id) + .get_region_snapshots(log, dataset, region_id) .await { Ok(v) => Ok(v), @@ -851,7 +842,7 @@ impl Crucible { /// Given a list of datasets and regions, send DELETE calls to the datasets /// corresponding Crucible Agent for each region. - pub async fn delete_crucible_regions( + pub async fn delete_regions( &self, log: &Logger, datasets_and_regions: Vec<(db::model::Dataset, db::model::Region)>, @@ -863,7 +854,7 @@ impl Crucible { futures::stream::iter(datasets_and_regions) .map(|(dataset, region)| async move { - self.delete_crucible_region(log, &dataset, region.id()).await + self.delete_region(log, &dataset, region.id()).await }) // Execute the requests concurrently. .buffer_unordered(std::cmp::min( @@ -879,26 +870,21 @@ impl Crucible { } /// Ensure that a Crucible "running snapshot" is deleted. - pub async fn delete_crucible_running_snapshot( + pub async fn delete_running_snapshot( &self, log: &Logger, dataset: &db::model::Dataset, region_id: Uuid, snapshot_id: Uuid, ) -> Result<(), Error> { - self.delete_crucible_running_snapshot_impl( - log, - dataset, - region_id, - snapshot_id, - ) - .await + self.delete_running_snapshot_impl(log, dataset, region_id, snapshot_id) + .await } /// Given a list of datasets and region snapshots, send DELETE calls to the /// datasets corresponding Crucible Agent for each running read-only /// downstairs corresponding to the snapshot. - pub async fn delete_crucible_running_snapshots( + pub async fn delete_running_snapshots( &self, log: &Logger, datasets_and_snapshots: Vec<( @@ -913,7 +899,7 @@ impl Crucible { futures::stream::iter(datasets_and_snapshots) .map(|(dataset, region_snapshot)| async move { - self.delete_crucible_running_snapshot_impl( + self.delete_running_snapshot_impl( &log, &dataset, region_snapshot.region_id, @@ -936,7 +922,7 @@ impl Crucible { /// Given a list of datasets and region snapshots, send DELETE calls to the /// dataset's corresponding Crucible Agent for each snapshot. - pub async fn delete_crucible_snapshots( + pub async fn delete_snapshots( &self, log: &Logger, datasets_and_snapshots: Vec<( @@ -951,7 +937,7 @@ impl Crucible { futures::stream::iter(datasets_and_snapshots) .map(|(dataset, region_snapshot)| async move { - self.delete_crucible_snapshot_impl( + self.delete_snapshot_impl( &log, &dataset, region_snapshot.region_id, diff --git a/nexus/src/app/deployment.rs b/nexus/src/app/deployment.rs index ae85545879..ca26d47826 100644 --- a/nexus/src/app/deployment.rs +++ b/nexus/src/app/deployment.rs @@ -56,7 +56,7 @@ impl Blueprint { Blueprint { nexus_id, datastore, background_tasks } } - pub async fn blueprint_list( + pub async fn list( &self, opctx: &OpContext, pagparams: &DataPageParams<'_, Uuid>, @@ -64,7 +64,7 @@ impl Blueprint { self.datastore.blueprints_list(opctx, pagparams).await } - pub async fn blueprint_view( + pub async fn view( &self, opctx: &OpContext, blueprint_id: Uuid, @@ -77,7 +77,7 @@ impl Blueprint { self.datastore.blueprint_read(opctx, &blueprint).await } - pub async fn blueprint_delete( + pub async fn delete( &self, opctx: &OpContext, blueprint_id: Uuid, @@ -90,14 +90,14 @@ impl Blueprint { self.datastore.blueprint_delete(opctx, &blueprint).await } - pub async fn blueprint_target_view( + pub async fn target_view( &self, opctx: &OpContext, ) -> Result { self.datastore.blueprint_target_get_current(opctx).await } - pub async fn blueprint_target_set( + pub async fn target_set( &self, opctx: &OpContext, params: BlueprintTargetSet, @@ -118,7 +118,7 @@ impl Blueprint { Ok(new_target) } - pub async fn blueprint_target_set_enabled( + pub async fn target_set_enabled( &self, opctx: &OpContext, params: BlueprintTargetSet, @@ -141,7 +141,7 @@ impl Blueprint { Ok(new_target) } - async fn blueprint_planning_context( + async fn planning_context( &self, opctx: &OpContext, ) -> Result { @@ -222,7 +222,7 @@ impl Blueprint { Ok(PlanningContext { planning_input, creator, inventory }) } - async fn blueprint_add( + async fn add( &self, opctx: &OpContext, blueprint: &nexus_types::deployment::Blueprint, @@ -230,14 +230,14 @@ impl Blueprint { self.datastore.blueprint_insert(opctx, blueprint).await } - pub async fn blueprint_create_regenerate( + pub async fn create_regenerate( &self, opctx: &OpContext, ) -> CreateResult { let (_, parent_blueprint) = self.datastore.blueprint_target_get_current_full(opctx).await?; - let planning_context = self.blueprint_planning_context(opctx).await?; + let planning_context = self.planning_context(opctx).await?; let inventory = planning_context.inventory.ok_or_else(|| { Error::internal_error("no recent inventory collection found") })?; @@ -260,16 +260,16 @@ impl Blueprint { )) })?; - self.blueprint_add(&opctx, &blueprint).await?; + self.add(&opctx, &blueprint).await?; Ok(blueprint) } - pub async fn blueprint_import( + pub async fn import( &self, opctx: &OpContext, blueprint: nexus_types::deployment::Blueprint, ) -> Result<(), Error> { - let _ = self.blueprint_add(&opctx, &blueprint).await?; + let _ = self.add(&opctx, &blueprint).await?; Ok(()) } } diff --git a/nexus/src/app/device_auth.rs b/nexus/src/app/device_auth.rs index 7bc3454d9e..4de44fe363 100644 --- a/nexus/src/app/device_auth.rs +++ b/nexus/src/app/device_auth.rs @@ -70,7 +70,7 @@ impl DeviceAuth { /// Start a device authorization grant flow. /// Corresponds to steps 1 & 2 in the flow description above. - pub(crate) async fn device_auth_request_create( + pub(crate) async fn request_create( &self, opctx: &OpContext, client_id: Uuid, @@ -87,7 +87,7 @@ impl DeviceAuth { /// request so that at most one token will be granted per request. /// Invoked in response to a request from the browser, not the client. /// Corresponds to step 5 in the flow description above. - pub(crate) async fn device_auth_request_verify( + pub(crate) async fn request_verify( &self, opctx: &OpContext, user_code: String, diff --git a/nexus/src/app/disk.rs b/nexus/src/app/disk.rs index 41abb9c9ac..ddd34defc8 100644 --- a/nexus/src/app/disk.rs +++ b/nexus/src/app/disk.rs @@ -76,7 +76,7 @@ impl Disk { &self.default_region_allocation_strategy } - pub fn disk_lookup<'a>( + pub fn lookup<'a>( &'a self, opctx: &'a OpContext, disk_selector: params::DiskSelector, @@ -92,7 +92,7 @@ impl Disk { project: Some(project), } => { let disk = self.project - .project_lookup(opctx, params::ProjectSelector { project })? + .lookup(opctx, params::ProjectSelector { project })? .disk_name_owned(name.into()); Ok(disk) } @@ -259,7 +259,7 @@ impl Disk { Ok(disk_created) } - pub(crate) async fn disk_list( + pub(crate) async fn list( &self, opctx: &OpContext, project_lookup: &lookup::Project<'_>, @@ -277,7 +277,7 @@ impl Disk { // However, it has been left for reference until then, as it will // likely be needed once that feature is implemented. #[allow(dead_code)] - pub(crate) async fn disk_set_runtime( + pub(crate) async fn set_runtime( &self, opctx: &OpContext, authz_disk: &authz::Disk, @@ -403,7 +403,7 @@ impl Disk { /// This is just a wrapper around the volume operation of the same /// name, but we provide this interface when all the caller has is /// the disk UUID as the internal volume_id is not exposed. - pub(crate) async fn disk_remove_read_only_parent( + pub(crate) async fn remove_read_only_parent( &self, opctx: &OpContext, saga_context: &SagaContext, @@ -418,11 +418,7 @@ impl Disk { .await?; self.volume - .volume_remove_read_only_parent( - &opctx, - saga_context, - db_disk.volume_id, - ) + .remove_read_only_parent(&opctx, saga_context, db_disk.volume_id) .await?; Ok(()) @@ -430,7 +426,7 @@ impl Disk { /// Move a disk from the "ImportReady" state to the "Importing" state, /// blocking any import from URL jobs. - pub(crate) async fn disk_manual_import_start( + pub(crate) async fn manual_import_start( &self, opctx: &OpContext, disk_lookup: &lookup::Disk<'_>, @@ -467,7 +463,7 @@ impl Disk { } /// Bulk write some bytes into a disk that's in state ImportingFromBulkWrites - pub(crate) async fn disk_manual_import( + pub(crate) async fn manual_import( &self, disk_lookup: &lookup::Disk<'_>, param: params::ImportBlocksBulkWrite, @@ -589,7 +585,7 @@ impl Disk { /// Move a disk from the "ImportingFromBulkWrites" state to the /// "ImportReady" state, usually signalling the end of manually importing /// blocks. - pub(crate) async fn disk_manual_import_stop( + pub(crate) async fn manual_import_stop( &self, opctx: &OpContext, disk_lookup: &lookup::Disk<'_>, @@ -627,7 +623,7 @@ impl Disk { /// Move a disk from the "ImportReady" state to the "Detach" state, making /// it ready for general use. - pub(crate) async fn disk_finalize_import( + pub(crate) async fn finalize_import( &self, opctx: &OpContext, saga_context: &SagaContext, diff --git a/nexus/src/app/external_ip.rs b/nexus/src/app/external_ip.rs index 26d5789956..9fe8907f4c 100644 --- a/nexus/src/app/external_ip.rs +++ b/nexus/src/app/external_ip.rs @@ -90,7 +90,7 @@ impl ExternalIp { } => { let floating_ip = self .project - .project_lookup(opctx, params::ProjectSelector { project })? + .lookup(opctx, params::ProjectSelector { project })? .floating_ip_name_owned(name.into()); Ok(floating_ip) } @@ -139,7 +139,7 @@ impl ExternalIp { let pool = match pool { Some(pool) => Some( self.ip_pool - .ip_pool_lookup(opctx, &pool)? + .lookup(opctx, &pool)? .lookup_for(authz::Action::CreateChild) .await? .0, @@ -208,10 +208,10 @@ impl ExternalIp { }; let instance = - self.instance.instance_lookup(opctx, instance_selector)?; + self.instance.lookup(opctx, instance_selector)?; self.instance - .instance_attach_floating_ip( + .attach_floating_ip( opctx, saga_context, &instance, @@ -246,19 +246,13 @@ impl ExternalIp { project: None, instance: parent_id.into(), }; - let instance = - self.instance.instance_lookup(opctx, instance_selector)?; + let instance = self.instance.lookup(opctx, instance_selector)?; let attach_params = ¶ms::ExternalIpDetach::Floating { floating_ip: authz_fip.id().into(), }; self.instance - .instance_detach_external_ip( - opctx, - saga_context, - &instance, - attach_params, - ) + .detach_external_ip(opctx, saga_context, &instance, attach_params) .await .and_then(FloatingIp::try_from) } diff --git a/nexus/src/app/image.rs b/nexus/src/app/image.rs index 3138b00eeb..df09c87fd0 100644 --- a/nexus/src/app/image.rs +++ b/nexus/src/app/image.rs @@ -50,7 +50,7 @@ impl Image { ) -> Image { Image { datastore, project, silo, sec_client } } - pub(crate) async fn image_lookup<'a>( + pub(crate) async fn lookup<'a>( &'a self, opctx: &'a OpContext, image_selector: params::ImageSelector, @@ -77,7 +77,7 @@ impl Image { project: Some(project), } => { let image = - self.project.project_lookup(opctx, params::ProjectSelector { project })?.project_image_name_owned(name.into()); + self.project.lookup(opctx, params::ProjectSelector { project })?.project_image_name_owned(name.into()); Ok(ImageLookup::ProjectImage(image)) } params::ImageSelector { @@ -97,7 +97,7 @@ impl Image { } /// Creates an image - pub(crate) async fn image_create( + pub(crate) async fn create( &self, opctx: &OpContext, lookup_parent: &ImageParentLookup<'_>, @@ -243,7 +243,7 @@ impl Image { } } - pub(crate) async fn image_list( + pub(crate) async fn list( &self, opctx: &OpContext, parent_lookup: &ImageParentLookup<'_>, @@ -267,7 +267,7 @@ impl Image { } } - pub(crate) async fn image_delete( + pub(crate) async fn delete( &self, opctx: &OpContext, saga_context: &SagaContext, @@ -302,7 +302,7 @@ impl Image { } /// Converts a project scoped image into a silo scoped image - pub(crate) async fn image_promote( + pub(crate) async fn promote( &self, opctx: &OpContext, image_lookup: &ImageLookup<'_>, @@ -330,7 +330,7 @@ impl Image { } /// Converts a silo scoped image into a project scoped image - pub(crate) async fn image_demote( + pub(crate) async fn demote( &self, opctx: &OpContext, image_lookup: &ImageLookup<'_>, diff --git a/nexus/src/app/instance.rs b/nexus/src/app/instance.rs index 046dd2d2d5..644e3002d4 100644 --- a/nexus/src/app/instance.rs +++ b/nexus/src/app/instance.rs @@ -248,7 +248,7 @@ impl Instance { } } - pub fn instance_lookup<'a>( + pub fn lookup<'a>( &'a self, opctx: &'a OpContext, instance_selector: params::InstanceSelector, @@ -267,7 +267,7 @@ impl Instance { project: Some(project) } => { let instance = self.project - .project_lookup(opctx, params::ProjectSelector { project })? + .lookup(opctx, params::ProjectSelector { project })? .instance_name_owned(name.into()); Ok(instance) } @@ -460,8 +460,7 @@ impl Instance { let lookup = LookupPath::new(opctx, &self.datastore) .instance_id(instance_id); - let start_result = - self.instance_start(opctx, saga_context, &lookup).await; + let start_result = self.start(opctx, saga_context, &lookup).await; if let Err(e) = start_result { info!(self.log, "failed to start newly-created instance"; "instance_id" => %instance_id, @@ -487,7 +486,7 @@ impl Instance { self.datastore.instance_fetch_with_vmm(opctx, &authz_instance).await } - pub(crate) async fn instance_list( + pub(crate) async fn list( &self, opctx: &OpContext, project_lookup: &lookup::Project<'_>, @@ -606,7 +605,7 @@ impl Instance { /// /// Asserts that `db_instance` has no migration ID or destination Propolis /// ID set. - pub(crate) async fn instance_set_migration_ids( + pub(crate) async fn set_migration_ids( &self, opctx: &OpContext, instance_id: Uuid, @@ -622,7 +621,7 @@ impl Instance { .lookup_for(authz::Action::Modify) .await?; - let sa = self.sled.sled_client(&sled_id).await?; + let sa = self.sled.client(&sled_id).await?; let instance_put_result = sa .instance_put_migration_ids( &instance_id, @@ -646,11 +645,7 @@ impl Instance { Err(e) => { if e.instance_unhealthy() { let _ = self - .mark_instance_failed( - &instance_id, - &prev_instance_runtime, - &e, - ) + .mark_failed(&instance_id, &prev_instance_runtime, &e) .await; } return Err(e.into()); @@ -681,7 +676,7 @@ impl Instance { /// /// Asserts that `db_instance` has a migration ID and destination Propolis /// ID set. - pub(crate) async fn instance_clear_migration_ids( + pub(crate) async fn clear_migration_ids( &self, instance_id: Uuid, sled_id: Uuid, @@ -690,7 +685,7 @@ impl Instance { assert!(prev_instance_runtime.migration_id.is_some()); assert!(prev_instance_runtime.dst_propolis_id.is_some()); - let sa = self.sled.sled_client(&sled_id).await?; + let sa = self.sled.client(&sled_id).await?; let instance_put_result = sa .instance_put_migration_ids( &instance_id, @@ -710,11 +705,7 @@ impl Instance { Err(e) => { if e.instance_unhealthy() { let _ = self - .mark_instance_failed( - &instance_id, - &prev_instance_runtime, - &e, - ) + .mark_failed(&instance_id, &prev_instance_runtime, &e) .await; } return Err(e.into()); @@ -725,7 +716,7 @@ impl Instance { } /// Reboot the specified instance. - pub(crate) async fn instance_reboot( + pub(crate) async fn reboot( &self, opctx: &OpContext, instance_lookup: &lookup::Instance<'_>, @@ -739,7 +730,7 @@ impl Instance { .await?; if let Err(e) = self - .instance_request_state( + .request_state( opctx, &authz_instance, state.instance(), @@ -751,7 +742,7 @@ impl Instance { if let InstanceStateChangeError::SledAgent(inner) = &e { if inner.instance_unhealthy() { let _ = self - .mark_instance_failed( + .mark_failed( &authz_instance.id(), state.instance().runtime(), inner, @@ -767,7 +758,7 @@ impl Instance { } /// Attempts to start an instance if it is currently stopped. - pub(crate) async fn instance_start( + pub(crate) async fn start( &self, opctx: &OpContext, saga_context: &SagaContext, @@ -832,7 +823,7 @@ impl Instance { } /// Make sure the given Instance is stopped. - pub(crate) async fn instance_stop( + pub(crate) async fn stop( &self, opctx: &OpContext, instance_lookup: &lookup::Instance<'_>, @@ -846,7 +837,7 @@ impl Instance { .await?; if let Err(e) = self - .instance_request_state( + .request_state( opctx, &authz_instance, state.instance(), @@ -858,7 +849,7 @@ impl Instance { if let InstanceStateChangeError::SledAgent(inner) = &e { if inner.instance_unhealthy() { let _ = self - .mark_instance_failed( + .mark_failed( &authz_instance.id(), state.instance().runtime(), inner, @@ -876,7 +867,7 @@ impl Instance { /// Idempotently ensures that the sled specified in `db_instance` does not /// have a record of the instance. If the instance is currently running on /// this sled, this operation rudely terminates it. - pub(crate) async fn instance_ensure_unregistered( + pub(crate) async fn ensure_unregistered( &self, opctx: &OpContext, authz_instance: &authz::Instance, @@ -884,7 +875,7 @@ impl Instance { ) -> Result, InstanceStateChangeError> { opctx.authorize(authz::Action::Modify, authz_instance).await?; - let sa = self.sled.sled_client(&sled_id).await?; + let sa = self.sled.client(&sled_id).await?; sa.instance_unregister(&authz_instance.id()) .await .map(|res| res.into_inner().updated_runtime.map(Into::into)) @@ -1038,7 +1029,7 @@ impl Instance { } } - pub(crate) async fn instance_request_state( + pub(crate) async fn request_state( &self, opctx: &OpContext, authz_instance: &authz::Instance, @@ -1056,7 +1047,7 @@ impl Instance { )? { InstanceStateChangeRequestAction::AlreadyDone => Ok(()), InstanceStateChangeRequestAction::SendToSled(sled_id) => { - let sa = self.sled.sled_client(&sled_id).await?; + let sa = self.sled.client(&sled_id).await?; let instance_put_result = sa .instance_put_state( &instance_id, @@ -1089,7 +1080,7 @@ impl Instance { /// Modifies the runtime state of the Instance as requested. This generally /// means booting or halting the Instance. - pub(crate) async fn instance_ensure_registered( + pub(crate) async fn ensure_registered( &self, opctx: &OpContext, authz_instance: &authz::Instance, @@ -1296,7 +1287,7 @@ impl Instance { // IDs. let (.., db_project) = self .project - .project_lookup( + .lookup( opctx, params::ProjectSelector { project: NameOrId::Id(db_instance.project_id), @@ -1340,7 +1331,7 @@ impl Instance { )), }; - let sa = self.sled.sled_client(&initial_vmm.sled_id).await?; + let sa = self.sled.client(&initial_vmm.sled_id).await?; let instance_register_result = sa .instance_register( &db_instance.id(), @@ -1369,7 +1360,7 @@ impl Instance { Err(e) => { if e.instance_unhealthy() { let _ = self - .mark_instance_failed( + .mark_failed( &db_instance.id(), db_instance.runtime(), &e, @@ -1432,7 +1423,7 @@ impl Instance { /// Attempts to move an instance from `prev_instance_runtime` to the /// `Failed` state in response to an error returned from a call to a sled /// agent instance API, supplied in `reason`. - pub(crate) async fn mark_instance_failed( + pub(crate) async fn mark_failed( &self, instance_id: &Uuid, prev_instance_runtime: &db::model::InstanceRuntimeState, @@ -1472,7 +1463,7 @@ impl Instance { } /// Lists disks attached to the instance. - pub(crate) async fn instance_list_disks( + pub(crate) async fn list_disks( &self, opctx: &OpContext, instance_lookup: &lookup::Instance<'_>, @@ -1486,7 +1477,7 @@ impl Instance { } /// Attach a disk to an instance. - pub(crate) async fn instance_attach_disk( + pub(crate) async fn attach_disk( &self, opctx: &OpContext, instance_lookup: &lookup::Instance<'_>, @@ -1496,7 +1487,7 @@ impl Instance { instance_lookup.lookup_for(authz::Action::Modify).await?; let (.., authz_project_disk, authz_disk) = self .disk - .disk_lookup( + .lookup( opctx, params::DiskSelector { project: match disk { @@ -1547,7 +1538,7 @@ impl Instance { } /// Detach a disk from an instance. - pub(crate) async fn instance_detach_disk( + pub(crate) async fn detach_disk( &self, opctx: &OpContext, instance_lookup: &lookup::Instance<'_>, @@ -1557,7 +1548,7 @@ impl Instance { instance_lookup.lookup_for(authz::Action::Modify).await?; let (.., authz_disk) = self .disk - .disk_lookup( + .lookup( opctx, params::DiskSelector { project: match disk { @@ -1613,7 +1604,7 @@ impl Instance { /// Returns the requested range of serial console output bytes, /// provided they are still in the propolis-server's cache. - pub(crate) async fn instance_serial_console_data( + pub(crate) async fn serial_console_data( &self, opctx: &OpContext, instance_lookup: &lookup::Instance<'_>, @@ -1653,7 +1644,7 @@ impl Instance { }) } - pub(crate) async fn instance_serial_console_stream( + pub(crate) async fn serial_console_stream( &self, opctx: &OpContext, mut client_stream: WebSocketStream, @@ -1927,7 +1918,7 @@ impl Instance { } /// Attach an ephemeral IP to an instance. - pub(crate) async fn instance_attach_ephemeral_ip( + pub(crate) async fn attach_ephemeral_ip( &self, opctx: &OpContext, saga_context: &SagaContext, @@ -1937,7 +1928,7 @@ impl Instance { let (.., authz_project, authz_instance) = instance_lookup.lookup_for(authz::Action::Modify).await?; - self.instance_attach_external_ip( + self.attach_external_ip( opctx, saga_context, authz_instance, @@ -1948,7 +1939,7 @@ impl Instance { } /// Attach an ephemeral IP to an instance. - pub(crate) async fn instance_attach_floating_ip( + pub(crate) async fn attach_floating_ip( &self, opctx: &OpContext, saga_context: &SagaContext, @@ -1965,7 +1956,7 @@ impl Instance { )); } - self.instance_attach_external_ip( + self.attach_external_ip( opctx, saga_context, authz_instance, @@ -1976,7 +1967,7 @@ impl Instance { } /// Attach an external IP to an instance. - pub(crate) async fn instance_attach_external_ip( + pub(crate) async fn attach_external_ip( &self, opctx: &OpContext, saga_context: &SagaContext, @@ -2006,7 +1997,7 @@ impl Instance { } /// Detach an external IP from an instance. - pub(crate) async fn instance_detach_external_ip( + pub(crate) async fn detach_external_ip( &self, opctx: &OpContext, saga_context: &SagaContext, diff --git a/nexus/src/app/ip_pool.rs b/nexus/src/app/ip_pool.rs index d10492e6cb..ce6e4074cc 100644 --- a/nexus/src/app/ip_pool.rs +++ b/nexus/src/app/ip_pool.rs @@ -60,7 +60,7 @@ impl IpPool { IpPool { datastore, silo } } - pub fn ip_pool_lookup<'a>( + pub fn lookup<'a>( &'a self, opctx: &'a OpContext, pool: &'a NameOrId, @@ -79,7 +79,7 @@ impl IpPool { } } - pub(crate) async fn ip_pool_create( + pub(crate) async fn create( &self, opctx: &OpContext, pool_params: ¶ms::IpPoolCreate, @@ -112,8 +112,7 @@ impl IpPool { opctx: &'a OpContext, pool: &'a NameOrId, ) -> LookupResult<(db::model::IpPool, db::model::IpPoolResource)> { - let (authz_pool, pool) = - self.ip_pool_lookup(opctx, pool)?.fetch().await?; + let (authz_pool, pool) = self.lookup(opctx, pool)?.fetch().await?; // 404 if no link is found in the current silo let link = self.datastore.ip_pool_fetch_link(opctx, pool.id()).await; @@ -124,7 +123,7 @@ impl IpPool { } /// List silos for a given pool - pub(crate) async fn ip_pool_silo_list( + pub(crate) async fn silo_list( &self, opctx: &OpContext, pool_lookup: &lookup::IpPool<'_>, @@ -155,7 +154,7 @@ impl IpPool { self.datastore.silo_ip_pool_list(opctx, &authz_silo, pagparams).await } - pub(crate) async fn ip_pool_link_silo( + pub(crate) async fn link_silo( &self, opctx: &OpContext, pool_lookup: &lookup::IpPool<'_>, @@ -170,7 +169,7 @@ impl IpPool { let (authz_silo,) = self .silo - .silo_lookup(&opctx, silo_link.silo.clone())? + .lookup(&opctx, silo_link.silo.clone())? .lookup_for(authz::Action::Modify) .await?; self.datastore @@ -186,7 +185,7 @@ impl IpPool { .await } - pub(crate) async fn ip_pool_unlink_silo( + pub(crate) async fn unlink_silo( &self, opctx: &OpContext, pool_lookup: &lookup::IpPool<'_>, @@ -207,7 +206,7 @@ impl IpPool { .await } - pub(crate) async fn ip_pool_silo_update( + pub(crate) async fn silo_update( &self, opctx: &OpContext, pool_lookup: &lookup::IpPool<'_>, @@ -234,7 +233,7 @@ impl IpPool { .await } - pub(crate) async fn ip_pools_list( + pub(crate) async fn list( &self, opctx: &OpContext, pagparams: &PaginatedBy<'_>, @@ -242,7 +241,7 @@ impl IpPool { self.datastore.ip_pools_list(opctx, pagparams).await } - pub(crate) async fn ip_pool_delete( + pub(crate) async fn delete( &self, opctx: &OpContext, pool_lookup: &lookup::IpPool<'_>, @@ -257,7 +256,7 @@ impl IpPool { self.datastore.ip_pool_delete(opctx, &authz_pool, &db_pool).await } - pub(crate) async fn ip_pool_update( + pub(crate) async fn update( &self, opctx: &OpContext, pool_lookup: &lookup::IpPool<'_>, @@ -275,7 +274,7 @@ impl IpPool { .await } - pub(crate) async fn ip_pool_list_ranges( + pub(crate) async fn list_ranges( &self, opctx: &OpContext, pool_lookup: &lookup::IpPool<'_>, @@ -291,7 +290,7 @@ impl IpPool { self.datastore.ip_pool_list_ranges(opctx, &authz_pool, pagparams).await } - pub(crate) async fn ip_pool_add_range( + pub(crate) async fn add_range( &self, opctx: &OpContext, pool_lookup: &lookup::IpPool<'_>, @@ -320,7 +319,7 @@ impl IpPool { self.datastore.ip_pool_add_range(opctx, &authz_pool, range).await } - pub(crate) async fn ip_pool_delete_range( + pub(crate) async fn delete_range( &self, opctx: &OpContext, pool_lookup: &lookup::IpPool<'_>, @@ -342,7 +341,7 @@ impl IpPool { // TODO(https://github.com/oxidecomputer/omicron/issues/1276): Should be // accessed via AZ UUID, probably. - pub(crate) async fn ip_pool_service_fetch( + pub(crate) async fn service_fetch( &self, opctx: &OpContext, ) -> LookupResult { @@ -352,7 +351,7 @@ impl IpPool { Ok(db_pool) } - pub(crate) async fn ip_pool_service_list_ranges( + pub(crate) async fn service_list_ranges( &self, opctx: &OpContext, pagparams: &DataPageParams<'_, IpNetwork>, @@ -363,7 +362,7 @@ impl IpPool { self.datastore.ip_pool_list_ranges(opctx, &authz_pool, pagparams).await } - pub(crate) async fn ip_pool_service_add_range( + pub(crate) async fn service_add_range( &self, opctx: &OpContext, range: &IpRange, @@ -386,7 +385,7 @@ impl IpPool { self.datastore.ip_pool_add_range(opctx, &authz_pool, range).await } - pub(crate) async fn ip_pool_service_delete_range( + pub(crate) async fn service_delete_range( &self, opctx: &OpContext, range: &IpRange, diff --git a/nexus/src/app/network_interface.rs b/nexus/src/app/network_interface.rs index 2f8526c8d8..3c2214868e 100644 --- a/nexus/src/app/network_interface.rs +++ b/nexus/src/app/network_interface.rs @@ -65,7 +65,7 @@ impl NetworkInterface { project } => { let network_interface = self.instance - .instance_lookup(opctx, params::InstanceSelector { project, instance })? + .lookup(opctx, params::InstanceSelector { project, instance })? .instance_network_interface_name_owned(name.into()); Ok(network_interface) } diff --git a/nexus/src/app/probe.rs b/nexus/src/app/probe.rs index f998eb11cc..e1965c50e3 100644 --- a/nexus/src/app/probe.rs +++ b/nexus/src/app/probe.rs @@ -52,7 +52,7 @@ impl Probe { } /// List the probes in the given project. - pub(crate) async fn probe_list( + pub(crate) async fn list( &self, opctx: &OpContext, project_lookup: &lookup::Project<'_>, @@ -65,7 +65,7 @@ impl Probe { /// List the probes for the given sled. This is used by sled agents to /// determine what probes they should be running. - pub(crate) async fn probe_list_for_sled( + pub(crate) async fn list_for_sled( &self, opctx: &OpContext, pagparams: &DataPageParams<'_, Uuid>, @@ -75,7 +75,7 @@ impl Probe { } /// Get info about a particular probe. - pub(crate) async fn probe_get( + pub(crate) async fn get( &self, opctx: &OpContext, project_lookup: &lookup::Project<'_>, @@ -89,7 +89,7 @@ impl Probe { /// Create a probe. This adds the probe to the data store and sets up the /// NAT state on the switch. Actual launching of the probe is done by the /// target sled agent asynchronously. - pub(crate) async fn probe_create( + pub(crate) async fn create( &self, opctx: &OpContext, project_lookup: &lookup::Project<'_>, @@ -102,7 +102,7 @@ impl Probe { let pool = match &new_probe_params.ip_pool { Some(pool) => Some( self.ip_pool - .ip_pool_lookup(opctx, &pool)? + .lookup(opctx, &pool)? .lookup_for(authz::Action::CreateChild) .await? .0, @@ -117,11 +117,8 @@ impl Probe { .probe_create(opctx, &authz_project, &new_probe, pool) .await?; - let (.., sled) = self - .sled - .sled_lookup(opctx, &new_probe_params.sled)? - .fetch() - .await?; + let (.., sled) = + self.sled.lookup(opctx, &new_probe_params.sled)?.fetch().await?; let boundary_switches = self.instance_network.boundary_switches(&self.opctx_alloc).await?; @@ -158,13 +155,13 @@ impl Probe { /// Delete a probe. This deletes the probe from the data store and tears /// down the associated NAT state. - pub(crate) async fn probe_delete( + pub(crate) async fn delete( &self, opctx: &OpContext, project_lookup: &lookup::Project<'_>, name_or_id: NameOrId, ) -> DeleteResult { - let probe = self.probe_get(opctx, project_lookup, &name_or_id).await?; + let probe = self.get(opctx, project_lookup, &name_or_id).await?; self.instance_network.probe_delete_dpd_config(opctx, probe.id).await?; diff --git a/nexus/src/app/project.rs b/nexus/src/app/project.rs index 2286d2d7b4..adecb51fce 100644 --- a/nexus/src/app/project.rs +++ b/nexus/src/app/project.rs @@ -42,7 +42,7 @@ impl Project { Project { datastore, sec_client } } - pub fn project_lookup<'a>( + pub fn lookup<'a>( &'a self, opctx: &'a OpContext, project_selector: params::ProjectSelector, @@ -58,7 +58,7 @@ impl Project { }) } - pub(crate) async fn project_create( + pub(crate) async fn create( &self, opctx: &OpContext, saga_context: &SagaContext, @@ -91,7 +91,7 @@ impl Project { Ok(db_project) } - pub(crate) async fn project_list( + pub(crate) async fn list( &self, opctx: &OpContext, pagparams: &PaginatedBy<'_>, @@ -99,7 +99,7 @@ impl Project { self.datastore.projects_list(opctx, pagparams).await } - pub(crate) async fn project_update( + pub(crate) async fn update( &self, opctx: &OpContext, project_lookup: &lookup::Project<'_>, @@ -112,7 +112,7 @@ impl Project { .await } - pub(crate) async fn project_delete( + pub(crate) async fn delete( &self, opctx: &OpContext, project_lookup: &lookup::Project<'_>, @@ -124,7 +124,7 @@ impl Project { // Role assignments - pub(crate) async fn project_fetch_policy( + pub(crate) async fn fetch_policy( &self, opctx: &OpContext, project_lookup: &lookup::Project<'_>, @@ -142,7 +142,7 @@ impl Project { Ok(shared::Policy { role_assignments }) } - pub(crate) async fn project_update_policy( + pub(crate) async fn update_policy( &self, opctx: &OpContext, project_lookup: &lookup::Project<'_>, diff --git a/nexus/src/app/rack.rs b/nexus/src/app/rack.rs index 8ba32453b8..058e2fe208 100644 --- a/nexus/src/app/rack.rs +++ b/nexus/src/app/rack.rs @@ -116,7 +116,7 @@ impl Rack { } } - pub(crate) async fn racks_list( + pub(crate) async fn list( &self, opctx: &OpContext, pagparams: &DataPageParams<'_, Uuid>, @@ -124,7 +124,7 @@ impl Rack { self.datastore.rack_list(&opctx, pagparams).await } - pub(crate) async fn rack_lookup( + pub(crate) async fn lookup( &self, opctx: &OpContext, rack_id: &Uuid, @@ -139,7 +139,7 @@ impl Rack { /// Marks the rack as initialized with information supplied by RSS. /// /// This function is a no-op if the rack has already been initialized. - pub(crate) async fn rack_initialize( + pub(crate) async fn initialize( &self, opctx: &OpContext, rack_id: Uuid, @@ -321,7 +321,7 @@ impl Rack { // The `rack` row is created with the rack ID we know when Nexus starts, // but we didn't know the rack subnet until now. Set it. - let mut rack = self.rack_lookup(opctx, &self.rack_id).await?; + let mut rack = self.lookup(opctx, &self.rack_id).await?; rack.rack_subnet = Some(IpNet::from(rack_network_config.rack_subnet).into()); self.datastore.update_rack_subnet(opctx, &rack).await?; @@ -748,7 +748,7 @@ impl Rack { /// See RFD 278 for additional context. pub(crate) async fn await_rack_initialization(&self, opctx: &OpContext) { loop { - let result = self.rack_lookup(&opctx, &self.rack_id).await; + let result = self.lookup(&opctx, &self.rack_id).await; match result { Ok(rack) => { if rack.initialized { @@ -928,7 +928,7 @@ impl Rack { ) -> Result { let addr = self .sled - .sled_list(opctx, &DataPageParams::max_page()) + .list(opctx, &DataPageParams::max_page()) .await? .get(0) .ok_or(Error::InternalError { diff --git a/nexus/src/app/sagas/disk_create.rs b/nexus/src/app/sagas/disk_create.rs index 39dc8dd17e..6efa152292 100644 --- a/nexus/src/app/sagas/disk_create.rs +++ b/nexus/src/app/sagas/disk_create.rs @@ -556,7 +556,7 @@ async fn sdc_regions_ensure_undo( let result = osagactx .crucible() - .delete_crucible_regions( + .delete_regions( log, sagactx.lookup::>( "datasets_and_regions", @@ -1110,8 +1110,7 @@ pub(crate) mod test { ), disk: Name::try_from(DISK_NAME.to_string()).unwrap().into(), }; - let disk_lookup = - nexus.disk.disk_lookup(&opctx, disk_selector).unwrap(); + let disk_lookup = nexus.disk.lookup(&opctx, disk_selector).unwrap(); nexus .disk diff --git a/nexus/src/app/sagas/disk_delete.rs b/nexus/src/app/sagas/disk_delete.rs index c202bf4ba0..3f7c8777ad 100644 --- a/nexus/src/app/sagas/disk_delete.rs +++ b/nexus/src/app/sagas/disk_delete.rs @@ -213,7 +213,7 @@ pub(crate) mod test { project: Name::try_from(PROJECT_NAME.to_string()).unwrap().into(), }; let project_lookup = - nexus.project.project_lookup(&opctx, project_selector).unwrap(); + nexus.project.lookup(&opctx, project_selector).unwrap(); nexus .disk diff --git a/nexus/src/app/sagas/instance_common.rs b/nexus/src/app/sagas/instance_common.rs index 60adc87119..218d6a6ac6 100644 --- a/nexus/src/app/sagas/instance_common.rs +++ b/nexus/src/app/sagas/instance_common.rs @@ -393,7 +393,7 @@ pub async fn instance_ip_add_opte( osagactx .sled() - .sled_client(&sled_uuid) + .client(&sled_uuid) .await .map_err(|_| { ActionError::action_failed(Error::unavail( @@ -448,7 +448,7 @@ pub async fn instance_ip_remove_opte( osagactx .sled() - .sled_client(&sled_uuid) + .client(&sled_uuid) .await .map_err(|_| { ActionError::action_failed(Error::unavail( diff --git a/nexus/src/app/sagas/instance_create.rs b/nexus/src/app/sagas/instance_create.rs index f2b43be114..d14d90aa1f 100644 --- a/nexus/src/app/sagas/instance_create.rs +++ b/nexus/src/app/sagas/instance_create.rs @@ -711,7 +711,7 @@ async fn sic_allocate_instance_external_ip( Some( osagactx .ip_pool() - .ip_pool_lookup(&opctx, name_or_id) + .lookup(&opctx, name_or_id) .map_err(ActionError::action_failed)? .lookup_for(authz::Action::CreateChild) .await diff --git a/nexus/src/app/sagas/instance_delete.rs b/nexus/src/app/sagas/instance_delete.rs index 38da98cc73..6958cfe04f 100644 --- a/nexus/src/app/sagas/instance_delete.rs +++ b/nexus/src/app/sagas/instance_delete.rs @@ -304,7 +304,7 @@ mod test { project: PROJECT_NAME.to_string().try_into().unwrap(), }; let project_lookup = - nexus.project.project_lookup(&opctx, project_selector).unwrap(); + nexus.project.lookup(&opctx, project_selector).unwrap(); let instance_state = nexus .instance diff --git a/nexus/src/app/sagas/instance_ip_attach.rs b/nexus/src/app/sagas/instance_ip_attach.rs index 1b46e6ac2e..8d3d52b982 100644 --- a/nexus/src/app/sagas/instance_ip_attach.rs +++ b/nexus/src/app/sagas/instance_ip_attach.rs @@ -96,7 +96,7 @@ async fn siia_begin_attach_ip( Some( osagactx .ip_pool() - .ip_pool_lookup(&opctx, name_or_id) + .lookup(&opctx, name_or_id) .map_err(ActionError::action_failed)? .lookup_for(authz::Action::CreateChild) .await diff --git a/nexus/src/app/sagas/instance_ip_detach.rs b/nexus/src/app/sagas/instance_ip_detach.rs index 89a6316020..939dd38e18 100644 --- a/nexus/src/app/sagas/instance_ip_detach.rs +++ b/nexus/src/app/sagas/instance_ip_detach.rs @@ -366,7 +366,7 @@ pub(crate) mod test { .await; nexus .instance - .instance_attach_external_ip( + .attach_external_ip( opctx, &nexus.saga_context, authz_instance.clone(), diff --git a/nexus/src/app/sagas/instance_migrate.rs b/nexus/src/app/sagas/instance_migrate.rs index b2e3104dae..fdc6ef024b 100644 --- a/nexus/src/app/sagas/instance_migrate.rs +++ b/nexus/src/app/sagas/instance_migrate.rs @@ -267,7 +267,7 @@ async fn sim_set_migration_ids( let updated_record = osagactx .instance() - .instance_set_migration_ids( + .set_migration_ids( &opctx, db_instance.id(), src_sled_id, @@ -308,7 +308,7 @@ async fn sim_clear_migration_ids( // as failed. if let Err(e) = osagactx .instance() - .instance_clear_migration_ids( + .clear_migration_ids( db_instance.id(), src_sled_id, db_instance.runtime(), @@ -351,7 +351,7 @@ async fn sim_ensure_destination_propolis( osagactx .instance() - .instance_ensure_registered( + .ensure_registered( &opctx, &authz_instance, &db_instance, @@ -400,7 +400,7 @@ async fn sim_ensure_destination_propolis_undo( // needed. match osagactx .instance() - .instance_ensure_unregistered(&opctx, &authz_instance, &dst_sled_id) + .ensure_unregistered(&opctx, &authz_instance, &dst_sled_id) .await { Ok(_) => Ok(()), @@ -462,7 +462,7 @@ async fn sim_instance_migrate( // generation numbers to filter out stale destruction requests. match osagactx .instance() - .instance_request_state( + .request_state( &opctx, &authz_instance, &db_instance, diff --git a/nexus/src/app/sagas/instance_start.rs b/nexus/src/app/sagas/instance_start.rs index 6066ce205d..663f033e29 100644 --- a/nexus/src/app/sagas/instance_start.rs +++ b/nexus/src/app/sagas/instance_start.rs @@ -491,7 +491,7 @@ async fn sis_ensure_registered( osagactx .instance() - .instance_ensure_registered( + .ensure_registered( &opctx, &authz_instance, &db_instance, @@ -537,7 +537,7 @@ async fn sis_ensure_registered_undo( // returned. if let Err(e) = osagactx .instance() - .instance_ensure_unregistered(&opctx, &authz_instance, &sled_id) + .ensure_unregistered(&opctx, &authz_instance, &sled_id) .await { error!(osagactx.log(), @@ -575,11 +575,7 @@ async fn sis_ensure_registered_undo( if let Err(set_failed_error) = osagactx .instance() - .mark_instance_failed( - &instance_id, - db_instance.runtime(), - &inner, - ) + .mark_failed(&instance_id, db_instance.runtime(), &inner) .await { error!(osagactx.log(), @@ -641,7 +637,7 @@ async fn sis_ensure_running( match osagactx .instance() - .instance_request_state( + .request_state( &opctx, &authz_instance, &db_instance, diff --git a/nexus/src/app/sagas/snapshot_create.rs b/nexus/src/app/sagas/snapshot_create.rs index 31d605920d..3812b21836 100644 --- a/nexus/src/app/sagas/snapshot_create.rs +++ b/nexus/src/app/sagas/snapshot_create.rs @@ -465,7 +465,7 @@ async fn ssc_regions_ensure_undo( warn!(log, "ssc_regions_ensure_undo: Deleting crucible regions"); osagactx .crucible() - .delete_crucible_regions( + .delete_regions( log, sagactx.lookup::>( "datasets_and_regions", @@ -725,7 +725,7 @@ async fn ssc_send_snapshot_request_to_sled_agent( let sled_agent_client = osagactx .sled() - .sled_client(&sled_id) + .client(&sled_id) .await .map_err(ActionError::action_failed)?; @@ -771,7 +771,7 @@ async fn ssc_send_snapshot_request_to_sled_agent_undo( for (dataset, region) in datasets_and_regions { osagactx .crucible() - .delete_crucible_snapshot(log, &dataset, region.id(), snapshot_id) + .delete_snapshot(log, &dataset, region.id(), snapshot_id) .await?; } @@ -1096,7 +1096,7 @@ async fn ssc_call_pantry_snapshot_for_disk_undo( for (dataset, region) in datasets_and_regions { osagactx .crucible() - .delete_crucible_snapshot(log, &dataset, region.id(), snapshot_id) + .delete_snapshot(log, &dataset, region.id(), snapshot_id) .await?; } Ok(()) @@ -1355,12 +1355,7 @@ async fn ssc_start_running_snapshot_undo( for (dataset, region) in datasets_and_regions { osagactx .crucible() - .delete_crucible_running_snapshot( - &log, - &dataset, - region.id(), - snapshot_id, - ) + .delete_running_snapshot(&log, &dataset, region.id(), snapshot_id) .await?; osagactx @@ -2031,7 +2026,7 @@ mod test { let sled_id = instance_state .sled_id() .expect("starting instance should have a sled"); - let sa = nexus.sled.sled_client(&sled_id).await.unwrap(); + let sa = nexus.sled.client(&sled_id).await.unwrap(); sa.instance_finish_transition(instance.identity.id).await; let instance_state = nexus diff --git a/nexus/src/app/sagas/test_helpers.rs b/nexus/src/app/sagas/test_helpers.rs index 9e4c292094..de81753c33 100644 --- a/nexus/src/app/sagas/test_helpers.rs +++ b/nexus/src/app/sagas/test_helpers.rs @@ -51,10 +51,10 @@ pub(crate) async fn instance_start( }; let instance_lookup = - nexus.instance.instance_lookup(&opctx, instance_selector).unwrap(); + nexus.instance.lookup(&opctx, instance_selector).unwrap(); nexus .instance - .instance_start(&opctx, &nexus.saga_context, &instance_lookup) + .start(&opctx, &nexus.saga_context, &instance_lookup) .await .expect("Failed to start instance"); } @@ -72,10 +72,10 @@ pub(crate) async fn instance_stop( }; let instance_lookup = - nexus.instance.instance_lookup(&opctx, instance_selector).unwrap(); + nexus.instance.lookup(&opctx, instance_selector).unwrap(); nexus .instance - .instance_stop(&opctx, &instance_lookup) + .stop(&opctx, &instance_lookup) .await .expect("Failed to stop instance"); } @@ -94,10 +94,10 @@ pub(crate) async fn instance_stop_by_name( }; let instance_lookup = - nexus.instance.instance_lookup(&opctx, instance_selector).unwrap(); + nexus.instance.lookup(&opctx, instance_selector).unwrap(); nexus .instance - .instance_stop(&opctx, &instance_lookup) + .stop(&opctx, &instance_lookup) .await .expect("Failed to stop instance"); } @@ -116,7 +116,7 @@ pub(crate) async fn instance_delete_by_name( }; let instance_lookup = - nexus.instance.instance_lookup(&opctx, instance_selector).unwrap(); + nexus.instance.lookup(&opctx, instance_selector).unwrap(); nexus .instance .project_destroy_instance(&opctx, &nexus.saga_context, &instance_lookup) @@ -158,7 +158,7 @@ pub(crate) async fn instance_simulate_by_name( }; let instance_lookup = - nexus.instance.instance_lookup(&opctx, instance_selector).unwrap(); + nexus.instance.lookup(&opctx, instance_selector).unwrap(); let (.., instance) = instance_lookup.fetch().await.unwrap(); let sa = nexus .instance_sled_by_id(&instance.id()) diff --git a/nexus/src/app/sagas/volume_delete.rs b/nexus/src/app/sagas/volume_delete.rs index 09e302a0a9..4cdc1a2f4c 100644 --- a/nexus/src/app/sagas/volume_delete.rs +++ b/nexus/src/app/sagas/volume_delete.rs @@ -162,7 +162,7 @@ async fn svd_delete_crucible_regions( osagactx .crucible() - .delete_crucible_regions(log, datasets_and_regions.clone()) + .delete_regions(log, datasets_and_regions.clone()) .await .map_err(|e| { ActionError::action_failed(format!( @@ -221,7 +221,7 @@ async fn svd_delete_crucible_running_snapshots( osagactx .crucible() - .delete_crucible_running_snapshots(log, datasets_and_snapshots.clone()) + .delete_running_snapshots(log, datasets_and_snapshots.clone()) .await .map_err(|e| { ActionError::action_failed(format!( @@ -264,7 +264,7 @@ async fn svd_delete_crucible_snapshots( osagactx .crucible() - .delete_crucible_snapshots(log, datasets_and_snapshots.clone()) + .delete_snapshots(log, datasets_and_snapshots.clone()) .await .map_err(|e| { ActionError::action_failed(format!( @@ -438,10 +438,7 @@ async fn svd_delete_freed_crucible_regions( // Send DELETE calls to the corresponding Crucible agents osagactx .crucible() - .delete_crucible_regions( - log, - vec![(dataset.clone(), region.clone())], - ) + .delete_regions(log, vec![(dataset.clone(), region.clone())]) .await .map_err(|e| { ActionError::action_failed(format!( diff --git a/nexus/src/app/sagas/vpc_create.rs b/nexus/src/app/sagas/vpc_create.rs index e3d9b8207b..8c97244018 100644 --- a/nexus/src/app/sagas/vpc_create.rs +++ b/nexus/src/app/sagas/vpc_create.rs @@ -382,7 +382,7 @@ async fn svc_update_firewall( sagactx.lookup::<(authz::Vpc, db::model::Vpc)>("vpc")?; let rules = osagactx .vpc() - .default_firewall_rules_for_vpc( + .default_firewall_rules( authz_vpc.id(), params.vpc_create.identity.name.clone().into(), ) @@ -509,7 +509,7 @@ pub(crate) mod test { let opctx = test_opctx(&cptestctx); let (.., authz_project) = nexus .project - .project_lookup(&opctx, project_selector) + .lookup(&opctx, project_selector) .expect("Invalid parameters constructing project lookup") .lookup_for(action) .await diff --git a/nexus/src/app/session.rs b/nexus/src/app/session.rs index 64bd2781a7..bb1e14f87f 100644 --- a/nexus/src/app/session.rs +++ b/nexus/src/app/session.rs @@ -79,7 +79,7 @@ impl Session { Ok(true) } - pub(crate) async fn session_create( + pub(crate) async fn create( &self, opctx: &OpContext, user_id: Uuid, @@ -96,7 +96,7 @@ impl Session { self.datastore.session_create(opctx, session).await } - pub(crate) async fn session_fetch( + pub(crate) async fn fetch( &self, opctx: &OpContext, token: String, @@ -118,7 +118,7 @@ impl Session { } /// Updates last_used to now. - pub(crate) async fn session_update_last_used( + pub(crate) async fn update_last_used( &self, opctx: &OpContext, token: &str, @@ -131,7 +131,7 @@ impl Session { self.datastore.session_update_last_used(opctx, &authz_session).await } - pub(crate) async fn session_hard_delete( + pub(crate) async fn hard_delete( &self, opctx: &OpContext, token: &str, diff --git a/nexus/src/app/silo.rs b/nexus/src/app/silo.rs index 45f6909b6a..9b06a1ef8b 100644 --- a/nexus/src/app/silo.rs +++ b/nexus/src/app/silo.rs @@ -61,10 +61,10 @@ impl Silo { .authn .silo_required() .internal_context("looking up current silo")?; - let silo = self.silo_lookup(opctx, NameOrId::Id(silo.id()))?; + let silo = self.lookup(opctx, NameOrId::Id(silo.id()))?; Ok(silo) } - pub fn silo_lookup<'a>( + pub fn lookup<'a>( &'a self, opctx: &'a OpContext, silo: NameOrId, @@ -82,13 +82,12 @@ impl Silo { } } - pub(crate) async fn silo_fq_dns_names( + pub(crate) async fn fq_dns_names( &self, opctx: &OpContext, silo_id: Uuid, ) -> ListResultVec { - let (_, silo) = - self.silo_lookup(opctx, silo_id.into())?.fetch().await?; + let (_, silo) = self.lookup(opctx, silo_id.into())?.fetch().await?; let silo_dns_name = silo_dns_name(&silo.name()); let external_dns_zones = self .datastore @@ -101,7 +100,7 @@ impl Silo { .collect()) } - pub(crate) async fn silo_create( + pub(crate) async fn create( &self, opctx: &OpContext, new_silo_params: params::SiloCreate, @@ -165,7 +164,7 @@ impl Silo { Ok(silo) } - pub(crate) async fn silos_list( + pub(crate) async fn list( &self, opctx: &OpContext, pagparams: &PaginatedBy<'_>, @@ -175,7 +174,7 @@ impl Silo { .await } - pub(crate) async fn silo_delete( + pub(crate) async fn delete( &self, opctx: &OpContext, silo_lookup: &lookup::Silo<'_>, @@ -201,7 +200,7 @@ impl Silo { // Role assignments - pub(crate) async fn silo_fetch_policy( + pub(crate) async fn fetch_policy( &self, opctx: &OpContext, silo_lookup: &lookup::Silo<'_>, @@ -219,7 +218,7 @@ impl Silo { Ok(shared::Policy { role_assignments }) } - pub(crate) async fn silo_update_policy( + pub(crate) async fn update_policy( &self, opctx: &OpContext, silo_lookup: &lookup::Silo<'_>, @@ -249,7 +248,7 @@ impl Silo { /// /// `LookupPath` lets you look up users directly, regardless of what Silo /// they're in. This helper validates that they're in the expected Silo. - async fn silo_user_lookup_by_id( + async fn user_lookup_by_id( &self, opctx: &OpContext, authz_silo: &authz::Silo, @@ -269,7 +268,7 @@ impl Silo { } /// List the users in a Silo - pub(crate) async fn silo_list_users( + pub(crate) async fn list_users( &self, opctx: &OpContext, silo_lookup: &lookup::Silo<'_>, @@ -283,7 +282,7 @@ impl Silo { } /// Fetch a user in a Silo - pub(crate) async fn silo_user_fetch( + pub(crate) async fn user_fetch( &self, opctx: &OpContext, silo_lookup: &lookup::Silo<'_>, @@ -291,7 +290,7 @@ impl Silo { ) -> LookupResult { let (authz_silo,) = silo_lookup.lookup_for(authz::Action::Read).await?; let (_, db_silo_user) = self - .silo_user_lookup_by_id( + .user_lookup_by_id( opctx, &authz_silo, silo_user_id, @@ -350,7 +349,7 @@ impl Silo { db_silo_user.id(), LookupType::ById(db_silo_user.id()), ); - self.silo_user_password_set_internal( + self.user_password_set_internal( opctx, &db_silo, &authz_silo_user, @@ -371,7 +370,7 @@ impl Silo { let (authz_silo, _) = self.local_idp_fetch_silo(silo_lookup).await?; let (authz_silo_user, _) = self - .silo_user_lookup_by_id( + .user_lookup_by_id( opctx, &authz_silo, silo_user_id, @@ -382,7 +381,7 @@ impl Silo { } /// Based on an authenticated subject, fetch or create a silo user - pub async fn silo_user_from_authenticated_subject( + pub async fn user_from_authenticated_subject( &self, opctx: &OpContext, authz_silo: &authz::Silo, @@ -453,7 +452,7 @@ impl Silo { db::model::UserProvisionType::Jit => { let silo_group = self - .silo_group_lookup_or_create_by_name( + .group_lookup_or_create_by_name( opctx, &authz_silo, &group, @@ -499,14 +498,14 @@ impl Silo { let (authz_silo, db_silo) = self.local_idp_fetch_silo(silo_lookup).await?; let (authz_silo_user, db_silo_user) = self - .silo_user_lookup_by_id( + .user_lookup_by_id( opctx, &authz_silo, silo_user_id, authz::Action::Modify, ) .await?; - self.silo_user_password_set_internal( + self.user_password_set_internal( opctx, &db_silo, &authz_silo_user, @@ -520,7 +519,7 @@ impl Silo { /// /// The caller should have already verified that this is a `LocalOnly` Silo /// and that the specified user is in that Silo. - async fn silo_user_password_set_internal( + async fn user_password_set_internal( &self, opctx: &OpContext, db_silo: &db::model::Silo, @@ -563,7 +562,7 @@ impl Silo { /// callers are expected to invoke this function during authentication even /// if they've found no user to match the requested credentials. That's why /// this function accepts `Option` rather than just a `SiloUser`. - pub(crate) async fn silo_user_password_verify( + pub(crate) async fn user_password_verify( &self, opctx: &OpContext, maybe_authz_silo_user: Option<&authz::SiloUser>, @@ -624,7 +623,7 @@ impl Silo { ) .await?; let verified = self - .silo_user_password_verify( + .user_password_verify( opctx, fetch_user.as_ref().map(|(authz_silo_user, _)| authz_silo_user), credentials.password.as_ref(), @@ -644,7 +643,7 @@ impl Silo { // Silo groups - pub async fn silo_group_lookup_or_create_by_name( + pub async fn group_lookup_or_create_by_name( &self, opctx: &OpContext, authz_silo: &authz::Silo, @@ -695,7 +694,7 @@ impl Silo { silo: Some(silo), } => { let saml_provider = self - .silo_lookup(opctx, silo)? + .lookup(opctx, silo)? .saml_identity_provider_name_owned(name.into()); Ok(saml_provider) } @@ -908,7 +907,7 @@ impl Silo { .await } - pub fn silo_group_lookup<'a>( + pub fn group_lookup<'a>( &'a self, opctx: &'a OpContext, group_id: &'a Uuid, diff --git a/nexus/src/app/sled.rs b/nexus/src/app/sled.rs index df5ffe8247..5f4dda4f80 100644 --- a/nexus/src/app/sled.rs +++ b/nexus/src/app/sled.rs @@ -61,7 +61,7 @@ impl Sled { &self.opctx_sled_lookup } - pub fn sled_lookup<'a>( + pub fn lookup<'a>( &'a self, opctx: &'a OpContext, sled_id: &Uuid, @@ -125,18 +125,18 @@ impl Sled { /// sufficient warning to the operator. /// /// This is idempotent, and it returns the old policy of the sled. - pub(crate) async fn sled_expunge( + pub(crate) async fn expunge( &self, opctx: &OpContext, sled_id: Uuid, ) -> Result { - let sled_lookup = self.sled_lookup(opctx, &sled_id)?; + let sled_lookup = self.lookup(opctx, &sled_id)?; let (authz_sled,) = sled_lookup.lookup_for(authz::Action::Modify).await?; self.datastore.sled_set_policy_to_expunged(opctx, &authz_sled).await } - pub(crate) async fn sled_request_firewall_rules( + pub(crate) async fn request_firewall_rules( &self, opctx: &OpContext, id: Uuid, @@ -146,7 +146,7 @@ impl Sled { Ok(()) } - pub(crate) async fn sled_list( + pub(crate) async fn list( &self, opctx: &OpContext, pagparams: &DataPageParams<'_, Uuid>, @@ -154,7 +154,7 @@ impl Sled { self.datastore.sled_list(&opctx, pagparams, SledFilter::InService).await } - pub async fn sled_client( + pub async fn client( &self, id: &Uuid, ) -> Result, Error> { @@ -203,7 +203,7 @@ impl Sled { } /// Returns the old provision policy. - pub(crate) async fn sled_set_provision_policy( + pub(crate) async fn set_provision_policy( &self, opctx: &OpContext, sled_lookup: &lookup::Sled<'_>, @@ -227,7 +227,7 @@ impl Sled { .physical_disk(disk_selector.disk_id)) } - pub(crate) async fn sled_list_physical_disks( + pub(crate) async fn list_physical_disks( &self, opctx: &OpContext, sled_id: Uuid, @@ -334,7 +334,7 @@ impl Sled { .await } - pub(crate) async fn sled_instance_list( + pub(crate) async fn instance_list( &self, opctx: &OpContext, sled_lookup: &lookup::Sled<'_>, diff --git a/nexus/src/app/snapshot.rs b/nexus/src/app/snapshot.rs index 6824a9955d..17e796ba4e 100644 --- a/nexus/src/app/snapshot.rs +++ b/nexus/src/app/snapshot.rs @@ -38,7 +38,7 @@ impl Snapshot { Snapshot { datastore, sec_client, project, disk } } - pub fn snapshot_lookup<'a>( + pub fn lookup<'a>( &'a self, opctx: &'a OpContext, snapshot_selector: params::SnapshotSelector, @@ -57,7 +57,7 @@ impl Snapshot { project: Some(project), } => { let snapshot = self.project - .project_lookup(opctx, params::ProjectSelector { project })? + .lookup(opctx, params::ProjectSelector { project })? .snapshot_name_owned(name.into()); Ok(snapshot) } @@ -73,7 +73,7 @@ impl Snapshot { } } - pub(crate) async fn snapshot_create( + pub(crate) async fn create( &self, opctx: &OpContext, saga_context: &SagaContext, @@ -93,7 +93,7 @@ impl Snapshot { .disk .clone() { - NameOrId::Id(id) => self.disk.disk_lookup( + NameOrId::Id(id) => self.disk.lookup( opctx, DiskSelector { disk: NameOrId::Id(id), project: None }, )?, @@ -158,7 +158,7 @@ impl Snapshot { Ok(snapshot_created) } - pub(crate) async fn snapshot_list( + pub(crate) async fn list( &self, opctx: &OpContext, project_lookup: &lookup::Project<'_>, @@ -170,7 +170,7 @@ impl Snapshot { self.datastore.snapshot_list(opctx, &authz_project, pagparams).await } - pub(crate) async fn snapshot_delete( + pub(crate) async fn delete( &self, opctx: &OpContext, saga_context: &SagaContext, diff --git a/nexus/src/app/ssh_key.rs b/nexus/src/app/ssh_key.rs index 59b095e93d..e5b775182c 100644 --- a/nexus/src/app/ssh_key.rs +++ b/nexus/src/app/ssh_key.rs @@ -32,7 +32,7 @@ impl SshKey { } // SSH Keys - pub fn ssh_key_lookup<'a>( + pub fn lookup<'a>( &'a self, opctx: &'a OpContext, ssh_key_selector: &'a params::SshKeySelector, @@ -58,7 +58,7 @@ impl SshKey { } } - pub(crate) async fn ssh_key_create( + pub(crate) async fn create( &self, opctx: &OpContext, silo_user_id: Uuid, @@ -73,7 +73,7 @@ impl SshKey { self.datastore.ssh_key_create(opctx, &authz_user, ssh_key).await } - pub(crate) async fn ssh_keys_list( + pub(crate) async fn list( &self, opctx: &OpContext, silo_user_id: Uuid, @@ -100,7 +100,7 @@ impl SshKey { .await } - pub(crate) async fn ssh_key_delete( + pub(crate) async fn delete( &self, opctx: &OpContext, silo_user_id: Uuid, diff --git a/nexus/src/app/switch.rs b/nexus/src/app/switch.rs index ddcb08f66d..ab6ec1e773 100644 --- a/nexus/src/app/switch.rs +++ b/nexus/src/app/switch.rs @@ -24,7 +24,7 @@ impl Switch { } // Switches - pub fn switch_lookup<'a>( + pub fn lookup<'a>( &'a self, opctx: &'a OpContext, switch_selector: params::SwitchSelector, @@ -35,7 +35,7 @@ impl Switch { /// Upserts a switch into the database, updated it if it already exists. /// Should only be called by the internal API - pub(crate) async fn switch_upsert( + pub(crate) async fn upsert( &self, id: Uuid, request: SwitchPutRequest, @@ -50,7 +50,7 @@ impl Switch { self.datastore.switch_upsert(switch).await } - pub(crate) async fn switch_list( + pub(crate) async fn list( &self, opctx: &OpContext, pagparams: &DataPageParams<'_, Uuid>, diff --git a/nexus/src/app/switch_interface.rs b/nexus/src/app/switch_interface.rs index 5ca501f6a6..3665f17539 100644 --- a/nexus/src/app/switch_interface.rs +++ b/nexus/src/app/switch_interface.rs @@ -64,11 +64,10 @@ impl SwitchInterface { validate_switch_location(params.switch_location.as_str())?; // Just a check to make sure a valid rack id was passed in. - self.rack.rack_lookup(&opctx, ¶ms.rack_id).await?; + self.rack.lookup(&opctx, ¶ms.rack_id).await?; - let address_lot_lookup = self - .address_lot - .address_lot_lookup(&opctx, params.address_lot.clone())?; + let address_lot_lookup = + self.address_lot.lookup(&opctx, params.address_lot.clone())?; let (.., authz_address_lot) = address_lot_lookup.lookup_for(authz::Action::CreateChild).await?; diff --git a/nexus/src/app/switch_port.rs b/nexus/src/app/switch_port.rs index ebbaccff54..4c7dc7ba73 100644 --- a/nexus/src/app/switch_port.rs +++ b/nexus/src/app/switch_port.rs @@ -56,7 +56,7 @@ impl SwitchPort { } } - pub(crate) async fn switch_port_settings_post( + pub(crate) async fn settings_post( &self, opctx: &OpContext, params: params::SwitchPortSettingsCreate, @@ -75,14 +75,12 @@ impl SwitchPort { ) .await { - Ok(id) => self.switch_port_settings_update(opctx, id, params).await, - Err(_) => { - self.switch_port_settings_create(opctx, params, None).await - } + Ok(id) => self.settings_update(opctx, id, params).await, + Err(_) => self.settings_create(opctx, params, None).await, } } - pub async fn switch_port_settings_create( + pub async fn settings_create( &self, opctx: &OpContext, params: params::SwitchPortSettingsCreate, @@ -91,14 +89,14 @@ impl SwitchPort { self.datastore.switch_port_settings_create(opctx, ¶ms, id).await } - pub(crate) async fn switch_port_settings_update( + pub(crate) async fn settings_update( &self, opctx: &OpContext, switch_port_settings_id: Uuid, new_settings: params::SwitchPortSettingsCreate, ) -> CreateResult { // delete old settings - self.switch_port_settings_delete( + self.settings_delete( opctx, ¶ms::SwitchPortSettingsSelector { port_settings: Some(NameOrId::Id(switch_port_settings_id)), @@ -108,7 +106,7 @@ impl SwitchPort { // create new settings let result = self - .switch_port_settings_create( + .settings_create( opctx, new_settings.clone(), Some(switch_port_settings_id), @@ -138,7 +136,7 @@ impl SwitchPort { Ok(result) } - pub(crate) async fn switch_port_settings_delete( + pub(crate) async fn settings_delete( &self, opctx: &OpContext, params: ¶ms::SwitchPortSettingsSelector, @@ -147,7 +145,7 @@ impl SwitchPort { self.datastore.switch_port_settings_delete(opctx, params).await } - pub(crate) async fn switch_port_settings_list( + pub(crate) async fn settings_list( &self, opctx: &OpContext, pagparams: &PaginatedBy<'_>, @@ -156,7 +154,7 @@ impl SwitchPort { self.datastore.switch_port_settings_list(opctx, pagparams).await } - pub(crate) async fn switch_port_settings_get( + pub(crate) async fn settings_get( &self, opctx: &OpContext, name_or_id: &NameOrId, @@ -165,7 +163,7 @@ impl SwitchPort { self.datastore.switch_port_settings_get(opctx, name_or_id).await } - async fn switch_port_create( + async fn create( &self, opctx: &OpContext, rack_id: Uuid, @@ -182,7 +180,7 @@ impl SwitchPort { .await } - pub(crate) async fn switch_port_list( + pub(crate) async fn list( &self, opctx: &OpContext, pagparams: &DataPageParams<'_, Uuid>, @@ -209,7 +207,7 @@ impl SwitchPort { .await } - pub(crate) async fn switch_port_apply_settings( + pub(crate) async fn apply_settings( &self, opctx: &OpContext, port: &Name, @@ -252,7 +250,7 @@ impl SwitchPort { Ok(()) } - pub(crate) async fn switch_port_clear_settings( + pub(crate) async fn clear_settings( &self, opctx: &OpContext, port: &Name, @@ -294,12 +292,7 @@ impl SwitchPort { ) -> CreateResult<()> { for port in ports { match self - .switch_port_create( - opctx, - self.rack_id, - switch.clone(), - port.clone(), - ) + .create(opctx, self.rack_id, switch.clone(), port.clone()) .await { Ok(_) => {} @@ -312,7 +305,7 @@ impl SwitchPort { Ok(()) } - pub(crate) async fn switch_port_status( + pub(crate) async fn status( &self, opctx: &OpContext, switch: Name, diff --git a/nexus/src/app/test_interfaces.rs b/nexus/src/app/test_interfaces.rs index bb021389d7..cdcd1cacea 100644 --- a/nexus/src/app/test_interfaces.rs +++ b/nexus/src/app/test_interfaces.rs @@ -87,7 +87,7 @@ impl TestInterfaces for super::Nexus { ) -> Result>, Error> { let sled_id = self.instance_sled_id_with_opctx(id, opctx).await?; if let Some(sled_id) = sled_id { - Ok(Some(self.sled.sled_client(&sled_id).await?)) + Ok(Some(self.sled.client(&sled_id).await?)) } else { Ok(None) } diff --git a/nexus/src/app/update/mod.rs b/nexus/src/app/update/mod.rs index afb8b46afa..fa7d6b6abd 100644 --- a/nexus/src/app/update/mod.rs +++ b/nexus/src/app/update/mod.rs @@ -58,7 +58,7 @@ impl Update { Update { log, datastore, updates_config } } - pub(crate) async fn updates_put_repository( + pub(crate) async fn put_repository( &self, opctx: &OpContext, body: impl Stream> + Send + Sync + 'static, @@ -90,7 +90,7 @@ impl Update { Ok(response.into_external()) } - pub(crate) async fn updates_get_repository( + pub(crate) async fn get_repository( &self, opctx: &OpContext, system_version: SemverVersion, @@ -112,7 +112,7 @@ impl Update { } /// Downloads a file (currently not implemented). - pub(crate) async fn updates_download_artifact( + pub(crate) async fn download_artifact( &self, _opctx: &OpContext, _artifact: ArtifactId, diff --git a/nexus/src/app/volume.rs b/nexus/src/app/volume.rs index 7dc3adab01..4e5923051e 100644 --- a/nexus/src/app/volume.rs +++ b/nexus/src/app/volume.rs @@ -44,7 +44,7 @@ impl Volume { } /// Start a saga to remove a read only parent from a volume. - pub(crate) async fn volume_remove_read_only_parent( + pub(crate) async fn remove_read_only_parent( &self, opctx: &OpContext, saga_context: &SagaContext, diff --git a/nexus/src/app/vpc.rs b/nexus/src/app/vpc.rs index e075c120b2..3e2625b2e0 100644 --- a/nexus/src/app/vpc.rs +++ b/nexus/src/app/vpc.rs @@ -60,7 +60,7 @@ impl Vpc { Vpc { log, datastore, sec_client, opctx_sled_lookup, project } } - pub fn vpc_lookup<'a>( + pub fn lookup<'a>( &'a self, opctx: &'a OpContext, vpc_selector: params::VpcSelector, @@ -75,7 +75,7 @@ impl Vpc { project: Some(project), } => { let vpc = self.project - .project_lookup(opctx, params::ProjectSelector { project })? + .lookup(opctx, params::ProjectSelector { project })? .vpc_name_owned(name.into()); Ok(vpc) } @@ -125,7 +125,7 @@ impl Vpc { Ok(db_vpc) } - pub(crate) async fn vpc_list( + pub(crate) async fn list( &self, opctx: &OpContext, project_lookup: &lookup::Project<'_>, @@ -184,7 +184,7 @@ impl Vpc { // Firewall rules - pub(crate) async fn vpc_list_firewall_rules( + pub(crate) async fn list_firewall_rules( &self, opctx: &OpContext, vpc_lookup: &lookup::Vpc<'_>, @@ -197,7 +197,7 @@ impl Vpc { .await } - pub(crate) async fn vpc_update_firewall_rules( + pub(crate) async fn update_firewall_rules( &self, opctx: &OpContext, vpc_lookup: &lookup::Vpc<'_>, @@ -220,7 +220,7 @@ impl Vpc { /// Customize the default firewall rules for a particular VPC /// by replacing the name `default` with the VPC's actual name. - pub(crate) async fn default_firewall_rules_for_vpc( + pub(crate) async fn default_firewall_rules( &self, vpc_id: Uuid, vpc_name: Name, diff --git a/nexus/src/app/vpc_router.rs b/nexus/src/app/vpc_router.rs index 02ba946259..67d73168b7 100644 --- a/nexus/src/app/vpc_router.rs +++ b/nexus/src/app/vpc_router.rs @@ -36,7 +36,7 @@ impl VpcRouter { VpcRouter { datastore, vpc } } - pub fn vpc_router_lookup<'a>( + pub fn lookup<'a>( &'a self, opctx: &'a OpContext, router_selector: params::RouterSelector, @@ -57,7 +57,7 @@ impl VpcRouter { project } => { let router = self.vpc - .vpc_lookup(opctx, params::VpcSelector { project, vpc })? + .lookup(opctx, params::VpcSelector { project, vpc })? .vpc_router_name_owned(name.into()); Ok(router) } @@ -73,7 +73,7 @@ impl VpcRouter { } } - pub(crate) async fn vpc_create_router( + pub(crate) async fn create( &self, opctx: &OpContext, vpc_lookup: &lookup::Vpc<'_>, @@ -96,7 +96,7 @@ impl VpcRouter { Ok(router) } - pub(crate) async fn vpc_router_list( + pub(crate) async fn list( &self, opctx: &OpContext, vpc_lookup: &lookup::Vpc<'_>, @@ -111,7 +111,7 @@ impl VpcRouter { Ok(routers) } - pub(crate) async fn vpc_update_router( + pub(crate) async fn update( &self, opctx: &OpContext, vpc_router_lookup: &lookup::VpcRouter<'_>, @@ -127,7 +127,7 @@ impl VpcRouter { // TODO: When a router is deleted all its routes should be deleted // TODO: When a router is deleted it should be unassociated w/ any subnets it may be associated with // or trigger an error - pub(crate) async fn vpc_delete_router( + pub(crate) async fn delete( &self, opctx: &OpContext, vpc_router_lookup: &lookup::VpcRouter<'_>, @@ -146,7 +146,7 @@ impl VpcRouter { // Routes - pub fn vpc_router_route_lookup<'a>( + pub fn route_lookup<'a>( &'a self, opctx: &'a OpContext, route_selector: params::RouteSelector, @@ -169,7 +169,7 @@ impl VpcRouter { project, } => { let route = self - .vpc_router_lookup( + .lookup( opctx, params::RouterSelector { project, vpc, router }, )? @@ -188,7 +188,7 @@ impl VpcRouter { } } - pub(crate) async fn router_create_route( + pub(crate) async fn create_route( &self, opctx: &OpContext, router_lookup: &lookup::VpcRouter<'_>, @@ -211,7 +211,7 @@ impl VpcRouter { Ok(route) } - pub(crate) async fn vpc_router_route_list( + pub(crate) async fn route_list( &self, opctx: &OpContext, vpc_router_lookup: &lookup::VpcRouter<'_>, @@ -224,7 +224,7 @@ impl VpcRouter { .await } - pub(crate) async fn router_update_route( + pub(crate) async fn update_route( &self, opctx: &OpContext, route_lookup: &lookup::RouterRoute<'_>, @@ -250,7 +250,7 @@ impl VpcRouter { .await } - pub(crate) async fn router_delete_route( + pub(crate) async fn delete_route( &self, opctx: &OpContext, route_lookup: &lookup::RouterRoute<'_>, diff --git a/nexus/src/app/vpc_subnet.rs b/nexus/src/app/vpc_subnet.rs index 035599e042..c0fe173254 100644 --- a/nexus/src/app/vpc_subnet.rs +++ b/nexus/src/app/vpc_subnet.rs @@ -48,7 +48,7 @@ impl VpcSubnet { VpcSubnet { log, datastore, tunables, vpc } } - pub fn vpc_subnet_lookup<'a>( + pub fn lookup<'a>( &'a self, opctx: &'a OpContext, subnet_selector: params::SubnetSelector, @@ -70,7 +70,7 @@ impl VpcSubnet { } => { let subnet = self .vpc - .vpc_lookup(opctx, params::VpcSelector { project, vpc })? + .lookup(opctx, params::VpcSelector { project, vpc })? .vpc_subnet_name_owned(name.into()); Ok(subnet) } @@ -88,7 +88,7 @@ impl VpcSubnet { } // TODO: When a subnet is created it should add a route entry into the VPC's // system router - pub(crate) async fn vpc_create_subnet( + pub(crate) async fn create( &self, opctx: &OpContext, vpc_lookup: &lookup::Vpc<'_>, @@ -238,7 +238,7 @@ impl VpcSubnet { } } - pub(crate) async fn vpc_subnet_list( + pub(crate) async fn list( &self, opctx: &OpContext, vpc_lookup: &lookup::Vpc<'_>, @@ -249,7 +249,7 @@ impl VpcSubnet { self.datastore.vpc_subnet_list(opctx, &authz_vpc, pagparams).await } - pub(crate) async fn vpc_update_subnet( + pub(crate) async fn update( &self, opctx: &OpContext, vpc_subnet_lookup: &lookup::VpcSubnet<'_>, @@ -264,7 +264,7 @@ impl VpcSubnet { // TODO: When a subnet is deleted it should remove its entry from the VPC's // system router. - pub(crate) async fn vpc_delete_subnet( + pub(crate) async fn delete( &self, opctx: &OpContext, vpc_subnet_lookup: &lookup::VpcSubnet<'_>, @@ -274,7 +274,7 @@ impl VpcSubnet { self.datastore.vpc_delete_subnet(opctx, &db_subnet, &authz_subnet).await } - pub(crate) async fn subnet_list_instance_network_interfaces( + pub(crate) async fn list_instance_network_interfaces( &self, opctx: &OpContext, subnet_lookup: &lookup::VpcSubnet<'_>, diff --git a/nexus/src/context.rs b/nexus/src/context.rs index 0d5f28317b..a55feba8b9 100644 --- a/nexus/src/context.rs +++ b/nexus/src/context.rs @@ -454,7 +454,7 @@ impl SessionStore for ServerContext { async fn session_fetch(&self, token: String) -> Option { let opctx = self.nexus.opctx_external_authn(); - self.nexus.session.session_fetch(opctx, token).await.ok() + self.nexus.session.fetch(opctx, token).await.ok() } async fn session_update_last_used( @@ -462,12 +462,12 @@ impl SessionStore for ServerContext { token: String, ) -> Option { let opctx = self.nexus.opctx_external_authn(); - self.nexus.session.session_update_last_used(&opctx, &token).await.ok() + self.nexus.session.update_last_used(&opctx, &token).await.ok() } async fn session_expire(&self, token: String) -> Option<()> { let opctx = self.nexus.opctx_external_authn(); - self.nexus.session.session_hard_delete(opctx, &token).await.ok() + self.nexus.session.hard_delete(opctx, &token).await.ok() } fn session_idle_timeout(&self) -> Duration { diff --git a/nexus/src/external_api/console_api.rs b/nexus/src/external_api/console_api.rs index 62ba44aa0d..5f4114b91a 100644 --- a/nexus/src/external_api/console_api.rs +++ b/nexus/src/external_api/console_api.rs @@ -363,7 +363,7 @@ pub(crate) async fn login_saml( let user = nexus .silo - .silo_user_from_authenticated_subject( + .user_from_authenticated_subject( &opctx, &authz_silo, &db_silo, @@ -444,7 +444,7 @@ pub(crate) async fn login_local( // happen using the Nexus "external authentication" context, which we // keep specifically for this purpose. let opctx = nexus.opctx_external_authn(); - let silo_lookup = nexus.silo.silo_lookup(&opctx, silo)?; + let silo_lookup = nexus.silo.lookup(&opctx, silo)?; let user = nexus.silo.login_local(&opctx, &silo_lookup, credentials).await?; @@ -480,7 +480,7 @@ async fn create_session( ) -> Result { let nexus = &apictx.context.nexus; let session = match user { - Some(user) => nexus.session.session_create(&opctx, user.id()).await?, + Some(user) => nexus.session.create(&opctx, user.id()).await?, None => Err(Error::Unauthenticated { internal_message: String::from( "no matching user found or credentials were not valid", @@ -509,10 +509,7 @@ pub(crate) async fn logout( if let Ok(opctx) = opctx { if let Some(token) = token { - nexus - .session - .session_hard_delete(&opctx, token.value()) - .await?; + nexus.session.hard_delete(&opctx, token.value()).await?; } } @@ -615,8 +612,7 @@ async fn get_login_url( // It might be nice to have some policy for choosing which one is used // here. let opctx = nexus.opctx_external_authn(); - let silo_lookup = - nexus.silo.silo_lookup(opctx, NameOrId::Id(silo.id()))?; + let silo_lookup = nexus.silo.lookup(opctx, NameOrId::Id(silo.id()))?; let idps = nexus .silo .identity_provider_list( diff --git a/nexus/src/external_api/device_auth.rs b/nexus/src/external_api/device_auth.rs index 0385d8d5c6..77004b8ced 100644 --- a/nexus/src/external_api/device_auth.rs +++ b/nexus/src/external_api/device_auth.rs @@ -85,10 +85,8 @@ pub(crate) async fn device_auth_request( } }; - let model = nexus - .device_auth - .device_auth_request_create(&opctx, params.client_id) - .await?; + let model = + nexus.device_auth.request_create(&opctx, params.client_id).await?; build_oauth_response( StatusCode::OK, &model.into_response(rqctx.server.using_tls(), host), @@ -157,11 +155,7 @@ pub(crate) async fn device_auth_confirm( )?; let _token = nexus .device_auth - .device_auth_request_verify( - &opctx, - params.user_code, - actor.actor_id(), - ) + .request_verify(&opctx, params.user_code, actor.actor_id()) .await?; Ok(HttpResponseUpdatedNoContent()) }; diff --git a/nexus/src/external_api/http_entrypoints.rs b/nexus/src/external_api/http_entrypoints.rs index 6df5812304..8afb2360e1 100644 --- a/nexus/src/external_api/http_entrypoints.rs +++ b/nexus/src/external_api/http_entrypoints.rs @@ -524,8 +524,8 @@ pub(crate) async fn policy_view( .id() .into(); - let silo_lookup = nexus.silo.silo_lookup(&opctx, silo)?; - let policy = nexus.silo.silo_fetch_policy(&opctx, &silo_lookup).await?; + let silo_lookup = nexus.silo.lookup(&opctx, silo)?; + let policy = nexus.silo.fetch_policy(&opctx, &silo_lookup).await?; Ok(HttpResponseOk(policy)) }; apictx @@ -559,11 +559,9 @@ async fn policy_update( .internal_context("loading current silo")? .id() .into(); - let silo_lookup = nexus.silo.silo_lookup(&opctx, silo)?; - let policy = nexus - .silo - .silo_update_policy(&opctx, &silo_lookup, &new_policy) - .await?; + let silo_lookup = nexus.silo.lookup(&opctx, silo)?; + let policy = + nexus.silo.update_policy(&opctx, &silo_lookup, &new_policy).await?; Ok(HttpResponseOk(policy)) }; apictx @@ -617,7 +615,7 @@ async fn silo_utilization_view( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let silo_lookup = - nexus.silo.silo_lookup(&opctx, path_params.into_inner().silo)?; + nexus.silo.lookup(&opctx, path_params.into_inner().silo)?; let quotas = nexus .utilization .silo_utilization_view(&opctx, &silo_lookup) @@ -727,7 +725,7 @@ async fn silo_quotas_view( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let silo_lookup = - nexus.silo.silo_lookup(&opctx, path_params.into_inner().silo)?; + nexus.silo.lookup(&opctx, path_params.into_inner().silo)?; let quota = nexus.quota.silo_quotas_view(&opctx, &silo_lookup).await?; Ok(HttpResponseOk(quota.into())) }; @@ -757,7 +755,7 @@ async fn silo_quotas_update( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let silo_lookup = - nexus.silo.silo_lookup(&opctx, path_params.into_inner().silo)?; + nexus.silo.lookup(&opctx, path_params.into_inner().silo)?; let quota = nexus .quota .silo_update_quota(&opctx, &silo_lookup, &new_quota.into_inner()) @@ -793,7 +791,7 @@ async fn silo_list( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let silos = nexus .silo - .silos_list(&opctx, &paginated_by) + .list(&opctx, &paginated_by) .await? .into_iter() .map(|p| p.try_into()) @@ -825,10 +823,8 @@ async fn silo_create( let handler = async { let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let nexus = &apictx.context.nexus; - let silo = nexus - .silo - .silo_create(&opctx, new_silo_params.into_inner()) - .await?; + let silo = + nexus.silo.create(&opctx, new_silo_params.into_inner()).await?; Ok(HttpResponseCreated(silo.try_into()?)) }; apictx @@ -855,7 +851,7 @@ async fn silo_view( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let nexus = &apictx.context.nexus; let path = path_params.into_inner(); - let silo_lookup = nexus.silo.silo_lookup(&opctx, path.silo)?; + let silo_lookup = nexus.silo.lookup(&opctx, path.silo)?; let (.., silo) = silo_lookup.fetch().await?; Ok(HttpResponseOk(silo.try_into()?)) }; @@ -892,7 +888,7 @@ async fn silo_ip_pool_list( let scan_params = ScanByNameOrId::from_query(&query)?; let paginated_by = name_or_id_pagination(&pag_params, scan_params)?; - let silo_lookup = nexus.silo.silo_lookup(&opctx, path.silo)?; + let silo_lookup = nexus.silo.lookup(&opctx, path.silo)?; let pools = nexus .ip_pool .silo_ip_pool_list(&opctx, &silo_lookup, &paginated_by) @@ -934,8 +930,8 @@ async fn silo_delete( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let nexus = &apictx.context.nexus; let params = path_params.into_inner(); - let silo_lookup = nexus.silo.silo_lookup(&opctx, params.silo)?; - nexus.silo.silo_delete(&opctx, &silo_lookup).await?; + let silo_lookup = nexus.silo.lookup(&opctx, params.silo)?; + nexus.silo.delete(&opctx, &silo_lookup).await?; Ok(HttpResponseDeleted()) }; apictx @@ -960,8 +956,8 @@ async fn silo_policy_view( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let nexus = &apictx.context.nexus; let path = path_params.into_inner(); - let silo_lookup = nexus.silo.silo_lookup(&opctx, path.silo)?; - let policy = nexus.silo.silo_fetch_policy(&opctx, &silo_lookup).await?; + let silo_lookup = nexus.silo.lookup(&opctx, path.silo)?; + let policy = nexus.silo.fetch_policy(&opctx, &silo_lookup).await?; Ok(HttpResponseOk(policy)) }; apictx @@ -991,11 +987,9 @@ async fn silo_policy_update( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let nexus = &apictx.context.nexus; let path = path_params.into_inner(); - let silo_lookup = nexus.silo.silo_lookup(&opctx, path.silo)?; - let policy = nexus - .silo - .silo_update_policy(&opctx, &silo_lookup, &new_policy) - .await?; + let silo_lookup = nexus.silo.lookup(&opctx, path.silo)?; + let policy = + nexus.silo.update_policy(&opctx, &silo_lookup, &new_policy).await?; Ok(HttpResponseOk(policy)) }; apictx @@ -1024,12 +1018,11 @@ async fn silo_user_list( let query = query_params.into_inner(); let pag_params = data_page_params_for(&rqctx, &query)?; let scan_params = ScanById::from_query(&query)?; - let silo_lookup = nexus - .silo - .silo_lookup(&opctx, scan_params.selector.silo.clone())?; + let silo_lookup = + nexus.silo.lookup(&opctx, scan_params.selector.silo.clone())?; let users = nexus .silo - .silo_list_users(&opctx, &silo_lookup, &pag_params) + .list_users(&opctx, &silo_lookup, &pag_params) .await? .into_iter() .map(|i| i.into()) @@ -1071,11 +1064,9 @@ async fn silo_user_view( let nexus = &apictx.context.nexus; let path = path_params.into_inner(); let query = query_params.into_inner(); - let silo_lookup = nexus.silo.silo_lookup(&opctx, query.silo)?; - let user = nexus - .silo - .silo_user_fetch(&opctx, &silo_lookup, path.user_id) - .await?; + let silo_lookup = nexus.silo.lookup(&opctx, query.silo)?; + let user = + nexus.silo.user_fetch(&opctx, &silo_lookup, path.user_id).await?; Ok(HttpResponseOk(user.into())) }; apictx @@ -1105,9 +1096,8 @@ async fn silo_identity_provider_list( let pag_params = data_page_params_for(&rqctx, &query)?; let scan_params = ScanByNameOrId::from_query(&query)?; let paginated_by = name_or_id_pagination(&pag_params, scan_params)?; - let silo_lookup = nexus - .silo - .silo_lookup(&opctx, scan_params.selector.silo.clone())?; + let silo_lookup = + nexus.silo.lookup(&opctx, scan_params.selector.silo.clone())?; let identity_providers = nexus .silo .identity_provider_list(&opctx, &silo_lookup, &paginated_by) @@ -1146,7 +1136,7 @@ async fn saml_identity_provider_create( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let nexus = &apictx.context.nexus; let query = query_params.into_inner(); - let silo_lookup = nexus.silo.silo_lookup(&opctx, query.silo)?; + let silo_lookup = nexus.silo.lookup(&opctx, query.silo)?; let provider = nexus .silo .saml_identity_provider_create( @@ -1228,7 +1218,7 @@ async fn local_idp_user_create( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let nexus = &apictx.context.nexus; let query = query_params.into_inner(); - let silo_lookup = nexus.silo.silo_lookup(&opctx, query.silo)?; + let silo_lookup = nexus.silo.lookup(&opctx, query.silo)?; let user = nexus .silo .local_idp_create_user( @@ -1263,7 +1253,7 @@ async fn local_idp_user_delete( let nexus = &apictx.context.nexus; let path = path_params.into_inner(); let query = query_params.into_inner(); - let silo_lookup = nexus.silo.silo_lookup(&opctx, query.silo)?; + let silo_lookup = nexus.silo.lookup(&opctx, query.silo)?; nexus .silo .local_idp_delete_user(&opctx, &silo_lookup, path.user_id) @@ -1298,7 +1288,7 @@ async fn local_idp_user_set_password( let nexus = &apictx.context.nexus; let path = path_params.into_inner(); let query = query_params.into_inner(); - let silo_lookup = nexus.silo.silo_lookup(&opctx, query.silo)?; + let silo_lookup = nexus.silo.lookup(&opctx, query.silo)?; nexus .silo .local_idp_user_set_password( @@ -1337,7 +1327,7 @@ async fn project_list( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let projects = nexus .project - .project_list(&opctx, &paginated_by) + .list(&opctx, &paginated_by) .await? .into_iter() .map(|p| p.into()) @@ -1371,11 +1361,7 @@ async fn project_create( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let project = nexus .project - .project_create( - &opctx, - &nexus.saga_context, - &new_project.into_inner(), - ) + .create(&opctx, &nexus.saga_context, &new_project.into_inner()) .await?; Ok(HttpResponseCreated(project.into())) }; @@ -1403,11 +1389,8 @@ async fn project_view( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let project_selector = params::ProjectSelector { project: path.project }; - let (.., project) = nexus - .project - .project_lookup(&opctx, project_selector)? - .fetch() - .await?; + let (.., project) = + nexus.project.lookup(&opctx, project_selector)?.fetch().await?; Ok(HttpResponseOk(project.into())) }; apictx @@ -1434,9 +1417,8 @@ async fn project_delete( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let project_selector = params::ProjectSelector { project: path.project }; - let project_lookup = - nexus.project.project_lookup(&opctx, project_selector)?; - nexus.project.project_delete(&opctx, &project_lookup).await?; + let project_lookup = nexus.project.lookup(&opctx, project_selector)?; + nexus.project.delete(&opctx, &project_lookup).await?; Ok(HttpResponseDeleted()) }; apictx @@ -1470,11 +1452,10 @@ async fn project_update( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let project_selector = params::ProjectSelector { project: path.project }; - let project_lookup = - nexus.project.project_lookup(&opctx, project_selector)?; + let project_lookup = nexus.project.lookup(&opctx, project_selector)?; let project = nexus .project - .project_update(&opctx, &project_lookup, &updated_project) + .update(&opctx, &project_lookup, &updated_project) .await?; Ok(HttpResponseOk(project.into())) }; @@ -1502,10 +1483,9 @@ async fn project_policy_view( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let project_selector = params::ProjectSelector { project: path.project }; - let project_lookup = - nexus.project.project_lookup(&opctx, project_selector)?; + let project_lookup = nexus.project.lookup(&opctx, project_selector)?; let policy = - nexus.project.project_fetch_policy(&opctx, &project_lookup).await?; + nexus.project.fetch_policy(&opctx, &project_lookup).await?; Ok(HttpResponseOk(policy)) }; apictx @@ -1534,11 +1514,10 @@ async fn project_policy_update( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let project_selector = params::ProjectSelector { project: path.project }; - let project_lookup = - nexus.project.project_lookup(&opctx, project_selector)?; + let project_lookup = nexus.project.lookup(&opctx, project_selector)?; nexus .project - .project_update_policy(&opctx, &project_lookup, &new_policy) + .update_policy(&opctx, &project_lookup, &new_policy) .await?; Ok(HttpResponseOk(new_policy)) }; @@ -1641,7 +1620,7 @@ async fn ip_pool_list( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let pools = nexus .ip_pool - .ip_pools_list(&opctx, &paginated_by) + .list(&opctx, &paginated_by) .await? .into_iter() .map(IpPool::from) @@ -1679,7 +1658,7 @@ async fn ip_pool_create( let pool_params = pool_params.into_inner(); let handler = async { let opctx = crate::context::op_context_for_external_api(&rqctx).await?; - let pool = nexus.ip_pool.ip_pool_create(&opctx, &pool_params).await?; + let pool = nexus.ip_pool.create(&opctx, &pool_params).await?; Ok(HttpResponseCreated(IpPool::from(pool))) }; apictx @@ -1706,11 +1685,8 @@ async fn ip_pool_view( let pool_selector = path_params.into_inner().pool; // We do not prevent the service pool from being fetched by name or ID // like we do for update, delete, associate. - let (.., pool) = nexus - .ip_pool - .ip_pool_lookup(&opctx, &pool_selector)? - .fetch() - .await?; + let (.., pool) = + nexus.ip_pool.lookup(&opctx, &pool_selector)?.fetch().await?; Ok(HttpResponseOk(IpPool::from(pool))) }; apictx @@ -1735,8 +1711,8 @@ async fn ip_pool_delete( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let nexus = &apictx.context.nexus; let path = path_params.into_inner(); - let pool_lookup = nexus.ip_pool.ip_pool_lookup(&opctx, &path.pool)?; - nexus.ip_pool.ip_pool_delete(&opctx, &pool_lookup).await?; + let pool_lookup = nexus.ip_pool.lookup(&opctx, &path.pool)?; + nexus.ip_pool.delete(&opctx, &pool_lookup).await?; Ok(HttpResponseDeleted()) }; apictx @@ -1763,11 +1739,8 @@ async fn ip_pool_update( let nexus = &apictx.context.nexus; let path = path_params.into_inner(); let updates = updates.into_inner(); - let pool_lookup = nexus.ip_pool.ip_pool_lookup(&opctx, &path.pool)?; - let pool = nexus - .ip_pool - .ip_pool_update(&opctx, &pool_lookup, &updates) - .await?; + let pool_lookup = nexus.ip_pool.lookup(&opctx, &path.pool)?; + let pool = nexus.ip_pool.update(&opctx, &pool_lookup, &updates).await?; Ok(HttpResponseOk(pool.into())) }; apictx @@ -1794,8 +1767,7 @@ async fn ip_pool_utilization_view( let pool_selector = path_params.into_inner().pool; // We do not prevent the service pool from being fetched by name or ID // like we do for update, delete, associate. - let pool_lookup = - nexus.ip_pool.ip_pool_lookup(&opctx, &pool_selector)?; + let pool_lookup = nexus.ip_pool.lookup(&opctx, &pool_selector)?; let utilization = nexus .utilization .ip_pool_utilization_view(&opctx, &pool_lookup) @@ -1839,11 +1811,11 @@ async fn ip_pool_silo_list( let pag_params = data_page_params_for(&rqctx, &query)?; let path = path_params.into_inner(); - let pool_lookup = nexus.ip_pool.ip_pool_lookup(&opctx, &path.pool)?; + let pool_lookup = nexus.ip_pool.lookup(&opctx, &path.pool)?; let assocs = nexus .ip_pool - .ip_pool_silo_list(&opctx, &pool_lookup, &pag_params) + .silo_list(&opctx, &pool_lookup, &pag_params) .await? .into_iter() .map(|assoc| assoc.into()) @@ -1883,10 +1855,10 @@ async fn ip_pool_silo_link( let nexus = &apictx.context.nexus; let path = path_params.into_inner(); let resource_assoc = resource_assoc.into_inner(); - let pool_lookup = nexus.ip_pool.ip_pool_lookup(&opctx, &path.pool)?; + let pool_lookup = nexus.ip_pool.lookup(&opctx, &path.pool)?; let assoc = nexus .ip_pool - .ip_pool_link_silo(&opctx, &pool_lookup, &resource_assoc) + .link_silo(&opctx, &pool_lookup, &resource_assoc) .await?; Ok(HttpResponseCreated(assoc.into())) }; @@ -1914,12 +1886,9 @@ async fn ip_pool_silo_unlink( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let nexus = &apictx.context.nexus; let path = path_params.into_inner(); - let pool_lookup = nexus.ip_pool.ip_pool_lookup(&opctx, &path.pool)?; - let silo_lookup = nexus.silo.silo_lookup(&opctx, path.silo)?; - nexus - .ip_pool - .ip_pool_unlink_silo(&opctx, &pool_lookup, &silo_lookup) - .await?; + let pool_lookup = nexus.ip_pool.lookup(&opctx, &path.pool)?; + let silo_lookup = nexus.silo.lookup(&opctx, path.silo)?; + nexus.ip_pool.unlink_silo(&opctx, &pool_lookup, &silo_lookup).await?; Ok(HttpResponseUpdatedNoContent()) }; apictx @@ -1951,11 +1920,11 @@ async fn ip_pool_silo_update( let nexus = &apictx.context.nexus; let path = path_params.into_inner(); let update = update.into_inner(); - let pool_lookup = nexus.ip_pool.ip_pool_lookup(&opctx, &path.pool)?; - let silo_lookup = nexus.silo.silo_lookup(&opctx, path.silo)?; + let pool_lookup = nexus.ip_pool.lookup(&opctx, &path.pool)?; + let silo_lookup = nexus.silo.lookup(&opctx, path.silo)?; let assoc = nexus .ip_pool - .ip_pool_silo_update(&opctx, &pool_lookup, &silo_lookup, &update) + .silo_update(&opctx, &pool_lookup, &silo_lookup, &update) .await?; Ok(HttpResponseOk(assoc.into())) }; @@ -1979,7 +1948,7 @@ async fn ip_pool_service_view( let nexus = &apictx.context.nexus; let handler = async { let opctx = crate::context::op_context_for_external_api(&rqctx).await?; - let pool = nexus.ip_pool.ip_pool_service_fetch(&opctx).await?; + let pool = nexus.ip_pool.service_fetch(&opctx).await?; Ok(HttpResponseOk(IpPool::from(pool))) }; apictx @@ -2019,10 +1988,10 @@ async fn ip_pool_range_list( direction: PaginationOrder::Ascending, marker, }; - let pool_lookup = nexus.ip_pool.ip_pool_lookup(&opctx, &path.pool)?; + let pool_lookup = nexus.ip_pool.lookup(&opctx, &path.pool)?; let ranges = nexus .ip_pool - .ip_pool_list_ranges(&opctx, &pool_lookup, &pag_params) + .list_ranges(&opctx, &pool_lookup, &pag_params) .await? .into_iter() .map(|range| range.into()) @@ -2061,11 +2030,8 @@ async fn ip_pool_range_add( let nexus = &apictx.context.nexus; let path = path_params.into_inner(); let range = range_params.into_inner(); - let pool_lookup = nexus.ip_pool.ip_pool_lookup(&opctx, &path.pool)?; - let out = nexus - .ip_pool - .ip_pool_add_range(&opctx, &pool_lookup, &range) - .await?; + let pool_lookup = nexus.ip_pool.lookup(&opctx, &path.pool)?; + let out = nexus.ip_pool.add_range(&opctx, &pool_lookup, &range).await?; Ok(HttpResponseCreated(out.into())) }; apictx @@ -2092,11 +2058,8 @@ async fn ip_pool_range_remove( let nexus = &apictx.context.nexus; let path = path_params.into_inner(); let range = range_params.into_inner(); - let pool_lookup = nexus.ip_pool.ip_pool_lookup(&opctx, &path.pool)?; - nexus - .ip_pool - .ip_pool_delete_range(&opctx, &pool_lookup, &range) - .await?; + let pool_lookup = nexus.ip_pool.lookup(&opctx, &path.pool)?; + nexus.ip_pool.delete_range(&opctx, &pool_lookup, &range).await?; Ok(HttpResponseUpdatedNoContent()) }; apictx @@ -2134,7 +2097,7 @@ async fn ip_pool_service_range_list( }; let ranges = nexus .ip_pool - .ip_pool_service_list_ranges(&opctx, &pag_params) + .service_list_ranges(&opctx, &pag_params) .await? .into_iter() .map(|range| range.into()) @@ -2171,8 +2134,7 @@ async fn ip_pool_service_range_add( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let nexus = &apictx.context.nexus; let range = range_params.into_inner(); - let out = - nexus.ip_pool.ip_pool_service_add_range(&opctx, &range).await?; + let out = nexus.ip_pool.service_add_range(&opctx, &range).await?; Ok(HttpResponseCreated(out.into())) }; apictx @@ -2197,7 +2159,7 @@ async fn ip_pool_service_range_remove( let range = range_params.into_inner(); let handler = async { let opctx = crate::context::op_context_for_external_api(&rqctx).await?; - nexus.ip_pool.ip_pool_service_delete_range(&opctx, &range).await?; + nexus.ip_pool.service_delete_range(&opctx, &range).await?; Ok(HttpResponseUpdatedNoContent()) }; apictx @@ -2227,9 +2189,8 @@ async fn floating_ip_list( let pag_params = data_page_params_for(&rqctx, &query)?; let scan_params = ScanByNameOrId::from_query(&query)?; let paginated_by = name_or_id_pagination(&pag_params, scan_params)?; - let project_lookup = nexus - .project - .project_lookup(&opctx, scan_params.selector.clone())?; + let project_lookup = + nexus.project.lookup(&opctx, scan_params.selector.clone())?; let ips = nexus .external_ip .floating_ips_list(&opctx, &project_lookup, &paginated_by) @@ -2264,7 +2225,7 @@ async fn floating_ip_create( let handler = async { let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let project_lookup = - nexus.project.project_lookup(&opctx, query_params.into_inner())?; + nexus.project.lookup(&opctx, query_params.into_inner())?; let ip = nexus .external_ip .floating_ip_create(&opctx, &project_lookup, floating_params) @@ -2492,12 +2453,11 @@ async fn disk_list( let pag_params = data_page_params_for(&rqctx, &query)?; let scan_params = ScanByNameOrId::from_query(&query)?; let paginated_by = name_or_id_pagination(&pag_params, scan_params)?; - let project_lookup = nexus - .project - .project_lookup(&opctx, scan_params.selector.clone())?; + let project_lookup = + nexus.project.lookup(&opctx, scan_params.selector.clone())?; let disks = nexus .disk - .disk_list(&opctx, &project_lookup, &paginated_by) + .list(&opctx, &project_lookup, &paginated_by) .await? .into_iter() .map(|disk| disk.into()) @@ -2533,7 +2493,7 @@ async fn disk_create( let nexus = &apictx.context.nexus; let query = query_params.into_inner(); let params = new_disk.into_inner(); - let project_lookup = nexus.project.project_lookup(&opctx, query)?; + let project_lookup = nexus.project.lookup(&opctx, query)?; let disk = nexus .disk .project_create_disk( @@ -2572,7 +2532,7 @@ async fn disk_view( let disk_selector = params::DiskSelector { disk: path.disk, project: query.project }; let (.., disk) = - nexus.disk.disk_lookup(&opctx, disk_selector)?.fetch().await?; + nexus.disk.lookup(&opctx, disk_selector)?.fetch().await?; Ok(HttpResponseOk(disk.into())) }; apictx @@ -2601,7 +2561,7 @@ async fn disk_delete( let query = query_params.into_inner(); let disk_selector = params::DiskSelector { disk: path.disk, project: query.project }; - let disk_lookup = nexus.disk.disk_lookup(&opctx, disk_selector)?; + let disk_lookup = nexus.disk.lookup(&opctx, disk_selector)?; nexus .disk .project_delete_disk(&opctx, &nexus.saga_context, &disk_lookup) @@ -2660,7 +2620,7 @@ async fn disk_metrics_list( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let (.., authz_disk) = nexus .disk - .disk_lookup(&opctx, disk_selector)? + .lookup(&opctx, disk_selector)? .lookup_for(authz::Action::Read) .await?; @@ -2705,9 +2665,9 @@ async fn disk_bulk_write_import_start( let disk_selector = params::DiskSelector { disk: path.disk, project: query.project }; - let disk_lookup = nexus.disk.disk_lookup(&opctx, disk_selector)?; + let disk_lookup = nexus.disk.lookup(&opctx, disk_selector)?; - nexus.disk.disk_manual_import_start(&opctx, &disk_lookup).await?; + nexus.disk.manual_import_start(&opctx, &disk_lookup).await?; Ok(HttpResponseUpdatedNoContent()) }; @@ -2740,9 +2700,9 @@ async fn disk_bulk_write_import( let disk_selector = params::DiskSelector { disk: path.disk, project: query.project }; - let disk_lookup = nexus.disk.disk_lookup(&opctx, disk_selector)?; + let disk_lookup = nexus.disk.lookup(&opctx, disk_selector)?; - nexus.disk.disk_manual_import(&disk_lookup, params).await?; + nexus.disk.manual_import(&disk_lookup, params).await?; Ok(HttpResponseUpdatedNoContent()) }; @@ -2775,9 +2735,9 @@ async fn disk_bulk_write_import_stop( let disk_selector = params::DiskSelector { disk: path.disk, project: query.project }; - let disk_lookup = nexus.disk.disk_lookup(&opctx, disk_selector)?; + let disk_lookup = nexus.disk.lookup(&opctx, disk_selector)?; - nexus.disk.disk_manual_import_stop(&opctx, &disk_lookup).await?; + nexus.disk.manual_import_stop(&opctx, &disk_lookup).await?; Ok(HttpResponseUpdatedNoContent()) }; @@ -2809,16 +2769,11 @@ async fn disk_finalize_import( let params = finalize_params.into_inner(); let disk_selector = params::DiskSelector { disk: path.disk, project: query.project }; - let disk_lookup = nexus.disk.disk_lookup(&opctx, disk_selector)?; + let disk_lookup = nexus.disk.lookup(&opctx, disk_selector)?; nexus .disk - .disk_finalize_import( - &opctx, - &nexus.saga_context, - &disk_lookup, - ¶ms, - ) + .finalize_import(&opctx, &nexus.saga_context, &disk_lookup, ¶ms) .await?; Ok(HttpResponseUpdatedNoContent()) @@ -2850,12 +2805,11 @@ async fn instance_list( let scan_params = ScanByNameOrId::from_query(&query)?; let paginated_by = name_or_id_pagination(&pag_params, scan_params)?; let opctx = crate::context::op_context_for_external_api(&rqctx).await?; - let project_lookup = nexus - .project - .project_lookup(&opctx, scan_params.selector.clone())?; + let project_lookup = + nexus.project.lookup(&opctx, scan_params.selector.clone())?; let instances = nexus .instance - .instance_list(&opctx, &project_lookup, &paginated_by) + .list(&opctx, &project_lookup, &paginated_by) .await? .into_iter() .map(|i| i.into()) @@ -2890,8 +2844,7 @@ async fn instance_create( let new_instance_params = &new_instance.into_inner(); let handler = async { let opctx = crate::context::op_context_for_external_api(&rqctx).await?; - let project_lookup = - nexus.project.project_lookup(&opctx, project_selector)?; + let project_lookup = nexus.project.lookup(&opctx, project_selector)?; let instance = nexus .instance .project_create_instance( @@ -2932,7 +2885,7 @@ async fn instance_view( instance: path.instance, }; let instance_lookup = - nexus.instance.instance_lookup(&opctx, instance_selector)?; + nexus.instance.lookup(&opctx, instance_selector)?; let (.., authz_instance) = instance_lookup.lookup_for(authz::Action::Read).await?; let instance_and_vmm = nexus @@ -2970,7 +2923,7 @@ async fn instance_delete( let handler = async { let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let instance_lookup = - nexus.instance.instance_lookup(&opctx, instance_selector)?; + nexus.instance.lookup(&opctx, instance_selector)?; nexus .instance .project_destroy_instance( @@ -3013,7 +2966,7 @@ async fn instance_migrate( let handler = async { let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let instance_lookup = - nexus.instance.instance_lookup(&opctx, instance_selector)?; + nexus.instance.lookup(&opctx, instance_selector)?; let instance = nexus .instance .project_instance_migrate( @@ -3054,9 +3007,8 @@ async fn instance_reboot( let handler = async { let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let instance_lookup = - nexus.instance.instance_lookup(&opctx, instance_selector)?; - let instance = - nexus.instance.instance_reboot(&opctx, &instance_lookup).await?; + nexus.instance.lookup(&opctx, instance_selector)?; + let instance = nexus.instance.reboot(&opctx, &instance_lookup).await?; Ok(HttpResponseAccepted(instance.into())) }; apictx @@ -3088,10 +3040,10 @@ async fn instance_start( let handler = async { let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let instance_lookup = - nexus.instance.instance_lookup(&opctx, instance_selector)?; + nexus.instance.lookup(&opctx, instance_selector)?; let instance = nexus .instance - .instance_start(&opctx, &nexus.saga_context, &instance_lookup) + .start(&opctx, &nexus.saga_context, &instance_lookup) .await?; Ok(HttpResponseAccepted(instance.into())) }; @@ -3124,9 +3076,8 @@ async fn instance_stop( let handler = async { let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let instance_lookup = - nexus.instance.instance_lookup(&opctx, instance_selector)?; - let instance = - nexus.instance.instance_stop(&opctx, &instance_lookup).await?; + nexus.instance.lookup(&opctx, instance_selector)?; + let instance = nexus.instance.stop(&opctx, &instance_lookup).await?; Ok(HttpResponseAccepted(instance.into())) }; apictx @@ -3158,10 +3109,10 @@ async fn instance_serial_console( instance: path.instance, }; let instance_lookup = - nexus.instance.instance_lookup(&opctx, instance_selector)?; + nexus.instance.lookup(&opctx, instance_selector)?; let data = nexus .instance - .instance_serial_console_data(&opctx, &instance_lookup, &query) + .serial_console_data(&opctx, &instance_lookup, &query) .await?; Ok(HttpResponseOk(data)) }; @@ -3199,11 +3150,11 @@ async fn instance_serial_console_stream( None, ) .await; - match nexus.instance.instance_lookup(&opctx, instance_selector) { + match nexus.instance.lookup(&opctx, instance_selector) { Ok(instance_lookup) => { nexus .instance - .instance_serial_console_stream( + .serial_console_stream( &opctx, client_stream, &instance_lookup, @@ -3254,7 +3205,7 @@ async fn instance_ssh_public_key_list( instance: path.instance, }; let instance_lookup = - nexus.instance.instance_lookup(&opctx, instance_selector)?; + nexus.instance.lookup(&opctx, instance_selector)?; let ssh_keys = nexus .ssh_key .instance_ssh_keys_list(&opctx, &instance_lookup, &paginated_by) @@ -3300,10 +3251,10 @@ async fn instance_disk_list( instance: path.instance, }; let instance_lookup = - nexus.instance.instance_lookup(&opctx, instance_selector)?; + nexus.instance.lookup(&opctx, instance_selector)?; let disks = nexus .instance - .instance_list_disks(&opctx, &instance_lookup, &paginated_by) + .list_disks(&opctx, &instance_lookup, &paginated_by) .await? .into_iter() .map(|d| d.into()) @@ -3345,11 +3296,9 @@ async fn instance_disk_attach( instance: path.instance, }; let instance_lookup = - nexus.instance.instance_lookup(&opctx, instance_selector)?; - let disk = nexus - .instance - .instance_attach_disk(&opctx, &instance_lookup, disk) - .await?; + nexus.instance.lookup(&opctx, instance_selector)?; + let disk = + nexus.instance.attach_disk(&opctx, &instance_lookup, disk).await?; Ok(HttpResponseAccepted(disk.into())) }; apictx @@ -3383,11 +3332,9 @@ async fn instance_disk_detach( instance: path.instance, }; let instance_lookup = - nexus.instance.instance_lookup(&opctx, instance_selector)?; - let disk = nexus - .instance - .instance_detach_disk(&opctx, &instance_lookup, disk) - .await?; + nexus.instance.lookup(&opctx, instance_selector)?; + let disk = + nexus.instance.detach_disk(&opctx, &instance_lookup, disk).await?; Ok(HttpResponseAccepted(disk.into())) }; apictx @@ -3423,7 +3370,7 @@ async fn certificate_list( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let certs = nexus .certificate - .certificates_list(&opctx, &paginated_by) + .list(&opctx, &paginated_by) .await? .into_iter() .map(|d| d.try_into()) @@ -3459,10 +3406,7 @@ async fn certificate_create( let nexus = &apictx.context.nexus; let new_cert_params = new_cert.into_inner(); let opctx = crate::context::op_context_for_external_api(&rqctx).await?; - let cert = nexus - .certificate - .certificate_create(&opctx, new_cert_params) - .await?; + let cert = nexus.certificate.create(&opctx, new_cert_params).await?; Ok(HttpResponseCreated(cert.try_into()?)) }; apictx @@ -3495,11 +3439,8 @@ async fn certificate_view( let nexus = &apictx.context.nexus; let path = path_params.into_inner(); let opctx = crate::context::op_context_for_external_api(&rqctx).await?; - let (.., cert) = nexus - .certificate - .certificate_lookup(&opctx, &path.certificate) - .fetch() - .await?; + let (.., cert) = + nexus.certificate.lookup(&opctx, &path.certificate).fetch().await?; Ok(HttpResponseOk(cert.try_into()?)) }; apictx @@ -3528,10 +3469,7 @@ async fn certificate_delete( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; nexus .certificate - .certificate_delete( - &opctx, - nexus.certificate.certificate_lookup(&opctx, &path.certificate), - ) + .delete(&opctx, nexus.certificate.lookup(&opctx, &path.certificate)) .await?; Ok(HttpResponseDeleted()) }; @@ -3557,8 +3495,7 @@ async fn networking_address_lot_create( let nexus = &apictx.context.nexus; let params = new_address_lot.into_inner(); let opctx = crate::context::op_context_for_external_api(&rqctx).await?; - let result = - nexus.address_lot.address_lot_create(&opctx, params).await?; + let result = nexus.address_lot.create(&opctx, params).await?; let lot: AddressLot = result.lot.into(); let blocks: Vec = @@ -3589,11 +3526,8 @@ async fn networking_address_lot_delete( let nexus = &apictx.context.nexus; let path = path_params.into_inner(); let address_lot_lookup = - nexus.address_lot.address_lot_lookup(&opctx, path.address_lot)?; - nexus - .address_lot - .address_lot_delete(&opctx, &address_lot_lookup) - .await?; + nexus.address_lot.lookup(&opctx, path.address_lot)?; + nexus.address_lot.delete(&opctx, &address_lot_lookup).await?; Ok(HttpResponseDeleted()) }; apictx @@ -3623,7 +3557,7 @@ async fn networking_address_lot_list( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let lots = nexus .address_lot - .address_lot_list(&opctx, &paginated_by) + .list(&opctx, &paginated_by) .await? .into_iter() .map(|p| p.into()) @@ -3661,10 +3595,10 @@ async fn networking_address_lot_block_list( let pagparams = data_page_params_for(&rqctx, &query)?; let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let address_lot_lookup = - nexus.address_lot.address_lot_lookup(&opctx, path.address_lot)?; + nexus.address_lot.lookup(&opctx, path.address_lot)?; let blocks = nexus .address_lot - .address_lot_block_list(&opctx, &address_lot_lookup, &pagparams) + .block_list(&opctx, &address_lot_lookup, &pagparams) .await? .into_iter() .map(|p| p.into()) @@ -3823,8 +3757,7 @@ async fn networking_switch_port_settings_create( let nexus = &apictx.context.nexus; let params = new_settings.into_inner(); let opctx = crate::context::op_context_for_external_api(&rqctx).await?; - let result = - nexus.switch_port.switch_port_settings_post(&opctx, params).await?; + let result = nexus.switch_port.settings_post(&opctx, params).await?; let settings: SwitchPortSettingsView = result.into(); Ok(HttpResponseCreated(settings)) @@ -3851,10 +3784,7 @@ async fn networking_switch_port_settings_delete( let nexus = &apictx.context.nexus; let selector = query_params.into_inner(); let opctx = crate::context::op_context_for_external_api(&rqctx).await?; - nexus - .switch_port - .switch_port_settings_delete(&opctx, &selector) - .await?; + nexus.switch_port.settings_delete(&opctx, &selector).await?; Ok(HttpResponseDeleted()) }; apictx @@ -3886,7 +3816,7 @@ async fn networking_switch_port_settings_list( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let settings = nexus .switch_port - .switch_port_settings_list(&opctx, &paginated_by) + .settings_list(&opctx, &paginated_by) .await? .into_iter() .map(|p| p.into()) @@ -3920,8 +3850,7 @@ async fn networking_switch_port_settings_view( let nexus = &apictx.context.nexus; let query = path_params.into_inner().port; let opctx = crate::context::op_context_for_external_api(&rqctx).await?; - let settings = - nexus.switch_port.switch_port_settings_get(&opctx, &query).await?; + let settings = nexus.switch_port.settings_get(&opctx, &query).await?; Ok(HttpResponseOk(settings.into())) }; apictx @@ -3949,7 +3878,7 @@ async fn networking_switch_port_list( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let addrs = nexus .switch_port - .switch_port_list(&opctx, &pagparams) + .list(&opctx, &pagparams) .await? .into_iter() .map(|p| p.into()) @@ -3988,7 +3917,7 @@ async fn networking_switch_port_status( Ok(HttpResponseOk( nexus .switch_port - .switch_port_status(&opctx, query.switch_location, path.port) + .status(&opctx, query.switch_location, path.port) .await?, )) }; @@ -4020,7 +3949,7 @@ async fn networking_switch_port_apply_settings( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; nexus .switch_port - .switch_port_apply_settings(&opctx, &port, &query, &settings) + .apply_settings(&opctx, &port, &query, &settings) .await?; Ok(HttpResponseUpdatedNoContent {}) }; @@ -4048,10 +3977,7 @@ async fn networking_switch_port_clear_settings( let port = path_params.into_inner().port; let query = query_params.into_inner(); let opctx = crate::context::op_context_for_external_api(&rqctx).await?; - nexus - .switch_port - .switch_port_clear_settings(&opctx, &port, &query) - .await?; + nexus.switch_port.clear_settings(&opctx, &port, &query).await?; Ok(HttpResponseUpdatedNoContent {}) }; apictx @@ -4076,7 +4002,7 @@ async fn networking_bgp_config_create( let nexus = &apictx.context.nexus; let config = config.into_inner(); let opctx = crate::context::op_context_for_external_api(&rqctx).await?; - let result = nexus.bgp.bgp_config_set(&opctx, &config).await?; + let result = nexus.bgp.config_set(&opctx, &config).await?; Ok(HttpResponseCreated::(result.into())) }; apictx @@ -4106,7 +4032,7 @@ async fn networking_bgp_config_list( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let configs = nexus .bgp - .bgp_config_list(&opctx, &paginated_by) + .config_list(&opctx, &paginated_by) .await? .into_iter() .map(|p| p.into()) @@ -4139,7 +4065,7 @@ async fn networking_bgp_status( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let handler = async { let nexus = &apictx.context.nexus; - let result = nexus.bgp.bgp_peer_status(&opctx).await?; + let result = nexus.bgp.peer_status(&opctx).await?; Ok(HttpResponseOk(result)) }; apictx @@ -4164,7 +4090,7 @@ async fn networking_bgp_message_history( let handler = async { let nexus = &apictx.context.nexus; let sel = query_params.into_inner(); - let result = nexus.bgp.bgp_message_history(&opctx, &sel).await?; + let result = nexus.bgp.message_history(&opctx, &sel).await?; Ok(HttpResponseOk(AggregateBgpMessageHistory::new(result))) }; apictx @@ -4190,7 +4116,7 @@ async fn networking_bgp_imported_routes_ipv4( let handler = async { let nexus = &apictx.context.nexus; let sel = query_params.into_inner(); - let result = nexus.bgp.bgp_imported_routes_ipv4(&opctx, &sel).await?; + let result = nexus.bgp.imported_routes_ipv4(&opctx, &sel).await?; Ok(HttpResponseOk(result)) }; apictx @@ -4215,7 +4141,7 @@ async fn networking_bgp_config_delete( let nexus = &apictx.context.nexus; let sel = sel.into_inner(); let opctx = crate::context::op_context_for_external_api(&rqctx).await?; - nexus.bgp.bgp_config_delete(&opctx, &sel).await?; + nexus.bgp.config_delete(&opctx, &sel).await?; Ok(HttpResponseUpdatedNoContent {}) }; apictx @@ -4240,7 +4166,7 @@ async fn networking_bgp_announce_set_create( let nexus = &apictx.context.nexus; let config = config.into_inner(); let opctx = crate::context::op_context_for_external_api(&rqctx).await?; - let result = nexus.bgp.bgp_create_announce_set(&opctx, &config).await?; + let result = nexus.bgp.create_announce_set(&opctx, &config).await?; Ok(HttpResponseCreated::(result.0.into())) }; apictx @@ -4268,7 +4194,7 @@ async fn networking_bgp_announce_set_list( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let result = nexus .bgp - .bgp_announce_list(&opctx, &sel) + .announce_list(&opctx, &sel) .await? .into_iter() .map(|p| p.into()) @@ -4297,7 +4223,7 @@ async fn networking_bgp_announce_set_delete( let nexus = &apictx.context.nexus; let sel = selector.into_inner(); let opctx = crate::context::op_context_for_external_api(&rqctx).await?; - nexus.bgp.bgp_delete_announce_set(&opctx, &sel).await?; + nexus.bgp.delete_announce_set(&opctx, &sel).await?; Ok(HttpResponseUpdatedNoContent {}) }; apictx @@ -4322,7 +4248,7 @@ async fn networking_bfd_enable( let nexus = &apictx.context.nexus; let opctx = crate::context::op_context_for_external_api(&rqctx).await?; opctx.authorize(authz::Action::ListChildren, &authz::FLEET).await?; - nexus.bfd.bfd_enable(&opctx, session.into_inner()).await?; + nexus.bfd.enable(&opctx, session.into_inner()).await?; Ok(HttpResponseUpdatedNoContent {}) }; apictx @@ -4347,7 +4273,7 @@ async fn networking_bfd_disable( let nexus = &apictx.context.nexus; let opctx = crate::context::op_context_for_external_api(&rqctx).await?; opctx.authorize(authz::Action::ListChildren, &authz::FLEET).await?; - nexus.bfd.bfd_disable(&opctx, session.into_inner()).await?; + nexus.bfd.disable(&opctx, session.into_inner()).await?; Ok(HttpResponseUpdatedNoContent {}) }; apictx @@ -4371,7 +4297,7 @@ async fn networking_bfd_status( let nexus = &apictx.context.nexus; let opctx = crate::context::op_context_for_external_api(&rqctx).await?; opctx.authorize(authz::Action::ListChildren, &authz::FLEET).await?; - let status = nexus.bfd.bfd_status(&opctx).await?; + let status = nexus.bfd.status(&opctx).await?; Ok(HttpResponseOk(status)) }; apictx @@ -4396,7 +4322,7 @@ async fn networking_allow_list_view( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; nexus .source_ip_allow_list - .allow_list_view(&opctx) + .view(&opctx) .await .map(HttpResponseOk) .map_err(HttpError::from) @@ -4427,7 +4353,7 @@ async fn networking_allow_list_update( let remote_addr = rqctx.request.remote_addr().ip(); nexus .source_ip_allow_list - .allow_list_upsert(&opctx, remote_addr, server_kind, params) + .upsert(&opctx, remote_addr, server_kind, params) .await .map(HttpResponseOk) .map_err(HttpError::from) @@ -4464,10 +4390,9 @@ async fn image_list( let paginated_by = name_or_id_pagination(&pag_params, scan_params)?; let parent_lookup = match scan_params.selector.project.clone() { Some(project) => { - let project_lookup = nexus.project.project_lookup( - &opctx, - params::ProjectSelector { project }, - )?; + let project_lookup = nexus + .project + .lookup(&opctx, params::ProjectSelector { project })?; ImageParentLookup::Project(project_lookup) } None => { @@ -4477,7 +4402,7 @@ async fn image_list( }; let images = nexus .image - .image_list(&opctx, &parent_lookup, &paginated_by) + .list(&opctx, &parent_lookup, &paginated_by) .await? .into_iter() .map(|d| d.into()) @@ -4516,10 +4441,9 @@ async fn image_create( let params = &new_image.into_inner(); let parent_lookup = match query.project.clone() { Some(project) => { - let project_lookup = nexus.project.project_lookup( - &opctx, - params::ProjectSelector { project }, - )?; + let project_lookup = nexus + .project + .lookup(&opctx, params::ProjectSelector { project })?; ImageParentLookup::Project(project_lookup) } None => { @@ -4527,8 +4451,7 @@ async fn image_create( ImageParentLookup::Silo(silo_lookup) } }; - let image = - nexus.image.image_create(&opctx, &parent_lookup, ¶ms).await?; + let image = nexus.image.create(&opctx, &parent_lookup, ¶ms).await?; Ok(HttpResponseCreated(image.into())) }; apictx @@ -4559,7 +4482,7 @@ async fn image_view( let query = query_params.into_inner(); let image: nexus_db_model::Image = match nexus .image - .image_lookup( + .lookup( &opctx, params::ImageSelector { image: path.image, @@ -4609,7 +4532,7 @@ async fn image_delete( let query = query_params.into_inner(); let image_lookup = nexus .image - .image_lookup( + .lookup( &opctx, params::ImageSelector { image: path.image, @@ -4617,10 +4540,7 @@ async fn image_delete( }, ) .await?; - nexus - .image - .image_delete(&opctx, &nexus.saga_context, &image_lookup) - .await?; + nexus.image.delete(&opctx, &nexus.saga_context, &image_lookup).await?; Ok(HttpResponseDeleted()) }; apictx @@ -4651,7 +4571,7 @@ async fn image_promote( let query = query_params.into_inner(); let image_lookup = nexus .image - .image_lookup( + .lookup( &opctx, params::ImageSelector { image: path.image, @@ -4659,7 +4579,7 @@ async fn image_promote( }, ) .await?; - let image = nexus.image.image_promote(&opctx, &image_lookup).await?; + let image = nexus.image.promote(&opctx, &image_lookup).await?; Ok(HttpResponseAccepted(image.into())) }; apictx @@ -4690,18 +4610,16 @@ async fn image_demote( let query = query_params.into_inner(); let image_lookup = nexus .image - .image_lookup( + .lookup( &opctx, params::ImageSelector { image: path.image, project: None }, ) .await?; - let project_lookup = nexus.project.project_lookup(&opctx, query)?; + let project_lookup = nexus.project.lookup(&opctx, query)?; - let image = nexus - .image - .image_demote(&opctx, &image_lookup, &project_lookup) - .await?; + let image = + nexus.image.demote(&opctx, &image_lookup, &project_lookup).await?; Ok(HttpResponseAccepted(image.into())) }; apictx @@ -4729,9 +4647,8 @@ async fn instance_network_interface_list( let pag_params = data_page_params_for(&rqctx, &query)?; let scan_params = ScanByNameOrId::from_query(&query)?; let paginated_by = name_or_id_pagination(&pag_params, scan_params)?; - let instance_lookup = nexus - .instance - .instance_lookup(&opctx, scan_params.selector.clone())?; + let instance_lookup = + nexus.instance.lookup(&opctx, scan_params.selector.clone())?; let interfaces = nexus .network_interface .instance_network_interface_list( @@ -4772,7 +4689,7 @@ async fn instance_network_interface_create( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let nexus = &apictx.context.nexus; let query = query_params.into_inner(); - let instance_lookup = nexus.instance.instance_lookup(&opctx, query)?; + let instance_lookup = nexus.instance.lookup(&opctx, query)?; let iface = nexus .network_interface .network_interface_create( @@ -4940,7 +4857,7 @@ async fn instance_external_ip_list( instance: path.instance, }; let instance_lookup = - nexus.instance.instance_lookup(&opctx, instance_selector)?; + nexus.instance.lookup(&opctx, instance_selector)?; let ips = nexus .external_ip .instance_list_external_ips(&opctx, &instance_lookup) @@ -4977,10 +4894,10 @@ async fn instance_ephemeral_ip_attach( instance: path.instance, }; let instance_lookup = - nexus.instance.instance_lookup(&opctx, instance_selector)?; + nexus.instance.lookup(&opctx, instance_selector)?; let ip = nexus .instance - .instance_attach_ephemeral_ip( + .attach_ephemeral_ip( &opctx, &nexus.saga_context, &instance_lookup, @@ -5018,10 +4935,10 @@ async fn instance_ephemeral_ip_detach( instance: path.instance, }; let instance_lookup = - nexus.instance.instance_lookup(&opctx, instance_selector)?; + nexus.instance.lookup(&opctx, instance_selector)?; nexus .instance - .instance_detach_external_ip( + .detach_external_ip( &opctx, &nexus.saga_context, &instance_lookup, @@ -5057,12 +4974,11 @@ async fn snapshot_list( let pag_params = data_page_params_for(&rqctx, &query)?; let scan_params = ScanByNameOrId::from_query(&query)?; let paginated_by = name_or_id_pagination(&pag_params, scan_params)?; - let project_lookup = nexus - .project - .project_lookup(&opctx, scan_params.selector.clone())?; + let project_lookup = + nexus.project.lookup(&opctx, scan_params.selector.clone())?; let snapshots = nexus .snapshot - .snapshot_list(&opctx, &project_lookup, &paginated_by) + .list(&opctx, &project_lookup, &paginated_by) .await? .into_iter() .map(|d| d.into()) @@ -5099,10 +5015,10 @@ async fn snapshot_create( let nexus = &apictx.context.nexus; let query = query_params.into_inner(); let new_snapshot_params = &new_snapshot.into_inner(); - let project_lookup = nexus.project.project_lookup(&opctx, query)?; + let project_lookup = nexus.project.lookup(&opctx, query)?; let snapshot = nexus .snapshot - .snapshot_create( + .create( &opctx, &nexus.saga_context, project_lookup, @@ -5139,11 +5055,8 @@ async fn snapshot_view( project: query.project, snapshot: path.snapshot, }; - let (.., snapshot) = nexus - .snapshot - .snapshot_lookup(&opctx, snapshot_selector)? - .fetch() - .await?; + let (.., snapshot) = + nexus.snapshot.lookup(&opctx, snapshot_selector)?.fetch().await?; Ok(HttpResponseOk(snapshot.into())) }; apictx @@ -5175,10 +5088,10 @@ async fn snapshot_delete( snapshot: path.snapshot, }; let snapshot_lookup = - nexus.snapshot.snapshot_lookup(&opctx, snapshot_selector)?; + nexus.snapshot.lookup(&opctx, snapshot_selector)?; nexus .snapshot - .snapshot_delete(&opctx, &nexus.saga_context, &snapshot_lookup) + .delete(&opctx, &nexus.saga_context, &snapshot_lookup) .await?; Ok(HttpResponseDeleted()) }; @@ -5209,12 +5122,11 @@ async fn vpc_list( let scan_params = ScanByNameOrId::from_query(&query)?; let paginated_by = name_or_id_pagination(&pag_params, scan_params)?; let opctx = crate::context::op_context_for_external_api(&rqctx).await?; - let project_lookup = nexus - .project - .project_lookup(&opctx, scan_params.selector.clone())?; + let project_lookup = + nexus.project.lookup(&opctx, scan_params.selector.clone())?; let vpcs = nexus .vpc - .vpc_list(&opctx, &project_lookup, &paginated_by) + .list(&opctx, &project_lookup, &paginated_by) .await? .into_iter() .map(|p| p.into()) @@ -5250,7 +5162,7 @@ async fn vpc_create( let new_vpc_params = body.into_inner(); let handler = async { let opctx = crate::context::op_context_for_external_api(&rqctx).await?; - let project_lookup = nexus.project.project_lookup(&opctx, query)?; + let project_lookup = nexus.project.lookup(&opctx, query)?; let vpc = nexus .vpc .project_create_vpc( @@ -5288,8 +5200,7 @@ async fn vpc_view( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let vpc_selector = params::VpcSelector { project: query.project, vpc: path.vpc }; - let (.., vpc) = - nexus.vpc.vpc_lookup(&opctx, vpc_selector)?.fetch().await?; + let (.., vpc) = nexus.vpc.lookup(&opctx, vpc_selector)?.fetch().await?; Ok(HttpResponseOk(vpc.into())) }; apictx @@ -5320,7 +5231,7 @@ async fn vpc_update( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let vpc_selector = params::VpcSelector { project: query.project, vpc: path.vpc }; - let vpc_lookup = nexus.vpc.vpc_lookup(&opctx, vpc_selector)?; + let vpc_lookup = nexus.vpc.lookup(&opctx, vpc_selector)?; let vpc = nexus .vpc .project_update_vpc(&opctx, &vpc_lookup, &updated_vpc_params) @@ -5353,7 +5264,7 @@ async fn vpc_delete( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let vpc_selector = params::VpcSelector { project: query.project, vpc: path.vpc }; - let vpc_lookup = nexus.vpc.vpc_lookup(&opctx, vpc_selector)?; + let vpc_lookup = nexus.vpc.lookup(&opctx, vpc_selector)?; nexus.vpc.project_delete_vpc(&opctx, &vpc_lookup).await?; Ok(HttpResponseDeleted()) }; @@ -5383,10 +5294,10 @@ async fn vpc_subnet_list( let paginated_by = name_or_id_pagination(&pag_params, scan_params)?; let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let vpc_lookup = - nexus.vpc.vpc_lookup(&opctx, scan_params.selector.clone())?; + nexus.vpc.lookup(&opctx, scan_params.selector.clone())?; let subnets = nexus .vpc_subnet - .vpc_subnet_list(&opctx, &vpc_lookup, &paginated_by) + .list(&opctx, &vpc_lookup, &paginated_by) .await? .into_iter() .map(|vpc| vpc.into()) @@ -5421,11 +5332,9 @@ async fn vpc_subnet_create( let query = query_params.into_inner(); let create = create_params.into_inner(); let opctx = crate::context::op_context_for_external_api(&rqctx).await?; - let vpc_lookup = nexus.vpc.vpc_lookup(&opctx, query)?; - let subnet = nexus - .vpc_subnet - .vpc_create_subnet(&opctx, &vpc_lookup, &create) - .await?; + let vpc_lookup = nexus.vpc.lookup(&opctx, query)?; + let subnet = + nexus.vpc_subnet.create(&opctx, &vpc_lookup, &create).await?; Ok(HttpResponseCreated(subnet.into())) }; apictx @@ -5457,11 +5366,8 @@ async fn vpc_subnet_view( vpc: query.vpc, subnet: path.subnet, }; - let (.., subnet) = nexus - .vpc_subnet - .vpc_subnet_lookup(&opctx, subnet_selector)? - .fetch() - .await?; + let (.., subnet) = + nexus.vpc_subnet.lookup(&opctx, subnet_selector)?.fetch().await?; Ok(HttpResponseOk(subnet.into())) }; apictx @@ -5493,9 +5399,8 @@ async fn vpc_subnet_delete( vpc: query.vpc, subnet: path.subnet, }; - let subnet_lookup = - nexus.vpc_subnet.vpc_subnet_lookup(&opctx, subnet_selector)?; - nexus.vpc_subnet.vpc_delete_subnet(&opctx, &subnet_lookup).await?; + let subnet_lookup = nexus.vpc_subnet.lookup(&opctx, subnet_selector)?; + nexus.vpc_subnet.delete(&opctx, &subnet_lookup).await?; Ok(HttpResponseDeleted()) }; apictx @@ -5529,11 +5434,10 @@ async fn vpc_subnet_update( vpc: query.vpc, subnet: path.subnet, }; - let subnet_lookup = - nexus.vpc_subnet.vpc_subnet_lookup(&opctx, subnet_selector)?; + let subnet_lookup = nexus.vpc_subnet.lookup(&opctx, subnet_selector)?; let subnet = nexus .vpc_subnet - .vpc_update_subnet(&opctx, &subnet_lookup, &subnet_params) + .update(&opctx, &subnet_lookup, &subnet_params) .await?; Ok(HttpResponseOk(subnet.into())) }; @@ -5573,11 +5477,10 @@ async fn vpc_subnet_list_network_interfaces( vpc: scan_params.selector.vpc.clone(), subnet: path.subnet, }; - let subnet_lookup = - nexus.vpc_subnet.vpc_subnet_lookup(&opctx, subnet_selector)?; + let subnet_lookup = nexus.vpc_subnet.lookup(&opctx, subnet_selector)?; let interfaces = nexus .vpc_subnet - .subnet_list_instance_network_interfaces( + .list_instance_network_interfaces( &opctx, &subnet_lookup, &paginated_by, @@ -5620,9 +5523,8 @@ async fn vpc_firewall_rules_view( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let nexus = &apictx.context.nexus; let query = query_params.into_inner(); - let vpc_lookup = nexus.vpc.vpc_lookup(&opctx, query)?; - let rules = - nexus.vpc.vpc_list_firewall_rules(&opctx, &vpc_lookup).await?; + let vpc_lookup = nexus.vpc.lookup(&opctx, query)?; + let rules = nexus.vpc.list_firewall_rules(&opctx, &vpc_lookup).await?; Ok(HttpResponseOk(VpcFirewallRules { rules: rules.into_iter().map(|rule| rule.into()).collect(), })) @@ -5653,10 +5555,10 @@ async fn vpc_firewall_rules_update( let nexus = &apictx.context.nexus; let query = query_params.into_inner(); let router_params = router_params.into_inner(); - let vpc_lookup = nexus.vpc.vpc_lookup(&opctx, query)?; + let vpc_lookup = nexus.vpc.lookup(&opctx, query)?; let rules = nexus .vpc - .vpc_update_firewall_rules(&opctx, &vpc_lookup, &router_params) + .update_firewall_rules(&opctx, &vpc_lookup, &router_params) .await?; Ok(HttpResponseOk(VpcFirewallRules { rules: rules.into_iter().map(|rule| rule.into()).collect(), @@ -5691,10 +5593,10 @@ async fn vpc_router_list( let scan_params = ScanByNameOrId::from_query(&query)?; let paginated_by = name_or_id_pagination(&pag_params, scan_params)?; let vpc_lookup = - nexus.vpc.vpc_lookup(&opctx, scan_params.selector.clone())?; + nexus.vpc.lookup(&opctx, scan_params.selector.clone())?; let routers = nexus .vpc_router - .vpc_router_list(&opctx, &vpc_lookup, &paginated_by) + .list(&opctx, &vpc_lookup, &paginated_by) .await? .into_iter() .map(|s| s.into()) @@ -5735,11 +5637,8 @@ async fn vpc_router_view( vpc: query.vpc, router: path.router, }; - let (.., vpc_router) = nexus - .vpc_router - .vpc_router_lookup(&opctx, router_selector)? - .fetch() - .await?; + let (.., vpc_router) = + nexus.vpc_router.lookup(&opctx, router_selector)?.fetch().await?; Ok(HttpResponseOk(vpc_router.into())) }; apictx @@ -5767,10 +5666,10 @@ async fn vpc_router_create( let query = query_params.into_inner(); let create = create_params.into_inner(); let opctx = crate::context::op_context_for_external_api(&rqctx).await?; - let vpc_lookup = nexus.vpc.vpc_lookup(&opctx, query)?; + let vpc_lookup = nexus.vpc.lookup(&opctx, query)?; let router = nexus .vpc_router - .vpc_create_router( + .create( &opctx, &vpc_lookup, &db::model::VpcRouterKind::Custom, @@ -5809,9 +5708,8 @@ async fn vpc_router_delete( vpc: query.vpc, router: path.router, }; - let router_lookup = - nexus.vpc_router.vpc_router_lookup(&opctx, router_selector)?; - nexus.vpc_router.vpc_delete_router(&opctx, &router_lookup).await?; + let router_lookup = nexus.vpc_router.lookup(&opctx, router_selector)?; + nexus.vpc_router.delete(&opctx, &router_lookup).await?; Ok(HttpResponseDeleted()) }; apictx @@ -5846,11 +5744,10 @@ async fn vpc_router_update( vpc: query.vpc, router: path.router, }; - let router_lookup = - nexus.vpc_router.vpc_router_lookup(&opctx, router_selector)?; + let router_lookup = nexus.vpc_router.lookup(&opctx, router_selector)?; let router = nexus .vpc_router - .vpc_update_router(&opctx, &router_lookup, &router_params) + .update(&opctx, &router_lookup, &router_params) .await?; Ok(HttpResponseOk(router.into())) }; @@ -5882,12 +5779,11 @@ async fn vpc_router_route_list( let pag_params = data_page_params_for(&rqctx, &query)?; let scan_params = ScanByNameOrId::from_query(&query)?; let paginated_by = name_or_id_pagination(&pag_params, scan_params)?; - let router_lookup = nexus - .vpc_router - .vpc_router_lookup(&opctx, scan_params.selector.clone())?; + let router_lookup = + nexus.vpc_router.lookup(&opctx, scan_params.selector.clone())?; let routes = nexus .vpc_router - .vpc_router_route_list(&opctx, &router_lookup, &paginated_by) + .route_list(&opctx, &router_lookup, &paginated_by) .await? .into_iter() .map(|route| route.into()) @@ -5933,7 +5829,7 @@ async fn vpc_router_route_view( }; let (.., route) = nexus .vpc_router - .vpc_router_route_lookup(&opctx, route_selector)? + .route_lookup(&opctx, route_selector)? .fetch() .await?; Ok(HttpResponseOk(route.into())) @@ -5963,11 +5859,10 @@ async fn vpc_router_route_create( let nexus = &apictx.context.nexus; let query = query_params.into_inner(); let create = create_params.into_inner(); - let router_lookup = - nexus.vpc_router.vpc_router_lookup(&opctx, query)?; + let router_lookup = nexus.vpc_router.lookup(&opctx, query)?; let route = nexus .vpc_router - .router_create_route( + .create_route( &opctx, &router_lookup, &RouterRouteKind::Custom, @@ -6008,8 +5903,8 @@ async fn vpc_router_route_delete( route: path.route, }; let route_lookup = - nexus.vpc_router.vpc_router_route_lookup(&opctx, route_selector)?; - nexus.vpc_router.router_delete_route(&opctx, &route_lookup).await?; + nexus.vpc_router.route_lookup(&opctx, route_selector)?; + nexus.vpc_router.delete_route(&opctx, &route_lookup).await?; Ok(HttpResponseDeleted()) }; apictx @@ -6046,10 +5941,10 @@ async fn vpc_router_route_update( route: path.route, }; let route_lookup = - nexus.vpc_router.vpc_router_route_lookup(&opctx, route_selector)?; + nexus.vpc_router.route_lookup(&opctx, route_selector)?; let route = nexus .vpc_router - .router_update_route(&opctx, &route_lookup, &router_params) + .update_route(&opctx, &route_lookup, &router_params) .await?; Ok(HttpResponseOk(route.into())) }; @@ -6079,7 +5974,7 @@ async fn rack_list( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let racks = nexus .rack - .racks_list(&opctx, &data_page_params_for(&rqctx, &query)?) + .list(&opctx, &data_page_params_for(&rqctx, &query)?) .await? .into_iter() .map(|r| r.into()) @@ -6119,7 +6014,7 @@ async fn rack_view( let nexus = &apictx.context.nexus; let path = path_params.into_inner(); let opctx = crate::context::op_context_for_external_api(&rqctx).await?; - let rack_info = nexus.rack.rack_lookup(&opctx, &path.rack_id).await?; + let rack_info = nexus.rack.lookup(&opctx, &path.rack_id).await?; Ok(HttpResponseOk(rack_info.into())) }; apictx @@ -6218,7 +6113,7 @@ async fn sled_list( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let sleds = nexus .sled - .sled_list(&opctx, &data_page_params_for(&rqctx, &query)?) + .list(&opctx, &data_page_params_for(&rqctx, &query)?) .await? .into_iter() .map(|s| s.into()) @@ -6252,7 +6147,7 @@ async fn sled_view( let path = path_params.into_inner(); let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let (.., sled) = - nexus.sled.sled_lookup(&opctx, &path.sled_id)?.fetch().await?; + nexus.sled.lookup(&opctx, &path.sled_id)?.fetch().await?; Ok(HttpResponseOk(sled.into())) }; apictx @@ -6282,11 +6177,11 @@ async fn sled_set_provision_policy( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; - let sled_lookup = nexus.sled.sled_lookup(&opctx, &path.sled_id)?; + let sled_lookup = nexus.sled.lookup(&opctx, &path.sled_id)?; let old_state = nexus .sled - .sled_set_provision_policy(&opctx, &sled_lookup, new_state) + .set_provision_policy(&opctx, &sled_lookup, new_state) .await?; let response = @@ -6318,10 +6213,10 @@ async fn sled_instance_list( let path = path_params.into_inner(); let query = query_params.into_inner(); let opctx = crate::context::op_context_for_external_api(&rqctx).await?; - let sled_lookup = nexus.sled.sled_lookup(&opctx, &path.sled_id)?; + let sled_lookup = nexus.sled.lookup(&opctx, &path.sled_id)?; let sled_instances = nexus .sled - .sled_instance_list( + .instance_list( &opctx, &sled_lookup, &data_page_params_for(&rqctx, &query)?, @@ -6430,7 +6325,7 @@ async fn switch_list( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let switches = nexus .switch - .switch_list(&opctx, &data_page_params_for(&rqctx, &query)?) + .list(&opctx, &data_page_params_for(&rqctx, &query)?) .await? .into_iter() .map(|s| s.into()) @@ -6465,10 +6360,7 @@ async fn switch_view( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let (.., switch) = nexus .switch - .switch_lookup( - &opctx, - params::SwitchSelector { switch: path.switch_id }, - )? + .lookup(&opctx, params::SwitchSelector { switch: path.switch_id })? .fetch() .await?; Ok(HttpResponseOk(switch.into())) @@ -6499,7 +6391,7 @@ async fn sled_physical_disk_list( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let disks = nexus .sled - .sled_list_physical_disks( + .list_physical_disks( &opctx, path.sled_id, &data_page_params_for(&rqctx, &query)?, @@ -6575,7 +6467,7 @@ async fn system_metric( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let silo_lookup = match other_params.into_inner().silo { - Some(silo) => Some(nexus.silo.silo_lookup(&opctx, silo)?), + Some(silo) => Some(nexus.silo.lookup(&opctx, silo)?), _ => None, }; @@ -6624,7 +6516,7 @@ async fn silo_metric( let project_lookup = match other_params.into_inner().project { Some(project) => { let project_selector = params::ProjectSelector { project }; - Some(nexus.project.project_lookup(&opctx, project_selector)?) + Some(nexus.project.lookup(&opctx, project_selector)?) } _ => None, }; @@ -6737,10 +6629,8 @@ async fn system_update_put_repository( let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let query = query.into_inner(); let body = body.into_stream(); - let update = nexus - .update - .updates_put_repository(&opctx, body, query.file_name) - .await?; + let update = + nexus.update.put_repository(&opctx, body, query.file_name).await?; Ok(HttpResponseOk(update)) }; apictx @@ -6768,10 +6658,8 @@ async fn system_update_get_repository( let handler = async { let opctx = crate::context::op_context_for_external_api(&rqctx).await?; let params = path_params.into_inner(); - let description = nexus - .update - .updates_get_repository(&opctx, params.system_version) - .await?; + let description = + nexus.update.get_repository(&opctx, params.system_version).await?; Ok(HttpResponseOk(TufRepoGetResponse { description: description.into_external(), })) @@ -6882,11 +6770,8 @@ async fn group_view( let nexus = &apictx.context.nexus; let path = path_params.into_inner(); let opctx = crate::context::op_context_for_external_api(&rqctx).await?; - let (.., group) = nexus - .silo - .silo_group_lookup(&opctx, &path.group_id) - .fetch() - .await?; + let (.., group) = + nexus.silo.group_lookup(&opctx, &path.group_id).fetch().await?; Ok(HttpResponseOk(group.into())) }; apictx @@ -7150,7 +7035,7 @@ async fn current_user_ssh_key_list( .internal_context("listing current user's ssh keys")?; let ssh_keys = nexus .ssh_key - .ssh_keys_list(&opctx, actor.actor_id(), &paginated_by) + .list(&opctx, actor.actor_id(), &paginated_by) .await? .into_iter() .map(SshKey::from) @@ -7190,7 +7075,7 @@ async fn current_user_ssh_key_create( .internal_context("creating ssh key for current user")?; let ssh_key = nexus .ssh_key - .ssh_key_create(&opctx, actor.actor_id(), new_key.into_inner()) + .create(&opctx, actor.actor_id(), new_key.into_inner()) .await?; Ok(HttpResponseCreated(ssh_key.into())) }; @@ -7226,8 +7111,7 @@ async fn current_user_ssh_key_view( silo_user_id: actor.actor_id(), ssh_key: path.ssh_key, }; - let ssh_key_lookup = - nexus.ssh_key.ssh_key_lookup(&opctx, &ssh_key_selector)?; + let ssh_key_lookup = nexus.ssh_key.lookup(&opctx, &ssh_key_selector)?; let (.., silo_user, _, ssh_key) = ssh_key_lookup.fetch().await?; // Ensure the SSH key exists in the current silo assert_eq!(silo_user.id(), actor.actor_id()); @@ -7265,12 +7149,8 @@ async fn current_user_ssh_key_delete( silo_user_id: actor.actor_id(), ssh_key: path.ssh_key, }; - let ssh_key_lookup = - nexus.ssh_key.ssh_key_lookup(&opctx, &ssh_key_selector)?; - nexus - .ssh_key - .ssh_key_delete(&opctx, actor.actor_id(), &ssh_key_lookup) - .await?; + let ssh_key_lookup = nexus.ssh_key.lookup(&opctx, &ssh_key_selector)?; + nexus.ssh_key.delete(&opctx, actor.actor_id(), &ssh_key_lookup).await?; Ok(HttpResponseDeleted()) }; apictx @@ -7300,14 +7180,11 @@ async fn probe_list( let pag_params = data_page_params_for(&rqctx, &query)?; let scan_params = ScanByNameOrId::from_query(&query)?; let paginated_by = name_or_id_pagination(&pag_params, scan_params)?; - let project_lookup = nexus - .project - .project_lookup(&opctx, scan_params.selector.clone())?; + let project_lookup = + nexus.project.lookup(&opctx, scan_params.selector.clone())?; - let probes = nexus - .probe - .probe_list(&opctx, &project_lookup, &paginated_by) - .await?; + let probes = + nexus.probe.list(&opctx, &project_lookup, &paginated_by).await?; Ok(HttpResponseOk(ScanByNameOrId::results_page( &query, @@ -7344,10 +7221,9 @@ async fn probe_view( let nexus = &apictx.context.nexus; let path = path_params.into_inner(); let project_selector = query_params.into_inner(); - let project_lookup = - nexus.project.project_lookup(&opctx, project_selector)?; + let project_lookup = nexus.project.lookup(&opctx, project_selector)?; let probe = - nexus.probe.probe_get(&opctx, &project_lookup, &path.probe).await?; + nexus.probe.get(&opctx, &project_lookup, &path.probe).await?; Ok(HttpResponseOk(probe)) }; apictx @@ -7376,11 +7252,10 @@ async fn probe_create( let nexus = &apictx.context.nexus; let new_probe_params = &new_probe.into_inner(); let project_selector = query_params.into_inner(); - let project_lookup = - nexus.project.project_lookup(&opctx, project_selector)?; + let project_lookup = nexus.project.lookup(&opctx, project_selector)?; let probe = nexus .probe - .probe_create(&opctx, &project_lookup, &new_probe_params) + .create(&opctx, &project_lookup, &new_probe_params) .await?; Ok(HttpResponseCreated(probe.into())) }; @@ -7410,9 +7285,8 @@ async fn probe_delete( let nexus = &apictx.context.nexus; let path = path_params.into_inner(); let project_selector = query_params.into_inner(); - let project_lookup = - nexus.project.project_lookup(&opctx, project_selector)?; - nexus.probe.probe_delete(&opctx, &project_lookup, path.probe).await?; + let project_lookup = nexus.project.lookup(&opctx, project_selector)?; + nexus.probe.delete(&opctx, &project_lookup, path.probe).await?; Ok(HttpResponseDeleted()) }; apictx diff --git a/nexus/src/internal_api/http_entrypoints.rs b/nexus/src/internal_api/http_entrypoints.rs index 81a02cc000..6cce1b8150 100644 --- a/nexus/src/internal_api/http_entrypoints.rs +++ b/nexus/src/internal_api/http_entrypoints.rs @@ -142,8 +142,7 @@ async fn sled_agent_get( let path = path_params.into_inner(); let sled_id = &path.sled_id; let handler = async { - let (.., sled) = - nexus.sled.sled_lookup(&opctx, sled_id)?.fetch().await?; + let (.., sled) = nexus.sled.lookup(&opctx, sled_id)?.fetch().await?; Ok(HttpResponseOk(sled.into())) }; apictx.internal_latencies.instrument_dropshot_handler(&rqctx, handler).await @@ -191,7 +190,7 @@ async fn sled_firewall_rules_request( let path = path_params.into_inner(); let sled_id = &path.sled_id; let handler = async { - nexus.sled.sled_request_firewall_rules(&opctx, *sled_id).await?; + nexus.sled.request_firewall_rules(&opctx, *sled_id).await?; Ok(HttpResponseUpdatedNoContent()) }; apictx.internal_latencies.instrument_dropshot_handler(&rqctx, handler).await @@ -221,7 +220,7 @@ async fn rack_initialization_complete( let request = info.into_inner(); let opctx = crate::context::op_context_for_internal_api(&rqctx).await; - nexus.rack.rack_initialize(&opctx, path.rack_id, request).await?; + nexus.rack.initialize(&opctx, path.rack_id, request).await?; Ok(HttpResponseUpdatedNoContent()) } @@ -246,7 +245,7 @@ async fn switch_put( let nexus = &apictx.nexus; let path = path_params.into_inner(); let switch = body.into_inner(); - nexus.switch.switch_upsert(path.switch_id, switch).await?; + nexus.switch.upsert(path.switch_id, switch).await?; Ok(HttpResponseOk(SwitchPutResponse {})) }; apictx.internal_latencies.instrument_dropshot_handler(&rqctx, handler).await @@ -344,7 +343,7 @@ async fn cpapi_volume_remove_read_only_parent( let opctx = crate::context::op_context_for_internal_api(&rqctx).await; nexus .volume - .volume_remove_read_only_parent( + .remove_read_only_parent( &opctx, &nexus.saga_context, path.volume_id, @@ -376,11 +375,7 @@ async fn cpapi_disk_remove_read_only_parent( let opctx = crate::context::op_context_for_internal_api(&rqctx).await; nexus .disk - .disk_remove_read_only_parent( - &opctx, - &nexus.saga_context, - path.disk_id, - ) + .remove_read_only_parent(&opctx, &nexus.saga_context, path.disk_id) .await?; Ok(HttpResponseUpdatedNoContent()) }; @@ -503,7 +498,7 @@ async fn cpapi_artifact_download( // TODO: return 404 if the error we get here says that the record isn't found let body = nexus .update - .updates_download_artifact(&opctx, path_params.into_inner()) + .download_artifact(&opctx, path_params.into_inner()) .await?; Ok(HttpResponseOk(Body::from(body).into())) @@ -889,8 +884,7 @@ async fn blueprint_list( let query = query_params.into_inner(); let opctx = crate::context::op_context_for_internal_api(&rqctx).await; let pagparams = data_page_params_for(&rqctx, &query)?; - let blueprints = - nexus.blueprint.blueprint_list(&opctx, &pagparams).await?; + let blueprints = nexus.blueprint.list(&opctx, &pagparams).await?; Ok(HttpResponseOk(ScanById::results_page( &query, blueprints, @@ -915,8 +909,7 @@ async fn blueprint_view( let opctx = crate::context::op_context_for_internal_api(&rqctx).await; let nexus = &apictx.nexus; let path = path_params.into_inner(); - let blueprint = - nexus.blueprint.blueprint_view(&opctx, path.blueprint_id).await?; + let blueprint = nexus.blueprint.view(&opctx, path.blueprint_id).await?; Ok(HttpResponseOk(blueprint)) }; apictx.internal_latencies.instrument_dropshot_handler(&rqctx, handler).await @@ -936,7 +929,7 @@ async fn blueprint_delete( let opctx = crate::context::op_context_for_internal_api(&rqctx).await; let nexus = &apictx.nexus; let path = path_params.into_inner(); - nexus.blueprint.blueprint_delete(&opctx, path.blueprint_id).await?; + nexus.blueprint.delete(&opctx, path.blueprint_id).await?; Ok(HttpResponseDeleted()) }; apictx.internal_latencies.instrument_dropshot_handler(&rqctx, handler).await @@ -956,7 +949,7 @@ async fn blueprint_target_view( let handler = async { let opctx = crate::context::op_context_for_internal_api(&rqctx).await; let nexus = &apictx.nexus; - let target = nexus.blueprint.blueprint_target_view(&opctx).await?; + let target = nexus.blueprint.target_view(&opctx).await?; Ok(HttpResponseOk(target)) }; apictx.internal_latencies.instrument_dropshot_handler(&rqctx, handler).await @@ -976,8 +969,7 @@ async fn blueprint_target_set( let opctx = crate::context::op_context_for_internal_api(&rqctx).await; let nexus = &apictx.nexus; let target = target.into_inner(); - let target = - nexus.blueprint.blueprint_target_set(&opctx, target).await?; + let target = nexus.blueprint.target_set(&opctx, target).await?; Ok(HttpResponseOk(target)) }; apictx.internal_latencies.instrument_dropshot_handler(&rqctx, handler).await @@ -997,10 +989,7 @@ async fn blueprint_target_set_enabled( let opctx = crate::context::op_context_for_internal_api(&rqctx).await; let nexus = &apictx.nexus; let target = target.into_inner(); - let target = nexus - .blueprint - .blueprint_target_set_enabled(&opctx, target) - .await?; + let target = nexus.blueprint.target_set_enabled(&opctx, target).await?; Ok(HttpResponseOk(target)) }; apictx.internal_latencies.instrument_dropshot_handler(&rqctx, handler).await @@ -1021,8 +1010,7 @@ async fn blueprint_regenerate( let handler = async { let opctx = crate::context::op_context_for_internal_api(&rqctx).await; let nexus = &apictx.nexus; - let result = - nexus.blueprint.blueprint_create_regenerate(&opctx).await?; + let result = nexus.blueprint.create_regenerate(&opctx).await?; Ok(HttpResponseOk(result)) }; apictx.internal_latencies.instrument_dropshot_handler(&rqctx, handler).await @@ -1044,7 +1032,7 @@ async fn blueprint_import( let opctx = crate::context::op_context_for_internal_api(&rqctx).await; let nexus = &apictx.nexus; let blueprint = blueprint.into_inner(); - nexus.blueprint.blueprint_import(&opctx, blueprint).await?; + nexus.blueprint.import(&opctx, blueprint).await?; Ok(HttpResponseUpdatedNoContent()) }; apictx.internal_latencies.instrument_dropshot_handler(&rqctx, handler).await @@ -1116,7 +1104,7 @@ async fn sled_expunge( let handler = async { let opctx = crate::context::op_context_for_internal_api(&rqctx).await; let previous_policy = - nexus.sled.sled_expunge(&opctx, sled.into_inner().sled).await?; + nexus.sled.expunge(&opctx, sled.into_inner().sled).await?; Ok(HttpResponseOk(previous_policy)) }; apictx.internal_latencies.instrument_dropshot_handler(&rqctx, handler).await @@ -1146,10 +1134,7 @@ async fn probes_get( let opctx = crate::context::op_context_for_internal_api(&rqctx).await; let pagparams = data_page_params_for(&rqctx, &query)?; Ok(HttpResponseOk( - nexus - .probe - .probe_list_for_sled(&opctx, &pagparams, path.sled) - .await?, + nexus.probe.list_for_sled(&opctx, &pagparams, path.sled).await?, )) }; apictx.internal_latencies.instrument_dropshot_handler(&rqctx, handler).await diff --git a/nexus/src/lib.rs b/nexus/src/lib.rs index e23171817b..9f87a503f2 100644 --- a/nexus/src/lib.rs +++ b/nexus/src/lib.rs @@ -309,7 +309,7 @@ impl nexus_test_interface::NexusServer for Server { .context .nexus .rack - .rack_initialize( + .initialize( &opctx, config.deployment.rack_id, internal_api::params::RackInitializationRequest { @@ -353,7 +353,7 @@ impl nexus_test_interface::NexusServer for Server { let nexus = &rv.server_context().nexus; nexus .sled - .sled_set_provision_policy( + .set_provision_policy( &opctx, &nexus_db_queries::db::lookup::LookupPath::new( &opctx, diff --git a/nexus/tests/integration_tests/instances.rs b/nexus/tests/integration_tests/instances.rs index 141776ca53..841b345c1d 100644 --- a/nexus/tests/integration_tests/instances.rs +++ b/nexus/tests/integration_tests/instances.rs @@ -4715,6 +4715,6 @@ async fn instance_simulate_on_sled( ) { info!(&cptestctx.logctx.log, "Poking simulated instance on sled"; "instance_id" => %instance_id, "sled_id" => %sled_id); - let sa = nexus.sled.sled_client(&sled_id).await.unwrap(); + let sa = nexus.sled.client(&sled_id).await.unwrap(); sa.instance_finish_transition(instance_id).await; } diff --git a/nexus/tests/integration_tests/saml.rs b/nexus/tests/integration_tests/saml.rs index 286063beb7..a59d7db636 100644 --- a/nexus/tests/integration_tests/saml.rs +++ b/nexus/tests/integration_tests/saml.rs @@ -94,7 +94,7 @@ async fn test_create_a_saml_idp(cptestctx: &ControlPlaneTestContext) { let nexus = &cptestctx.server.server_context().nexus; let (.., _retrieved_silo_nexus) = nexus .silo - .silo_lookup( + .lookup( &nexus.opctx_external_authn(), omicron_common::api::external::Name::try_from( SILO_NAME.to_string(), diff --git a/nexus/tests/integration_tests/silo_users.rs b/nexus/tests/integration_tests/silo_users.rs index f3c3dc939d..19419d42af 100644 --- a/nexus/tests/integration_tests/silo_users.rs +++ b/nexus/tests/integration_tests/silo_users.rs @@ -54,7 +54,7 @@ async fn test_silo_group_users(cptestctx: &ControlPlaneTestContext) { let group_name = "group1".to_string(); nexus .silo - .silo_group_lookup_or_create_by_name(&opctx, &authz_silo, &group_name) + .group_lookup_or_create_by_name(&opctx, &authz_silo, &group_name) .await .expect("Group created"); diff --git a/nexus/tests/integration_tests/silos.rs b/nexus/tests/integration_tests/silos.rs index 5fa9afcd67..12713e2fec 100644 --- a/nexus/tests/integration_tests/silos.rs +++ b/nexus/tests/integration_tests/silos.rs @@ -318,7 +318,7 @@ async fn test_silo_admin_group(cptestctx: &ControlPlaneTestContext) { // Test that a user is granted privileges from their group membership let admin_group_user = nexus .silo - .silo_user_from_authenticated_subject( + .user_from_authenticated_subject( &authn_opctx, &authz_silo, &db_silo, @@ -816,7 +816,7 @@ async fn test_silo_user_provision_types(cptestctx: &ControlPlaneTestContext) { let existing_silo_user = nexus .silo - .silo_user_from_authenticated_subject( + .user_from_authenticated_subject( &authn_opctx, &authz_silo, &db_silo, @@ -1055,7 +1055,7 @@ async fn test_silo_groups_jit(cptestctx: &ControlPlaneTestContext) { // Should create two groups from the authenticated subject let existing_silo_user = nexus .silo - .silo_user_from_authenticated_subject( + .user_from_authenticated_subject( &authn_opctx, &authz_silo, &db_silo, @@ -1130,7 +1130,7 @@ async fn test_silo_groups_fixed(cptestctx: &ControlPlaneTestContext) { // Should not create groups from the authenticated subject let existing_silo_user = nexus .silo - .silo_user_from_authenticated_subject( + .user_from_authenticated_subject( &authn_opctx, &authz_silo, &db_silo, @@ -1187,7 +1187,7 @@ async fn test_silo_groups_remove_from_one_group( // Add to two groups let existing_silo_user = nexus .silo - .silo_user_from_authenticated_subject( + .user_from_authenticated_subject( &authn_opctx, &authz_silo, &db_silo, @@ -1231,7 +1231,7 @@ async fn test_silo_groups_remove_from_one_group( // Then remove their membership from one group let existing_silo_user = nexus .silo - .silo_user_from_authenticated_subject( + .user_from_authenticated_subject( &authn_opctx, &authz_silo, &db_silo, @@ -1302,7 +1302,7 @@ async fn test_silo_groups_remove_from_both_groups( // Add to two groups let existing_silo_user = nexus .silo - .silo_user_from_authenticated_subject( + .user_from_authenticated_subject( &authn_opctx, &authz_silo, &db_silo, @@ -1346,7 +1346,7 @@ async fn test_silo_groups_remove_from_both_groups( // Then remove from both groups, and add to a new one let existing_silo_user = nexus .silo - .silo_user_from_authenticated_subject( + .user_from_authenticated_subject( &authn_opctx, &authz_silo, &db_silo, @@ -1416,7 +1416,7 @@ async fn test_silo_delete_clean_up_groups(cptestctx: &ControlPlaneTestContext) { // Add a user with a group membership let silo_user = nexus .silo - .silo_user_from_authenticated_subject( + .user_from_authenticated_subject( &opctx_external_authn, &authz_silo, &db_silo, @@ -1498,7 +1498,7 @@ async fn test_ensure_same_silo_group(cptestctx: &ControlPlaneTestContext) { // Add the first user with a group membership let _silo_user_1 = nexus .silo - .silo_user_from_authenticated_subject( + .user_from_authenticated_subject( &nexus.opctx_external_authn(), &authz_silo, &db_silo, @@ -1514,7 +1514,7 @@ async fn test_ensure_same_silo_group(cptestctx: &ControlPlaneTestContext) { // Add the first user with a group membership let _silo_user_2 = nexus .silo - .silo_user_from_authenticated_subject( + .user_from_authenticated_subject( &nexus.opctx_external_authn(), &authz_silo, &db_silo,