diff --git a/subiquity/client/client.py b/subiquity/client/client.py index 9ee6a286..095e8a38 100644 --- a/subiquity/client/client.py +++ b/subiquity/client/client.py @@ -136,6 +136,8 @@ class SubiquityClient(TuiApplication): self.conn = aiohttp.UnixConnector(self.opts.socket) self.client = make_client_for_conn(API, self.conn, self.resp_hook) + self.client1 = make_client_for_conn( + API, self.conn, self.resp_hook, headers={'x-first-request': 'yes'}) self.error_reporter = ErrorReporter( self.context.child("ErrorReporter"), self.opts.dry_run, self.root, diff --git a/subiquity/client/controller.py b/subiquity/client/controller.py index 1740ef05..9192bc36 100644 --- a/subiquity/client/controller.py +++ b/subiquity/client/controller.py @@ -35,3 +35,4 @@ class SubiquityTuiController(TuiController): self.answers = app.answers.get(self.name, {}) if self.endpoint_name is not None: self.endpoint = getattr(self.app.client, self.endpoint_name) + self.endpoint1 = getattr(self.app.client1, self.endpoint_name) diff --git a/subiquity/client/controllers/filesystem.py b/subiquity/client/controllers/filesystem.py index 33f494de..a61c7386 100644 --- a/subiquity/client/controllers/filesystem.py +++ b/subiquity/client/controllers/filesystem.py @@ -55,7 +55,7 @@ class FilesystemController(SubiquityTuiController, FilesystemManipulator): self.answers.setdefault('manual', []) async def make_ui(self): - status = await self.endpoint.guided.GET() + status = await self.endpoint1.guided.GET() if status.status == ProbeStatus.PROBING: self.app.aio_loop.create_task(self._wait_for_probing()) return SlowProbing(self) diff --git a/subiquity/client/controllers/identity.py b/subiquity/client/controllers/identity.py index b0ccda7b..501ce0cf 100644 --- a/subiquity/client/controllers/identity.py +++ b/subiquity/client/controllers/identity.py @@ -27,7 +27,7 @@ class IdentityController(SubiquityTuiController): endpoint_name = 'identity' async def make_ui(self): - data = await self.endpoint.GET() + data = await self.endpoint1.GET() return IdentityView(self, data) def run_answers(self): diff --git a/subiquity/client/controllers/keyboard.py b/subiquity/client/controllers/keyboard.py index cc6d8f6f..3bff896d 100644 --- a/subiquity/client/controllers/keyboard.py +++ b/subiquity/client/controllers/keyboard.py @@ -28,7 +28,7 @@ class KeyboardController(SubiquityTuiController): endpoint_name = 'keyboard' async def make_ui(self): - setup = await self.endpoint.GET() + setup = await self.endpoint1.GET() return KeyboardView(self, setup) async def run_answers(self): diff --git a/subiquity/client/controllers/mirror.py b/subiquity/client/controllers/mirror.py index 3626c3f5..d976789a 100644 --- a/subiquity/client/controllers/mirror.py +++ b/subiquity/client/controllers/mirror.py @@ -26,7 +26,7 @@ class MirrorController(SubiquityTuiController): endpoint_name = 'mirror' async def make_ui(self): - mirror = await self.endpoint.GET() + mirror = await self.endpoint1.GET() return MirrorView(self, mirror) def run_answers(self): diff --git a/subiquity/client/controllers/network.py b/subiquity/client/controllers/network.py index 77d946e9..0abeb48f 100644 --- a/subiquity/client/controllers/network.py +++ b/subiquity/client/controllers/network.py @@ -107,7 +107,7 @@ class NetworkController(SubiquityTuiController, NetworkAnswersMixin): shutil.rmtree(self.tdir) async def make_ui(self): - network_status = await self.endpoint.GET() + network_status = await self.endpoint1.GET() self.view = NetworkView( self, network_status.devices, network_status.wlan_support_install_state.name) diff --git a/subiquity/client/controllers/proxy.py b/subiquity/client/controllers/proxy.py index 0223b04a..02cc02c7 100644 --- a/subiquity/client/controllers/proxy.py +++ b/subiquity/client/controllers/proxy.py @@ -26,7 +26,7 @@ class ProxyController(SubiquityTuiController): endpoint_name = 'proxy' async def make_ui(self): - proxy = await self.endpoint.GET() + proxy = await self.endpoint1.GET() return ProxyView(self, proxy) def run_answers(self): diff --git a/subiquity/client/controllers/refresh.py b/subiquity/client/controllers/refresh.py index 05214a9e..3933e6e4 100644 --- a/subiquity/client/controllers/refresh.py +++ b/subiquity/client/controllers/refresh.py @@ -54,7 +54,7 @@ class RefreshController(SubiquityTuiController): if self.app.updated: raise Skip() show = False - self.status = await self.endpoint.GET() + self.status = await self.endpoint1.GET() if index == 1: if self.status.availability == RefreshCheckState.AVAILABLE: show = True diff --git a/subiquity/client/controllers/serial.py b/subiquity/client/controllers/serial.py index 039d23d5..a8e33ba3 100644 --- a/subiquity/client/controllers/serial.py +++ b/subiquity/client/controllers/serial.py @@ -26,7 +26,7 @@ class SerialController(SubiquityTuiController): async def make_ui(self): if not self.app.opts.run_on_serial: raise Skip() - ssh_info = await self.app.client.meta.ssh_info.GET() + ssh_info = await self.app.client1.meta.ssh_info.GET() return SerialView(self, ssh_info) def run_answers(self): diff --git a/subiquity/client/controllers/snaplist.py b/subiquity/client/controllers/snaplist.py index 32161304..e0d14ab3 100644 --- a/subiquity/client/controllers/snaplist.py +++ b/subiquity/client/controllers/snaplist.py @@ -37,7 +37,7 @@ class SnapListController(SubiquityTuiController): endpoint_name = 'snaplist' async def make_ui(self): - data = await self.endpoint.GET() + data = await self.endpoint1.GET() if data.status == SnapCheckState.FAILED: # If loading snaps failed or the network is disabled, skip the # screen. diff --git a/subiquity/client/controllers/source.py b/subiquity/client/controllers/source.py index c0ce37a7..d2b549db 100644 --- a/subiquity/client/controllers/source.py +++ b/subiquity/client/controllers/source.py @@ -26,7 +26,7 @@ class SourceController(SubiquityTuiController): endpoint_name = 'source' async def make_ui(self): - sources = await self.endpoint.GET() + sources = await self.endpoint1.GET() return SourceView(self, sources.sources, sources.current_id) def run_answers(self): diff --git a/subiquity/client/controllers/ssh.py b/subiquity/client/controllers/ssh.py index 3eae0117..f5450580 100644 --- a/subiquity/client/controllers/ssh.py +++ b/subiquity/client/controllers/ssh.py @@ -47,7 +47,7 @@ class SSHController(SubiquityTuiController): 'ssh-import-id'] async def make_ui(self): - ssh_data = await self.endpoint.GET() + ssh_data = await self.endpoint1.GET() return SSHView(self, ssh_data) def run_answers(self): diff --git a/subiquity/client/controllers/welcome.py b/subiquity/client/controllers/welcome.py index ff600174..10a4056a 100644 --- a/subiquity/client/controllers/welcome.py +++ b/subiquity/client/controllers/welcome.py @@ -30,7 +30,7 @@ class WelcomeController(SubiquityTuiController): async def make_ui(self): if not self.app.rich_mode: raise Skip() - language = await self.endpoint.GET() + language = await self.endpoint1.GET() i18n.switch_language(language) self.serial = self.app.opts.run_on_serial return WelcomeView(self, language, self.serial) diff --git a/subiquity/client/controllers/zdev.py b/subiquity/client/controllers/zdev.py index 92c7d590..7ae1923f 100644 --- a/subiquity/client/controllers/zdev.py +++ b/subiquity/client/controllers/zdev.py @@ -27,7 +27,7 @@ class ZdevController(SubiquityTuiController): endpoint_name = 'zdev' async def make_ui(self): - infos = await self.endpoint.GET() + infos = await self.endpoint1.GET() return ZdevView(self, infos) def run_answers(self): diff --git a/subiquity/common/api/client.py b/subiquity/common/api/client.py index 868a52c4..5db1f230 100644 --- a/subiquity/common/api/client.py +++ b/subiquity/common/api/client.py @@ -67,11 +67,13 @@ def make_client(endpoint_cls, make_request, serializer=None): def make_client_for_conn( - endpoint_cls, conn, resp_hook=lambda r: r, serializer=None): + endpoint_cls, conn, resp_hook=lambda r: r, serializer=None, + headers={}): @contextlib38.asynccontextmanager async def make_request(method, path, *, params, json): async with aiohttp.ClientSession( - connector=conn, connector_owner=False) as session: + connector=conn, connector_owner=False, + headers=headers) as session: # session.request needs a full URL with scheme and host # even though that's in some ways a bit silly with a unix # socket, so we just hardcode something here (I guess the diff --git a/subiquity/server/server.py b/subiquity/server/server.py index 52d734e7..6c6c6786 100644 --- a/subiquity/server/server.py +++ b/subiquity/server/server.py @@ -407,7 +407,8 @@ class SubiquityServer(Application): if isinstance(controller, SubiquityController): if not controller.interactive(): override_status = 'skip' - elif self.state == ApplicationState.NEEDS_CONFIRMATION: + elif (self.state == ApplicationState.NEEDS_CONFIRMATION and + request.headers.get('x-first-request') == 'yes'): if self.base_model.is_postinstall_only(controller.model_name): override_status = 'confirm' if override_status is not None: