hivectl: rename hivectl agents to hivectl agent <name> <verb>
This commit is contained in:
parent
f48ba3ca0d
commit
03afbd1316
19 changed files with 367 additions and 525 deletions
|
|
@ -1,6 +1,7 @@
|
|||
//! `hivectl agents quota` — per-agent disk accounting + optional quotas via
|
||||
//! btrfs qgroups. The daemon holds the privileged helper that reads /
|
||||
//! sets qgroups; hivectl relays the request and formats the reply.
|
||||
//! `hivectl quota-enable` + `hivectl agent <name> quota` — per-agent disk
|
||||
//! accounting + optional quotas via btrfs qgroups. The daemon holds the
|
||||
//! privileged helper that reads / sets qgroups; hivectl relays the
|
||||
//! request and formats the reply.
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
|
|
@ -13,20 +14,20 @@ pub(crate) async fn quota_enable(socket: &Path) -> Result<()> {
|
|||
daemon_request(socket, hive_host_sock::HostRequest::QuotaEnable, "quota").await
|
||||
}
|
||||
|
||||
/// `quota show [name]` — report per-agent disk usage from btrfs qgroups.
|
||||
/// The daemon resolves the agent set + reads each subvolume's usage (it
|
||||
/// holds the privileged helper); the client just formats the returned rows.
|
||||
pub(crate) async fn quota_show(socket: &Path, name: Option<&str>) -> Result<()> {
|
||||
/// `agent <name> quota show` — report one agent's disk usage from btrfs
|
||||
/// qgroups. The daemon reads that subvolume's usage (it holds the
|
||||
/// privileged helper); the client just formats the returned row(s).
|
||||
pub(crate) async fn quota_show(socket: &Path, name: &str) -> Result<()> {
|
||||
let resp = crate::client::request(
|
||||
socket,
|
||||
hive_host_sock::HostRequest::QuotaShow {
|
||||
name: name.map(crate::util::parse_ident).transpose()?,
|
||||
name: Some(crate::util::parse_ident(name)?),
|
||||
},
|
||||
)
|
||||
.await
|
||||
.with_context(|| format!("connect to daemon socket {}", socket.display()))?;
|
||||
if !resp.ok {
|
||||
// Carries the "btrfs quota not enabled — run `hivectl agents quota enable`
|
||||
// Carries the "btrfs quota not enabled — run `hivectl quota-enable`
|
||||
// first" hint when qgroups are off.
|
||||
bail!("{}", resp.error.as_deref().unwrap_or("quota show failed"));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue