Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions sled-agent/src/bootstrap/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ pub(crate) struct Agent {
sled_config: SledConfig,
}

fn get_subnet_path() -> PathBuf {
Path::new(omicron_common::OMICRON_CONFIG_PATH).join("subnet.toml")
fn get_sled_agent_request_path() -> PathBuf {
Path::new(omicron_common::OMICRON_CONFIG_PATH)
.join("sled-agent-request.toml")
}

fn mac_to_socket_addr(mac: MacAddr) -> SocketAddrV6 {
Expand Down Expand Up @@ -147,11 +148,11 @@ impl Agent {
sled_config,
};

let subnet_path = get_subnet_path();
if subnet_path.exists() {
let request_path = get_sled_agent_request_path();
if request_path.exists() {
info!(agent.log, "Sled already configured, loading sled agent");
let sled_request: SledAgentRequest = toml::from_str(
&tokio::fs::read_to_string(&subnet_path).await?,
&tokio::fs::read_to_string(&request_path).await?,
)?;
agent.request_agent(sled_request).await?;
}
Expand Down Expand Up @@ -207,13 +208,13 @@ impl Agent {
maybe_agent.replace(server);
info!(&self.log, "Sled Agent loaded; recording configuration");

// Record the subnet, so the sled agent can be automatically
// Record this request so the sled agent can be automatically
// initialized on the next boot.
tokio::fs::write(
get_subnet_path(),
get_sled_agent_request_path(),
&toml::to_string(
&toml::Value::try_from(&request.subnet)
.expect("Cannot serialize IP"),
&toml::Value::try_from(&request)
.expect("Cannot serialize request"),
)
.expect("Cannot convert toml to string"),
)
Expand Down