This is not a installation mode but rather tells us where to fetch the
answer file from.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
answer::FilterMatch,
sysinfo::SysInfo,
utils::{
answer::FilterMatch,
sysinfo::SysInfo,
utils::{
- get_matched_udev_indexes, get_nic_list, get_single_udev_index, AutoInstMode,
+ get_matched_udev_indexes, get_nic_list, get_single_udev_index, FetchAnswerFrom,
AutoInstSettings, HttpOptions,
},
};
AutoInstSettings, HttpOptions,
},
};
/// Where the automatic installer should fetch the answer file from.
#[arg(long, value_enum)]
/// Where the automatic installer should fetch the answer file from.
#[arg(long, value_enum)]
- fetch_from: AutoInstMode,
+ fetch_from: FetchAnswerFrom,
/// Include the specified answer file in the ISO. Requires the '--fetch-from' parameter
/// to be set to 'iso'.
/// Include the specified answer file in the ISO. Requires the '--fetch-from' parameter
/// to be set to 'iso'.
fn prepare_iso(args: &CommandPrepareISO) -> Result<()> {
check_prepare_requirements(args)?;
fn prepare_iso(args: &CommandPrepareISO) -> Result<()> {
check_prepare_requirements(args)?;
- if args.fetch_from == AutoInstMode::Included {
+ if args.fetch_from == FetchAnswerFrom::Iso {
if args.answer_file.is_none() {
bail!("Missing path to answer file needed for 'direct' install mode.");
}
if args.answer_file.is_none() {
bail!("Missing path to answer file needed for 'direct' install mode.");
}
if args.url.is_some() {
bail!("No URL needed for direct install mode. Drop the parameter!");
}
if args.url.is_some() {
bail!("No URL needed for direct install mode. Drop the parameter!");
}
- } else if args.fetch_from == AutoInstMode::Partition {
+ } else if args.fetch_from == FetchAnswerFrom::Partition {
if args.cert_fingerprint.is_some() {
bail!(
"No certificate fingerprint needed for partition install mode. Drop the parameter!"
if args.cert_fingerprint.is_some() {
bail!(
"No certificate fingerprint needed for partition install mode. Drop the parameter!"
bail!("No URL needed for partition install mode. Drop the parameter!");
}
}
bail!("No URL needed for partition install mode. Drop the parameter!");
}
}
- if args.answer_file.is_some() && args.fetch_from != AutoInstMode::Included {
+ if args.answer_file.is_some() && args.fetch_from != FetchAnswerFrom::Iso {
bail!("Set '-i', '--install-mode' to 'included' to place the answer file directly in the ISO.");
}
bail!("Set '-i', '--install-mode' to 'included' to place the answer file directly in the ISO.");
}
return specified;
}
let mut suffix: String = match args.fetch_from {
return specified;
}
let mut suffix: String = match args.fetch_from {
- AutoInstMode::Http => "auto-from-http",
- AutoInstMode::Included => "auto-from-iso",
- AutoInstMode::Partition => "auto-from-partition",
+ FetchAnswerFrom::Http => "auto-from-http",
+ FetchAnswerFrom::Iso => "auto-from-iso",
+ FetchAnswerFrom::Partition => "auto-from-partition",
#[derive(Deserialize, Serialize, Debug, Clone, ValueEnum, PartialEq)]
#[serde(rename_all = "lowercase", deny_unknown_fields)]
#[derive(Deserialize, Serialize, Debug, Clone, ValueEnum, PartialEq)]
#[serde(rename_all = "lowercase", deny_unknown_fields)]
-pub enum AutoInstMode {
- Included,
+pub enum FetchAnswerFrom {
+ Iso,
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "lowercase", deny_unknown_fields)]
pub struct AutoInstSettings {
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "lowercase", deny_unknown_fields)]
pub struct AutoInstSettings {
- pub mode: AutoInstMode,
+ pub mode: FetchAnswerFrom,
#[serde(default)]
pub http: HttpOptions,
}
#[serde(default)]
pub http: HttpOptions,
}
use proxmox_auto_installer::{
log::AutoInstLogger,
use proxmox_auto_installer::{
log::AutoInstLogger,
- utils::{AutoInstMode, AutoInstSettings},
+ utils::{FetchAnswerFrom, AutoInstSettings},
};
use fetch_plugins::{http::FetchFromHTTP, partition::FetchFromPartition};
};
use fetch_plugins::{http::FetchFromHTTP, partition::FetchFromPartition};
fn fetch_answer(install_settings: &AutoInstSettings) -> Result<String> {
info!("Fetching answer file in mode {:?}:", &install_settings.mode);
match install_settings.mode {
fn fetch_answer(install_settings: &AutoInstSettings) -> Result<String> {
info!("Fetching answer file in mode {:?}:", &install_settings.mode);
match install_settings.mode {
- AutoInstMode::Included => {
+ FetchAnswerFrom::Iso => {
let answer_path = PathBuf::from("/cdrom/answer.toml");
match fs::read_to_string(answer_path) {
Ok(answer) => return Ok(answer),
Err(err) => info!("Fetching answer file from ISO failed: {err}"),
}
}
let answer_path = PathBuf::from("/cdrom/answer.toml");
match fs::read_to_string(answer_path) {
Ok(answer) => return Ok(answer),
Err(err) => info!("Fetching answer file from ISO failed: {err}"),
}
}
- AutoInstMode::Partition => match FetchFromPartition::get_answer() {
+ FetchAnswerFrom::Partition => match FetchFromPartition::get_answer() {
Ok(answer) => return Ok(answer),
Err(err) => info!("Fetching answer file from partition failed: {err}"),
},
Ok(answer) => return Ok(answer),
Err(err) => info!("Fetching answer file from partition failed: {err}"),
},
- AutoInstMode::Http => match FetchFromHTTP::get_answer(&install_settings.http) {
+ FetchAnswerFrom::Http => match FetchFromHTTP::get_answer(&install_settings.http) {
Ok(answer) => return Ok(answer),
Err(err) => info!("Fetching answer file via HTTP failed: {err}"),
},
Ok(answer) => return Ok(answer),
Err(err) => info!("Fetching answer file via HTTP failed: {err}"),
},