Skip to content

Commit

Permalink
Merge pull request #19 from flyingcircusio/PL-131857-guest-properties…
Browse files Browse the repository at this point in the history
…-test-coverage

Test coverage for seeding of additional guest properties into VMs at boot time
  • Loading branch information
ctheune authored Oct 18, 2024
2 parents 25d44d2 + 417562a commit 9c382fb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/fc/qemu/hazmat/volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,16 +424,18 @@ def seed(self, enc, generation):
# the ENC data, a separate file allows properties which
# are not exposed to guests through ENC to be added in the
# future.
properties = {}
properties["binary_generation"] = generation
for key in self.ENC_SEED_PARAMETERS:
if key in enc["parameters"]:
properties[key] = enc["parameters"][key]
self.log.debug("guest-properties", properties=properties)
guest_properties = p.join(fc_data, "qemu-guest-properties-booted")
with open(guest_properties, "w") as f:
props = {}
props["binary_generation"] = generation
for key in self.ENC_SEED_PARAMETERS:
if key in enc["parameters"]:
props[key] = enc["parameters"][key]
json.dump(props, f)
json.dump(properties, f)
# For backwards compatibility with old fc-agent versions,
# write the Qemu binary generation into a separate file.
self.log.debug("binary-generation", generation=generation)
generation_marker = p.join(fc_data, "qemu-binary-generation-booted")
with open(generation_marker, "w") as f:
f.write(str(generation) + "\n")
2 changes: 2 additions & 0 deletions src/fc/qemu/tests/vm_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ def test_simple_vm_lifecycle_start_stop(vm, patterns):
seed machine=simplevm subsystem=ceph volume=rbd.ssd/simplevm.tmp
mount args="/dev/rbd/rbd.ssd/simplevm.tmp-part1" "/mnt/rbd/rbd.ssd/simplevm.tmp" machine=simplevm subsystem=ceph volume=rbd.ssd/simplevm.tmp
mount machine=simplevm returncode=0 subsystem=ceph volume=rbd.ssd/simplevm.tmp
guest-properties machine=simplevm properties={'binary_generation': 2, 'rbd_pool': 'rbd.ssd'} subsystem=ceph volume=rbd.ssd/simplevm.tmp
binary-generation generation=2 machine=simplevm subsystem=ceph volume=rbd.ssd/simplevm.tmp
umount args="/mnt/rbd/rbd.ssd/simplevm.tmp" machine=simplevm subsystem=ceph volume=rbd.ssd/simplevm.tmp
umount machine=simplevm returncode=0 subsystem=ceph volume=rbd.ssd/simplevm.tmp
rbd args=-c "/etc/ceph/ceph.conf" --id "host1" unmap "/dev/rbd/rbd.ssd/simplevm.tmp" machine=simplevm subsystem=ceph volume=rbd.ssd/simplevm.tmp
Expand Down

0 comments on commit 9c382fb

Please sign in to comment.