Skip to content

Commit

Permalink
feat: Use chassis serial number as configuration output filename
Browse files Browse the repository at this point in the history
Instead of using a static filename, the server configuration is now saved
using the server's chassis serial number. This helps identify which
configuration belongs to which physical server and prevents accidental
overwrites when collecting data from multiple servers.

Changes:
- Added filename sanitization function to handle invalid characters
- Replaced static server_config.toml with dynamic {serial_number}.toml
- Updated user feedback messages to show actual filename being used

Example output: ABC123DEF456.toml instead of server_config.toml
  • Loading branch information
kennethdsheridan committed Nov 18, 2024
1 parent dad8167 commit 75b9c7c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Binary file modified build/release/hardware_report-linux-x86_64
Binary file not shown.
8 changes: 4 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1393,9 +1393,9 @@ fn main() -> Result<(), Box<dyn Error>> {

// Get chassis serial number ans sanitize it for use as the file_name
let chassis_serial = server_info.summary.chassis.serial.clone();
let safe_filename = sanitze_filename(&chassis_serial);
let safe_filename = sanitize_filename(&chassis_serial);

fn sanitze_filename(filename: &str) -> String {
fn sanitize_filename(filename: &str) -> String {
filename
.chars()
.map(|c| {
Expand All @@ -1409,11 +1409,11 @@ fn main() -> Result<(), Box<dyn Error>> {
}

println!(
"\nFull configuration being written to {}.toml...",
"\nCreating TOML output for system serial number: {}",
safe_filename
);

let output_filename = format!("{}.toml", safe_filename);
let output_filename = format!("{}_hardware_report.toml", safe_filename);

// Convert to TOML
let toml_string = toml::to_string_pretty(&server_info)?;
Expand Down

0 comments on commit 75b9c7c

Please sign in to comment.