Skip to content

Draft: Engine saves guest screenshot

Josep Maria Viñolas Auquer requested to merge vinolas/isardvdi:screenshots into main

When the guest is started (status Started) and changes its status to 'Screenshooting' the engine:

  1. takes an screenshot
  2. detects it's mimetype
  3. saves with correct extension
  4. converts it to jpg

The image is saved at /screenshots in isard-engine and isard-webapp containers and in /opt/isard-local/screenshots in the host.

The image filename is the domain id now.

TODO:

  • Move the screenshot to a launch thread? (it's commented in code). It does'nt seem to take so long, but as the image is raw it is 2-3MB that has to be downloaded through the ssh connection, thus collapsing it for some cents of milliseconds
  • Recreate at /opt/isard-local/screenshots the same folder structure as with qcows?
  • Rename the converted image with an incremental number, the next from the last number in the filenames existing for that domain? Another way could be to just take into account the file date when serving to frontends.
  • Add an endpoint to server those images to make it accessible from the new frontend, webapp, external plugins through api...
  • Allow to delete those images. We could use a minio bucket that has the option to automatically delete objects after some time (https://gitlab.com/isard/isard-sso/-/blob/master/admin/src/admin/lib/avatars.py)
  • Add custom info to the image like username, date taken from using the Pillow

Example adding text to an image using Pillow:

from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw 

img = Image.open("sample.jpg")
draw = ImageDraw.Draw(img)
font = ImageFont.truetype("sans-serif.ttf", 16)
draw.text((0, 0),"This is an IsardVDI screenshot",(255,255,255),font=font)
img.save('sample.jpg')

Merge request reports