diff --git a/autoinstall-schema.json b/autoinstall-schema.json index 1e78394d..1503dcb2 100644 --- a/autoinstall-schema.json +++ b/autoinstall-schema.json @@ -721,6 +721,13 @@ "type": "string" } } + }, + "shutdown": { + "type": "string", + "enum": [ + "reboot", + "poweroff" + ] } }, "required": [ diff --git a/subiquity/server/controllers/shutdown.py b/subiquity/server/controllers/shutdown.py index bf74f4cb..e82732b1 100644 --- a/subiquity/server/controllers/shutdown.py +++ b/subiquity/server/controllers/shutdown.py @@ -33,6 +33,11 @@ log = logging.getLogger("subiquity.controllers.restart") class ShutdownController(SubiquityController): endpoint = API.shutdown + autoinstall_key = 'shutdown' + autoinstall_schema = { + 'type': 'string', + 'enum': ['reboot', 'poweroff'] + } def __init__(self, app): super().__init__(app) @@ -46,6 +51,12 @@ class ShutdownController(SubiquityController): self.shuttingdown_event = asyncio.Event() self.mode = ShutdownMode.REBOOT + def load_autoinstall_data(self, data): + if data == 'reboot': + self.mode = ShutdownMode.REBOOT + elif data == 'poweroff': + self.mode = ShutdownMode.POWEROFF + async def POST(self, mode: ShutdownMode, immediate: bool = False): self.mode = mode self.app.controllers.Install.stop_uu()