Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
52 changes: 52 additions & 0 deletions nexus/src/app/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,58 @@ impl super::Nexus {
&"creating images from snapshots not supported",
));
}

params::ImageSource::YouCanBootAnythingAsLongAsItsAlpine => {
// Each Propolis zone ships with an alpine.iso (it's part of the
// package-manifest.toml blobs), and for development purposes
// allow users to boot that. This should go away when that blob
// does.
let db_block_size = db::model::BlockSize::Traditional;
let block_size: u64 = db_block_size.to_bytes() as u64;

let volume_construction_request = sled_agent_client::types::VolumeConstructionRequest::Volume {
block_size,
sub_volumes: vec![
sled_agent_client::types::VolumeConstructionRequest::File {
block_size,
path: "/opt/oxide/propolis-server/blob/alpine.iso".into(),
}
],
read_only_parent: None,
};

let volume_data =
serde_json::to_string(&volume_construction_request)?;

// Nexus runs in its own zone so we can't ask the propolis zone
// image tar file for size of alpine.iso. Conservatively set the
// size to 100M (at the time of this comment, it's 41M). Any
// disk created from this image has to be larger than it.
let size: u64 = 100 * 1024 * 1024;
let size: external::ByteCount =
size.try_into().map_err(|e| Error::InvalidValue {
label: String::from("size"),
message: format!("size is invalid: {}", e),
})?;

let new_image_volume =
db::model::Volume::new(Uuid::new_v4(), volume_data);
let volume =
self.db_datastore.volume_create(new_image_volume).await?;

db::model::GlobalImage {
identity: db::model::GlobalImageIdentity::new(
Uuid::new_v4(),
params.identity.clone(),
),
volume_id: volume.id(),
url: None,
version: None,
digest: None,
block_size: db_block_size,
size: size.into(),
}
}
};

self.db_datastore.global_image_create_image(opctx, new_image).await
Expand Down
4 changes: 4 additions & 0 deletions nexus/src/external_api/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,10 @@ pub struct NetworkInterfaceIdentifier {
pub enum ImageSource {
Url(String),
Snapshot(Uuid),

/// Boot the Alpine ISO that ships with the Propolis zone. Intended for
/// development purposes only.
YouCanBootAnythingAsLongAsItsAlpine,
}

/// Create-time parameters for an
Expand Down
15 changes: 15 additions & 0 deletions openapi/nexus.json
Original file line number Diff line number Diff line change
Expand Up @@ -6040,6 +6040,21 @@
"src",
"type"
]
},
{
"description": "Boot the Alpine ISO that ships with the Propolis zone. Intended for development purposes only.",
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"you_can_boot_anything_as_long_as_its_alpine"
]
}
},
"required": [
"type"
]
}
]
},
Expand Down