move identity controller to new world
This commit is contained in:
parent
4adae88563
commit
bd69f2a746
|
@ -2,6 +2,7 @@
|
||||||
subiquity/client/client.py
|
subiquity/client/client.py
|
||||||
subiquity/client/controller.py
|
subiquity/client/controller.py
|
||||||
subiquity/client/controllers/filesystem.py
|
subiquity/client/controllers/filesystem.py
|
||||||
|
subiquity/client/controllers/identity.py
|
||||||
subiquity/client/controllers/__init__.py
|
subiquity/client/controllers/__init__.py
|
||||||
subiquity/client/controllers/keyboard.py
|
subiquity/client/controllers/keyboard.py
|
||||||
subiquity/client/controllers/mirror.py
|
subiquity/client/controllers/mirror.py
|
||||||
|
@ -38,7 +39,6 @@ subiquity/common/tests/test_filesystem.py
|
||||||
subiquity/common/tests/test_keyboard.py
|
subiquity/common/tests/test_keyboard.py
|
||||||
subiquity/common/types.py
|
subiquity/common/types.py
|
||||||
subiquity/controller.py
|
subiquity/controller.py
|
||||||
subiquity/controllers/identity.py
|
|
||||||
subiquity/controllers/__init__.py
|
subiquity/controllers/__init__.py
|
||||||
subiquity/controllers/reboot.py
|
subiquity/controllers/reboot.py
|
||||||
subiquity/controllers/snaplist.py
|
subiquity/controllers/snaplist.py
|
||||||
|
@ -120,6 +120,7 @@ subiquity/server/controller.py
|
||||||
subiquity/server/controllers/cmdlist.py
|
subiquity/server/controllers/cmdlist.py
|
||||||
subiquity/server/controllers/debconf.py
|
subiquity/server/controllers/debconf.py
|
||||||
subiquity/server/controllers/filesystem.py
|
subiquity/server/controllers/filesystem.py
|
||||||
|
subiquity/server/controllers/identity.py
|
||||||
subiquity/server/controllers/__init__.py
|
subiquity/server/controllers/__init__.py
|
||||||
subiquity/server/controllers/install.py
|
subiquity/server/controllers/install.py
|
||||||
subiquity/server/controllers/keyboard.py
|
subiquity/server/controllers/keyboard.py
|
||||||
|
|
|
@ -99,6 +99,7 @@ class SubiquityClient(TuiApplication):
|
||||||
"Mirror",
|
"Mirror",
|
||||||
"Refresh",
|
"Refresh",
|
||||||
"Filesystem",
|
"Filesystem",
|
||||||
|
"Identity",
|
||||||
"Progress",
|
"Progress",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
from subiquitycore.tuicontroller import RepeatedController
|
from subiquitycore.tuicontroller import RepeatedController
|
||||||
from .filesystem import FilesystemController
|
from .filesystem import FilesystemController
|
||||||
|
from .identity import IdentityController
|
||||||
from .keyboard import KeyboardController
|
from .keyboard import KeyboardController
|
||||||
from .mirror import MirrorController
|
from .mirror import MirrorController
|
||||||
from .network import NetworkController
|
from .network import NetworkController
|
||||||
|
@ -26,6 +27,7 @@ from .zdev import ZdevController
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'FilesystemController',
|
'FilesystemController',
|
||||||
|
'IdentityController',
|
||||||
'KeyboardController',
|
'KeyboardController',
|
||||||
'MirrorController',
|
'MirrorController',
|
||||||
'NetworkController',
|
'NetworkController',
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
# Copyright 2015 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.common.types import IdentityData
|
||||||
|
from subiquity.ui.views import IdentityView
|
||||||
|
|
||||||
|
log = logging.getLogger('subiquity.client.controllers.identity')
|
||||||
|
|
||||||
|
|
||||||
|
class IdentityController(SubiquityTuiController):
|
||||||
|
|
||||||
|
endpoint_name = 'identity'
|
||||||
|
|
||||||
|
async def make_ui(self):
|
||||||
|
data = await self.endpoint.GET()
|
||||||
|
return IdentityView(self, data)
|
||||||
|
|
||||||
|
def run_answers(self):
|
||||||
|
if all(elem in self.answers for elem in
|
||||||
|
['realname', 'username', 'password', 'hostname']):
|
||||||
|
identity = IdentityData(
|
||||||
|
realname=self.answers['realname'],
|
||||||
|
username=self.answers['username'],
|
||||||
|
hostname=self.answers['hostname'],
|
||||||
|
crypted_password=self.answers['password'])
|
||||||
|
self.done(identity)
|
||||||
|
|
||||||
|
def cancel(self):
|
||||||
|
self.app.prev_screen()
|
||||||
|
|
||||||
|
def done(self, identity_data):
|
||||||
|
log.debug(
|
||||||
|
"IdentityController.done next_screen user_spec=%s",
|
||||||
|
identity_data)
|
||||||
|
self.app.next_screen(self.endpoint.POST(identity_data))
|
|
@ -28,6 +28,7 @@ from subiquity.common.types import (
|
||||||
ApplicationStatus,
|
ApplicationStatus,
|
||||||
ErrorReportRef,
|
ErrorReportRef,
|
||||||
KeyboardSetting,
|
KeyboardSetting,
|
||||||
|
IdentityData,
|
||||||
InstallState,
|
InstallState,
|
||||||
InstallStatus,
|
InstallStatus,
|
||||||
RefreshStatus,
|
RefreshStatus,
|
||||||
|
@ -43,6 +44,7 @@ class API:
|
||||||
keyboard = simple_endpoint(KeyboardSetting)
|
keyboard = simple_endpoint(KeyboardSetting)
|
||||||
proxy = simple_endpoint(str)
|
proxy = simple_endpoint(str)
|
||||||
mirror = simple_endpoint(str)
|
mirror = simple_endpoint(str)
|
||||||
|
identity = simple_endpoint(IdentityData)
|
||||||
|
|
||||||
class meta:
|
class meta:
|
||||||
class status:
|
class status:
|
||||||
|
|
|
@ -13,13 +13,11 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# 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/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from .identity import IdentityController
|
|
||||||
from .reboot import RebootController
|
from .reboot import RebootController
|
||||||
from .snaplist import SnapListController
|
from .snaplist import SnapListController
|
||||||
from .ssh import SSHController
|
from .ssh import SSHController
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'IdentityController',
|
|
||||||
'RebootController',
|
'RebootController',
|
||||||
'SnapListController',
|
'SnapListController',
|
||||||
'SSHController',
|
'SSHController',
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
from .cmdlist import EarlyController, LateController, ErrorController
|
from .cmdlist import EarlyController, LateController, ErrorController
|
||||||
from .debconf import DebconfController
|
from .debconf import DebconfController
|
||||||
from .filesystem import FilesystemController
|
from .filesystem import FilesystemController
|
||||||
|
from .identity import IdentityController
|
||||||
from .install import InstallController
|
from .install import InstallController
|
||||||
from .keyboard import KeyboardController
|
from .keyboard import KeyboardController
|
||||||
from .locale import LocaleController
|
from .locale import LocaleController
|
||||||
|
@ -33,6 +34,7 @@ __all__ = [
|
||||||
'EarlyController',
|
'EarlyController',
|
||||||
'ErrorController',
|
'ErrorController',
|
||||||
'FilesystemController',
|
'FilesystemController',
|
||||||
|
'IdentityController',
|
||||||
'InstallController',
|
'InstallController',
|
||||||
'KeyboardController',
|
'KeyboardController',
|
||||||
'LateController',
|
'LateController',
|
||||||
|
|
|
@ -19,14 +19,16 @@ import attr
|
||||||
|
|
||||||
from subiquitycore.context import with_context
|
from subiquitycore.context import with_context
|
||||||
|
|
||||||
|
from subiquity.common.apidef import API
|
||||||
from subiquity.common.types import IdentityData
|
from subiquity.common.types import IdentityData
|
||||||
from subiquity.controller import SubiquityTuiController
|
from subiquity.server.controller import SubiquityController
|
||||||
from subiquity.ui.views import IdentityView
|
|
||||||
|
|
||||||
log = logging.getLogger('subiquity.controllers.identity')
|
log = logging.getLogger('subiquity.server.controllers.identity')
|
||||||
|
|
||||||
|
|
||||||
class IdentityController(SubiquityTuiController):
|
class IdentityController(SubiquityController):
|
||||||
|
|
||||||
|
endpoint = API.identity
|
||||||
|
|
||||||
autoinstall_key = model_name = "identity"
|
autoinstall_key = model_name = "identity"
|
||||||
autoinstall_schema = {
|
autoinstall_schema = {
|
||||||
|
@ -57,39 +59,22 @@ class IdentityController(SubiquityTuiController):
|
||||||
if 'user-data' not in self.app.autoinstall_config:
|
if 'user-data' not in self.app.autoinstall_config:
|
||||||
raise Exception("no identity data provided")
|
raise Exception("no identity data provided")
|
||||||
|
|
||||||
def make_ui(self):
|
|
||||||
data = IdentityData()
|
|
||||||
if self.model.user is not None:
|
|
||||||
data.username = self.model.user.username
|
|
||||||
data.realname = self.model.user.realname
|
|
||||||
if self.model.hostname:
|
|
||||||
data.hostname = self.model.hostname
|
|
||||||
return IdentityView(self, data)
|
|
||||||
|
|
||||||
def run_answers(self):
|
|
||||||
if all(elem in self.answers for elem in
|
|
||||||
['realname', 'username', 'password', 'hostname']):
|
|
||||||
identity = IdentityData(
|
|
||||||
realname=self.answers['realname'],
|
|
||||||
username=self.answers['username'],
|
|
||||||
hostname=self.answers['hostname'],
|
|
||||||
crypted_password=self.answers['password'])
|
|
||||||
self.done(identity)
|
|
||||||
|
|
||||||
def cancel(self):
|
|
||||||
self.app.prev_screen()
|
|
||||||
|
|
||||||
def done(self, identity_data):
|
|
||||||
log.debug(
|
|
||||||
"IdentityController.done next_screen user_spec=%s",
|
|
||||||
identity_data)
|
|
||||||
self.model.add_user(identity_data)
|
|
||||||
self.configured()
|
|
||||||
self.app.next_screen()
|
|
||||||
|
|
||||||
def make_autoinstall(self):
|
def make_autoinstall(self):
|
||||||
if self.model.user is None:
|
if self.model.user is None:
|
||||||
return {}
|
return {}
|
||||||
r = attr.asdict(self.model.user)
|
r = attr.asdict(self.model.user)
|
||||||
r['hostname'] = self.model.hostname
|
r['hostname'] = self.model.hostname
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
async def GET(self) -> IdentityData:
|
||||||
|
data = IdentityData()
|
||||||
|
if self.model.user is not None:
|
||||||
|
data.username = self.model.user.username
|
||||||
|
data.realname = self.model.user.realname
|
||||||
|
if self.model.hostname:
|
||||||
|
data.hostname = self.model.hostname
|
||||||
|
return data
|
||||||
|
|
||||||
|
async def POST(self, data: IdentityData):
|
||||||
|
self.model.add_user(data)
|
||||||
|
self.configured()
|
|
@ -126,6 +126,7 @@ class SubiquityServer(Application):
|
||||||
"Proxy",
|
"Proxy",
|
||||||
"Mirror",
|
"Mirror",
|
||||||
"Filesystem",
|
"Filesystem",
|
||||||
|
"Identity",
|
||||||
"Install",
|
"Install",
|
||||||
"Late",
|
"Late",
|
||||||
]
|
]
|
||||||
|
|
|
@ -4,7 +4,7 @@ from unittest import mock
|
||||||
from subiquitycore.signals import Signal
|
from subiquitycore.signals import Signal
|
||||||
from subiquitycore.testing import view_helpers
|
from subiquitycore.testing import view_helpers
|
||||||
|
|
||||||
from subiquity.controllers.identity import IdentityController
|
from subiquity.client.controllers.identity import IdentityController
|
||||||
from subiquity.common.types import IdentityData
|
from subiquity.common.types import IdentityData
|
||||||
from subiquity.ui.views.identity import IdentityView
|
from subiquity.ui.views.identity import IdentityView
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue