SAHARA IMAGE GENERATION
IN N AND O
ELISE GAFFORD
OCTOBER 28, 2016
SESSION OVERVIEW
PART I: WHAT ARE YOU TALKING ABOUT
Or, In Which Elise Talks Smack About DIB
WHERE WE WERE
Sahara had 2 flows that were relevant to image manipulation:
WHY WHERE WE WERE WAS KINDA BAD
OUR DREAM IMPLEMENTATION
THE PLAN
PART II: WHAT EXISTS TODAY
Or, In Which We Lament that the Universe Does Not in Fact Contain More Time and then Talk About Image Gen Forever
WHERE WE ARE AS OF N
WAIT WE HAVE THIS ALREADY?
ELISE YOU WRITE TOO MUCH AND IT’S FRIDAY AFTERNOON AT SUMMIT JUST TELL US ABOUT IT
YAMLS ARE OUR FRIENDS
A NEW PLUGIN SPI METHOD
def get_image_arguments(self, hadoop_version):
Gets the argument set taken by the plugin's image generator.
Note: If the plugin can generate or validate an image but takes no arguments, please return an empty sequence rather than NotImplemented for all versions that support image generation or validation. This is used as a flag to determine whether the plugin has implemented this optional feature.
:returns: A sequence with items of type sahara.plugins.images.ImageArgument
class ImageArgument(object):
An argument used by an image specification.
def __init__(self, name, description=None, default=None, required=False, choices=None):
ANOTHER NEW PLUGIN SPI METHOD
def pack_image(self, hadoop_version, remote, reconcile=True, image_arguments=None):
Packs an image for registration in Glance and use by Sahara
:param remote: A remote (usually of type sahara.cli.image_pack.api.ImageRemote) that serves as a handle to the image to modify. Note that this image will be modified in-place, not copied.
:param reconcile: If set to False, this method will only test to ensure that the image already meets the plugin's requirements. This can be used to test images without modification. If set to True per the default, this method will modify the image if any requirements are not met.
:param image_arguments: A dict of image argument name to argument value.
LAST NEW PLUGIN SPI METHOD YOU GUYS
def validate_images(self, cluster, reconcile=True, image_arguments=None):
Validates the image to be used by a cluster.
:param cluster: The object handle to a cluster which has active instances ready to generate remote handles.
:param reconcile: If set to False, this method will only test to ensure that the image already meets the plugin's requirements. This can be used to test images without modification. If set to True per the default, this method will modify the image if any requirements are not met.
:param image_arguments: A dict of image argument name to argument value.
GREAT THAT’S THE SPI HOW DOES IT WORK
def from_yaml(cls, yaml_path, validator_map=None, resource_roots=None):
"""Constructs and returns a validator from the provided yaml file.
:param yaml_path: The relative path to a yaml file.
:param validator_map: A map of validator name to class.
:param resource_roots: The roots from which relative paths to resources (scripts and such) will be referenced. Any resource will be pulled from the first path in the list at which a file exists.
:return A SaharaImageValidator built to the yaml specification.
WAIT WHAT’S A SAHARAIMAGEVALIDATORBASE
GREAT MY PLUGIN HAS A VALIDATOR WHAT NOW
def validate(self, remote, reconcile=True, **kwargs):
Validates the image.
:param remote: A remote socket to the instance.
:param reconcile: If false, all validators will only verify that a desired state is present, and fail if it is not. If true, all validators will attempt to enforce the desired state if possible, and succeed if this enforcement succeeds.
:raises ImageValidationError: If validation fails.
I’M EXCITED AND I WANT TO WRITE A NEW VALIDATOR RIGHT NOW
WE’RE JUST HERE TO SEE THE NEW CLI
Command structure:
sahara-image-pack --image ./image.qcow2 [--test-only] PLUGIN VERSION [plugin arguments]
Features:
Note: In dev, use the “images” tox env and install python-libguestfs and libguestfs-tools on your machine: python-libguestfs isn’t pip installable
DEMO TIME
PART III: WHAT’S NEXT
Or, haaalp plz kthxbye
HEY THAT EARLIER SLIDE SEEMS RELEVANT
WHAT I’D LOVE
ANY QUESTIONS?
Or volunteers?
THANK YOU
Let’s Do This Thing
- ELISE GAFFORD