console_conf/subiquity: split identitymodel, as it is not the same at all.

This commit is contained in:
Dimitri John Ledkov 2019-08-08 14:58:31 +01:00
parent 290c26d244
commit e755bf4b5f
6 changed files with 53 additions and 6 deletions

View File

@ -1,6 +1,6 @@
from subiquitycore.models.network import NetworkModel
from subiquitycore.models.identity import IdentityModel
from .identity import IdentityModel
class ConsoleConfModel:

View File

@ -0,0 +1,48 @@
# 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
import attr
log = logging.getLogger('console_conf.models.identity')
@attr.s
class User(object):
realname = attr.ib()
username = attr.ib()
homedir = attr.ib(default=None)
fingerprints = attr.ib(init=False, default=[])
class IdentityModel(object):
""" Model representing user identity
"""
def __init__(self):
self._user = None
def add_user(self, result):
result = result.copy()
self._user = User(**result)
@property
def user(self):
return self._user
def __repr__(self):
return "<LocalUser: {}>".format(self.user)

View File

@ -20,7 +20,7 @@ import attr
from subiquitycore.utils import crypt_password
log = logging.getLogger('subiquitycore.models.identity')
log = logging.getLogger('subiquity.models.identity')
@attr.s

View File

@ -22,7 +22,6 @@ import yaml
from curtin.config import merge_config
from subiquitycore.models.identity import IdentityModel
from subiquitycore.models.network import NetworkModel
from subiquitycore.file_util import write_file
from subiquitycore.utils import run_command
@ -34,6 +33,7 @@ from .proxy import ProxyModel
from .mirror import MirrorModel
from .snaplist import SnapListModel
from .ssh import SSHModel
from .identity import IdentityModel
log = logging.getLogger('subiquity.models.subiquity')

View File

@ -1,10 +1,10 @@
import unittest
from unittest import mock
from subiquitycore.models.identity import IdentityModel
from subiquitycore.signals import Signal
from subiquitycore.testing import view_helpers
from subiquity.models.identity import IdentityModel
from subiquity.controllers.identity import IdentityController
from subiquity.ui.views.identity import IdentityView

View File

@ -13,6 +13,5 @@
# 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/>.
from .identity import IdentityModel
from .network import NetworkModel
__all__ = ['IdentityModel', 'NetworkModel']
__all__ = ['NetworkModel']