move proxy controller to new world

This commit is contained in:
Michael Hudson-Doyle 2020-10-12 12:27:57 +13:00
parent 7f41803418
commit c264884c0c
9 changed files with 64 additions and 26 deletions

View File

@ -5,6 +5,7 @@ subiquity/client/controllers/__init__.py
subiquity/client/controllers/keyboard.py subiquity/client/controllers/keyboard.py
subiquity/client/controllers/network.py subiquity/client/controllers/network.py
subiquity/client/controllers/progress.py subiquity/client/controllers/progress.py
subiquity/client/controllers/proxy.py
subiquity/client/controllers/refresh.py subiquity/client/controllers/refresh.py
subiquity/client/controllers/welcome.py subiquity/client/controllers/welcome.py
subiquity/client/controllers/zdev.py subiquity/client/controllers/zdev.py
@ -36,7 +37,6 @@ subiquity/controllers/filesystem.py
subiquity/controllers/identity.py subiquity/controllers/identity.py
subiquity/controllers/__init__.py subiquity/controllers/__init__.py
subiquity/controllers/mirror.py subiquity/controllers/mirror.py
subiquity/controllers/proxy.py
subiquity/controllers/reboot.py subiquity/controllers/reboot.py
subiquity/controllers/snaplist.py subiquity/controllers/snaplist.py
subiquity/controllers/ssh.py subiquity/controllers/ssh.py
@ -124,6 +124,7 @@ subiquity/server/controllers/keyboard.py
subiquity/server/controllers/locale.py subiquity/server/controllers/locale.py
subiquity/server/controllers/network.py subiquity/server/controllers/network.py
subiquity/server/controllers/package.py subiquity/server/controllers/package.py
subiquity/server/controllers/proxy.py
subiquity/server/controllers/refresh.py subiquity/server/controllers/refresh.py
subiquity/server/controllers/reporting.py subiquity/server/controllers/reporting.py
subiquity/server/controllers/userdata.py subiquity/server/controllers/userdata.py

View File

@ -95,6 +95,7 @@ class SubiquityClient(TuiApplication):
"Keyboard", "Keyboard",
"Zdev", "Zdev",
"Network", "Network",
"Proxy",
"Progress", "Progress",
] ]

View File

@ -16,6 +16,7 @@
from .keyboard import KeyboardController from .keyboard import KeyboardController
from .network import NetworkController from .network import NetworkController
from .progress import ProgressController from .progress import ProgressController
from .proxy import ProxyController
from .refresh import RefreshController from .refresh import RefreshController
from .welcome import WelcomeController from .welcome import WelcomeController
from .zdev import ZdevController from .zdev import ZdevController
@ -24,6 +25,7 @@ __all__ = [
'KeyboardController', 'KeyboardController',
'NetworkController', 'NetworkController',
'ProgressController', 'ProgressController',
'ProxyController',
'RefreshController', 'RefreshController',
'WelcomeController', 'WelcomeController',
'ZdevController', 'ZdevController',

View File

@ -0,0 +1,41 @@
# Copyright 2018 Canonical, Ltd.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import logging
from subiquity.client.controller import SubiquityTuiController
from subiquity.ui.views.proxy import ProxyView
log = logging.getLogger('subiquity.client.controllers.proxy')
class ProxyController(SubiquityTuiController):
endpoint_name = 'proxy'
async def make_ui(self):
proxy = await self.endpoint.GET()
return ProxyView(self, proxy)
def run_answers(self):
if 'proxy' in self.answers:
self.done(self.answers['proxy'])
def cancel(self):
self.app.prev_screen()
def done(self, proxy):
log.debug("ProxyController.done next_screen proxy=%s", proxy)
self.app.next_screen(self.endpoint.POST(proxy))

View File

@ -40,6 +40,7 @@ class API:
"""The API offered by the subiquity installer process.""" """The API offered by the subiquity installer process."""
locale = simple_endpoint(str) locale = simple_endpoint(str)
keyboard = simple_endpoint(KeyboardSetting) keyboard = simple_endpoint(KeyboardSetting)
proxy = simple_endpoint(str)
class meta: class meta:
class status: class status:

View File

@ -17,7 +17,6 @@ from ..controller import RepeatedController
from .filesystem import FilesystemController from .filesystem import FilesystemController
from .identity import IdentityController from .identity import IdentityController
from .mirror import MirrorController from .mirror import MirrorController
from .proxy import ProxyController
from .reboot import RebootController from .reboot import RebootController
from .snaplist import SnapListController from .snaplist import SnapListController
from .ssh import SSHController from .ssh import SSHController
@ -26,7 +25,6 @@ __all__ = [
'FilesystemController', 'FilesystemController',
'IdentityController', 'IdentityController',
'MirrorController', 'MirrorController',
'ProxyController',
'RebootController', 'RebootController',
'RepeatedController', 'RepeatedController',
'SnapListController', 'SnapListController',

View File

@ -20,6 +20,7 @@ from .keyboard import KeyboardController
from .locale import LocaleController from .locale import LocaleController
from .network import NetworkController from .network import NetworkController
from .package import PackageController from .package import PackageController
from .proxy import ProxyController
from .refresh import RefreshController from .refresh import RefreshController
from .reporting import ReportingController from .reporting import ReportingController
from .userdata import UserdataController from .userdata import UserdataController
@ -35,6 +36,7 @@ __all__ = [
'LocaleController', 'LocaleController',
'NetworkController', 'NetworkController',
'PackageController', 'PackageController',
'ProxyController',
'RefreshController', 'RefreshController',
'ReportingController', 'ReportingController',
'UserdataController', 'UserdataController',

View File

@ -18,13 +18,15 @@ import os
from subiquitycore.context import with_context from subiquitycore.context import with_context
from subiquity.controller import SubiquityTuiController from subiquity.common.apidef import API
from subiquity.ui.views.proxy import ProxyView from subiquity.server.controller import SubiquityController
log = logging.getLogger('subiquity.controllers.proxy') log = logging.getLogger('subiquity.server.controllers.proxy')
class ProxyController(SubiquityTuiController): class ProxyController(SubiquityController):
endpoint = API.proxy
autoinstall_key = model_name = "proxy" autoinstall_key = model_name = "proxy"
autoinstall_schema = { autoinstall_schema = {
@ -48,30 +50,19 @@ class ProxyController(SubiquityTuiController):
# by everything; don't have a way to do that today. # by everything; don't have a way to do that today.
pass pass
def make_ui(self):
return ProxyView(self, self.model.proxy)
def run_answers(self):
if 'proxy' in self.answers:
self.done(self.answers['proxy'])
def cancel(self):
self.app.prev_screen()
def serialize(self): def serialize(self):
return self.model.proxy return self.model.proxy
def deserialize(self, data): def deserialize(self, data):
self.model.proxy = data self.model.proxy = data
def done(self, proxy):
log.debug("ProxyController.done next_screen proxy=%s", proxy)
if proxy != self.model.proxy:
self.model.proxy = proxy
os.environ['http_proxy'] = os.environ['https_proxy'] = proxy
self.signal.emit_signal('network-proxy-set')
self.configured()
self.app.next_screen()
def make_autoinstall(self): def make_autoinstall(self):
return self.model.proxy return self.model.proxy
async def GET(self) -> str:
return self.model.proxy
async def POST(self, data: str):
self.model.proxy = data
self.signal.emit_signal('network-proxy-set')
self.configured()

View File

@ -123,6 +123,7 @@ class SubiquityServer(Application):
"Keyboard", "Keyboard",
"Zdev", "Zdev",
"Network", "Network",
"Proxy",
"Install", "Install",
"Late", "Late",
] ]