Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test coverage for seeding of additional guest properties into VMs at boot time #19

Merged
merged 1 commit into from
Oct 18, 2024
Merged
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
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
Loading