move ssh controller to new world
This commit is contained in:
parent
bd69f2a746
commit
4ab676d984
|
@ -10,6 +10,7 @@ subiquity/client/controllers/network.py
|
|||
subiquity/client/controllers/progress.py
|
||||
subiquity/client/controllers/proxy.py
|
||||
subiquity/client/controllers/refresh.py
|
||||
subiquity/client/controllers/ssh.py
|
||||
subiquity/client/controllers/welcome.py
|
||||
subiquity/client/controllers/zdev.py
|
||||
subiquity/client/__init__.py
|
||||
|
@ -42,7 +43,6 @@ subiquity/controller.py
|
|||
subiquity/controllers/__init__.py
|
||||
subiquity/controllers/reboot.py
|
||||
subiquity/controllers/snaplist.py
|
||||
subiquity/controllers/ssh.py
|
||||
subiquitycore/async_helpers.py
|
||||
subiquitycore/contextlib38.py
|
||||
subiquitycore/context.py
|
||||
|
@ -131,6 +131,7 @@ subiquity/server/controllers/package.py
|
|||
subiquity/server/controllers/proxy.py
|
||||
subiquity/server/controllers/refresh.py
|
||||
subiquity/server/controllers/reporting.py
|
||||
subiquity/server/controllers/ssh.py
|
||||
subiquity/server/controllers/userdata.py
|
||||
subiquity/server/controllers/zdev.py
|
||||
subiquity/server/dryrun.py
|
||||
|
|
|
@ -100,6 +100,7 @@ class SubiquityClient(TuiApplication):
|
|||
"Refresh",
|
||||
"Filesystem",
|
||||
"Identity",
|
||||
"SSH",
|
||||
"Progress",
|
||||
]
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ from .network import NetworkController
|
|||
from .progress import ProgressController
|
||||
from .proxy import ProxyController
|
||||
from .refresh import RefreshController
|
||||
from .ssh import SSHController
|
||||
from .welcome import WelcomeController
|
||||
from .zdev import ZdevController
|
||||
|
||||
|
@ -35,6 +36,7 @@ __all__ = [
|
|||
'ProxyController',
|
||||
'RefreshController',
|
||||
'RepeatedController',
|
||||
'SSHController',
|
||||
'WelcomeController',
|
||||
'ZdevController',
|
||||
]
|
||||
|
|
|
@ -20,11 +20,11 @@ from subiquitycore.async_helpers import schedule_task
|
|||
from subiquitycore.context import with_context
|
||||
from subiquitycore import utils
|
||||
|
||||
from subiquity.client.controller import SubiquityTuiController
|
||||
from subiquity.common.types import SSHData
|
||||
from subiquity.controller import SubiquityTuiController
|
||||
from subiquity.ui.views.ssh import SSHView
|
||||
|
||||
log = logging.getLogger('subiquity.controllers.ssh')
|
||||
log = logging.getLogger('subiquity.client.controllers.ssh')
|
||||
|
||||
|
||||
class FetchSSHKeysFailure(Exception):
|
||||
|
@ -35,18 +35,7 @@ class FetchSSHKeysFailure(Exception):
|
|||
|
||||
class SSHController(SubiquityTuiController):
|
||||
|
||||
autoinstall_key = model_name = "ssh"
|
||||
autoinstall_schema = {
|
||||
'type': 'object',
|
||||
'properties': {
|
||||
'install-server': {'type': 'boolean'},
|
||||
'authorized-keys': {
|
||||
'type': 'array',
|
||||
'items': {'type': 'string'},
|
||||
},
|
||||
'allow-pw': {'type': 'boolean'},
|
||||
},
|
||||
}
|
||||
endpoint_name = 'ssh'
|
||||
|
||||
def __init__(self, app):
|
||||
super().__init__(app)
|
||||
|
@ -57,19 +46,8 @@ class SSHController(SubiquityTuiController):
|
|||
self.answers['ssh-import-id'] = identity_answers[
|
||||
'ssh-import-id']
|
||||
|
||||
def load_autoinstall_data(self, data):
|
||||
if data is None:
|
||||
return
|
||||
self.model.install_server = data.get('install-server', False)
|
||||
self.model.authorized_keys = data.get(
|
||||
'authorized-keys', [])
|
||||
self.model.pwauth = data.get(
|
||||
'allow-pw', not self.model.authorized_keys)
|
||||
|
||||
def make_ui(self):
|
||||
ssh_data = SSHData(
|
||||
install_server=self.model.install_server,
|
||||
allow_pw=self.model.pwauth)
|
||||
async def make_ui(self):
|
||||
ssh_data = await self.endpoint.GET()
|
||||
return SSHView(self, ssh_data)
|
||||
|
||||
def run_answers(self):
|
||||
|
@ -141,16 +119,6 @@ class SSHController(SubiquityTuiController):
|
|||
self._fetch_ssh_keys(
|
||||
ssh_import_id=ssh_import_id, ssh_data=ssh_data))
|
||||
|
||||
def done(self, data: SSHData):
|
||||
self.model.install_server = data.install_server
|
||||
self.model.authorized_keys = data.authorized_keys
|
||||
self.model.pwauth = data.allow_pw
|
||||
self.configured()
|
||||
self.app.next_screen()
|
||||
|
||||
def make_autoinstall(self):
|
||||
return {
|
||||
'install-server': self.model.install_server,
|
||||
'authorized-keys': self.model.authorized_keys,
|
||||
'allow-pw': self.model.pwauth,
|
||||
}
|
||||
def done(self, result):
|
||||
log.debug("SSHController.done next_screen result=%s", result)
|
||||
self.app.next_screen(self.endpoint.POST(result))
|
|
@ -32,6 +32,7 @@ from subiquity.common.types import (
|
|||
InstallState,
|
||||
InstallStatus,
|
||||
RefreshStatus,
|
||||
SSHData,
|
||||
StorageResponse,
|
||||
ZdevInfo,
|
||||
)
|
||||
|
@ -45,6 +46,7 @@ class API:
|
|||
proxy = simple_endpoint(str)
|
||||
mirror = simple_endpoint(str)
|
||||
identity = simple_endpoint(IdentityData)
|
||||
ssh = simple_endpoint(SSHData)
|
||||
|
||||
class meta:
|
||||
class status:
|
||||
|
|
|
@ -15,10 +15,8 @@
|
|||
|
||||
from .reboot import RebootController
|
||||
from .snaplist import SnapListController
|
||||
from .ssh import SSHController
|
||||
|
||||
__all__ = [
|
||||
'RebootController',
|
||||
'SnapListController',
|
||||
'SSHController',
|
||||
]
|
||||
|
|
|
@ -26,6 +26,7 @@ from .package import PackageController
|
|||
from .proxy import ProxyController
|
||||
from .refresh import RefreshController
|
||||
from .reporting import ReportingController
|
||||
from .ssh import SSHController
|
||||
from .userdata import UserdataController
|
||||
from .zdev import ZdevController
|
||||
|
||||
|
@ -45,6 +46,7 @@ __all__ = [
|
|||
'ProxyController',
|
||||
'RefreshController',
|
||||
'ReportingController',
|
||||
'SSHController',
|
||||
'UserdataController',
|
||||
'ZdevController',
|
||||
]
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
# 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.common.apidef import API
|
||||
from subiquity.common.types import SSHData
|
||||
from subiquity.server.controller import SubiquityController
|
||||
|
||||
log = logging.getLogger('subiquity.server.controllers.ssh')
|
||||
|
||||
|
||||
class SSHController(SubiquityController):
|
||||
|
||||
endpoint = API.ssh
|
||||
|
||||
autoinstall_key = model_name = "ssh"
|
||||
autoinstall_schema = {
|
||||
'type': 'object',
|
||||
'properties': {
|
||||
'install-server': {'type': 'boolean'},
|
||||
'authorized-keys': {
|
||||
'type': 'array',
|
||||
'items': {'type': 'string'},
|
||||
},
|
||||
'allow-pw': {'type': 'boolean'},
|
||||
},
|
||||
}
|
||||
|
||||
def load_autoinstall_data(self, data):
|
||||
if data is None:
|
||||
return
|
||||
self.model.install_server = data.get('install-server', False)
|
||||
self.model.authorized_keys = data.get('authorized-keys', [])
|
||||
self.model.pwauth = data.get(
|
||||
'allow-pw', not self.model.authorized_keys)
|
||||
|
||||
def make_autoinstall(self):
|
||||
return {
|
||||
'install-server': self.model.install_server,
|
||||
'authorized-keys': self.model.authorized_keys,
|
||||
'allow-pw': self.model.pwauth,
|
||||
}
|
||||
|
||||
async def GET(self) -> SSHData:
|
||||
return SSHData(
|
||||
install_server=self.model.install_server,
|
||||
allow_pw=self.model.pwauth)
|
||||
|
||||
async def POST(self, data: SSHData):
|
||||
self.model.install_server = data.install_server
|
||||
self.model.authorized_keys = data.authorized_keys
|
||||
self.model.pwauth = data.allow_pw
|
||||
self.configured()
|
|
@ -127,6 +127,7 @@ class SubiquityServer(Application):
|
|||
"Mirror",
|
||||
"Filesystem",
|
||||
"Identity",
|
||||
"SSH",
|
||||
"Install",
|
||||
"Late",
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue