[docs]classResolveVMImages(AbstractPlugin):""" Assign a default image to all :py:class:`VMEndpoints <base_objects.VMEndpoint>`. """default_images={"host":Ubuntu1604Server,"router":Helium118,"switch":Ubuntu1604Server,}
[docs]def_assign_default_images(self):""" For every :py:class:`VMEndpoint <base_objects.VMEndpoint>` in the experiment graph, assign an image if one hasn't been assigned already. If a type is not specified for an endpoint, use ``"host"``. Default images are specified based on the type property. """forvinself.g.get_vertices():ifv.is_decorated_by(VMEndpoint):v.vm["image_store"]={"path":self.image_store.cache,"name":self.image_store.store,}has_image=Falsetry:image_name=v.vm["image"]ifimage_name:has_image=TrueexceptAttributeError:self.log.debug('Assigning default image to VM "%s".',v.name)exceptKeyError:has_image=Falseifnothas_image:# Assign a default image.try:# Based on v.typev.decorate(self.default_images[v.type])exceptAttributeError:# We have no type. Just make a default host.# We already know this is a VMEndpoint.v.decorate(self.default_images["host"])exceptKeyError:# Unknown type.self.log.warning('Encountered unknown type for VM "%s". Cannot assign a default image.',v.name,)continue# We currently only handle minimega VMs.v.decorate(MinimegaEmulatedVM)
[docs]defrun(self):""" Create the :py:class:`ImageStore <firewheel.control.image_store.ImageStore>` and call :py:meth:`_assign_default_images` which performs the main plugin logic. """self.image_store=ImageStore()self._assign_default_images()