move zdev controller to new world
This commit is contained in:
parent
45a85c554e
commit
e9071a00ca
|
@ -6,6 +6,7 @@ subiquity/client/controllers/keyboard.py
|
||||||
subiquity/client/controllers/progress.py
|
subiquity/client/controllers/progress.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/__init__.py
|
subiquity/client/__init__.py
|
||||||
subiquity/client/keyboard.py
|
subiquity/client/keyboard.py
|
||||||
subiquity/client/keycodes.py
|
subiquity/client/keycodes.py
|
||||||
|
@ -41,7 +42,6 @@ subiquity/controllers/snaplist.py
|
||||||
subiquity/controllers/ssh.py
|
subiquity/controllers/ssh.py
|
||||||
subiquity/controllers/tests/__init__.py
|
subiquity/controllers/tests/__init__.py
|
||||||
subiquity/controllers/tests/test_filesystem.py
|
subiquity/controllers/tests/test_filesystem.py
|
||||||
subiquity/controllers/zdev.py
|
|
||||||
subiquitycore/async_helpers.py
|
subiquitycore/async_helpers.py
|
||||||
subiquitycore/contextlib38.py
|
subiquitycore/contextlib38.py
|
||||||
subiquitycore/context.py
|
subiquitycore/context.py
|
||||||
|
@ -126,6 +126,7 @@ subiquity/server/controllers/package.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
|
||||||
|
subiquity/server/controllers/zdev.py
|
||||||
subiquity/server/dryrun.py
|
subiquity/server/dryrun.py
|
||||||
subiquity/server/errors.py
|
subiquity/server/errors.py
|
||||||
subiquity/server/__init__.py
|
subiquity/server/__init__.py
|
||||||
|
|
|
@ -93,6 +93,7 @@ class SubiquityClient(TuiApplication):
|
||||||
"Welcome",
|
"Welcome",
|
||||||
"Refresh",
|
"Refresh",
|
||||||
"Keyboard",
|
"Keyboard",
|
||||||
|
"Zdev",
|
||||||
"Progress",
|
"Progress",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -17,10 +17,12 @@ from .keyboard import KeyboardController
|
||||||
from .progress import ProgressController
|
from .progress import ProgressController
|
||||||
from .refresh import RefreshController
|
from .refresh import RefreshController
|
||||||
from .welcome import WelcomeController
|
from .welcome import WelcomeController
|
||||||
|
from .zdev import ZdevController
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'KeyboardController',
|
'KeyboardController',
|
||||||
'ProgressController',
|
'ProgressController',
|
||||||
'RefreshController',
|
'RefreshController',
|
||||||
'WelcomeController',
|
'WelcomeController',
|
||||||
|
'ZdevController',
|
||||||
]
|
]
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
# Copyright 2019 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 import ZdevView
|
||||||
|
|
||||||
|
|
||||||
|
log = logging.getLogger("subiquity.client.controller.zdev")
|
||||||
|
|
||||||
|
|
||||||
|
class ZdevController(SubiquityTuiController):
|
||||||
|
|
||||||
|
endpoint_name = 'zdev'
|
||||||
|
|
||||||
|
async def make_ui(self):
|
||||||
|
infos = await self.endpoint.GET()
|
||||||
|
return ZdevView(self, infos)
|
||||||
|
|
||||||
|
def run_answers(self):
|
||||||
|
if 'accept-default' in self.answers:
|
||||||
|
self.done()
|
||||||
|
|
||||||
|
def cancel(self):
|
||||||
|
self.app.prev_screen()
|
||||||
|
|
||||||
|
def done(self):
|
||||||
|
# switch to next screen
|
||||||
|
self.app.next_screen()
|
||||||
|
|
||||||
|
async def chzdev(self, action, zdevinfo):
|
||||||
|
return await self.endpoint.chzdev.POST(action, zdevinfo)
|
|
@ -24,6 +24,7 @@ from subiquity.common.types import (
|
||||||
InstallState,
|
InstallState,
|
||||||
InstallStatus,
|
InstallStatus,
|
||||||
RefreshStatus,
|
RefreshStatus,
|
||||||
|
ZdevInfo,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -61,7 +62,6 @@ class API:
|
||||||
class crash:
|
class crash:
|
||||||
def GET() -> None:
|
def GET() -> None:
|
||||||
"""Requests to this method will fail with a HTTP 500."""
|
"""Requests to this method will fail with a HTTP 500."""
|
||||||
|
|
||||||
class refresh:
|
class refresh:
|
||||||
def GET(wait: bool = False) -> RefreshStatus:
|
def GET(wait: bool = False) -> RefreshStatus:
|
||||||
"""Get information about the snap refresh status.
|
"""Get information about the snap refresh status.
|
||||||
|
@ -74,6 +74,12 @@ class API:
|
||||||
class progress:
|
class progress:
|
||||||
def GET(change_id: int) -> dict: ...
|
def GET(change_id: int) -> dict: ...
|
||||||
|
|
||||||
|
class zdev:
|
||||||
|
def GET() -> List[ZdevInfo]: ...
|
||||||
|
|
||||||
|
class chzdev:
|
||||||
|
def POST(action: str, zdev: ZdevInfo) -> List[ZdevInfo]: ...
|
||||||
|
|
||||||
class install:
|
class install:
|
||||||
class status:
|
class status:
|
||||||
def GET(cur: Optional[InstallState] = None) -> InstallStatus: ...
|
def GET(cur: Optional[InstallState] = None) -> InstallStatus: ...
|
||||||
|
|
|
@ -115,6 +115,13 @@ class ZdevInfo:
|
||||||
return self.type
|
return self.type
|
||||||
|
|
||||||
|
|
||||||
|
class Bootloader(enum.Enum):
|
||||||
|
NONE = "NONE" # a system where the bootloader is external, e.g. s390x
|
||||||
|
BIOS = "BIOS" # BIOS, where the bootloader dd-ed to the start of a device
|
||||||
|
UEFI = "UEFI" # UEFI, ESPs and /boot/efi and all that (amd64 and arm64)
|
||||||
|
PREP = "PREP" # ppc64el, which puts grub on a PReP partition
|
||||||
|
|
||||||
|
|
||||||
@attr.s(auto_attribs=True)
|
@attr.s(auto_attribs=True)
|
||||||
class IdentityData:
|
class IdentityData:
|
||||||
realname: str = ''
|
realname: str = ''
|
||||||
|
|
|
@ -22,7 +22,6 @@ 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
|
||||||
from .zdev import ZdevController
|
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'FilesystemController',
|
'FilesystemController',
|
||||||
|
@ -34,5 +33,4 @@ __all__ = [
|
||||||
'RepeatedController',
|
'RepeatedController',
|
||||||
'SnapListController',
|
'SnapListController',
|
||||||
'SSHController',
|
'SSHController',
|
||||||
'ZdevController',
|
|
||||||
]
|
]
|
||||||
|
|
|
@ -34,10 +34,10 @@ from subiquitycore.utils import (
|
||||||
|
|
||||||
|
|
||||||
from subiquity.common.errorreport import ErrorReportKind
|
from subiquity.common.errorreport import ErrorReportKind
|
||||||
|
from subiquity.common.types import Bootloader
|
||||||
from subiquity.controller import SubiquityTuiController
|
from subiquity.controller import SubiquityTuiController
|
||||||
from subiquity.models.filesystem import (
|
from subiquity.models.filesystem import (
|
||||||
align_up,
|
align_up,
|
||||||
Bootloader,
|
|
||||||
DeviceAction,
|
DeviceAction,
|
||||||
dehumanize_size,
|
dehumanize_size,
|
||||||
Partition,
|
Partition,
|
||||||
|
|
|
@ -34,6 +34,8 @@ from probert.storage import StorageInfo
|
||||||
|
|
||||||
from subiquitycore.gettext38 import pgettext
|
from subiquitycore.gettext38 import pgettext
|
||||||
|
|
||||||
|
from subiquity.common.types import Bootloader
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger('subiquity.models.filesystem')
|
log = logging.getLogger('subiquity.models.filesystem')
|
||||||
|
|
||||||
|
@ -1308,13 +1310,6 @@ def align_down(size, block_size=1 << 20):
|
||||||
return size & ~(block_size - 1)
|
return size & ~(block_size - 1)
|
||||||
|
|
||||||
|
|
||||||
class Bootloader(enum.Enum):
|
|
||||||
NONE = "NONE" # a system where the bootloader is external, e.g. s390x
|
|
||||||
BIOS = "BIOS" # BIOS, where the bootloader dd-ed to the start of a device
|
|
||||||
UEFI = "UEFI" # UEFI, ESPs and /boot/efi and all that (amd64 and arm64)
|
|
||||||
PREP = "PREP" # ppc64el, which puts grub on a PReP partition
|
|
||||||
|
|
||||||
|
|
||||||
class FilesystemModel(object):
|
class FilesystemModel(object):
|
||||||
|
|
||||||
lower_size_limit = 128 * (1 << 20)
|
lower_size_limit = 128 * (1 << 20)
|
||||||
|
|
|
@ -22,6 +22,7 @@ from .package import PackageController
|
||||||
from .refresh import RefreshController
|
from .refresh import RefreshController
|
||||||
from .reporting import ReportingController
|
from .reporting import ReportingController
|
||||||
from .userdata import UserdataController
|
from .userdata import UserdataController
|
||||||
|
from .zdev import ZdevController
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'DebconfController',
|
'DebconfController',
|
||||||
|
@ -35,4 +36,5 @@ __all__ = [
|
||||||
'RefreshController',
|
'RefreshController',
|
||||||
'ReportingController',
|
'ReportingController',
|
||||||
'UserdataController',
|
'UserdataController',
|
||||||
|
'ZdevController',
|
||||||
]
|
]
|
||||||
|
|
|
@ -17,20 +17,18 @@ import asyncio
|
||||||
import logging
|
import logging
|
||||||
import platform
|
import platform
|
||||||
import random
|
import random
|
||||||
|
from typing import List
|
||||||
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
from subiquitycore.tuicontroller import (
|
|
||||||
Skip,
|
|
||||||
)
|
|
||||||
from subiquitycore.utils import arun_command, run_command
|
from subiquitycore.utils import arun_command, run_command
|
||||||
|
|
||||||
from subiquity.common.types import ZdevInfo
|
from subiquity.common.apidef import API
|
||||||
from subiquity.controller import SubiquityTuiController
|
from subiquity.common.types import Bootloader, ZdevInfo
|
||||||
from subiquity.ui.views import ZdevView
|
from subiquity.server.controller import SubiquityController
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger("subiquitycore.controller.zdev")
|
log = logging.getLogger("subiquity.server.controller.zdev")
|
||||||
|
|
||||||
lszdev_cmd = ['lszdev', '--pairs', '--columns',
|
lszdev_cmd = ['lszdev', '--pairs', '--columns',
|
||||||
'id,type,on,exists,pers,auto,failed,names']
|
'id,type,on,exists,pers,auto,failed,names']
|
||||||
|
@ -592,7 +590,9 @@ id="0.0.f1fe:0.0.f1ff" type="ctc" on="no" exists="yes" pers="no" auto="no" faile
|
||||||
id="0.0.c0fe" type="generic-ccw" on="no" exists="yes" pers="no" auto="no" failed="yes" names=""''' # noqa: E501
|
id="0.0.c0fe" type="generic-ccw" on="no" exists="yes" pers="no" auto="no" failed="yes" names=""''' # noqa: E501
|
||||||
|
|
||||||
|
|
||||||
class ZdevController(SubiquityTuiController):
|
class ZdevController(SubiquityController):
|
||||||
|
|
||||||
|
endpoint = API.zdev
|
||||||
|
|
||||||
def __init__(self, app):
|
def __init__(self, app):
|
||||||
super().__init__(app)
|
super().__init__(app)
|
||||||
|
@ -605,35 +605,23 @@ class ZdevController(SubiquityTuiController):
|
||||||
zdevinfos = [ZdevInfo.from_row(row) for row in devices]
|
zdevinfos = [ZdevInfo.from_row(row) for row in devices]
|
||||||
self.zdevinfos = OrderedDict([(i.id, i) for i in zdevinfos])
|
self.zdevinfos = OrderedDict([(i.id, i) for i in zdevinfos])
|
||||||
|
|
||||||
def make_ui(self):
|
def interactive(self):
|
||||||
if not self.app.opts.bootloader == 'none' \
|
if self.app.base_model.filesystem.bootloader != Bootloader.NONE:
|
||||||
and platform.machine() != 's390x':
|
return False
|
||||||
raise Skip
|
return super().interactive()
|
||||||
return ZdevView(self, self.get_zdevinfos())
|
|
||||||
|
|
||||||
def run_answers(self):
|
async def chzdev_POST(self, action: str, zdev: ZdevInfo) -> List[ZdevInfo]:
|
||||||
if 'accept-default' in self.answers:
|
|
||||||
self.done()
|
|
||||||
|
|
||||||
def cancel(self):
|
|
||||||
self.app.prev_screen()
|
|
||||||
|
|
||||||
def done(self):
|
|
||||||
# switch to next screen
|
|
||||||
self.app.next_screen()
|
|
||||||
|
|
||||||
async def chzdev(self, action, zdevinfo):
|
|
||||||
if self.opts.dry_run:
|
if self.opts.dry_run:
|
||||||
await asyncio.sleep(random.random()*0.4)
|
await asyncio.sleep(random.random()*0.4)
|
||||||
on = action == 'enable'
|
on = action == 'enable'
|
||||||
self.zdevinfos[zdevinfo.id].on = on
|
self.zdevinfos[zdev.id].on = on
|
||||||
self.zdevinfos[zdevinfo.id].pers = on
|
self.zdevinfos[zdev.id].pers = on
|
||||||
else:
|
else:
|
||||||
chzdev_cmd = ['chzdev', '--%s' % action, zdevinfo.id]
|
chzdev_cmd = ['chzdev', '--%s' % action, zdev.id]
|
||||||
await arun_command(chzdev_cmd)
|
await arun_command(chzdev_cmd)
|
||||||
return self.get_zdevinfos()
|
return await self.GET()
|
||||||
|
|
||||||
def get_zdevinfos(self):
|
async def GET(self) -> List[ZdevInfo]:
|
||||||
if self.opts.dry_run:
|
if self.opts.dry_run:
|
||||||
return self.zdevinfos.values()
|
return self.zdevinfos.values()
|
||||||
else:
|
else:
|
|
@ -121,6 +121,7 @@ class SubiquityServer(Application):
|
||||||
"Locale",
|
"Locale",
|
||||||
"Refresh",
|
"Refresh",
|
||||||
"Keyboard",
|
"Keyboard",
|
||||||
|
"Zdev",
|
||||||
"Install",
|
"Install",
|
||||||
"Late",
|
"Late",
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue