[docs]classPlugin(AbstractPlugin):"""ACME plugin to set hostnames for all VMs"""
[docs]defrun(self):""" Find all Ubuntu servers and try to assign a new hostname to them using our custom VM resource. """forvminself.g.get_vertices():ifvm.is_decorated_by(Ubuntu2204Server):try:hostname=vm.name.replace("building","b",1).replace("host","ubuntu",1)exceptAttributeError:print(f"Found VM without a name: {vm}")continuevm.run_executable(-40,"set_hostname.py",hostname,vm_resource=True)