Skip to content

Commit db5e26c

Browse files
committed
cargo fmt
1 parent bf36944 commit db5e26c

File tree

4 files changed

+61
-37
lines changed

4 files changed

+61
-37
lines changed

usermgmt_lib/src/cli/on_which_system.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ pub struct OnWhichSystemCli {
2121
/// Same as [`OnWhichSystemCli`] but without directory management.
2222
#[derive(Args, CopyGetters, Getters, Debug)]
2323
pub struct OnSlurmLdapOnlyCli {
24-
/// If true, the action will be performed on Slurm.
25-
/// Overrides the default provided by conf.toml.
24+
/// If true, the action will be performed on Slurm.
25+
/// Overrides the default provided by conf.toml.
2626
#[clap(long, verbatim_doc_comment)]
2727
#[getset(get_copy = "pub")]
2828
slurm: Option<bool>,
29-
/// If true, the action will be performed on LDAP.
30-
/// Overrides the default provided by conf.toml.
29+
/// If true, the action will be performed on LDAP.
30+
/// Overrides the default provided by conf.toml.
3131
#[clap(long, verbatim_doc_comment)]
3232
#[getset(get_copy = "pub")]
3333
ldap: Option<bool>,

usermgmt_lib/src/config.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use serde::{Deserialize, Serialize};
1111
use crate::{config, prelude::*};
1212

1313
/// This is the main configuration. The values are usually stored in a configuration file (conf.toml).
14-
/// It enables control over various features of the application and the way operations are performed
14+
/// It enables control over various features of the application and the way operations are performed
1515
/// on the cluster.
1616
#[derive(Debug, Serialize, Deserialize, Clone)]
1717
pub struct MgmtConfig {
@@ -159,8 +159,12 @@ pub fn load_config(manual_path: Option<PathBuf>) -> AppResult<LoadedMgmtConfig>
159159

160160
info!("Loading configuration file from path: {:?}", path);
161161
// Load (or create if nonexistent) configuration file conf.toml
162-
let config = confy::load_path(&path)
163-
.with_context(|| format!("Error during loading or creating config file at {:?}", &path))?;
162+
let config = confy::load_path(&path).with_context(|| {
163+
format!(
164+
"Error during loading or creating config file at {:?}",
165+
&path
166+
)
167+
})?;
164168
let path = path
165169
.parent()
166170
.ok_or_else(|| anyhow!("{:?} must have a parent folder", &path))?

usermgmt_lib/src/dir.rs

Lines changed: 49 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/// Module for directory management
22
use log::{debug, info, warn};
33

4-
use crate::util::ResultAccumulator;
54
use crate::config::MgmtConfig;
65
use crate::prelude::AppResult;
76
use crate::ssh::{self, SshConnection, SshCredentials};
7+
use crate::util::ResultAccumulator;
88
use crate::{Group, NewEntity};
99

1010
pub fn add_user_directories<T>(
@@ -24,11 +24,7 @@ where
2424
Ok(())
2525
}
2626

27-
pub fn delete_user_directories<T>(
28-
username: &str,
29-
config: &MgmtConfig,
30-
credentials: &T,
31-
) -> AppResult
27+
pub fn delete_user_directories<T>(username: &str, config: &MgmtConfig, credentials: &T) -> AppResult
3228
where
3329
T: SshCredentials,
3430
{
@@ -59,10 +55,16 @@ where
5955
warn!("No root directory on compute nodes provided in config. Unable to delete user directories on nodes.");
6056
return Ok(());
6157
}
62-
58+
6359
let mut rm_exit_codes = Vec::new();
6460
for server in config.compute_nodes.iter() {
65-
info!("{}", format!("Connecting to compute node {} for directory deletion", server));
61+
info!(
62+
"{}",
63+
format!(
64+
"Connecting to compute node {} for directory deletion",
65+
server
66+
)
67+
);
6668
let sess = SshConnection::new(server, config, credentials.clone());
6769
// Delete directory
6870
let directory = format!("{}/{}", config.compute_node_root_dir, username);
@@ -79,17 +81,20 @@ where
7981
all_exit_codes_are_zero,
8082
"Not all compute nodes returned exit code 0 during directory deletion!".to_owned(),
8183
);
82-
84+
8385
if !errors_from_codes.errs.is_empty() {
84-
warn!("{}: {}", errors_from_codes.base_err_msg, errors_from_codes.errs.join("\n"));
86+
warn!(
87+
"{}: {}",
88+
errors_from_codes.base_err_msg,
89+
errors_from_codes.errs.join("\n")
90+
);
8591
} else {
8692
info!("Successfully deleted directories on compute nodes.");
8793
}
88-
94+
8995
Ok(())
9096
}
9197

92-
9398
/// Establish SSH connection to NFS hosts and delete user directory
9499
fn delete_nfs_dir<T>(username: &str, config: &MgmtConfig, credentials: &T) -> AppResult
95100
where
@@ -112,15 +117,23 @@ where
112117
let current_nfs_host = &config.nfs_host[i];
113118
let current_nfs_root_dir = &config.nfs_root_dir[i];
114119

115-
info!("Connecting to NFS host {} for directory deletion", current_nfs_host);
120+
info!(
121+
"Connecting to NFS host {} for directory deletion",
122+
current_nfs_host
123+
);
116124
let sess = SshConnection::new(current_nfs_host, config, credentials.clone());
117125

118126
// Infer user group
119127
let mut group_dir = "staff";
120-
if username.chars().last().map(|c| c.is_ascii_digit()).unwrap_or(false) {
128+
if username
129+
.chars()
130+
.last()
131+
.map(|c| c.is_ascii_digit())
132+
.unwrap_or(false)
133+
{
121134
group_dir = "students";
122135
}
123-
136+
124137
let directory = format!("{}/{}/{}", current_nfs_root_dir, group_dir, username);
125138
let (dir_exit_code, _) = delete_directory(&sess, &directory)?;
126139

@@ -131,17 +144,21 @@ where
131144
));
132145
} else {
133146
info!(
134-
"{}",
135-
format!(
136-
"Successfully deleted user directory on NFS host {}.",
137-
current_nfs_host
138-
)
139-
);
147+
"{}",
148+
format!(
149+
"Successfully deleted user directory on NFS host {}.",
150+
current_nfs_host
151+
)
152+
);
140153
}
141154
}
142155

