Skip to content

Commit

Permalink
More clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
karencfv committed Mar 1, 2024
1 parent 169bef9 commit ced7675
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 142 deletions.
4 changes: 0 additions & 4 deletions sled-agent/src/profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use std::{
fmt::{Display, Formatter},
};

#[derive(Clone)]
pub struct ProfileBuilder {
name: String,
services: Vec<ServiceBuilder>,
Expand Down Expand Up @@ -59,7 +58,6 @@ impl Display for ProfileBuilder {
}
}

#[derive(Clone)]
pub struct ServiceBuilder {
name: String,
instances: Vec<ServiceInstanceBuilder>,
Expand Down Expand Up @@ -116,7 +114,6 @@ impl Display for ServiceBuilder {
}
}

#[derive(Clone)]
pub struct ServiceInstanceBuilder {
name: String,
enabled: bool,
Expand Down Expand Up @@ -166,7 +163,6 @@ impl Display for ServiceInstanceBuilder {
}
}

#[derive(Clone)]
pub struct PropertyGroupBuilder {
name: String,
/// names of the properties that were added, in the order they were added
Expand Down
125 changes: 2 additions & 123 deletions sled-agent/src/services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1161,8 +1161,7 @@ impl ServiceManager {
zone_args.omicron_type(),
Some(OmicronZoneType::ExternalDns { .. })
| Some(OmicronZoneType::Nexus { .. })
| Some(OmicronZoneType::BoundaryNtp { .. }) // TODO: Add if necessary
// | Some(OmicronZoneType::InternalNtp { .. })
| Some(OmicronZoneType::BoundaryNtp { .. })
) {
return Ok(vec![]);
}
Expand Down Expand Up @@ -1337,63 +1336,6 @@ impl ServiceManager {
needed
}

// TODO: Set up a new service for this
// async fn configure_dns_client(
// &self,
// running_zone: &RunningZone,
// dns_servers: &[IpAddr],
// domain: &Option<String>,
// ) -> Result<(), Error> {
// struct DnsClient {}
//
// impl crate::smf_helper::Service for DnsClient {
// fn service_name(&self) -> String {
// "dns_client".to_string()
// }
// fn smf_name(&self) -> String {
// "svc:/network/dns/client".to_string()
// }
// fn should_import(&self) -> bool {
// false
// }
// }
//
// let service = DnsClient {};
// let smfh = SmfHelper::new(&running_zone, &service);
//
// let etc = running_zone.root().join("etc");
// let resolv_conf = etc.join("resolv.conf");
// let nsswitch_conf = etc.join("nsswitch.conf");
// let nsswitch_dns = etc.join("nsswitch.dns");
//
// if dns_servers.is_empty() {
// // Disable the dns/client service
// smfh.disable()?;
// } else {
// debug!(self.inner.log, "enabling {:?}", service.service_name());
// let mut config = String::new();
// if let Some(d) = domain {
// config.push_str(&format!("domain {d}\n"));
// }
// for s in dns_servers {
// config.push_str(&format!("nameserver {s}\n"));
// }
//
// debug!(self.inner.log, "creating {resolv_conf}");
// tokio::fs::write(&resolv_conf, config)
// .await
// .map_err(|err| Error::io_path(&resolv_conf, err))?;
//
// tokio::fs::copy(&nsswitch_dns, &nsswitch_conf)
// .await
// .map_err(|err| Error::io_path(&nsswitch_dns, err))?;
//
// smfh.refresh()?;
// smfh.enable()?;
// }
// Ok(())
// }

async fn dns_install(
info: &SledAgentInfo,
ip_addrs: Option<Vec<IpAddr>>,
Expand Down Expand Up @@ -2034,7 +1976,7 @@ impl ServiceManager {
);

for s in ntp_servers {
ntp_config = ntp_config.clone().add_property(
ntp_config = ntp_config.add_property(
"server",
"astring",
&s.to_string(),
Expand Down Expand Up @@ -2397,69 +2339,6 @@ impl ServiceManager {
// service is enabled.
smfh.refresh()?;
}
// TODO: Remove this section once implemented
// OmicronZoneType::BoundaryNtp {
// ntp_servers,
// dns_servers,
// domain,
// ..
// }
// | OmicronZoneType::InternalNtp {
// ntp_servers,
// dns_servers,
// domain,
// ..
// } => {
// let boundary = matches!(
// &zone_config.zone.zone_type,
// OmicronZoneType::BoundaryNtp { .. }
// );
// info!(
// self.inner.log,
// "Set up NTP service boundary={}, Servers={:?}",
// boundary,
// ntp_servers
// );
//
// let sled_info =
// if let Some(info) = self.inner.sled_info.get() {
// info
// } else {
// return Err(Error::SledAgentNotReady);
// };
//
// // TODO: Left off here
// let rack_net = Ipv6Subnet::<RACK_PREFIX>::new(
// sled_info.underlay_address,
// )
// .net();
//
// smfh.setprop("config/allow", &format!("{}", rack_net))?;
// smfh.setprop(
// "config/boundary",
// if boundary { "true" } else { "false" },
// )?;
//
// if boundary {
// // Configure OPTE port for boundary NTP
// running_zone
// .ensure_address_for_port("public", 0)
// .await?;
// }
//
// smfh.delpropvalue("config/server", "*")?;
// for server in ntp_servers {
// smfh.addpropvalue("config/server", server)?;
// }
// self.configure_dns_client(
// &running_zone,
// &dns_servers,
// &domain,
// )
// .await?;
//
// smfh.refresh()?;
// }
OmicronZoneType::BoundaryNtp { .. }
| OmicronZoneType::Clickhouse { .. }
| OmicronZoneType::ClickhouseKeeper { .. }
Expand Down
15 changes: 0 additions & 15 deletions sled-agent/src/smf_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,19 +236,4 @@ impl<'t> SmfHelper<'t> {
})?;
Ok(())
}

// pub fn disable(&self) -> Result<(), Error> {
// self.running_zone
// .run_cmd(&[
// illumos_utils::zone::SVCADM,
// "disable",
// "-t",
// &self.default_smf_name,
// ])
// .map_err(|err| Error::ZoneCommand {
// intent: format!("Disable {} service", self.default_smf_name),
// err,
// })?;
// Ok(())
// }
}

0 comments on commit ced7675

Please sign in to comment.