add autoinstall config to choose shutdown mode

This commit is contained in:
Michael Hudson-Doyle 2021-08-19 14:52:34 +12:00
parent 7f1beb1d64
commit a9d7e46b5f
2 changed files with 18 additions and 0 deletions

View File

@ -721,6 +721,13 @@
"type": "string"
}
}
},
"shutdown": {
"type": "string",
"enum": [
"reboot",
"poweroff"
]
}
},
"required": [

View File

@ -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()