Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

67 changes: 11 additions & 56 deletions dev-tools/reconfigurator-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! developer REPL for driving blueprint planning

use anyhow::{Context, anyhow, bail};
use camino::{Utf8Path, Utf8PathBuf};
use camino::Utf8PathBuf;
use chrono::{DateTime, Utc};
use clap::{ArgAction, ValueEnum};
use clap::{Args, Parser, Subcommand};
Expand All @@ -20,7 +20,9 @@ use nexus_inventory::CollectionBuilder;
use nexus_reconfigurator_blippy::Blippy;
use nexus_reconfigurator_blippy::BlippyReportSortKey;
use nexus_reconfigurator_planning::blueprint_builder::BlueprintBuilder;
use nexus_reconfigurator_planning::example::ExampleSystemBuilder;
use nexus_reconfigurator_planning::example::{
ExampleSystemBuilder, extract_tuf_repo_description, tuf_assemble,
};
use nexus_reconfigurator_planning::planner::Planner;
use nexus_reconfigurator_planning::system::{
RotStateOverrides, SledBuilder, SledInventoryVisibility, SystemDescription,
Expand Down Expand Up @@ -48,8 +50,8 @@ use nexus_types::external_api::views::SledPolicy;
use nexus_types::external_api::views::SledProvisionPolicy;
use nexus_types::inventory::CollectionDisplayCliFilter;
use omicron_common::address::REPO_DEPOT_PORT;
use omicron_common::api::external::Generation;
use omicron_common::api::external::Name;
use omicron_common::api::external::{Generation, TufRepoDescription};
use omicron_common::disk::M2Slot;
use omicron_common::policy::NEXUS_REDUNDANCY;
use omicron_common::update::OmicronZoneManifestSource;
Expand All @@ -74,9 +76,6 @@ use tufaceous_artifact::ArtifactHash;
use tufaceous_artifact::ArtifactVersion;
use tufaceous_artifact::ArtifactVersionError;
use tufaceous_lib::assemble::ArtifactManifest;
use update_common::artifacts::{
ArtifactsWithPlan, ControlPlaneZonesMode, VerificationMode,
};

mod log_capture;

Expand Down Expand Up @@ -2752,32 +2751,6 @@ fn mupdate_source_to_description(
}
}

fn extract_tuf_repo_description(
log: &slog::Logger,
filename: &Utf8Path,
) -> anyhow::Result<TufRepoDescription> {
let file = std::fs::File::open(filename)
.with_context(|| format!("open {:?}", filename))?;
let buf = std::io::BufReader::new(file);
let rt =
tokio::runtime::Runtime::new().context("creating tokio runtime")?;
let repo_hash = ArtifactHash([0; 32]);
let artifacts_with_plan = rt.block_on(async {
ArtifactsWithPlan::from_zip(
buf,
None,
repo_hash,
ControlPlaneZonesMode::Split,
VerificationMode::BlindlyTrustAnything,
log,
)
.await
.with_context(|| format!("unpacking {:?}", filename))
})?;
let description = artifacts_with_plan.description().clone();
Ok(description)
}

fn cmd_tuf_assemble(
sim: &ReconfiguratorSim,
args: TufAssembleArgs,
Expand Down Expand Up @@ -2808,30 +2781,12 @@ fn cmd_tuf_assemble(
Utf8PathBuf::from(format!("repo-{}.zip", manifest.system_version))
};

if output_path.exists() {
bail!("output path `{output_path}` already exists");
}

// Just use a fixed key for now.
//
// In the future we may want to test changing the TUF key.
let mut tufaceous_args = vec![
"tufaceous",
"--key",
DEFAULT_TUFACEOUS_KEY,
"assemble",
manifest_path.as_str(),
output_path.as_str(),
];
if args.allow_non_semver {
tufaceous_args.push("--allow-non-semver");
}
let args = tufaceous::Args::try_parse_from(tufaceous_args)
.expect("args are valid so this shouldn't fail");
let rt =
tokio::runtime::Runtime::new().context("creating tokio runtime")?;
rt.block_on(async move { args.exec(&sim.log).await })
.context("error executing tufaceous assemble")?;
tuf_assemble(
&sim.log,
&manifest_path,
&output_path,
args.allow_non_semver,
)?;

let rv = format!(
"created {} for system version {}",
Expand Down
7 changes: 7 additions & 0 deletions nexus/reconfigurator/planning/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ workspace = true

[dependencies]
anyhow.workspace = true
camino.workspace = true
camino-tempfile.workspace = true
clap.workspace = true
clickhouse-admin-types.workspace = true
cockroach-admin-types.workspace = true
chrono.workspace = true
Expand Down Expand Up @@ -41,8 +44,12 @@ static_assertions.workspace = true
strum.workspace = true
swrite.workspace = true
thiserror.workspace = true
tokio.workspace = true
tufaceous.workspace = true
tufaceous-artifact.workspace = true
tufaceous-lib.workspace = true
typed-rng.workspace = true
update-common.workspace = true
uuid.workspace = true

omicron-workspace-hack.workspace = true
Expand Down
Loading
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.