move controllers with no api presence to server
This commit is contained in:
parent
3367b41cf1
commit
7faa1634ff
|
@ -27,25 +27,19 @@ subiquity/common/serialize.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/cmdlist.py
|
|
||||||
subiquity/controllers/debconf.py
|
|
||||||
subiquity/controllers/error.py
|
|
||||||
subiquity/controllers/filesystem.py
|
subiquity/controllers/filesystem.py
|
||||||
subiquity/controllers/identity.py
|
subiquity/controllers/identity.py
|
||||||
subiquity/controllers/__init__.py
|
subiquity/controllers/__init__.py
|
||||||
subiquity/controllers/keyboard.py
|
subiquity/controllers/keyboard.py
|
||||||
subiquity/controllers/mirror.py
|
subiquity/controllers/mirror.py
|
||||||
subiquity/controllers/network.py
|
subiquity/controllers/network.py
|
||||||
subiquity/controllers/package.py
|
|
||||||
subiquity/controllers/proxy.py
|
subiquity/controllers/proxy.py
|
||||||
subiquity/controllers/reboot.py
|
subiquity/controllers/reboot.py
|
||||||
subiquity/controllers/refresh.py
|
subiquity/controllers/refresh.py
|
||||||
subiquity/controllers/reporting.py
|
|
||||||
subiquity/controllers/snaplist.py
|
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/userdata.py
|
|
||||||
subiquity/controllers/zdev.py
|
subiquity/controllers/zdev.py
|
||||||
subiquitycore/async_helpers.py
|
subiquitycore/async_helpers.py
|
||||||
subiquitycore/contextlib38.py
|
subiquitycore/contextlib38.py
|
||||||
|
@ -122,9 +116,14 @@ subiquity/models/tests/test_filesystem.py
|
||||||
subiquity/models/tests/test_mirror.py
|
subiquity/models/tests/test_mirror.py
|
||||||
subiquity/models/tests/test_subiquity.py
|
subiquity/models/tests/test_subiquity.py
|
||||||
subiquity/server/controller.py
|
subiquity/server/controller.py
|
||||||
|
subiquity/server/controllers/cmdlist.py
|
||||||
|
subiquity/server/controllers/debconf.py
|
||||||
subiquity/server/controllers/__init__.py
|
subiquity/server/controllers/__init__.py
|
||||||
subiquity/server/controllers/install.py
|
subiquity/server/controllers/install.py
|
||||||
subiquity/server/controllers/locale.py
|
subiquity/server/controllers/locale.py
|
||||||
|
subiquity/server/controllers/package.py
|
||||||
|
subiquity/server/controllers/reporting.py
|
||||||
|
subiquity/server/controllers/userdata.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
|
||||||
|
|
|
@ -14,42 +14,29 @@
|
||||||
# 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 ..controller import RepeatedController
|
from ..controller import RepeatedController
|
||||||
from .cmdlist import EarlyController, LateController
|
|
||||||
from .debconf import DebconfController
|
|
||||||
from .error import ErrorController
|
|
||||||
from .filesystem import FilesystemController
|
from .filesystem import FilesystemController
|
||||||
from .identity import IdentityController
|
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
|
||||||
from .package import PackageController
|
|
||||||
from .proxy import ProxyController
|
from .proxy import ProxyController
|
||||||
from .reboot import RebootController
|
from .reboot import RebootController
|
||||||
from .refresh import RefreshController
|
from .refresh import RefreshController
|
||||||
from .reporting import ReportingController
|
|
||||||
from .snaplist import SnapListController
|
from .snaplist import SnapListController
|
||||||
from .ssh import SSHController
|
from .ssh import SSHController
|
||||||
from .userdata import UserdataController
|
|
||||||
from .zdev import ZdevController
|
from .zdev import ZdevController
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'DebconfController',
|
|
||||||
'EarlyController',
|
|
||||||
'ErrorController',
|
|
||||||
'FilesystemController',
|
'FilesystemController',
|
||||||
'IdentityController',
|
'IdentityController',
|
||||||
'KeyboardController',
|
'KeyboardController',
|
||||||
'LateController',
|
|
||||||
'MirrorController',
|
'MirrorController',
|
||||||
'NetworkController',
|
'NetworkController',
|
||||||
'PackageController',
|
|
||||||
'ProxyController',
|
'ProxyController',
|
||||||
'RebootController',
|
'RebootController',
|
||||||
'RefreshController',
|
'RefreshController',
|
||||||
'RepeatedController',
|
'RepeatedController',
|
||||||
'ReportingController',
|
|
||||||
'SnapListController',
|
'SnapListController',
|
||||||
'SSHController',
|
'SSHController',
|
||||||
'UserdataController',
|
|
||||||
'ZdevController',
|
'ZdevController',
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
# 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.controllers.cmdlist import CmdListController
|
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger('subiquity.controllers.error')
|
|
||||||
|
|
||||||
|
|
||||||
class ErrorController(CmdListController):
|
|
||||||
|
|
||||||
autoinstall_key = 'error-commands'
|
|
||||||
cmd_check = False
|
|
|
@ -13,10 +13,22 @@
|
||||||
# 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 .cmdlist import EarlyController, LateController, ErrorController
|
||||||
|
from .debconf import DebconfController
|
||||||
from .install import InstallController
|
from .install import InstallController
|
||||||
from .locale import LocaleController
|
from .locale import LocaleController
|
||||||
|
from .package import PackageController
|
||||||
|
from .reporting import ReportingController
|
||||||
|
from .userdata import UserdataController
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
|
'DebconfController',
|
||||||
|
'EarlyController',
|
||||||
|
'ErrorController',
|
||||||
'InstallController',
|
'InstallController',
|
||||||
|
'LateController',
|
||||||
'LocaleController',
|
'LocaleController',
|
||||||
|
'PackageController',
|
||||||
|
'ReportingController',
|
||||||
|
'UserdataController',
|
||||||
]
|
]
|
||||||
|
|
|
@ -13,15 +13,19 @@
|
||||||
# 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/>.
|
||||||
|
|
||||||
|
import asyncio
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from systemd import journal
|
||||||
|
|
||||||
from subiquitycore.context import with_context
|
from subiquitycore.context import with_context
|
||||||
from subiquitycore.utils import arun_command
|
from subiquitycore.utils import arun_command
|
||||||
|
|
||||||
from subiquity.controller import SubiquityController
|
from subiquity.common.types import InstallState
|
||||||
|
from subiquity.server.controller import NonInteractiveController
|
||||||
|
|
||||||
|
|
||||||
class CmdListController(SubiquityController):
|
class CmdListController(NonInteractiveController):
|
||||||
|
|
||||||
autoinstall_default = []
|
autoinstall_default = []
|
||||||
autoinstall_schema = {
|
autoinstall_schema = {
|
||||||
|
@ -33,6 +37,11 @@ class CmdListController(SubiquityController):
|
||||||
}
|
}
|
||||||
cmds = ()
|
cmds = ()
|
||||||
cmd_check = True
|
cmd_check = True
|
||||||
|
send_to_journal = False
|
||||||
|
|
||||||
|
def __init__(self, app):
|
||||||
|
super().__init__(app)
|
||||||
|
self.run_event = asyncio.Event()
|
||||||
|
|
||||||
def load_autoinstall_data(self, data):
|
def load_autoinstall_data(self, data):
|
||||||
self.cmds = data
|
self.cmds = data
|
||||||
|
@ -44,18 +53,32 @@ class CmdListController(SubiquityController):
|
||||||
async def run(self, context):
|
async def run(self, context):
|
||||||
env = self.env()
|
env = self.env()
|
||||||
for i, cmd in enumerate(self.cmds):
|
for i, cmd in enumerate(self.cmds):
|
||||||
with context.child("command_{}".format(i), cmd):
|
if isinstance(cmd, str):
|
||||||
|
desc = cmd
|
||||||
|
else:
|
||||||
|
desc = ' '.join(cmd)
|
||||||
|
with context.child("command_{}".format(i), desc):
|
||||||
if isinstance(cmd, str):
|
if isinstance(cmd, str):
|
||||||
cmd = ['sh', '-c', cmd]
|
cmd = ['sh', '-c', cmd]
|
||||||
|
if self.send_to_journal:
|
||||||
|
journal.send(
|
||||||
|
" running " + desc,
|
||||||
|
SYSLOG_IDENTIFIER=self.app.early_commands_syslog_id)
|
||||||
|
cmd = [
|
||||||
|
'systemd-cat', '--level-prefix=false',
|
||||||
|
'--identifier=' + self.app.early_commands_syslog_id,
|
||||||
|
] + cmd
|
||||||
await arun_command(
|
await arun_command(
|
||||||
cmd, env=env,
|
cmd, env=env,
|
||||||
stdin=None, stdout=None, stderr=None,
|
stdin=None, stdout=None, stderr=None,
|
||||||
check=self.cmd_check)
|
check=self.cmd_check)
|
||||||
|
self.run_event.set()
|
||||||
|
|
||||||
|
|
||||||
class EarlyController(CmdListController):
|
class EarlyController(CmdListController):
|
||||||
|
|
||||||
autoinstall_key = 'early-commands'
|
autoinstall_key = 'early-commands'
|
||||||
|
send_to_journal = True
|
||||||
|
|
||||||
|
|
||||||
class LateController(CmdListController):
|
class LateController(CmdListController):
|
||||||
|
@ -67,6 +90,17 @@ class LateController(CmdListController):
|
||||||
env['TARGET_MOUNT_POINT'] = self.app.base_model.target
|
env['TARGET_MOUNT_POINT'] = self.app.base_model.target
|
||||||
return env
|
return env
|
||||||
|
|
||||||
@with_context()
|
def start(self):
|
||||||
async def apply_autoinstall_config(self, context):
|
self.app.aio_loop.create_task(self._run())
|
||||||
await self.run(context=context)
|
|
||||||
|
async def _run(self):
|
||||||
|
Install = self.app.controllers.Install
|
||||||
|
await Install.install_task
|
||||||
|
if Install.install_state == InstallState.DONE:
|
||||||
|
await self.run()
|
||||||
|
|
||||||
|
|
||||||
|
class ErrorController(CmdListController):
|
||||||
|
|
||||||
|
autoinstall_key = 'error-commands'
|
||||||
|
cmd_check = False
|
|
@ -13,10 +13,10 @@
|
||||||
# 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 subiquity.controller import SubiquityController
|
from subiquity.server.controller import NonInteractiveController
|
||||||
|
|
||||||
|
|
||||||
class DebconfController(SubiquityController):
|
class DebconfController(NonInteractiveController):
|
||||||
|
|
||||||
model_name = "debconf_selections"
|
model_name = "debconf_selections"
|
||||||
autoinstall_key = "debconf-selections"
|
autoinstall_key = "debconf-selections"
|
|
@ -13,10 +13,10 @@
|
||||||
# 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 subiquity.controller import SubiquityController
|
from subiquity.server.controller import NonInteractiveController
|
||||||
|
|
||||||
|
|
||||||
class PackageController(SubiquityController):
|
class PackageController(NonInteractiveController):
|
||||||
|
|
||||||
model_name = autoinstall_key = "packages"
|
model_name = autoinstall_key = "packages"
|
||||||
autoinstall_default = []
|
autoinstall_default = []
|
|
@ -29,7 +29,7 @@ from curtin.reporter.handlers import (
|
||||||
LogHandler,
|
LogHandler,
|
||||||
)
|
)
|
||||||
|
|
||||||
from subiquity.controller import SubiquityController
|
from subiquity.server.controller import NonInteractiveController
|
||||||
|
|
||||||
|
|
||||||
class LogHandler(LogHandler):
|
class LogHandler(LogHandler):
|
||||||
|
@ -42,10 +42,13 @@ class LogHandler(LogHandler):
|
||||||
available_handlers.unregister_item('log')
|
available_handlers.unregister_item('log')
|
||||||
available_handlers.register_item('log', LogHandler)
|
available_handlers.register_item('log', LogHandler)
|
||||||
|
|
||||||
INITIAL_CONFIG = {'logging': {'type': 'log'}}
|
INITIAL_CONFIG = {
|
||||||
|
'logging': {'type': 'log'},
|
||||||
|
}
|
||||||
|
NON_INTERACTIVE_CONFIG = {'builtin': {'type': 'print'}}
|
||||||
|
|
||||||
|
|
||||||
class ReportingController(SubiquityController):
|
class ReportingController(NonInteractiveController):
|
||||||
|
|
||||||
autoinstall_key = "reporting"
|
autoinstall_key = "reporting"
|
||||||
autoinstall_schema = {
|
autoinstall_schema = {
|
||||||
|
@ -61,13 +64,14 @@ class ReportingController(SubiquityController):
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, app):
|
def __init__(self, app):
|
||||||
self.config = copy.deepcopy(INITIAL_CONFIG)
|
|
||||||
super().__init__(app)
|
super().__init__(app)
|
||||||
|
self.config = copy.deepcopy(INITIAL_CONFIG)
|
||||||
app.add_event_listener(self)
|
app.add_event_listener(self)
|
||||||
|
|
||||||
def load_autoinstall_data(self, data):
|
def load_autoinstall_data(self, data):
|
||||||
if self.app.interactive():
|
if self.app.interactive():
|
||||||
return
|
return
|
||||||
|
self.config.update(copy.deepcopy(NON_INTERACTIVE_CONFIG))
|
||||||
if data is not None:
|
if data is not None:
|
||||||
self.config.update(copy.deepcopy(data))
|
self.config.update(copy.deepcopy(data))
|
||||||
|
|
|
@ -13,10 +13,10 @@
|
||||||
# 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 subiquity.controller import SubiquityController
|
from subiquity.server.controller import NonInteractiveController
|
||||||
|
|
||||||
|
|
||||||
class UserdataController(SubiquityController):
|
class UserdataController(NonInteractiveController):
|
||||||
|
|
||||||
model_name = 'userdata'
|
model_name = 'userdata'
|
||||||
autoinstall_key = "user-data"
|
autoinstall_key = "user-data"
|
|
@ -112,8 +112,15 @@ class SubiquityServer(Application):
|
||||||
project = "subiquity"
|
project = "subiquity"
|
||||||
from subiquity.server import controllers as controllers_mod
|
from subiquity.server import controllers as controllers_mod
|
||||||
controllers = [
|
controllers = [
|
||||||
|
"Early",
|
||||||
|
"Reporting",
|
||||||
|
"Error",
|
||||||
|
"Userdata",
|
||||||
|
"Package",
|
||||||
|
"Debconf",
|
||||||
"Locale",
|
"Locale",
|
||||||
"Install",
|
"Install",
|
||||||
|
"Late",
|
||||||
]
|
]
|
||||||
|
|
||||||
def make_model(self):
|
def make_model(self):
|
||||||
|
|
Loading…
Reference in New Issue