From 32596df7f9ef6cb59c4cff348a4fd530ea319a8f Mon Sep 17 00:00:00 2001 From: Sean Klein Date: Mon, 1 Jul 2024 13:50:19 -0700 Subject: [PATCH] Remove unused zone code --- illumos-utils/src/running_zone.rs | 143 ------------------------------ 1 file changed, 143 deletions(-) diff --git a/illumos-utils/src/running_zone.rs b/illumos-utils/src/running_zone.rs index 19672a857b..a66fa44e9c 100644 --- a/illumos-utils/src/running_zone.rs +++ b/illumos-utils/src/running_zone.rs @@ -102,60 +102,6 @@ pub enum EnsureAddressError { OpteGatewayConfig(#[from] RunCommandError), } -/// Errors returned from [`RunningZone::get`]. -#[derive(thiserror::Error, Debug)] -pub enum GetZoneError { - #[error("While looking up zones with prefix '{prefix}', could not get zones: {err}")] - GetZones { - prefix: String, - #[source] - err: crate::zone::AdmError, - }, - - #[error("Invalid Utf8 path: {0}")] - FromPathBuf(#[from] camino::FromPathBufError), - - #[error("Zone with prefix '{prefix}' not found")] - NotFound { prefix: String }, - - #[error("Cannot get zone '{name}': it is in the {state:?} state instead of running")] - NotRunning { name: String, state: zone::State }, - - #[error( - "Cannot get zone '{name}': Failed to acquire control interface {err}" - )] - ControlInterface { - name: String, - #[source] - err: crate::zone::GetControlInterfaceError, - }, - - #[error("Cannot get zone '{name}': Failed to create addrobj: {err}")] - AddrObject { - name: String, - #[source] - err: crate::addrobj::ParseError, - }, - - #[error( - "Cannot get zone '{name}': Failed to ensure address exists: {err}" - )] - EnsureAddress { - name: String, - #[source] - err: crate::zone::EnsureAddressError, - }, - - #[error( - "Cannot get zone '{name}': Incorrect bootstrap interface access {err}" - )] - BootstrapInterface { - name: String, - #[source] - err: crate::zone::GetBootstrapInterfaceError, - }, -} - #[cfg(target_os = "illumos")] static REAPER_THREAD: OnceLock> = OnceLock::new(); @@ -803,95 +749,6 @@ impl RunningZone { Ok(()) } - /// Looks up a running zone based on the `zone_prefix`, if one already exists. - /// - /// - If the zone was found, is running, and has a network interface, it is - /// returned. - /// - If the zone was not found `Error::NotFound` is returned. - /// - If the zone was found, but not running, `Error::NotRunning` is - /// returned. - /// - Other errors may be returned attempting to look up and accessing an - /// address on the zone. - // pub async fn get( - // log: &Logger, - // vnic_allocator: &VnicAllocator, - // zone_prefix: &str, - // addrtype: AddressRequest, - // ) -> Result { - // let zone_info = Zones::get() - // .await - // .map_err(|err| GetZoneError::GetZones { - // prefix: zone_prefix.to_string(), - // err, - // })? - // .into_iter() - // .find(|zone_info| zone_info.name().starts_with(&zone_prefix)) - // .ok_or_else(|| GetZoneError::NotFound { - // prefix: zone_prefix.to_string(), - // })?; - // - // if zone_info.state() != zone::State::Running { - // return Err(GetZoneError::NotRunning { - // name: zone_info.name().to_string(), - // state: zone_info.state(), - // }); - // } - // - // let zone_name = zone_info.name(); - // let vnic_name = - // Zones::get_control_interface(zone_name).map_err(|err| { - // GetZoneError::ControlInterface { - // name: zone_name.to_string(), - // err, - // } - // })?; - // let addrobj = AddrObject::new_control(&vnic_name).map_err(|err| { - // GetZoneError::AddrObject { name: zone_name.to_string(), err } - // })?; - // Zones::ensure_address(Some(zone_name), &addrobj, addrtype).map_err( - // |err| GetZoneError::EnsureAddress { - // name: zone_name.to_string(), - // err, - // }, - // )?; - // - // let control_vnic = vnic_allocator - // .wrap_existing(vnic_name) - // .expect("Failed to wrap valid control VNIC"); - // - // // The bootstrap address for a running zone never changes, - // // so there's no need to call `Zones::ensure_address`. - // // Currently, only the switch zone has a bootstrap interface. - // let bootstrap_vnic = Zones::get_bootstrap_interface(zone_name) - // .map_err(|err| GetZoneError::BootstrapInterface { - // name: zone_name.to_string(), - // err, - // })? - // .map(|name| { - // vnic_allocator - // .wrap_existing(name) - // .expect("Failed to wrap valid bootstrap VNIC") - // }); - // - // Ok(Self { - // id: zone_info.id().map(|x| { - // x.try_into().expect("zoneid_t is expected to be an i32") - // }), - // inner: InstalledZone { - // log: log.new(o!("zone" => zone_name.to_string())), - // zonepath: zone_info.path().to_path_buf().try_into()?, - // name: zone_name.to_string(), - // control_vnic, - // // TODO(https://github.com/oxidecomputer/omicron/issues/725) - // // - // // Re-initialize guest_vnic state by inspecting the zone. - // opte_ports: vec![], - // links: vec![], - // bootstrap_vnic, - // }, - // }) - // } - /// Return references to the OPTE ports for this zone. pub fn opte_ports(&self) -> impl Iterator { self.inner.opte_ports()