From b74ccb8d5d0fb19608455209890c71507b57e695 Mon Sep 17 00:00:00 2001 From: Carlos Nihelton Date: Thu, 23 Feb 2023 22:28:10 -0300 Subject: [PATCH] Implements autoinstall for AD --- autoinstall-schema.json | 12 +++++++++ subiquity/server/controllers/ad.py | 42 +++++++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/autoinstall-schema.json b/autoinstall-schema.json index 3781d033..a8926023 100644 --- a/autoinstall-schema.json +++ b/autoinstall-schema.json @@ -461,6 +461,18 @@ "additionalProperties": false } }, + "ad": { + "type": "object", + "properties": { + "admin_name": { + "type": "string" + }, + "domain_name": { + "type": "string" + } + }, + "additionalProperties": false + }, "codecs": { "type": "object", "properties": { diff --git a/subiquity/server/controllers/ad.py b/subiquity/server/controllers/ad.py index 605c825f..13eb7fbb 100644 --- a/subiquity/server/controllers/ad.py +++ b/subiquity/server/controllers/ad.py @@ -91,9 +91,49 @@ class StubDcPingStrategy(DcPingStrategy): class ADController(SubiquityController): """ Implements the server part of the Active Directory feature. """ - model_name = "ad" endpoint = API.active_directory # No auto install key and schema for now due password handling uncertainty. + autoinstall_key = model_name = "ad" + autoinstall_schema = { + 'type': 'object', + 'properties': { + 'admin_name': { + 'type': 'string', + }, + 'domain_name': { + 'type': 'string', + }, + }, + 'additionalProperties': False, + } + autoinstall_default = {"admin_name": '', 'domain_name': ''} + + def serialize(self): + info = self.model.conn_info + if info is None: + return None + + return {'admin_name': info.admin_name, 'domain_name': info.domain_name} + + def deserialize(self, state): + if state is None: + return + if 'admin_name' in state and 'domain_name' in state: + info = ADConnectionInfo(admin_name=state['admin_name'], + domain_name=state['domain_name']) + self.model.set(info) + + def make_autoinstall(self): + return self.serialize() + + def load_autoinstall_data(self, data): + self.deserialize(data) + self.model.do_join = False + + def interactive(self): + # Since we don't accept the domain admin password in the autoinstall + # file, this cannot be non-interactive. + return True def __init__(self, app): super().__init__(app)