Skip to content
This repository has been archived by the owner on Jul 25, 2022. It is now read-only.

Commit

Permalink
Add add/remove_fstab_entry agent actions (#2352)
Browse files Browse the repository at this point in the history
Signed-off-by: Nathaniel Clark <nclark@whamcloud.com>
  • Loading branch information
utopiabound authored Oct 28, 2020
1 parent e3ce868 commit aa1c0f1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions iml-agent/src/action_plugins/action_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ pub fn create_registry() -> action_plugins::Actions {
.add_plugin("mount_many", lustre::client::mount_many)
.add_plugin("unmount", lustre::client::unmount)
.add_plugin("unmount_many", lustre::client::unmount_many)
.add_plugin("add_fstab_entry", lustre::client::add_fstab_entry)
.add_plugin("remove_fstab_entry", lustre::client::remove_fstab_entry)
.add_plugin("ha_resource_start", high_availability::start_resource)
.add_plugin("ha_resource_stop", high_availability::stop_resource)
.add_plugin("crm_attribute", high_availability::crm_attribute)
Expand Down
21 changes: 21 additions & 0 deletions iml-agent/src/action_plugins/lustre/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,27 @@ pub async fn unmount(unmount: Unmount) -> Result<(), ImlAgentError> {
.map(drop)
}

/// This action will attempt to:
/// - Create the specified `Mount.mountpoint` path
/// - Add a systemd mount to `/etc/fstab`
/// - Optionally set systemd mount to start at boot iff `Mount.persist` is `true`.
pub async fn add_fstab_entry(mount: Mount) -> Result<(), ImlAgentError> {
// This should return Ok(()) if the dir already exists.
fs::create_dir_all(&mount.mountpoint).await?;

update_fstab_entry(&mount.mountspec, &mount.mountpoint, mount.persist).await?;

Ok(())
}

/// This action will attempt to:
/// - Remove a mountpoint from `/etc/fstab`
pub async fn remove_fstab_entry(mount: Mount) -> Result<(), ImlAgentError> {
delete_fstab_entry(&mount.mountpoint).await?;

Ok(())
}

pub async fn unmount_many(xs: Vec<Unmount>) -> Result<(), ImlAgentError> {
for x in xs {
unmount(x).await?;
Expand Down

0 comments on commit aa1c0f1

Please sign in to comment.