Skip to content

Commit

Permalink
test: test
Browse files Browse the repository at this point in the history
Signed-off-by: Abhinandan Purkait <purkaitabhinandan@gmail.com>
  • Loading branch information
Abhinandan-Purkait committed Nov 23, 2024
1 parent 197bb11 commit abe89bc
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 44 deletions.
1 change: 1 addition & 0 deletions control-plane/csi-driver/src/bin/node/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ mod main_;
mod match_dev;
#[cfg(target_os = "linux")]
mod mount;
#[cfg(target_os = "linux")]
mod mount_utils;
#[cfg(target_os = "linux")]
mod node;
Expand Down
24 changes: 12 additions & 12 deletions control-plane/csi-driver/src/bin/node/main_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,24 +262,24 @@ pub(super) async fn main() -> anyhow::Result<()> {
.subcommand(
clap::Command::new("mount")
.arg(
Arg::new("src-path")
.long("src-path")
Arg::new("source")
.long("source")
.value_name("PATH")
.required(true)
.help("Mount src path")
.help("Mount source path")
)
.arg(
Arg::new("dsc-path")
.long("dsc-path")
Arg::new("target")
.long("target")
.value_name("PATH")
.required(true)
.help("Mount dsc path")
.help("Mount target path")
)
.arg(
Arg::new("fstype")
.long("fstype")
.value_name("STRING")
.help("Filesystem type iff filesystem volume")
.help("Filesystem type for filesystem volume")
)
.arg(
Arg::new("data")
Expand All @@ -299,8 +299,8 @@ pub(super) async fn main() -> anyhow::Result<()> {
.subcommand(
clap::Command::new("unmount")
.arg(
Arg::new("target-path")
.long("target-path")
Arg::new("target")
.long("target")
.value_name("PATH")
.required(true)
.help("Unmount target path")
Expand Down Expand Up @@ -342,8 +342,8 @@ pub(super) async fn main() -> anyhow::Result<()> {
.map_err(|error| CsiDriverError::Fsfreeze { source: error })
}
("mount", arg_matches) => {
let src_path = arg_matches.get_one::<String>("src-path").unwrap();
let dsc_path = arg_matches.get_one::<String>("dsc-path").unwrap();
let src_path = arg_matches.get_one::<String>("source").unwrap();
let dsc_path = arg_matches.get_one::<String>("target").unwrap();
let fstype = arg_matches.get_one::<String>("fstype");
let data = arg_matches.get_one::<String>("data");
let mnt_flags = arg_matches
Expand All @@ -360,7 +360,7 @@ pub(super) async fn main() -> anyhow::Result<()> {
.map_err(|error| CsiDriverError::Mount { source: error })
}
("unmount", arg_matches) => {
let target_path = arg_matches.get_one::<String>("target-path").unwrap();
let target_path = arg_matches.get_one::<String>("target").unwrap();
let flags = arg_matches
.get_one::<sys_mount::UnmountFlags>("unmount-flags")
.unwrap();
Expand Down
28 changes: 14 additions & 14 deletions control-plane/csi-driver/src/bin/node/mount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ pub(crate) async fn filesystem_mount(
}
.fstype(fstype.as_ref())
.flags(flags.join(",").as_str())
.device(device)
.target_path(target)
.source(device)
.target(target)
.mount()
.await?;

Expand All @@ -179,7 +179,7 @@ pub(crate) async fn filesystem_unmount(target: &str) -> Result<(), Status> {

MayastorMount::new()
.flags(flags.join(",").as_str())
.target_path(target)
.target(target)
.unmount()
.await?;

Expand All @@ -205,7 +205,7 @@ pub(crate) async fn bind_mount(

let mount = MayastorMount::new()
.flags(flags.join(",").as_str())
.target_path(target)
.target(target)
.mount()
.await?;

Expand Down Expand Up @@ -239,8 +239,8 @@ pub(crate) async fn bind_remount(
}
.fstype("none")
.flags(flags.join(",").as_str())
.device("none")
.target_path(target)
.source("none")
.target(target)
.mount()
.await?;

Expand All @@ -260,7 +260,7 @@ pub(crate) async fn bind_unmount(target: &str) -> Result<(), Status> {

MayastorMount::new()
.flags(flags.join(",").as_str())
.target_path(target)
.target(target)
.unmount()
.await?;

Expand All @@ -281,8 +281,8 @@ pub(crate) async fn remount(target: &str, ro: bool) -> Result<MayastorMount, Sta
let mount = MayastorMount::new()
.fstype("none")
.flags(flags.join(",").as_str())
.device("")
.target_path(target)
.source("")
.target(target)
.mount()
.await?;

Expand All @@ -305,8 +305,8 @@ pub(crate) async fn blockdevice_mount(
let mount = MayastorMount::new()
.fstype("none")
.flags(flags.join(",").as_str())
.device(source)
.target_path(target)
.source(source)
.target(target)
.mount()
.await?;

Expand All @@ -319,8 +319,8 @@ pub(crate) async fn blockdevice_mount(
let mount = MayastorMount::new()
.fstype("none")
.flags(flags.join(",").as_str())
.device("")
.target_path(target)
.source("")
.target(target)
.mount()
.await?;

Expand All @@ -343,7 +343,7 @@ pub(crate) async fn blockdevice_unmount(target: &str) -> Result<(), Status> {

MayastorMount::new()
.flags(flags.join(",").as_str())
.target_path(target)
.target(target)
.unmount()
.await?;
info!("block device at {} has been unmounted", target);
Expand Down
35 changes: 17 additions & 18 deletions control-plane/csi-driver/src/bin/node/mount_utils/mod.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
pub(crate) mod bin;

use snafu::Snafu;
use tokio::process::Command;
use tonic::Status;

const CSI_NODE_BINARY: &str = "csi-node";
const MOUNT: &str = "mount";
const UNMOUNT: &str = "unmount";
const DEVICE: &str = "--device";
const SOURCE: &str = "--source";
const DATA: &str = "--data";
const FSTYPE: &str = "--fstype";
const TARGET_PATH: &str = "--target-path";
const TARGET: &str = "--target";
const MOUNT_FLAGS: &str = "--mount-flags";
const UNMOUNT_FLAGS: &str = "--unmount-flags";

#[derive(Debug, Snafu)]
#[derive(Debug)]
pub(crate) struct MayastorMount {
binary_name: String,
operation: String,
device: String,
target_path: String,
source: String,
target: String,
data: Option<String>,
fstype: Option<String>,
flags: String,
Expand All @@ -30,21 +29,21 @@ impl MayastorMount {
Self {
binary_name: CSI_NODE_BINARY.to_string(),
operation: String::new(),
device: String::new(),
target_path: String::new(),
source: String::new(),
target: String::new(),
data: None,
fstype: None,
flags: String::new(),
}
}

pub(crate) fn device(mut self, path: &str) -> Self {
self.device = path.into();
pub(crate) fn source(mut self, path: &str) -> Self {
self.source = path.into();
self
}

pub(crate) fn target_path(mut self, path: &str) -> Self {
self.target_path = path.into();
pub(crate) fn target(mut self, path: &str) -> Self {
self.target = path.into();
self
}

Expand All @@ -68,10 +67,10 @@ impl MayastorMount {
let mut command = Command::new(&self.binary_name);
command
.arg(&self.operation)
.arg(DEVICE)
.arg(&self.device)
.arg(TARGET_PATH)
.arg(&self.target_path)
.arg(SOURCE)
.arg(&self.source)
.arg(TARGET)
.arg(&self.target)
.arg(MOUNT_FLAGS)
.arg(&self.flags);

Expand All @@ -96,8 +95,8 @@ impl MayastorMount {

let mut command = Command::new(&self.binary_name);
command
.arg(TARGET_PATH)
.arg(&self.target_path)
.arg(TARGET)
.arg(&self.target)
.arg(UNMOUNT_FLAGS)
.arg(&self.flags);

Expand Down

0 comments on commit abe89bc

Please sign in to comment.