-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
providers: add experimental initrd network bootstrap
This adds initial/experimental support for bootstrapping the network in the initrd. It is meant to support weird cloud providers where DHCP is not available or not usable. This feature is currently reachable as a dedicated `exp rd-net-bootstrap` subcommand. The first provider where this logic is required is `ibmcloud-classic`.
- Loading branch information
Showing
7 changed files
with
203 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[Unit] | ||
Description=Afterburn network bootstrapping | ||
# IBM Cloud (Classic) has no DHCP. | ||
ConditionKernelCommandLine=|ignition.platform.id=ibmcloud-classic | ||
|
||
Before=ignition-fetch.service | ||
|
||
OnFailure=emergency.target | ||
OnFailureJobMode=isolate | ||
|
||
[Service] | ||
ExecStart=/usr/bin/afterburn exp rd-net-bootstrap --cmdline | ||
Type=oneshot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
//! `exp` CLI sub-command. | ||
use crate::errors::*; | ||
use crate::metadata; | ||
use clap::ArgMatches; | ||
use error_chain::bail; | ||
|
||
#[derive(Debug)] | ||
pub enum CliExp { | ||
NetBootstrap(CliNetBootstrap), | ||
} | ||
|
||
impl CliExp { | ||
/// Parse sub-command into configuration. | ||
pub(crate) fn parse(app_matches: &ArgMatches) -> Result<super::CliConfig> { | ||
if app_matches.subcommand_name().is_none() { | ||
bail!("missing exp subcommand"); | ||
} | ||
|
||
let cfg = match app_matches.subcommand() { | ||
("rd-net-bootstrap", Some(matches)) => CliNetBootstrap::parse(matches)?, | ||
(x, _) => unreachable!("unrecognized exp subcommand '{}'", x), | ||
}; | ||
|
||
Ok(super::CliConfig::Exp(cfg)) | ||
} | ||
|
||
// Run sub-command. | ||
pub(crate) fn run(&self) -> Result<()> { | ||
match self { | ||
CliExp::NetBootstrap(cmd) => cmd.run()?, | ||
}; | ||
Ok(()) | ||
} | ||
} | ||
|
||
/// Sub-command for network bootstrap. | ||
#[derive(Debug)] | ||
pub struct CliNetBootstrap { | ||
platform: String, | ||
} | ||
|
||
impl CliNetBootstrap { | ||
/// Parse sub-command into configuration. | ||
pub(crate) fn parse(matches: &ArgMatches) -> Result<CliExp> { | ||
let platform = super::parse_provider(matches)?; | ||
|
||
let cfg = Self { platform }; | ||
Ok(CliExp::NetBootstrap(cfg)) | ||
} | ||
|
||
/// Run the sub-command. | ||
pub(crate) fn run(&self) -> Result<()> { | ||
let provider = metadata::fetch_metadata(&self.platform)?; | ||
provider.rd_net_bootstrap()?; | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters