cli: backup manager: rust fmt
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
6082d75966
commit
4ad118c613
@ -4,19 +4,19 @@ use std::io::{self, Write};
|
||||
use anyhow::Error;
|
||||
use serde_json::{json, Value};
|
||||
|
||||
use proxmox_sys::fs::CreateOptions;
|
||||
use proxmox_router::{cli::*, RpcEnvironment};
|
||||
use proxmox_schema::api;
|
||||
use proxmox_sys::fs::CreateOptions;
|
||||
|
||||
use pbs_api_types::percent_encoding::percent_encode_component;
|
||||
use pbs_api_types::{
|
||||
GroupFilter, SyncJobConfig, DATASTORE_SCHEMA, GROUP_FILTER_LIST_SCHEMA,
|
||||
IGNORE_VERIFIED_BACKUPS_SCHEMA, REMOTE_ID_SCHEMA, REMOVE_VANISHED_BACKUPS_SCHEMA, UPID_SCHEMA,
|
||||
VERIFICATION_OUTDATED_AFTER_SCHEMA,
|
||||
};
|
||||
use pbs_client::{display_task_log, view_task_result};
|
||||
use pbs_config::sync;
|
||||
use pbs_tools::json::required_string_param;
|
||||
use pbs_api_types::percent_encoding::percent_encode_component;
|
||||
use pbs_api_types::{
|
||||
GroupFilter, SyncJobConfig,
|
||||
DATASTORE_SCHEMA, GROUP_FILTER_LIST_SCHEMA, IGNORE_VERIFIED_BACKUPS_SCHEMA, REMOTE_ID_SCHEMA,
|
||||
REMOVE_VANISHED_BACKUPS_SCHEMA, UPID_SCHEMA, VERIFICATION_OUTDATED_AFTER_SCHEMA,
|
||||
};
|
||||
|
||||
use proxmox_rest_server::wait_for_local_worker;
|
||||
|
||||
@ -42,7 +42,6 @@ use proxmox_backup_manager::*;
|
||||
)]
|
||||
/// Start garbage collection for a specific datastore.
|
||||
async fn start_garbage_collection(param: Value) -> Result<Value, Error> {
|
||||
|
||||
let output_format = get_output_format(¶m);
|
||||
|
||||
let store = required_string_param(¶m, "store")?;
|
||||
@ -73,7 +72,6 @@ async fn start_garbage_collection(param: Value) -> Result<Value, Error> {
|
||||
)]
|
||||
/// Show garbage collection status for a specific datastore.
|
||||
async fn garbage_collection_status(param: Value) -> Result<Value, Error> {
|
||||
|
||||
let output_format = get_output_format(¶m);
|
||||
|
||||
let store = required_string_param(¶m, "store")?;
|
||||
@ -94,17 +92,18 @@ async fn garbage_collection_status(param: Value) -> Result<Value, Error> {
|
||||
}
|
||||
|
||||
fn garbage_collection_commands() -> CommandLineInterface {
|
||||
|
||||
let cmd_def = CliCommandMap::new()
|
||||
.insert("status",
|
||||
CliCommand::new(&API_METHOD_GARBAGE_COLLECTION_STATUS)
|
||||
.insert(
|
||||
"status",
|
||||
CliCommand::new(&API_METHOD_GARBAGE_COLLECTION_STATUS)
|
||||
.arg_param(&["store"])
|
||||
.completion_cb("store", pbs_config::datastore::complete_datastore_name)
|
||||
.completion_cb("store", pbs_config::datastore::complete_datastore_name),
|
||||
)
|
||||
.insert("start",
|
||||
CliCommand::new(&API_METHOD_START_GARBAGE_COLLECTION)
|
||||
.insert(
|
||||
"start",
|
||||
CliCommand::new(&API_METHOD_START_GARBAGE_COLLECTION)
|
||||
.arg_param(&["store"])
|
||||
.completion_cb("store", pbs_config::datastore::complete_datastore_name)
|
||||
.completion_cb("store", pbs_config::datastore::complete_datastore_name),
|
||||
);
|
||||
|
||||
cmd_def.into()
|
||||
@ -135,7 +134,6 @@ fn garbage_collection_commands() -> CommandLineInterface {
|
||||
)]
|
||||
/// List running server tasks.
|
||||
async fn task_list(param: Value) -> Result<Value, Error> {
|
||||
|
||||
let output_format = get_output_format(¶m);
|
||||
|
||||
let client = connect_to_localhost()?;
|
||||
@ -147,15 +145,25 @@ async fn task_list(param: Value) -> Result<Value, Error> {
|
||||
"start": 0,
|
||||
"limit": limit,
|
||||
});
|
||||
let mut result = client.get("api2/json/nodes/localhost/tasks", Some(args)).await?;
|
||||
let mut result = client
|
||||
.get("api2/json/nodes/localhost/tasks", Some(args))
|
||||
.await?;
|
||||
|
||||
let mut data = result["data"].take();
|
||||
let return_type = &api2::node::tasks::API_METHOD_LIST_TASKS.returns;
|
||||
|
||||
use pbs_tools::format::{render_epoch, render_task_status};
|
||||
let options = default_table_format_options()
|
||||
.column(ColumnConfig::new("starttime").right_align(false).renderer(render_epoch))
|
||||
.column(ColumnConfig::new("endtime").right_align(false).renderer(render_epoch))
|
||||
.column(
|
||||
ColumnConfig::new("starttime")
|
||||
.right_align(false)
|
||||
.renderer(render_epoch),
|
||||
)
|
||||
.column(
|
||||
ColumnConfig::new("endtime")
|
||||
.right_align(false)
|
||||
.renderer(render_epoch),
|
||||
)
|
||||
.column(ColumnConfig::new("upid"))
|
||||
.column(ColumnConfig::new("status").renderer(render_task_status));
|
||||
|
||||
@ -175,7 +183,6 @@ async fn task_list(param: Value) -> Result<Value, Error> {
|
||||
)]
|
||||
/// Display the task log.
|
||||
async fn task_log(param: Value) -> Result<Value, Error> {
|
||||
|
||||
let upid = required_string_param(¶m, "upid")?;
|
||||
|
||||
let client = connect_to_localhost()?;
|
||||
@ -196,24 +203,23 @@ async fn task_log(param: Value) -> Result<Value, Error> {
|
||||
)]
|
||||
/// Try to stop a specific task.
|
||||
async fn task_stop(param: Value) -> Result<Value, Error> {
|
||||
|
||||
let upid_str = required_string_param(¶m, "upid")?;
|
||||
|
||||
let client = connect_to_localhost()?;
|
||||
|
||||
let path = format!("api2/json/nodes/localhost/tasks/{}", percent_encode_component(upid_str));
|
||||
let path = format!(
|
||||
"api2/json/nodes/localhost/tasks/{}",
|
||||
percent_encode_component(upid_str)
|
||||
);
|
||||
let _ = client.delete(&path, None).await?;
|
||||
|
||||
Ok(Value::Null)
|
||||
}
|
||||
|
||||
fn task_mgmt_cli() -> CommandLineInterface {
|
||||
let task_log_cmd_def = CliCommand::new(&API_METHOD_TASK_LOG).arg_param(&["upid"]);
|
||||
|
||||
let task_log_cmd_def = CliCommand::new(&API_METHOD_TASK_LOG)
|
||||
.arg_param(&["upid"]);
|
||||
|
||||
let task_stop_cmd_def = CliCommand::new(&API_METHOD_TASK_STOP)
|
||||
.arg_param(&["upid"]);
|
||||
let task_stop_cmd_def = CliCommand::new(&API_METHOD_TASK_STOP).arg_param(&["upid"]);
|
||||
|
||||
let cmd_def = CliCommandMap::new()
|
||||
.insert("list", CliCommand::new(&API_METHOD_TASK_LIST))
|
||||
@ -260,7 +266,6 @@ async fn pull_datastore(
|
||||
group_filter: Option<Vec<GroupFilter>>,
|
||||
param: Value,
|
||||
) -> Result<Value, Error> {
|
||||
|
||||
let output_format = get_output_format(¶m);
|
||||
|
||||
let client = connect_to_localhost()?;
|
||||
@ -308,11 +313,7 @@ async fn pull_datastore(
|
||||
}
|
||||
)]
|
||||
/// Verify backups
|
||||
async fn verify(
|
||||
store: String,
|
||||
mut param: Value,
|
||||
) -> Result<Value, Error> {
|
||||
|
||||
async fn verify(store: String, mut param: Value) -> Result<Value, Error> {
|
||||
let output_format = extract_output_format(&mut param);
|
||||
|
||||
let client = connect_to_localhost()?;
|
||||
@ -357,15 +358,18 @@ async fn get_versions(verbose: bool, param: Value) -> Result<Value, Error> {
|
||||
let output_format = get_output_format(¶m);
|
||||
|
||||
let packages = crate::api2::node::apt::get_versions()?;
|
||||
let mut packages = json!(if verbose { &packages[..] } else { &packages[1..2] });
|
||||
let mut packages = json!(if verbose {
|
||||
&packages[..]
|
||||
} else {
|
||||
&packages[1..2]
|
||||
});
|
||||
|
||||
let options = default_table_format_options()
|
||||
.disable_sort()
|
||||
.noborder(true) // just not helpful for version info which gets copy pasted often
|
||||
.column(ColumnConfig::new("Package"))
|
||||
.column(ColumnConfig::new("Version"))
|
||||
.column(ColumnConfig::new("ExtraInfo").header("Extra Info"))
|
||||
;
|
||||
.column(ColumnConfig::new("ExtraInfo").header("Extra Info"));
|
||||
let return_type = &crate::api2::node::apt::API_METHOD_GET_VERSIONS.returns;
|
||||
|
||||
format_and_print_result_full(&mut packages, return_type, &output_format, &options);
|
||||
@ -374,7 +378,6 @@ async fn get_versions(verbose: bool, param: Value) -> Result<Value, Error> {
|
||||
}
|
||||
|
||||
async fn run() -> Result<(), Error> {
|
||||
|
||||
let cmd_def = CliCommandMap::new()
|
||||
.insert("acl", acl_commands())
|
||||
.insert("datastore", datastore_commands())
|
||||
@ -397,33 +400,40 @@ async fn run() -> Result<(), Error> {
|
||||
"pull",
|
||||
CliCommand::new(&API_METHOD_PULL_DATASTORE)
|
||||
.arg_param(&["remote", "remote-store", "local-store"])
|
||||
.completion_cb("local-store", pbs_config::datastore::complete_datastore_name)
|
||||
.completion_cb(
|
||||
"local-store",
|
||||
pbs_config::datastore::complete_datastore_name,
|
||||
)
|
||||
.completion_cb("remote", pbs_config::remote::complete_remote_name)
|
||||
.completion_cb("remote-store", complete_remote_datastore_name)
|
||||
.completion_cb("group_filter", complete_remote_datastore_group_filter)
|
||||
.completion_cb("group_filter", complete_remote_datastore_group_filter),
|
||||
)
|
||||
.insert(
|
||||
"verify",
|
||||
CliCommand::new(&API_METHOD_VERIFY)
|
||||
.arg_param(&["store"])
|
||||
.completion_cb("store", pbs_config::datastore::complete_datastore_name)
|
||||
.completion_cb("store", pbs_config::datastore::complete_datastore_name),
|
||||
)
|
||||
.insert("report",
|
||||
CliCommand::new(&API_METHOD_REPORT)
|
||||
)
|
||||
.insert("versions",
|
||||
CliCommand::new(&API_METHOD_GET_VERSIONS)
|
||||
);
|
||||
.insert("report", CliCommand::new(&API_METHOD_REPORT))
|
||||
.insert("versions", CliCommand::new(&API_METHOD_GET_VERSIONS));
|
||||
|
||||
let args: Vec<String> = std::env::args().take(2).collect();
|
||||
let avoid_init = args.len() >= 2 && (args[1] == "bashcomplete" || args[1] == "printdoc");
|
||||
|
||||
if !avoid_init {
|
||||
let backup_user = pbs_config::backup_user()?;
|
||||
let file_opts = CreateOptions::new().owner(backup_user.uid).group(backup_user.gid);
|
||||
proxmox_rest_server::init_worker_tasks(pbs_buildcfg::PROXMOX_BACKUP_LOG_DIR_M!().into(), file_opts)?;
|
||||
let file_opts = CreateOptions::new()
|
||||
.owner(backup_user.uid)
|
||||
.group(backup_user.gid);
|
||||
proxmox_rest_server::init_worker_tasks(
|
||||
pbs_buildcfg::PROXMOX_BACKUP_LOG_DIR_M!().into(),
|
||||
file_opts,
|
||||
)?;
|
||||
|
||||
let mut commando_sock = proxmox_rest_server::CommandSocket::new(proxmox_rest_server::our_ctrl_sock(), backup_user.gid);
|
||||
let mut commando_sock = proxmox_rest_server::CommandSocket::new(
|
||||
proxmox_rest_server::our_ctrl_sock(),
|
||||
backup_user.gid,
|
||||
);
|
||||
proxmox_rest_server::register_task_control_commands(&mut commando_sock)?;
|
||||
commando_sock.spawn()?;
|
||||
}
|
||||
@ -437,7 +447,6 @@ async fn run() -> Result<(), Error> {
|
||||
}
|
||||
|
||||
fn main() -> Result<(), Error> {
|
||||
|
||||
proxmox_backup::tools::setup_safe_path_env();
|
||||
|
||||
proxmox_async::runtime::main(run())
|
||||
@ -450,34 +459,28 @@ fn get_sync_job(id: &String) -> Result<SyncJobConfig, Error> {
|
||||
}
|
||||
|
||||
fn get_remote(param: &HashMap<String, String>) -> Option<String> {
|
||||
param
|
||||
.get("remote")
|
||||
.map(|r| r.to_owned())
|
||||
.or_else(|| {
|
||||
if let Some(id) = param.get("id") {
|
||||
if let Ok(job) = get_sync_job(id) {
|
||||
return Some(job.remote);
|
||||
}
|
||||
param.get("remote").map(|r| r.to_owned()).or_else(|| {
|
||||
if let Some(id) = param.get("id") {
|
||||
if let Ok(job) = get_sync_job(id) {
|
||||
return Some(job.remote);
|
||||
}
|
||||
None
|
||||
})
|
||||
}
|
||||
None
|
||||
})
|
||||
}
|
||||
|
||||
fn get_remote_store(param: &HashMap<String, String>) -> Option<(String, String)> {
|
||||
let mut job: Option<SyncJobConfig> = None;
|
||||
|
||||
let remote = param
|
||||
.get("remote")
|
||||
.map(|r| r.to_owned())
|
||||
.or_else(|| {
|
||||
if let Some(id) = param.get("id") {
|
||||
job = get_sync_job(id).ok();
|
||||
if let Some(ref job) = job {
|
||||
return Some(job.remote.clone());
|
||||
}
|
||||
let remote = param.get("remote").map(|r| r.to_owned()).or_else(|| {
|
||||
if let Some(id) = param.get("id") {
|
||||
job = get_sync_job(id).ok();
|
||||
if let Some(ref job) = job {
|
||||
return Some(job.remote.clone());
|
||||
}
|
||||
None
|
||||
});
|
||||
}
|
||||
None
|
||||
});
|
||||
|
||||
if let Some(remote) = remote {
|
||||
let store = param
|
||||
@ -486,7 +489,7 @@ fn get_remote_store(param: &HashMap<String, String>) -> Option<(String, String)>
|
||||
.or_else(|| job.map(|job| job.remote_store));
|
||||
|
||||
if let Some(store) = store {
|
||||
return Some((remote, store))
|
||||
return Some((remote, store));
|
||||
}
|
||||
}
|
||||
|
||||
@ -495,14 +498,12 @@ fn get_remote_store(param: &HashMap<String, String>) -> Option<(String, String)>
|
||||
|
||||
// shell completion helper
|
||||
pub fn complete_remote_datastore_name(_arg: &str, param: &HashMap<String, String>) -> Vec<String> {
|
||||
|
||||
let mut list = Vec::new();
|
||||
|
||||
if let Some(remote) = get_remote(param) {
|
||||
if let Ok(data) = proxmox_async::runtime::block_on(async move {
|
||||
crate::api2::config::remote::scan_remote_datastores(remote).await
|
||||
}) {
|
||||
|
||||
crate::api2::config::remote::scan_remote_datastores(remote).await
|
||||
}) {
|
||||
for item in data {
|
||||
list.push(item.store);
|
||||
}
|
||||
@ -514,14 +515,13 @@ pub fn complete_remote_datastore_name(_arg: &str, param: &HashMap<String, String
|
||||
|
||||
// shell completion helper
|
||||
pub fn complete_remote_datastore_group(_arg: &str, param: &HashMap<String, String>) -> Vec<String> {
|
||||
|
||||
let mut list = Vec::new();
|
||||
|
||||
if let Some((remote, remote_store)) = get_remote_store(param) {
|
||||
if let Ok(data) = proxmox_async::runtime::block_on(async move {
|
||||
crate::api2::config::remote::scan_remote_groups(remote.clone(), remote_store.clone()).await
|
||||
crate::api2::config::remote::scan_remote_groups(remote.clone(), remote_store.clone())
|
||||
.await
|
||||
}) {
|
||||
|
||||
for item in data {
|
||||
list.push(format!("{}/{}", item.backup_type, item.backup_id));
|
||||
}
|
||||
@ -532,8 +532,10 @@ pub fn complete_remote_datastore_group(_arg: &str, param: &HashMap<String, Strin
|
||||
}
|
||||
|
||||
// shell completion helper
|
||||
pub fn complete_remote_datastore_group_filter(_arg: &str, param: &HashMap<String, String>) -> Vec<String> {
|
||||
|
||||
pub fn complete_remote_datastore_group_filter(
|
||||
_arg: &str,
|
||||
param: &HashMap<String, String>,
|
||||
) -> Vec<String> {
|
||||
let mut list = Vec::new();
|
||||
|
||||
list.push("regex:".to_string());
|
||||
@ -541,7 +543,11 @@ pub fn complete_remote_datastore_group_filter(_arg: &str, param: &HashMap<String
|
||||
list.push("type:host".to_string());
|
||||
list.push("type:vm".to_string());
|
||||
|
||||
list.extend(complete_remote_datastore_group(_arg, param).iter().map(|group| format!("group:{}", group)));
|
||||
list.extend(
|
||||
complete_remote_datastore_group(_arg, param)
|
||||
.iter()
|
||||
.map(|group| format!("group:{}", group)),
|
||||
);
|
||||
|
||||
list
|
||||
}
|
||||
|
@ -18,7 +18,6 @@ use proxmox_backup::api2;
|
||||
)]
|
||||
/// Access Control list.
|
||||
fn list_acls(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
|
||||
|
||||
let output_format = get_output_format(¶m);
|
||||
|
||||
let info = &api2::access::acl::API_METHOD_READ_ACL;
|
||||
@ -28,7 +27,9 @@ fn list_acls(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Err
|
||||
};
|
||||
|
||||
fn render_ugid(value: &Value, record: &Value) -> Result<String, Error> {
|
||||
if value.is_null() { return Ok(String::new()); }
|
||||
if value.is_null() {
|
||||
return Ok(String::new());
|
||||
}
|
||||
let ugid = value.as_str().unwrap();
|
||||
let ugid_type = record["ugid_type"].as_str().unwrap();
|
||||
|
||||
@ -53,7 +54,6 @@ fn list_acls(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Err
|
||||
}
|
||||
|
||||
pub fn acl_commands() -> CommandLineInterface {
|
||||
|
||||
let cmd_def = CliCommandMap::new()
|
||||
.insert("list", CliCommand::new(&API_METHOD_LIST_ACLS))
|
||||
.insert(
|
||||
@ -61,8 +61,7 @@ pub fn acl_commands() -> CommandLineInterface {
|
||||
CliCommand::new(&api2::access::acl::API_METHOD_UPDATE_ACL)
|
||||
.arg_param(&["path", "role"])
|
||||
.completion_cb("auth-id", pbs_config::user::complete_authid)
|
||||
.completion_cb("path", pbs_config::datastore::complete_acl_path)
|
||||
|
||||
.completion_cb("path", pbs_config::datastore::complete_acl_path),
|
||||
);
|
||||
|
||||
cmd_def.into()
|
||||
|
@ -3,9 +3,9 @@ use std::io::Write;
|
||||
use anyhow::{bail, Error};
|
||||
use serde_json::Value;
|
||||
|
||||
use proxmox_sys::fs::file_get_contents;
|
||||
use proxmox_router::{cli::*, ApiHandler, RpcEnvironment};
|
||||
use proxmox_schema::api;
|
||||
use proxmox_sys::fs::file_get_contents;
|
||||
|
||||
use proxmox_backup::acme::AcmeClient;
|
||||
use proxmox_backup::api2;
|
||||
|
@ -3,13 +3,12 @@ use anyhow::{bail, Error};
|
||||
use proxmox_router::cli::*;
|
||||
use proxmox_schema::api;
|
||||
|
||||
use proxmox_backup::config;
|
||||
use proxmox_backup::auth_helpers::*;
|
||||
use proxmox_backup::config;
|
||||
|
||||
#[api]
|
||||
/// Display node certificate information.
|
||||
fn cert_info() -> Result<(), Error> {
|
||||
|
||||
let cert = proxmox_backup::cert_info()?;
|
||||
|
||||
println!("Subject: {}", cert.subject_name()?);
|
||||
@ -36,7 +35,10 @@ fn cert_info() -> Result<(), Error> {
|
||||
println!("Fingerprint (sha256): {}", cert.fingerprint()?);
|
||||
|
||||
let pubkey = cert.public_key()?;
|
||||
println!("Public key type: {}", openssl::nid::Nid::from_raw(pubkey.id().as_raw()).long_name()?);
|
||||
println!(
|
||||
"Public key type: {}",
|
||||
openssl::nid::Nid::from_raw(pubkey.id().as_raw()).long_name()?
|
||||
);
|
||||
println!("Public key bits: {}", pubkey.bits());
|
||||
|
||||
Ok(())
|
||||
@ -55,7 +57,6 @@ fn cert_info() -> Result<(), Error> {
|
||||
)]
|
||||
/// Update node certificates and generate all needed files/directories.
|
||||
fn update_certs(force: Option<bool>) -> Result<(), Error> {
|
||||
|
||||
config::create_configdir()?;
|
||||
|
||||
if let Err(err) = generate_auth_key() {
|
||||
@ -72,7 +73,6 @@ fn update_certs(force: Option<bool>) -> Result<(), Error> {
|
||||
}
|
||||
|
||||
pub fn cert_mgmt_cli() -> CommandLineInterface {
|
||||
|
||||
let cmd_def = CliCommandMap::new()
|
||||
.insert("info", CliCommand::new(&API_METHOD_CERT_INFO))
|
||||
.insert("update", CliCommand::new(&API_METHOD_UPDATE_CERTS));
|
||||
|
@ -4,8 +4,8 @@ use serde_json::Value;
|
||||
use proxmox_router::{cli::*, ApiHandler, RpcEnvironment};
|
||||
use proxmox_schema::api;
|
||||
|
||||
use pbs_client::view_task_result;
|
||||
use pbs_api_types::{DataStoreConfig, DATASTORE_SCHEMA};
|
||||
use pbs_client::view_task_result;
|
||||
|
||||
use proxmox_backup::api2;
|
||||
use proxmox_backup::client_helpers::connect_to_localhost;
|
||||
@ -22,7 +22,6 @@ use proxmox_backup::client_helpers::connect_to_localhost;
|
||||
)]
|
||||
/// Datastore list.
|
||||
fn list_datastores(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
|
||||
|
||||
let output_format = get_output_format(¶m);
|
||||
|
||||
let info = &api2::config::datastore::API_METHOD_LIST_DATASTORES;
|
||||
@ -56,7 +55,6 @@ fn list_datastores(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Valu
|
||||
)]
|
||||
/// Show datastore configuration
|
||||
fn show_datastore(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
|
||||
|
||||
let output_format = get_output_format(¶m);
|
||||
|
||||
let info = &api2::config::datastore::API_METHOD_READ_DATASTORE;
|
||||
@ -88,12 +86,13 @@ fn show_datastore(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value
|
||||
)]
|
||||
/// Create new datastore config.
|
||||
async fn create_datastore(mut param: Value) -> Result<Value, Error> {
|
||||
|
||||
let output_format = extract_output_format(&mut param);
|
||||
|
||||
let client = connect_to_localhost()?;
|
||||
|
||||
let result = client.post("api2/json/config/datastore", Some(param)).await?;
|
||||
let result = client
|
||||
.post("api2/json/config/datastore", Some(param))
|
||||
.await?;
|
||||
|
||||
view_task_result(&client, result, &output_format).await?;
|
||||
|
||||
@ -101,29 +100,37 @@ async fn create_datastore(mut param: Value) -> Result<Value, Error> {
|
||||
}
|
||||
|
||||
pub fn datastore_commands() -> CommandLineInterface {
|
||||
|
||||
let cmd_def = CliCommandMap::new()
|
||||
.insert("list", CliCommand::new(&API_METHOD_LIST_DATASTORES))
|
||||
.insert("show",
|
||||
CliCommand::new(&API_METHOD_SHOW_DATASTORE)
|
||||
.insert(
|
||||
"show",
|
||||
CliCommand::new(&API_METHOD_SHOW_DATASTORE)
|
||||
.arg_param(&["name"])
|
||||
.completion_cb("name", pbs_config::datastore::complete_datastore_name),
|
||||
)
|
||||
.insert(
|
||||
"create",
|
||||
CliCommand::new(&API_METHOD_CREATE_DATASTORE).arg_param(&["name", "path"]),
|
||||
)
|
||||
.insert(
|
||||
"update",
|
||||
CliCommand::new(&api2::config::datastore::API_METHOD_UPDATE_DATASTORE)
|
||||
.arg_param(&["name"])
|
||||
.completion_cb("name", pbs_config::datastore::complete_datastore_name)
|
||||
.completion_cb(
|
||||
"gc-schedule",
|
||||
pbs_config::datastore::complete_calendar_event,
|
||||
)
|
||||
.completion_cb(
|
||||
"prune-schedule",
|
||||
pbs_config::datastore::complete_calendar_event,
|
||||
),
|
||||
)
|
||||
.insert("create",
|
||||
CliCommand::new(&API_METHOD_CREATE_DATASTORE)
|
||||
.arg_param(&["name", "path"])
|
||||
)
|
||||
.insert("update",
|
||||
CliCommand::new(&api2::config::datastore::API_METHOD_UPDATE_DATASTORE)
|
||||
.insert(
|
||||
"remove",
|
||||
CliCommand::new(&api2::config::datastore::API_METHOD_DELETE_DATASTORE)
|
||||
.arg_param(&["name"])
|
||||
.completion_cb("name", pbs_config::datastore::complete_datastore_name)
|
||||
.completion_cb("gc-schedule", pbs_config::datastore::complete_calendar_event)
|
||||
.completion_cb("prune-schedule", pbs_config::datastore::complete_calendar_event)
|
||||
)
|
||||
.insert("remove",
|
||||
CliCommand::new(&api2::config::datastore::API_METHOD_DELETE_DATASTORE)
|
||||
.arg_param(&["name"])
|
||||
.completion_cb("name", pbs_config::datastore::complete_datastore_name)
|
||||
.completion_cb("name", pbs_config::datastore::complete_datastore_name),
|
||||
);
|
||||
|
||||
cmd_def.into()
|
||||
|
@ -5,14 +5,10 @@ use proxmox_router::{cli::*, ApiHandler, RpcEnvironment};
|
||||
use proxmox_schema::api;
|
||||
|
||||
use pbs_api_types::{
|
||||
DISK_LIST_SCHEMA, ZFS_ASHIFT_SCHEMA, ZfsRaidLevel, ZfsCompressionType,
|
||||
BLOCKDEVICE_NAME_SCHEMA, DATASTORE_SCHEMA,
|
||||
};
|
||||
use proxmox_backup::tools::disks::{
|
||||
FileSystemType,
|
||||
SmartAttribute,
|
||||
complete_disk_name,
|
||||
ZfsCompressionType, ZfsRaidLevel, BLOCKDEVICE_NAME_SCHEMA, DATASTORE_SCHEMA, DISK_LIST_SCHEMA,
|
||||
ZFS_ASHIFT_SCHEMA,
|
||||
};
|
||||
use proxmox_backup::tools::disks::{complete_disk_name, FileSystemType, SmartAttribute};
|
||||
|
||||
use proxmox_backup::api2;
|
||||
|
||||
@ -28,7 +24,6 @@ use proxmox_backup::api2;
|
||||
)]
|
||||
/// Local disk list.
|
||||
fn list_disks(mut param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
|
||||
|
||||
let output_format = get_output_format(¶m);
|
||||
|
||||
param["node"] = "localhost".into();
|
||||
@ -41,7 +36,10 @@ fn list_disks(mut param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value
|
||||
|
||||
let render_wearout = |value: &Value, _record: &Value| -> Result<String, Error> {
|
||||
match value.as_f64() {
|
||||
Some(value) => Ok(format!("{:.2} %", if value <= 100.0 { 100.0 - value } else { 0.0 })),
|
||||
Some(value) => Ok(format!(
|
||||
"{:.2} %",
|
||||
if value <= 100.0 { 100.0 - value } else { 0.0 }
|
||||
)),
|
||||
None => Ok(String::from("-")),
|
||||
}
|
||||
};
|
||||
@ -54,8 +52,7 @@ fn list_disks(mut param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value
|
||||
.column(ColumnConfig::new("size"))
|
||||
.column(ColumnConfig::new("model"))
|
||||
.column(ColumnConfig::new("wearout").renderer(render_wearout))
|
||||
.column(ColumnConfig::new("status"))
|
||||
;
|
||||
.column(ColumnConfig::new("status"));
|
||||
|
||||
format_and_print_result_full(&mut data, &info.returns, &output_format, &options);
|
||||
|
||||
@ -84,7 +81,6 @@ fn list_disks(mut param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value
|
||||
)]
|
||||
/// Show SMART attributes.
|
||||
fn smart_attributes(mut param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
|
||||
|
||||
let output_format = get_output_format(¶m);
|
||||
|
||||
param["node"] = "localhost".into();
|
||||
@ -98,7 +94,12 @@ fn smart_attributes(mut param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result
|
||||
let mut data = data["attributes"].take();
|
||||
|
||||
let options = default_table_format_options();
|
||||
format_and_print_result_full(&mut data, &API_METHOD_SMART_ATTRIBUTES.returns, &output_format, &options);
|
||||
format_and_print_result_full(
|
||||
&mut data,
|
||||
&API_METHOD_SMART_ATTRIBUTES.returns,
|
||||
&output_format,
|
||||
&options,
|
||||
);
|
||||
|
||||
Ok(Value::Null)
|
||||
}
|
||||
@ -123,7 +124,6 @@ async fn initialize_disk(
|
||||
mut param: Value,
|
||||
rpcenv: &mut dyn RpcEnvironment,
|
||||
) -> Result<Value, Error> {
|
||||
|
||||
param["node"] = "localhost".into();
|
||||
|
||||
let info = &api2::node::disks::API_METHOD_INITIALIZE_DISK;
|
||||
@ -166,11 +166,7 @@ async fn initialize_disk(
|
||||
},
|
||||
)]
|
||||
/// create a zfs pool
|
||||
async fn create_zpool(
|
||||
mut param: Value,
|
||||
rpcenv: &mut dyn RpcEnvironment,
|
||||
) -> Result<Value, Error> {
|
||||
|
||||
async fn create_zpool(mut param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
|
||||
param["node"] = "localhost".into();
|
||||
|
||||
let info = &api2::node::disks::zfs::API_METHOD_CREATE_ZPOOL;
|
||||
@ -196,7 +192,6 @@ async fn create_zpool(
|
||||
)]
|
||||
/// Local zfs pools.
|
||||
fn list_zpools(mut param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
|
||||
|
||||
let output_format = get_output_format(¶m);
|
||||
|
||||
param["node"] = "localhost".into();
|
||||
@ -216,13 +211,17 @@ fn list_zpools(mut param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Valu
|
||||
if size == 0 {
|
||||
bail!("got zero size");
|
||||
}
|
||||
Ok(format!("{:.2} %", (value as f64)/(size as f64)))
|
||||
Ok(format!("{:.2} %", (value as f64) / (size as f64)))
|
||||
};
|
||||
|
||||
let options = default_table_format_options()
|
||||
.column(ColumnConfig::new("name"))
|
||||
.column(ColumnConfig::new("size"))
|
||||
.column(ColumnConfig::new("alloc").right_align(true).renderer(render_usage))
|
||||
.column(
|
||||
ColumnConfig::new("alloc")
|
||||
.right_align(true)
|
||||
.renderer(render_usage),
|
||||
)
|
||||
.column(ColumnConfig::new("health"));
|
||||
|
||||
format_and_print_result_full(&mut data, &info.returns, &output_format, &options);
|
||||
@ -231,13 +230,13 @@ fn list_zpools(mut param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Valu
|
||||
}
|
||||
|
||||
pub fn zpool_commands() -> CommandLineInterface {
|
||||
|
||||
let cmd_def = CliCommandMap::new()
|
||||
.insert("list", CliCommand::new(&API_METHOD_LIST_ZPOOLS))
|
||||
.insert("create",
|
||||
CliCommand::new(&API_METHOD_CREATE_ZPOOL)
|
||||
.insert(
|
||||
"create",
|
||||
CliCommand::new(&API_METHOD_CREATE_ZPOOL)
|
||||
.arg_param(&["name"])
|
||||
.completion_cb("devices", complete_disk_name) // fixme: complete the list
|
||||
.completion_cb("devices", complete_disk_name), // fixme: complete the list
|
||||
);
|
||||
|
||||
cmd_def.into()
|
||||
@ -254,8 +253,10 @@ pub fn zpool_commands() -> CommandLineInterface {
|
||||
}
|
||||
)]
|
||||
/// List systemd datastore mount units.
|
||||
fn list_datastore_mounts(mut param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
|
||||
|
||||
fn list_datastore_mounts(
|
||||
mut param: Value,
|
||||
rpcenv: &mut dyn RpcEnvironment,
|
||||
) -> Result<Value, Error> {
|
||||
let output_format = get_output_format(¶m);
|
||||
|
||||
param["node"] = "localhost".into();
|
||||
@ -303,7 +304,6 @@ async fn create_datastore_disk(
|
||||
mut param: Value,
|
||||
rpcenv: &mut dyn RpcEnvironment,
|
||||
) -> Result<Value, Error> {
|
||||
|
||||
param["node"] = "localhost".into();
|
||||
|
||||
let info = &api2::node::disks::directory::API_METHOD_CREATE_DATASTORE_DISK;
|
||||
@ -318,33 +318,34 @@ async fn create_datastore_disk(
|
||||
}
|
||||
|
||||
pub fn filesystem_commands() -> CommandLineInterface {
|
||||
|
||||
let cmd_def = CliCommandMap::new()
|
||||
.insert("list", CliCommand::new(&API_METHOD_LIST_DATASTORE_MOUNTS))
|
||||
.insert("create",
|
||||
CliCommand::new(&API_METHOD_CREATE_DATASTORE_DISK)
|
||||
.insert(
|
||||
"create",
|
||||
CliCommand::new(&API_METHOD_CREATE_DATASTORE_DISK)
|
||||
.arg_param(&["name"])
|
||||
.completion_cb("disk", complete_disk_name)
|
||||
.completion_cb("disk", complete_disk_name),
|
||||
);
|
||||
|
||||
cmd_def.into()
|
||||
}
|
||||
|
||||
pub fn disk_commands() -> CommandLineInterface {
|
||||
|
||||
let cmd_def = CliCommandMap::new()
|
||||
.insert("list", CliCommand::new(&API_METHOD_LIST_DISKS))
|
||||
.insert("smart-attributes",
|
||||
CliCommand::new(&API_METHOD_SMART_ATTRIBUTES)
|
||||
.insert(
|
||||
"smart-attributes",
|
||||
CliCommand::new(&API_METHOD_SMART_ATTRIBUTES)
|
||||
.arg_param(&["disk"])
|
||||
.completion_cb("disk", complete_disk_name)
|
||||
.completion_cb("disk", complete_disk_name),
|
||||
)
|
||||
.insert("fs", filesystem_commands())
|
||||
.insert("zpool", zpool_commands())
|
||||
.insert("initialize",
|
||||
CliCommand::new(&API_METHOD_INITIALIZE_DISK)
|
||||
.insert(
|
||||
"initialize",
|
||||
CliCommand::new(&API_METHOD_INITIALIZE_DISK)
|
||||
.arg_param(&["disk"])
|
||||
.completion_cb("disk", complete_disk_name)
|
||||
.completion_cb("disk", complete_disk_name),
|
||||
);
|
||||
|
||||
cmd_def.into()
|
||||
|
@ -18,7 +18,6 @@ use proxmox_backup::api2;
|
||||
)]
|
||||
/// Read DNS settings
|
||||
fn get_dns(mut param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
|
||||
|
||||
let output_format = get_output_format(¶m);
|
||||
|
||||
param["node"] = "localhost".into();
|
||||
@ -29,7 +28,6 @@ fn get_dns(mut param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, E
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
|
||||
let options = default_table_format_options()
|
||||
.column(ColumnConfig::new("search"))
|
||||
.column(ColumnConfig::new("dns1"))
|
||||
@ -42,16 +40,12 @@ fn get_dns(mut param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, E
|
||||
}
|
||||
|
||||
pub fn dns_commands() -> CommandLineInterface {
|
||||
|
||||
let cmd_def = CliCommandMap::new()
|
||||
.insert(
|
||||
"get",
|
||||
CliCommand::new(&API_METHOD_GET_DNS)
|
||||
)
|
||||
.insert("get", CliCommand::new(&API_METHOD_GET_DNS))
|
||||
.insert(
|
||||
"set",
|
||||
CliCommand::new(&api2::node::dns::API_METHOD_UPDATE_DNS)
|
||||
.fixed_param("node", String::from("localhost"))
|
||||
.fixed_param("node", String::from("localhost")),
|
||||
);
|
||||
|
||||
cmd_def.into()
|
||||
|
@ -18,7 +18,6 @@ use proxmox_backup::api2;
|
||||
)]
|
||||
/// Network device list.
|
||||
fn list_network_devices(mut param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
|
||||
|
||||
let output_format = get_output_format(¶m);
|
||||
|
||||
param["node"] = "localhost".into();
|
||||
@ -42,7 +41,9 @@ fn list_network_devices(mut param: Value, rpcenv: &mut dyn RpcEnvironment) -> Re
|
||||
text.push_str(cidr);
|
||||
}
|
||||
if let Some(cidr) = record["cidr6"].as_str() {
|
||||
if !text.is_empty() { text.push('\n'); }
|
||||
if !text.is_empty() {
|
||||
text.push('\n');
|
||||
}
|
||||
text.push_str(cidr);
|
||||
}
|
||||
|
||||
@ -71,7 +72,9 @@ fn list_network_devices(mut param: Value, rpcenv: &mut dyn RpcEnvironment) -> Re
|
||||
text.push_str(gateway);
|
||||
}
|
||||
if let Some(gateway) = record["gateway6"].as_str() {
|
||||
if !text.is_empty() { text.push('\n'); }
|
||||
if !text.is_empty() {
|
||||
text.push('\n');
|
||||
}
|
||||
text.push_str(gateway);
|
||||
}
|
||||
|
||||
@ -84,9 +87,21 @@ fn list_network_devices(mut param: Value, rpcenv: &mut dyn RpcEnvironment) -> Re
|
||||
.column(ColumnConfig::new("autostart"))
|
||||
.column(ColumnConfig::new("method"))
|
||||
.column(ColumnConfig::new("method6"))
|
||||
.column(ColumnConfig::new("cidr").header("address").renderer(render_address))
|
||||
.column(ColumnConfig::new("gateway").header("gateway").renderer(render_gateway))
|
||||
.column(ColumnConfig::new("bridge_ports").header("ports/slaves").renderer(render_ports));
|
||||
.column(
|
||||
ColumnConfig::new("cidr")
|
||||
.header("address")
|
||||
.renderer(render_address),
|
||||
)
|
||||
.column(
|
||||
ColumnConfig::new("gateway")
|
||||
.header("gateway")
|
||||
.renderer(render_gateway),
|
||||
)
|
||||
.column(
|
||||
ColumnConfig::new("bridge_ports")
|
||||
.header("ports/slaves")
|
||||
.renderer(render_ports),
|
||||
);
|
||||
|
||||
format_and_print_result_full(&mut data, &info.returns, &output_format, &options);
|
||||
|
||||
@ -95,7 +110,10 @@ fn list_network_devices(mut param: Value, rpcenv: &mut dyn RpcEnvironment) -> Re
|
||||
|
||||
#[api()]
|
||||
/// Show pending configuration changes (diff)
|
||||
fn pending_network_changes(mut param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
|
||||
fn pending_network_changes(
|
||||
mut param: Value,
|
||||
rpcenv: &mut dyn RpcEnvironment,
|
||||
) -> Result<Value, Error> {
|
||||
param["node"] = "localhost".into();
|
||||
|
||||
let info = &api2::node::network::API_METHOD_LIST_NETWORK_DEVICES;
|
||||
@ -112,15 +130,11 @@ fn pending_network_changes(mut param: Value, rpcenv: &mut dyn RpcEnvironment) ->
|
||||
}
|
||||
|
||||
pub fn network_commands() -> CommandLineInterface {
|
||||
|
||||
let cmd_def = CliCommandMap::new()
|
||||
.insert(
|
||||
"list",
|
||||
CliCommand::new(&API_METHOD_LIST_NETWORK_DEVICES)
|
||||
)
|
||||
.insert("list", CliCommand::new(&API_METHOD_LIST_NETWORK_DEVICES))
|
||||
.insert(
|
||||
"changes",
|
||||
CliCommand::new(&API_METHOD_PENDING_NETWORK_CHANGES)
|
||||
CliCommand::new(&API_METHOD_PENDING_NETWORK_CHANGES),
|
||||
)
|
||||
.insert(
|
||||
"create",
|
||||
@ -129,7 +143,7 @@ pub fn network_commands() -> CommandLineInterface {
|
||||
.arg_param(&["iface"])
|
||||
.completion_cb("iface", pbs_config::network::complete_interface_name)
|
||||
.completion_cb("bridge_ports", pbs_config::network::complete_port_list)
|
||||
.completion_cb("slaves", pbs_config::network::complete_port_list)
|
||||
.completion_cb("slaves", pbs_config::network::complete_port_list),
|
||||
)
|
||||
.insert(
|
||||
"update",
|
||||
@ -138,24 +152,24 @@ pub fn network_commands() -> CommandLineInterface {
|
||||
.arg_param(&["iface"])
|
||||
.completion_cb("iface", pbs_config::network::complete_interface_name)
|
||||
.completion_cb("bridge_ports", pbs_config::network::complete_port_list)
|
||||
.completion_cb("slaves", pbs_config::network::complete_port_list)
|
||||
.completion_cb("slaves", pbs_config::network::complete_port_list),
|
||||
)
|
||||
.insert(
|
||||
"remove",
|
||||
CliCommand::new(&api2::node::network::API_METHOD_DELETE_INTERFACE)
|
||||
.fixed_param("node", String::from("localhost"))
|
||||
.arg_param(&["iface"])
|
||||
.completion_cb("iface", pbs_config::network::complete_interface_name)
|
||||
.completion_cb("iface", pbs_config::network::complete_interface_name),
|
||||
)
|
||||
.insert(
|
||||
"revert",
|
||||
CliCommand::new(&api2::node::network::API_METHOD_REVERT_NETWORK_CONFIG)
|
||||
.fixed_param("node", String::from("localhost"))
|
||||
.fixed_param("node", String::from("localhost")),
|
||||
)
|
||||
.insert(
|
||||
"reload",
|
||||
CliCommand::new(&api2::node::network::API_METHOD_RELOAD_NETWORK_CONFIG)
|
||||
.fixed_param("node", String::from("localhost"))
|
||||
.fixed_param("node", String::from("localhost")),
|
||||
);
|
||||
|
||||
cmd_def.into()
|
||||
|
@ -18,7 +18,6 @@ use proxmox_backup::api2;
|
||||
)]
|
||||
/// Show node configuration
|
||||
fn get_node_config(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
|
||||
|
||||
let output_format = get_output_format(¶m);
|
||||
|
||||
let info = &api2::node::config::API_METHOD_GET_NODE_CONFIG;
|
||||
@ -35,14 +34,11 @@ fn get_node_config(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Valu
|
||||
|
||||
pub fn node_commands() -> CommandLineInterface {
|
||||
let cmd_def = CliCommandMap::new()
|
||||
.insert(
|
||||
"show",
|
||||
CliCommand::new(&API_METHOD_GET_NODE_CONFIG),
|
||||
)
|
||||
.insert("show", CliCommand::new(&API_METHOD_GET_NODE_CONFIG))
|
||||
.insert(
|
||||
"update",
|
||||
CliCommand::new(&api2::node::config::API_METHOD_UPDATE_NODE_CONFIG)
|
||||
.fixed_param("node", String::from("localhost"))
|
||||
.fixed_param("node", String::from("localhost")),
|
||||
);
|
||||
|
||||
cmd_def.into()
|
||||
|
@ -8,7 +8,6 @@ use pbs_api_types::REALM_ID_SCHEMA;
|
||||
|
||||
use proxmox_backup::api2;
|
||||
|
||||
|
||||
#[api(
|
||||
input: {
|
||||
properties: {
|
||||
@ -21,7 +20,6 @@ use proxmox_backup::api2;
|
||||
)]
|
||||
/// List configured OpenId realms
|
||||
fn list_openid_realms(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
|
||||
|
||||
let output_format = get_output_format(¶m);
|
||||
|
||||
let info = &api2::config::access::openid::API_METHOD_LIST_OPENID_REALMS;
|
||||
@ -55,7 +53,6 @@ fn list_openid_realms(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<V
|
||||
|
||||
/// Show OpenID realm configuration
|
||||
fn show_openid_realm(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
|
||||
|
||||
let output_format = get_output_format(¶m);
|
||||
|
||||
let info = &api2::config::access::openid::API_METHOD_READ_OPENID_REALM;
|
||||
@ -71,32 +68,35 @@ fn show_openid_realm(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Va
|
||||
}
|
||||
|
||||
pub fn openid_commands() -> CommandLineInterface {
|
||||
|
||||
let cmd_def = CliCommandMap::new()
|
||||
.insert("list", CliCommand::new(&API_METHOD_LIST_OPENID_REALMS))
|
||||
.insert("show", CliCommand::new(&API_METHOD_SHOW_OPENID_REALM)
|
||||
.insert(
|
||||
"show",
|
||||
CliCommand::new(&API_METHOD_SHOW_OPENID_REALM)
|
||||
.arg_param(&["realm"])
|
||||
.completion_cb("realm", pbs_config::domains::complete_openid_realm_name)
|
||||
.completion_cb("realm", pbs_config::domains::complete_openid_realm_name),
|
||||
)
|
||||
.insert("create",
|
||||
CliCommand::new(&api2::config::access::openid::API_METHOD_CREATE_OPENID_REALM)
|
||||
.insert(
|
||||
"create",
|
||||
CliCommand::new(&api2::config::access::openid::API_METHOD_CREATE_OPENID_REALM)
|
||||
.arg_param(&["realm"])
|
||||
.arg_param(&["realm"])
|
||||
.completion_cb("realm", pbs_config::domains::complete_openid_realm_name)
|
||||
.completion_cb("realm", pbs_config::domains::complete_openid_realm_name),
|
||||
)
|
||||
.insert("update",
|
||||
CliCommand::new(&api2::config::access::openid::API_METHOD_UPDATE_OPENID_REALM)
|
||||
.insert(
|
||||
"update",
|
||||
CliCommand::new(&api2::config::access::openid::API_METHOD_UPDATE_OPENID_REALM)
|
||||
.arg_param(&["realm"])
|
||||
.arg_param(&["realm"])
|
||||
.completion_cb("realm", pbs_config::domains::complete_openid_realm_name)
|
||||
.completion_cb("realm", pbs_config::domains::complete_openid_realm_name),
|
||||
)
|
||||
.insert("delete",
|
||||
CliCommand::new(&api2::config::access::openid::API_METHOD_DELETE_OPENID_REALM)
|
||||
.insert(
|
||||
"delete",
|
||||
CliCommand::new(&api2::config::access::openid::API_METHOD_DELETE_OPENID_REALM)
|
||||
.arg_param(&["realm"])
|
||||
.arg_param(&["realm"])
|
||||
.completion_cb("realm", pbs_config::domains::complete_openid_realm_name)
|
||||
)
|
||||
;
|
||||
.completion_cb("realm", pbs_config::domains::complete_openid_realm_name),
|
||||
);
|
||||
|
||||
cmd_def.into()
|
||||
cmd_def.into()
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ use pbs_api_types::REMOTE_ID_SCHEMA;
|
||||
|
||||
use proxmox_backup::api2;
|
||||
|
||||
|
||||
#[api(
|
||||
input: {
|
||||
properties: {
|
||||
@ -21,7 +20,6 @@ use proxmox_backup::api2;
|
||||
)]
|
||||
/// List configured remotes.
|
||||
fn list_remotes(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
|
||||
|
||||
let output_format = get_output_format(¶m);
|
||||
|
||||
let info = &api2::config::remote::API_METHOD_LIST_REMOTES;
|
||||
@ -57,7 +55,6 @@ fn list_remotes(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value,
|
||||
)]
|
||||
/// Show remote configuration
|
||||
fn show_remote(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
|
||||
|
||||
let output_format = get_output_format(¶m);
|
||||
|
||||
let info = &api2::config::remote::API_METHOD_READ_REMOTE;
|
||||
@ -73,32 +70,30 @@ fn show_remote(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, E
|
||||
}
|
||||
|
||||
pub fn remote_commands() -> CommandLineInterface {
|
||||
|
||||
let cmd_def = CliCommandMap::new()
|
||||
.insert("list", CliCommand::new(&API_METHOD_LIST_REMOTES))
|
||||
.insert(
|
||||
"show",
|
||||
CliCommand::new(&API_METHOD_SHOW_REMOTE)
|
||||
.arg_param(&["name"])
|
||||
.completion_cb("name", pbs_config::remote::complete_remote_name)
|
||||
.completion_cb("name", pbs_config::remote::complete_remote_name),
|
||||
)
|
||||
.insert(
|
||||
"create",
|
||||
// fixme: howto handle password parameter?
|
||||
CliCommand::new(&api2::config::remote::API_METHOD_CREATE_REMOTE)
|
||||
.arg_param(&["name"])
|
||||
CliCommand::new(&api2::config::remote::API_METHOD_CREATE_REMOTE).arg_param(&["name"]),
|
||||
)
|
||||
.insert(
|
||||
"update",
|
||||
CliCommand::new(&api2::config::remote::API_METHOD_UPDATE_REMOTE)
|
||||
.arg_param(&["name"])
|
||||
.completion_cb("name", pbs_config::remote::complete_remote_name)
|
||||
.completion_cb("name", pbs_config::remote::complete_remote_name),
|
||||
)
|
||||
.insert(
|
||||
"remove",
|
||||
CliCommand::new(&api2::config::remote::API_METHOD_DELETE_REMOTE)
|
||||
.arg_param(&["name"])
|
||||
.completion_cb("name", pbs_config::remote::complete_remote_name)
|
||||
.completion_cb("name", pbs_config::remote::complete_remote_name),
|
||||
);
|
||||
|
||||
cmd_def.into()
|
||||
|
@ -18,7 +18,6 @@ use proxmox_backup::api2;
|
||||
)]
|
||||
/// Read subscription info.
|
||||
fn get(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
|
||||
|
||||
let output_format = get_output_format(¶m);
|
||||
|
||||
let info = &api2::node::subscription::API_METHOD_GET_SUBSCRIPTION;
|
||||
@ -34,23 +33,24 @@ fn get(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
|
||||
}
|
||||
|
||||
pub fn subscription_commands() -> CommandLineInterface {
|
||||
|
||||
let cmd_def = CliCommandMap::new()
|
||||
.insert("get", CliCommand::new(&API_METHOD_GET))
|
||||
.insert("set",
|
||||
.insert(
|
||||
"set",
|
||||
CliCommand::new(&api2::node::subscription::API_METHOD_SET_SUBSCRIPTION)
|
||||
.fixed_param("node", "localhost".into())
|
||||
.arg_param(&["key"])
|
||||
.arg_param(&["key"]),
|
||||
)
|
||||
.insert("update",
|
||||
.insert(
|
||||
"update",
|
||||
CliCommand::new(&api2::node::subscription::API_METHOD_CHECK_SUBSCRIPTION)
|
||||
.fixed_param("node", "localhost".into())
|
||||
.fixed_param("node", "localhost".into()),
|
||||
)
|
||||
.insert("remove",
|
||||
.insert(
|
||||
"remove",
|
||||
CliCommand::new(&api2::node::subscription::API_METHOD_DELETE_SUBSCRIPTION)
|
||||
.fixed_param("node", "localhost".into())
|
||||
)
|
||||
;
|
||||
.fixed_param("node", "localhost".into()),
|
||||
);
|
||||
|
||||
cmd_def.into()
|
||||
}
|
||||
|
@ -10,10 +10,7 @@ use proxmox_backup::api2;
|
||||
|
||||
fn render_group_filter(value: &Value, _record: &Value) -> Result<String, Error> {
|
||||
if let Some(group_filters) = value.as_array() {
|
||||
let group_filters:Vec<&str> = group_filters
|
||||
.iter()
|
||||
.filter_map(Value::as_str)
|
||||
.collect();
|
||||
let group_filters: Vec<&str> = group_filters.iter().filter_map(Value::as_str).collect();
|
||||
Ok(group_filters.join(" OR "))
|
||||
} else {
|
||||
Ok(String::from("all"))
|
||||
@ -32,7 +29,6 @@ fn render_group_filter(value: &Value, _record: &Value) -> Result<String, Error>
|
||||
)]
|
||||
/// Sync job list.
|
||||
fn list_sync_jobs(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
|
||||
|
||||
let output_format = get_output_format(¶m);
|
||||
|
||||
let info = &api2::config::sync::API_METHOD_LIST_SYNC_JOBS;
|
||||
@ -71,7 +67,6 @@ fn list_sync_jobs(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value
|
||||
)]
|
||||
/// Show sync job configuration
|
||||
fn show_sync_job(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
|
||||
|
||||
let output_format = get_output_format(¶m);
|
||||
|
||||
let info = &api2::config::sync::API_METHOD_READ_SYNC_JOB;
|
||||
@ -93,37 +88,40 @@ fn show_sync_job(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value,
|
||||
}
|
||||
|
||||
pub fn sync_job_commands() -> CommandLineInterface {
|
||||
|
||||
let cmd_def = CliCommandMap::new()
|
||||
.insert("list", CliCommand::new(&API_METHOD_LIST_SYNC_JOBS))
|
||||
.insert("show",
|
||||
CliCommand::new(&API_METHOD_SHOW_SYNC_JOB)
|
||||
.insert(
|
||||
"show",
|
||||
CliCommand::new(&API_METHOD_SHOW_SYNC_JOB)
|
||||
.arg_param(&["id"])
|
||||
.completion_cb("id", pbs_config::sync::complete_sync_job_id)
|
||||
.completion_cb("id", pbs_config::sync::complete_sync_job_id),
|
||||
)
|
||||
.insert("create",
|
||||
CliCommand::new(&api2::config::sync::API_METHOD_CREATE_SYNC_JOB)
|
||||
.insert(
|
||||
"create",
|
||||
CliCommand::new(&api2::config::sync::API_METHOD_CREATE_SYNC_JOB)
|
||||
.arg_param(&["id"])
|
||||
.completion_cb("id", pbs_config::sync::complete_sync_job_id)
|
||||
.completion_cb("schedule", pbs_config::datastore::complete_calendar_event)
|
||||
.completion_cb("store", pbs_config::datastore::complete_datastore_name)
|
||||
.completion_cb("remote", pbs_config::remote::complete_remote_name)
|
||||
.completion_cb("remote-store", crate::complete_remote_datastore_name)
|
||||
.completion_cb("groups", crate::complete_remote_datastore_group_filter)
|
||||
.completion_cb("groups", crate::complete_remote_datastore_group_filter),
|
||||
)
|
||||
.insert("update",
|
||||
CliCommand::new(&api2::config::sync::API_METHOD_UPDATE_SYNC_JOB)
|
||||
.insert(
|
||||
"update",
|
||||
CliCommand::new(&api2::config::sync::API_METHOD_UPDATE_SYNC_JOB)
|
||||
.arg_param(&["id"])
|
||||
.completion_cb("id", pbs_config::sync::complete_sync_job_id)
|
||||
.completion_cb("schedule", pbs_config::datastore::complete_calendar_event)
|
||||
.completion_cb("store", pbs_config::datastore::complete_datastore_name)
|
||||
.completion_cb("remote-store", crate::complete_remote_datastore_name)
|
||||
.completion_cb("groups", crate::complete_remote_datastore_group_filter)
|
||||
.completion_cb("groups", crate::complete_remote_datastore_group_filter),
|
||||
)
|
||||
.insert("remove",
|
||||
CliCommand::new(&api2::config::sync::API_METHOD_DELETE_SYNC_JOB)
|
||||
.insert(
|
||||
"remove",
|
||||
CliCommand::new(&api2::config::sync::API_METHOD_DELETE_SYNC_JOB)
|
||||
.arg_param(&["id"])
|
||||
.completion_cb("id", pbs_config::sync::complete_sync_job_id)
|
||||
.completion_cb("id", pbs_config::sync::complete_sync_job_id),
|
||||
);
|
||||
|
||||
cmd_def.into()
|
||||
|
@ -10,7 +10,6 @@ use pbs_tools::format::render_bytes_human_readable;
|
||||
use proxmox_backup::api2;
|
||||
use proxmox_backup::client_helpers::connect_to_localhost;
|
||||
|
||||
|
||||
#[api(
|
||||
input: {
|
||||
properties: {
|
||||
@ -23,7 +22,6 @@ use proxmox_backup::client_helpers::connect_to_localhost;
|
||||
)]
|
||||
/// List configured traffic control rules.
|
||||
fn list_traffic_controls(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
|
||||
|
||||
let output_format = get_output_format(¶m);
|
||||
|
||||
let info = &api2::config::traffic_control::API_METHOD_LIST_TRAFFIC_CONTROLS;
|
||||
@ -62,7 +60,6 @@ fn list_traffic_controls(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Resul
|
||||
)]
|
||||
/// Show traffic control configuration
|
||||
fn show_traffic_control(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
|
||||
|
||||
let output_format = get_output_format(¶m);
|
||||
|
||||
let info = &api2::config::traffic_control::API_METHOD_READ_TRAFFIC_CONTROL;
|
||||
@ -89,7 +86,6 @@ fn show_traffic_control(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result
|
||||
)]
|
||||
/// Show current traffic for all rules.
|
||||
async fn show_current_traffic(param: Value) -> Result<Value, Error> {
|
||||
|
||||
let output_format = get_output_format(¶m);
|
||||
|
||||
let client = connect_to_localhost()?;
|
||||
@ -111,7 +107,6 @@ async fn show_current_traffic(param: Value) -> Result<Value, Error> {
|
||||
}
|
||||
|
||||
pub fn traffic_control_commands() -> CommandLineInterface {
|
||||
|
||||
let cmd_def = CliCommandMap::new()
|
||||
.insert("list", CliCommand::new(&API_METHOD_LIST_TRAFFIC_CONTROLS))
|
||||
.insert("traffic", CliCommand::new(&API_METHOD_SHOW_CURRENT_TRAFFIC))
|
||||
@ -119,24 +114,33 @@ pub fn traffic_control_commands() -> CommandLineInterface {
|
||||
"show",
|
||||
CliCommand::new(&API_METHOD_SHOW_TRAFFIC_CONTROL)
|
||||
.arg_param(&["name"])
|
||||
.completion_cb("name", pbs_config::traffic_control::complete_traffic_control_name)
|
||||
.completion_cb(
|
||||
"name",
|
||||
pbs_config::traffic_control::complete_traffic_control_name,
|
||||
),
|
||||
)
|
||||
.insert(
|
||||
"create",
|
||||
CliCommand::new(&api2::config::traffic_control::API_METHOD_CREATE_TRAFFIC_CONTROL)
|
||||
.arg_param(&["name"])
|
||||
.arg_param(&["name"]),
|
||||
)
|
||||
.insert(
|
||||
"update",
|
||||
CliCommand::new(&api2::config::traffic_control::API_METHOD_UPDATE_TRAFFIC_CONTROL)
|
||||
.arg_param(&["name"])
|
||||
.completion_cb("name", pbs_config::traffic_control::complete_traffic_control_name)
|
||||
.completion_cb(
|
||||
"name",
|
||||
pbs_config::traffic_control::complete_traffic_control_name,
|
||||
),
|
||||
)
|
||||
.insert(
|
||||
"remove",
|
||||
CliCommand::new(&api2::config::traffic_control::API_METHOD_DELETE_TRAFFIC_CONTROL)
|
||||
.arg_param(&["name"])
|
||||
.completion_cb("name", pbs_config::traffic_control::complete_traffic_control_name)
|
||||
.completion_cb(
|
||||
"name",
|
||||
pbs_config::traffic_control::complete_traffic_control_name,
|
||||
),
|
||||
);
|
||||
|
||||
cmd_def.into()
|
||||
|
@ -6,13 +6,15 @@ use std::collections::HashMap;
|
||||
use proxmox_router::{cli::*, ApiHandler, RpcEnvironment};
|
||||
use proxmox_schema::api;
|
||||
|
||||
use pbs_api_types::{ACL_PATH_SCHEMA, Authid, Userid};
|
||||
use pbs_api_types::{Authid, Userid, ACL_PATH_SCHEMA};
|
||||
|
||||
use proxmox_backup::api2;
|
||||
|
||||
fn render_expire(value: &Value, _record: &Value) -> Result<String, Error> {
|
||||
let never = String::from("never");
|
||||
if value.is_null() { return Ok(never); }
|
||||
if value.is_null() {
|
||||
return Ok(never);
|
||||
}
|
||||
let text = match value.as_i64() {
|
||||
Some(epoch) if epoch == 0 => never,
|
||||
Some(epoch) => {
|
||||
@ -21,7 +23,7 @@ fn render_expire(value: &Value, _record: &Value) -> Result<String, Error> {
|
||||
} else {
|
||||
epoch.to_string()
|
||||
}
|
||||
},
|
||||
}
|
||||
None => value.to_string(),
|
||||
};
|
||||
Ok(text)
|
||||
@ -39,7 +41,6 @@ fn render_expire(value: &Value, _record: &Value) -> Result<String, Error> {
|
||||
)]
|
||||
/// List configured users.
|
||||
fn list_users(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
|
||||
|
||||
let output_format = get_output_format(¶m);
|
||||
|
||||
let info = &api2::access::user::API_METHOD_LIST_USERS;
|
||||
@ -51,13 +52,9 @@ fn list_users(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Er
|
||||
let options = default_table_format_options()
|
||||
.column(ColumnConfig::new("userid"))
|
||||
.column(
|
||||
ColumnConfig::new("enable")
|
||||
.renderer(pbs_tools::format::render_bool_with_default_true)
|
||||
)
|
||||
.column(
|
||||
ColumnConfig::new("expire")
|
||||
.renderer(render_expire)
|
||||
ColumnConfig::new("enable").renderer(pbs_tools::format::render_bool_with_default_true),
|
||||
)
|
||||
.column(ColumnConfig::new("expire").renderer(render_expire))
|
||||
.column(ColumnConfig::new("firstname"))
|
||||
.column(ColumnConfig::new("lastname"))
|
||||
.column(ColumnConfig::new("email"))
|
||||
@ -83,7 +80,6 @@ fn list_users(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Er
|
||||
)]
|
||||
/// List tokens associated with user.
|
||||
fn list_tokens(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
|
||||
|
||||
let output_format = get_output_format(¶m);
|
||||
|
||||
let info = &api2::access::user::API_METHOD_LIST_TOKENS;
|
||||
@ -95,13 +91,9 @@ fn list_tokens(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, E
|
||||
let options = default_table_format_options()
|
||||
.column(ColumnConfig::new("tokenid"))
|
||||
.column(
|
||||
ColumnConfig::new("enable")
|
||||
.renderer(pbs_tools::format::render_bool_with_default_true)
|
||||
)
|
||||
.column(
|
||||
ColumnConfig::new("expire")
|
||||
.renderer(render_expire)
|
||||
ColumnConfig::new("enable").renderer(pbs_tools::format::render_bool_with_default_true),
|
||||
)
|
||||
.column(ColumnConfig::new("expire").renderer(render_expire))
|
||||
.column(ColumnConfig::new("comment"));
|
||||
|
||||
format_and_print_result_full(&mut data, &info.returns, &output_format, &options);
|
||||
@ -109,7 +101,6 @@ fn list_tokens(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, E
|
||||
Ok(Value::Null)
|
||||
}
|
||||
|
||||
|
||||
#[api(
|
||||
input: {
|
||||
properties: {
|
||||
@ -129,7 +120,6 @@ fn list_tokens(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, E
|
||||
)]
|
||||
/// List permissions of user/token.
|
||||
fn list_permissions(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
|
||||
|
||||
let output_format = get_output_format(¶m);
|
||||
|
||||
let info = &api2::access::API_METHOD_LIST_PERMISSIONS;
|
||||
@ -140,13 +130,13 @@ fn list_permissions(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Val
|
||||
|
||||
if output_format == "text" {
|
||||
println!("Privileges with (*) have the propagate flag set\n");
|
||||
let data:HashMap<String, HashMap<String, bool>> = serde_json::from_value(data)?;
|
||||
let mut paths:Vec<String> = data.keys().cloned().collect();
|
||||
let data: HashMap<String, HashMap<String, bool>> = serde_json::from_value(data)?;
|
||||
let mut paths: Vec<String> = data.keys().cloned().collect();
|
||||
paths.sort_unstable();
|
||||
for path in paths {
|
||||
println!("Path: {}", path);
|
||||
let priv_map = data.get(&path).unwrap();
|
||||
let mut privs:Vec<String> = priv_map.keys().cloned().collect();
|
||||
let mut privs: Vec<String> = priv_map.keys().cloned().collect();
|
||||
if privs.is_empty() {
|
||||
println!("- NoAccess");
|
||||
} else {
|
||||
@ -167,54 +157,51 @@ fn list_permissions(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Val
|
||||
Ok(Value::Null)
|
||||
}
|
||||
|
||||
|
||||
pub fn user_commands() -> CommandLineInterface {
|
||||
|
||||
let cmd_def = CliCommandMap::new()
|
||||
.insert("list", CliCommand::new(&API_METHOD_LIST_USERS))
|
||||
.insert(
|
||||
"create",
|
||||
// fixme: howto handle password parameter?
|
||||
CliCommand::new(&api2::access::user::API_METHOD_CREATE_USER)
|
||||
.arg_param(&["userid"])
|
||||
CliCommand::new(&api2::access::user::API_METHOD_CREATE_USER).arg_param(&["userid"]),
|
||||
)
|
||||
.insert(
|
||||
"update",
|
||||
CliCommand::new(&api2::access::user::API_METHOD_UPDATE_USER)
|
||||
.arg_param(&["userid"])
|
||||
.completion_cb("userid", pbs_config::user::complete_userid)
|
||||
.completion_cb("userid", pbs_config::user::complete_userid),
|
||||
)
|
||||
.insert(
|
||||
"remove",
|
||||
CliCommand::new(&api2::access::user::API_METHOD_DELETE_USER)
|
||||
.arg_param(&["userid"])
|
||||
.completion_cb("userid", pbs_config::user::complete_userid)
|
||||
.completion_cb("userid", pbs_config::user::complete_userid),
|
||||
)
|
||||
.insert(
|
||||
"list-tokens",
|
||||
CliCommand::new(&API_METHOD_LIST_TOKENS)
|
||||
.arg_param(&["userid"])
|
||||
.completion_cb("userid", pbs_config::user::complete_userid)
|
||||
.completion_cb("userid", pbs_config::user::complete_userid),
|
||||
)
|
||||
.insert(
|
||||
"generate-token",
|
||||
CliCommand::new(&api2::access::user::API_METHOD_GENERATE_TOKEN)
|
||||
.arg_param(&["userid", "token-name"])
|
||||
.completion_cb("userid", pbs_config::user::complete_userid)
|
||||
.completion_cb("userid", pbs_config::user::complete_userid),
|
||||
)
|
||||
.insert(
|
||||
"delete-token",
|
||||
CliCommand::new(&api2::access::user::API_METHOD_DELETE_TOKEN)
|
||||
.arg_param(&["userid", "token-name"])
|
||||
.completion_cb("userid", pbs_config::user::complete_userid)
|
||||
.completion_cb("token-name", pbs_config::user::complete_token_name)
|
||||
.completion_cb("token-name", pbs_config::user::complete_token_name),
|
||||
)
|
||||
.insert(
|
||||
"permissions",
|
||||
CliCommand::new(&API_METHOD_LIST_PERMISSIONS)
|
||||
.arg_param(&["auth-id"])
|
||||
.completion_cb("auth-id", pbs_config::user::complete_authid)
|
||||
.completion_cb("path", pbs_config::datastore::complete_acl_path)
|
||||
.completion_cb("path", pbs_config::datastore::complete_acl_path),
|
||||
);
|
||||
|
||||
cmd_def.into()
|
||||
|
@ -20,7 +20,6 @@ use proxmox_backup::api2;
|
||||
)]
|
||||
/// List all verification jobs
|
||||
fn list_verification_jobs(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
|
||||
|
||||
let output_format = get_output_format(¶m);
|
||||
|
||||
let info = &api2::config::verify::API_METHOD_LIST_VERIFICATION_JOBS;
|
||||
@ -57,7 +56,6 @@ fn list_verification_jobs(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Resu
|
||||
)]
|
||||
/// Show verification job configuration
|
||||
fn show_verification_job(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
|
||||
|
||||
let output_format = get_output_format(¶m);
|
||||
|
||||
let info = &api2::config::verify::API_METHOD_READ_VERIFICATION_JOB;
|
||||
@ -73,33 +71,36 @@ fn show_verification_job(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Resul
|
||||
}
|
||||
|
||||
pub fn verify_job_commands() -> CommandLineInterface {
|
||||
|
||||
let cmd_def = CliCommandMap::new()
|
||||
.insert("list", CliCommand::new(&API_METHOD_LIST_VERIFICATION_JOBS))
|
||||
.insert("show",
|
||||
CliCommand::new(&API_METHOD_SHOW_VERIFICATION_JOB)
|
||||
.insert(
|
||||
"show",
|
||||
CliCommand::new(&API_METHOD_SHOW_VERIFICATION_JOB)
|
||||
.arg_param(&["id"])
|
||||
.completion_cb("id", pbs_config::verify::complete_verification_job_id),
|
||||
)
|
||||
.insert(
|
||||
"create",
|
||||
CliCommand::new(&api2::config::verify::API_METHOD_CREATE_VERIFICATION_JOB)
|
||||
.arg_param(&["id"])
|
||||
.completion_cb("id", pbs_config::verify::complete_verification_job_id)
|
||||
.completion_cb("schedule", pbs_config::datastore::complete_calendar_event)
|
||||
.completion_cb("store", pbs_config::datastore::complete_datastore_name),
|
||||
)
|
||||
.insert("create",
|
||||
CliCommand::new(&api2::config::verify::API_METHOD_CREATE_VERIFICATION_JOB)
|
||||
.insert(
|
||||
"update",
|
||||
CliCommand::new(&api2::config::verify::API_METHOD_UPDATE_VERIFICATION_JOB)
|
||||
.arg_param(&["id"])
|
||||
.completion_cb("id", pbs_config::verify::complete_verification_job_id)
|
||||
.completion_cb("schedule", pbs_config::datastore::complete_calendar_event)
|
||||
.completion_cb("store", pbs_config::datastore::complete_datastore_name)
|
||||
.completion_cb("remote-store", crate::complete_remote_datastore_name),
|
||||
)
|
||||
.insert("update",
|
||||
CliCommand::new(&api2::config::verify::API_METHOD_UPDATE_VERIFICATION_JOB)
|
||||
.insert(
|
||||
"remove",
|
||||
CliCommand::new(&api2::config::verify::API_METHOD_DELETE_VERIFICATION_JOB)
|
||||
.arg_param(&["id"])
|
||||
.completion_cb("id", pbs_config::verify::complete_verification_job_id)
|
||||
.completion_cb("schedule", pbs_config::datastore::complete_calendar_event)
|
||||
.completion_cb("store", pbs_config::datastore::complete_datastore_name)
|
||||
.completion_cb("remote-store", crate::complete_remote_datastore_name)
|
||||
)
|
||||
.insert("remove",
|
||||
CliCommand::new(&api2::config::verify::API_METHOD_DELETE_VERIFICATION_JOB)
|
||||
.arg_param(&["id"])
|
||||
.completion_cb("id", pbs_config::verify::complete_verification_job_id)
|
||||
.completion_cb("id", pbs_config::verify::complete_verification_job_id),
|
||||
);
|
||||
|
||||
cmd_def.into()
|
||||
|
Loading…
Reference in New Issue
Block a user