diff --git a/subiquity/controllers/filesystem.py b/subiquity/controllers/filesystem.py
index d99b9c6d..3459b213 100644
--- a/subiquity/controllers/filesystem.py
+++ b/subiquity/controllers/filesystem.py
@@ -24,7 +24,6 @@ from subiquity.curtin import (
CURTIN_CONFIGS,
curtin_write_storage_actions,
)
-from subiquity.models import (FilesystemModel, RaidModel)
from subiquity.models.filesystem import humanize_size
from subiquity.ui.views import (
BcacheView,
@@ -50,10 +49,9 @@ class FilesystemController(BaseController):
def __init__(self, common):
super().__init__(common)
- self.model = FilesystemModel(self.prober, self.opts)
+ self.model = self.base_model.filesystem
# self.iscsi_model = IscsiDiskModel()
# self.ceph_model = CephDiskModel()
- self.raid_model = RaidModel()
self.model.probe() # probe before we complete
def default(self):
diff --git a/subiquity/controllers/identity.py b/subiquity/controllers/identity.py
index 1d4a92cd..e23576c3 100644
--- a/subiquity/controllers/identity.py
+++ b/subiquity/controllers/identity.py
@@ -17,7 +17,6 @@
import logging
from subiquitycore.controller import BaseController
-from subiquitycore.models import IdentityModel
from subiquitycore.user import create_user
from subiquity.curtin import curtin_write_postinst_config
@@ -30,7 +29,7 @@ class IdentityController(BaseController):
def __init__(self, common):
super().__init__(common)
- self.model = IdentityModel(self.opts)
+ self.model = self.base_model.identity
def default(self):
title = _("Profile setup")
diff --git a/subiquity/controllers/installpath.py b/subiquity/controllers/installpath.py
index 6c5b86cb..9932d43f 100644
--- a/subiquity/controllers/installpath.py
+++ b/subiquity/controllers/installpath.py
@@ -20,7 +20,7 @@ import lsb_release
from subiquitycore.controller import BaseController
from subiquitycore.ui.dummy import DummyView
-from subiquity.models import InstallpathModel
+from subiquity.models.installpath import InstallpathModel
from subiquity.ui.views import InstallpathView
log = logging.getLogger('subiquity.controller.installpath')
diff --git a/subiquity/controllers/welcome.py b/subiquity/controllers/welcome.py
index de5970b3..02c245db 100644
--- a/subiquity/controllers/welcome.py
+++ b/subiquity/controllers/welcome.py
@@ -16,7 +16,6 @@
from subiquitycore.controller import BaseController
-from subiquity.models import LocaleModel
from subiquity.ui.views import WelcomeView
@@ -24,7 +23,7 @@ class WelcomeController(BaseController):
def __init__(self, common):
super().__init__(common)
- self.model = LocaleModel()
+ self.model = self.base_model.locale
def default(self):
title = "Willkommen! Bienvenue! Welcome! Добро пожаловать! Welkom!"
diff --git a/subiquity/core.py b/subiquity/core.py
index 4c0a4f35..61edbc4e 100644
--- a/subiquity/core.py
+++ b/subiquity/core.py
@@ -17,6 +17,8 @@ import logging
from subiquitycore.core import Application
+from subiquity.models.subiquity import SubiquityModel
+
log = logging.getLogger('console_conf.core')
@@ -25,6 +27,9 @@ class Subiquity(Application):
from subiquity.palette import PALETTE, STYLES, STYLES_MONO
project = "subiquity"
+
+ model_class = SubiquityModel
+
controllers = [
"Welcome",
"Network",
diff --git a/subiquity/models/__init__.py b/subiquity/models/__init__.py
index 2ba6475f..653d1c16 100644
--- a/subiquity/models/__init__.py
+++ b/subiquity/models/__init__.py
@@ -12,8 +12,3 @@
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-
-from .installpath import InstallpathModel # NOQA
-from .filesystem import FilesystemModel # NOQA
-from .raid import RaidModel # NOQA
-from .locale import LocaleModel
diff --git a/subiquity/models/filesystem.py b/subiquity/models/filesystem.py
index c6817c50..363d6e56 100644
--- a/subiquity/models/filesystem.py
+++ b/subiquity/models/filesystem.py
@@ -272,9 +272,8 @@ class FilesystemModel(object):
longest_fs_name = len(fs.label)
fs_by_name[fs.label] = fs
- def __init__(self, prober, opts):
+ def __init__(self, prober):
self.prober = prober
- self.opts = opts
self._available_disks = {} # keyed by path, eg /dev/sda
self.reset()
diff --git a/subiquity/models/locale.py b/subiquity/models/locale.py
index 7a91f3b3..00177dfa 100644
--- a/subiquity/models/locale.py
+++ b/subiquity/models/locale.py
@@ -17,13 +17,12 @@ import gettext
import logging
from subiquitycore import i18n
-log = logging.getLogger('subiquity.models.welcome')
-
+log = logging.getLogger('subiquity.models.locale')
class LocaleModel(object):
""" Model representing locale selection
- Only supports language selection for now.
+ XXX Only represents *language* selection for now.
"""
supported_languages = [
@@ -33,6 +32,7 @@ class LocaleModel(object):
('lv_LV', 'Latvian'),
('ru_RU', 'Russian'),
]
+
selected_language = None
def get_languages(self):
diff --git a/subiquity/models/subiquity.py b/subiquity/models/subiquity.py
new file mode 100644
index 00000000..b3467856
--- /dev/null
+++ b/subiquity/models/subiquity.py
@@ -0,0 +1,30 @@
+# 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 .
+
+from subiquitycore.models.identity import IdentityModel
+from subiquitycore.models.network import NetworkModel
+
+from .filesystem import FilesystemModel
+from .locale import LocaleModel
+
+
+class SubiquityModel:
+ """The overall model for subiquity."""
+
+ def __init__(self, common):
+ self.locale = LocaleModel()
+ self.network = NetworkModel()
+ self.filesystem = FilesystemModel(common['prober'])
+ self.identity = IdentityModel()
diff --git a/subiquitycore/controller.py b/subiquitycore/controller.py
index 8faf97c6..ce4a1ac0 100644
--- a/subiquitycore/controller.py
+++ b/subiquitycore/controller.py
@@ -34,6 +34,7 @@ class BaseController(ABC):
self.prober = common['prober']
self.controllers = common['controllers']
self.pool = common['pool']
+ self.base_model = common['base_model']
def register_signals(self):
"""Defines signals associated with controller from model."""
diff --git a/subiquitycore/controllers/network.py b/subiquitycore/controllers/network.py
index 5419d328..4fbb71a1 100644
--- a/subiquitycore/controllers/network.py
+++ b/subiquitycore/controllers/network.py
@@ -225,6 +225,7 @@ def sanitize_config(config):
ap_config['password'] = ''
return config
+
class SubiquityNetworkEventReceiver(NetworkEventReceiver):
def __init__(self, model):
self.model = model
@@ -299,6 +300,7 @@ class NetworkController(BaseController):
def __init__(self, common):
super().__init__(common)
+ self.model = self.base_model.network
if self.opts.dry_run:
self.root = os.path.abspath(".subiquity")
self.tried_once = False
@@ -310,7 +312,7 @@ class NetworkController(BaseController):
os.makedirs(netplan_dir)
with open(netplan_path, 'w') as fp:
fp.write(default_netplan)
- self.model = NetworkModel(self.root)
+ self.model.parse_netplan_configs(self.root)
self.network_event_receiver = SubiquityNetworkEventReceiver(self.model)
self.observer, fds = self.prober.probe_network(self.network_event_receiver)
@@ -369,7 +371,7 @@ class NetworkController(BaseController):
w.write("# This is the network config written by '{}'\n".format(self.opts.project))
w.write(yaml.dump(config))
os.rename(tmppath, netplan_path)
- self.model.parse_netplan_configs()
+ self.model.parse_netplan_configs(self.root)
if self.opts.dry_run:
tasks = [
('one', BackgroundProcess(['sleep', '0.1'])),
diff --git a/subiquitycore/core.py b/subiquitycore/core.py
index 4735c448..7357150e 100644
--- a/subiquitycore/core.py
+++ b/subiquitycore/core.py
@@ -179,6 +179,8 @@ class Application:
log.debug("Running event loop: {}".format(
self.common['loop'].event_loop))
+ self.common['base_model'] = self.model_class(self.common)
+
try:
self.common['loop'].set_alarm_in(0.05, self.next_screen)
controllers_mod = __import__('%s.controllers' % self.project, None, None, [''])
diff --git a/subiquitycore/models/identity.py b/subiquitycore/models/identity.py
index 93a5e1d4..5e17c646 100644
--- a/subiquitycore/models/identity.py
+++ b/subiquitycore/models/identity.py
@@ -58,8 +58,7 @@ class IdentityModel(object):
""" Model representing user identity
"""
- def __init__(self, opts):
- self.opts = opts
+ def __init__(self):
self._user = None
def add_user(self, result):
diff --git a/subiquitycore/models/network.py b/subiquitycore/models/network.py
index 92697819..3ced94de 100644
--- a/subiquitycore/models/network.py
+++ b/subiquitycore/models/network.py
@@ -363,7 +363,7 @@ class NetworkModel(object):
6: 'balance-alb',
}
- def __init__(self, netplan_root):
+ def __init__(self):
self.devices = {} # Maps ifindex to Networkdev
self.devices_by_name = {} # Maps interface names to Networkdev
self.default_v4_gateway = None
@@ -371,15 +371,13 @@ class NetworkModel(object):
self.v4_gateway_dev = None
self.v6_gateway_dev = None
self.network_routes = {}
- self.netplan_root = netplan_root
- self.parse_netplan_configs()
- def parse_netplan_configs(self):
+ def parse_netplan_configs(self, netplan_root):
self.config = NetplanConfig()
configs_by_basename = {}
- paths = glob.glob(os.path.join(self.netplan_root, 'lib/netplan', "*.yaml")) + \
- glob.glob(os.path.join(self.netplan_root, 'etc/netplan', "*.yaml")) + \
- glob.glob(os.path.join(self.netplan_root, 'run/netplan', "*.yaml"))
+ paths = glob.glob(os.path.join(netplan_root, 'lib/netplan', "*.yaml")) + \
+ glob.glob(os.path.join(netplan_root, 'etc/netplan', "*.yaml")) + \
+ glob.glob(os.path.join(netplan_root, 'run/netplan', "*.yaml"))
for path in paths:
configs_by_basename[os.path.basename(path)] = path
for _, path in sorted(configs_by_basename.items()):