143156
if !detected_errors.errs.is_empty() {
144-
warn!("{}: {}", detected_errors.base_err_msg, detected_errors.errs.join("\n"));
157+
warn!(
158+
"{}: {}",
159+
detected_errors.base_err_msg,
160+
detected_errors.errs.join("\n")
161+
);
145162
}
146163

147164
Ok(())
@@ -158,10 +175,13 @@ where
158175
warn!("No home host provided in config. Unable to delete user home directory.");
159176
return Ok(());
160177
}
161-
178+
162179
info!(
163180
"{}",
164-
format!("Connecting to home host {} for directory deletion", &config.home_host)
181+
format!(
182+
"Connecting to home host {} for directory deletion",
183+
&config.home_host
184+
)
165185
);
166186
let sess = SshConnection::new(&config.home_host, config, credentials.clone());
167187

@@ -171,16 +191,16 @@ where
171191

172192
if dir_exit_code == 0 {
173193
info!("Successfully deleted user home directory.");
174-
175194
} else {
176-
warn!("{}", format!("Failed to delete user home directory: {}", &directory));
195+
warn!(
196+
"{}",
197+
format!("Failed to delete user home directory: {}", &directory)
198+
);
177199
}
178-
200+
179201
Ok(())
180202
}
181203

182-
183-
184204
/// Establish SSH connection to each compute node, make user directory and set quota
185205
fn handle_compute_nodes<T>(entity: &NewEntity, config: &MgmtConfig, credentials: &T) -> AppResult
186206
where

usermgmt_lib/src/operations.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ where
190190
on_dir_action(&ssh_session)?;
191191
}
192192
}
193-
193+
194194
Ok(())
195195
}
196196

0 commit comments

Comments
 (0)