aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCara Salter <cara@devcara.com>2022-07-10 22:03:49 -0400
committerCara Salter <cara@devcara.com>2022-07-10 22:03:49 -0400
commit30766d2a0438134a54725c89d9d6ae03afc1d782 (patch)
treed58e3b7e7b74a65a87131e291d33d0f40c88b632
parent5429fcc0859c93da965e91e94e6676c2e6cdd24e (diff)
downloadsolarlib-30766d2a0438134a54725c89d9d6ae03afc1d782.tar.gz
solarlib-30766d2a0438134a54725c89d9d6ae03afc1d782.zip
star: Support an optional seed_base for new planets
Pass in any URL that can be appended with "/{meta,user}-data" and return valid cloud-init stuff
-rw-r--r--src/star.rs4
-rw-r--r--templates/vm.rs.xml12
2 files changed, 9 insertions, 7 deletions
diff --git a/src/star.rs b/src/star.rs
index 28caa21..46f5bff 100644
--- a/src/star.rs
+++ b/src/star.rs
@@ -124,7 +124,7 @@ impl Star {
/// If the installation image doesn't exist in the default libvirtd pool, this will fail with
/// [`Error::MissingImage`][crate::errors::Error::MissingImage].
///
- pub fn planet(&mut self, name: String, max_mem: Memory, max_cpus: CpuCount, disk_size_mb: u64, ship: Ship) -> Result<Planet, Error> {
+ pub fn planet(&mut self, name: String, max_mem: Memory, max_cpus: CpuCount, disk_size_mb: u64, ship: Ship, seed_base: Option<String>) -> Result<Planet, Error> {
// Check for image on host machine
if self.remote {
@@ -198,7 +198,7 @@ impl Star {
true,
max_mem.0,
max_cpus.0,
- "blank".to_string()
+ seed_base,
)?;
let buf = String::from_utf8(buf).unwrap();
diff --git a/templates/vm.rs.xml b/templates/vm.rs.xml
index daf66b2..5ba90cc 100644
--- a/templates/vm.rs.xml
+++ b/templates/vm.rs.xml
@@ -1,4 +1,4 @@
-@(name: String, uuid: String, mac_address: String, sata: bool, memory: u64, cpus: u64, seed: String)
+@(name: String, uuid: String, mac_address: String, sata: bool, memory: u64, cpus: u64, seed: Option<String>)
<domain type="kvm" xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
<name>@name</name>
<uuid>@uuid</uuid>
@@ -75,9 +75,11 @@
<backend model="random">/dev/urandom</backend>
</rng>
</devices>
- <qemu:commandline>
- <qemu:arg value="-smbios" />
- <qemu:arg value="type=1,serial=ds=nocloud-net;s=@seed" />
- </qemu:commandline>
+ @if let Some(s) = seed {
+ <qemu:commandline>
+ <qemu:arg value="-smbios" />
+ <qemu:arg value="type=1,serial=ds=nocloud-net;s=@s/@uuid/"/>
+ </qemu:commandline>
+ }
</domain>