mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
rust/pvapconfig: Add --unbind option
When the --unbind option is enabled, run with an empty config instead, effectively unbinding all APQNs. Reviewed-by: Harald Freudenberger <freude@linux.ibm.com> Acked-by: Steffen Eiden <seiden@linux.ibm.com> Signed-off-by: Jakob Naucke <naucke@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
committed by
Jan Höppner
parent
b4cc30ac10
commit
76bddf9715
@@ -91,6 +91,9 @@ All AP config entries need to be satisfied to have pvapconfig
|
||||
terminate with success. Without this option one applied AP config
|
||||
entry is enough to meet the expectations.
|
||||
.TP 8
|
||||
.B \-\-unbind
|
||||
Unbind all available APQNs.
|
||||
.TP 8
|
||||
.B \-v, \-\-verbose
|
||||
Print out informational messages about what pvapconfig is actually
|
||||
doing.
|
||||
|
||||
@@ -29,6 +29,10 @@ pub struct Cli {
|
||||
#[arg(long = "strict")]
|
||||
pub strict: bool,
|
||||
|
||||
/// Unbind all available APQNs.
|
||||
#[arg(long, conflicts_with_all = ["config", "strict"])]
|
||||
pub unbind: bool,
|
||||
|
||||
/// Provide more detailed output.
|
||||
#[arg(short, long)]
|
||||
pub verbose: bool,
|
||||
|
||||
@@ -150,6 +150,7 @@ impl ApConfigEntry {
|
||||
}
|
||||
|
||||
/// Wrapper object around Vector of ApConfigEntry
|
||||
#[derive(Default)]
|
||||
pub struct ApConfigList(Vec<ApConfigEntry>);
|
||||
|
||||
impl ApConfigList {
|
||||
|
||||
@@ -86,42 +86,48 @@ fn main() -> ExitCode {
|
||||
on_error_print_and_exit!(r);
|
||||
info!("UV support and environment is ok.\n");
|
||||
|
||||
// read configuration
|
||||
let configfile: &str = match &cli::ARGS.config {
|
||||
Some(f) => f,
|
||||
_ => cli::PATH_DEFAULT_CONFIG_FILE,
|
||||
};
|
||||
info!(
|
||||
"Reading AP configuration entries from file '{}'...\n",
|
||||
configfile
|
||||
);
|
||||
let apconfig: ApConfigList = match ApConfigList::read_and_validate_yaml_file(configfile) {
|
||||
Ok(apcfg) => apcfg,
|
||||
Err(err) => println_and_exit_failure!("{}", err),
|
||||
};
|
||||
if apconfig.is_empty() {
|
||||
println!(
|
||||
"No AP configuration entries in config file '{}': Nothing to do.",
|
||||
let mut apconfig: ApConfigList = Default::default();
|
||||
if !cli::ARGS.unbind {
|
||||
// read configuration
|
||||
let configfile: &str = match &cli::ARGS.config {
|
||||
Some(f) => f,
|
||||
_ => cli::PATH_DEFAULT_CONFIG_FILE,
|
||||
};
|
||||
info!(
|
||||
"Reading AP configuration entries from file '{}'...\n",
|
||||
configfile
|
||||
);
|
||||
return ExitCode::SUCCESS;
|
||||
}
|
||||
info!("Found {} AP configuration entries.\n", apconfig.len());
|
||||
apconfig = match ApConfigList::read_and_validate_yaml_file(configfile) {
|
||||
Ok(apcfg) => apcfg,
|
||||
Err(err) => println_and_exit_failure!("{}", err),
|
||||
};
|
||||
if apconfig.is_empty() {
|
||||
println!(
|
||||
"No AP configuration entries in config file '{}': Nothing to do.",
|
||||
configfile
|
||||
);
|
||||
return ExitCode::SUCCESS;
|
||||
}
|
||||
info!("Found {} AP configuration entries.\n", apconfig.len());
|
||||
};
|
||||
|
||||
// get list of secrets from UV
|
||||
info!("Fetching list of secrets from UV...\n");
|
||||
let secrets: SecretList = match uv::gather_secrets() {
|
||||
Err(e) => println_and_exit_failure!("{}", e),
|
||||
Ok(los) => los,
|
||||
};
|
||||
info!("Fetched {} Secret entries from UV.\n", secrets.len());
|
||||
let mut secrets = SecretList::new(0, Vec::new());
|
||||
if !cli::ARGS.unbind {
|
||||
info!("Fetching list of secrets from UV...\n");
|
||||
secrets = match uv::gather_secrets() {
|
||||
Err(e) => println_and_exit_failure!("{}", e),
|
||||
Ok(los) => los,
|
||||
};
|
||||
info!("Fetched {} Secret entries from UV.\n", secrets.len());
|
||||
}
|
||||
|
||||
// Warning if no UV secrets given but AP config entries require it
|
||||
let non_accel_apc = apconfig
|
||||
.iter()
|
||||
.filter(|apc| apc.mode != config::STR_MODE_ACCEL)
|
||||
.count();
|
||||
if non_accel_apc > 0 && secrets.is_empty() {
|
||||
if !cli::ARGS.unbind && non_accel_apc > 0 && secrets.is_empty() {
|
||||
println!(
|
||||
"Warning: No UV Secrets given but at least one AP config entry requires a Secret."
|
||||
);
|
||||
@@ -153,7 +159,7 @@ fn main() -> ExitCode {
|
||||
Ok(n) => n,
|
||||
};
|
||||
|
||||
if n == 0 {
|
||||
if !cli::ARGS.unbind && n == 0 {
|
||||
println_and_exit_failure!(
|
||||
"None out of {} AP config entries could be applied.",
|
||||
apconfig.len()
|
||||
@@ -166,11 +172,13 @@ fn main() -> ExitCode {
|
||||
);
|
||||
}
|
||||
|
||||
info!(
|
||||
"Successfully applied {} out of {} AP config entries.\n",
|
||||
n,
|
||||
apconfig.len()
|
||||
);
|
||||
if !cli::ARGS.unbind {
|
||||
info!(
|
||||
"Successfully applied {} out of {} AP config entries.\n",
|
||||
n,
|
||||
apconfig.len()
|
||||
);
|
||||
}
|
||||
|
||||
ExitCode::SUCCESS
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user