Consistent naming - part 1 - AdModel
No other class starts with both capitals 'AD'.
This commit is contained in:
parent
03af76d431
commit
2057dcd64a
|
@ -8,7 +8,7 @@ import logging
|
|||
import re
|
||||
import os
|
||||
from typing import List
|
||||
from subiquity.models.ad import ADModel
|
||||
from subiquity.models.ad import AdModel
|
||||
|
||||
|
||||
class FailedTestCase(Exception):
|
||||
|
@ -18,7 +18,7 @@ class FailedTestCase(Exception):
|
|||
async def target_packages() -> List[str]:
|
||||
""" Returns the list of packages the AD Model wants to install in the
|
||||
target system."""
|
||||
model = ADModel()
|
||||
model = AdModel()
|
||||
model.do_join = True
|
||||
return await model.target_packages()
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ from subiquitycore.models.network import (
|
|||
|
||||
from subiquity.common.api.defs import api, Payload, simple_endpoint
|
||||
from subiquity.common.types import (
|
||||
ADConnectionInfo,
|
||||
AdConnectionInfo,
|
||||
AdAdminNameValidation,
|
||||
AdDomainNameValidation,
|
||||
AdJoinResult,
|
||||
|
@ -415,9 +415,9 @@ class API:
|
|||
def GET() -> CasperMd5Results: ...
|
||||
|
||||
class active_directory:
|
||||
def GET() -> Optional[ADConnectionInfo]: ...
|
||||
def GET() -> Optional[AdConnectionInfo]: ...
|
||||
# POST expects input validated by the check methods below:
|
||||
def POST(data: Payload[ADConnectionInfo]) -> None: ...
|
||||
def POST(data: Payload[AdConnectionInfo]) -> None: ...
|
||||
|
||||
class has_support:
|
||||
""" Whether the live system supports Active Directory or not.
|
||||
|
|
|
@ -773,7 +773,7 @@ class MirrorSelectionFallback(enum.Enum):
|
|||
|
||||
|
||||
@attr.s(auto_attribs=True)
|
||||
class ADConnectionInfo:
|
||||
class AdConnectionInfo:
|
||||
admin_name: str = ""
|
||||
domain_name: str = ""
|
||||
password: str = attr.ib(repr=False, default="")
|
||||
|
|
|
@ -16,18 +16,18 @@
|
|||
import logging
|
||||
from typing import Optional
|
||||
|
||||
from subiquity.common.types import ADConnectionInfo
|
||||
from subiquity.common.types import AdConnectionInfo
|
||||
|
||||
log = logging.getLogger('subiquity.models.ad')
|
||||
|
||||
|
||||
class ADModel:
|
||||
class AdModel:
|
||||
""" Models the Active Directory feature """
|
||||
def __init__(self) -> None:
|
||||
self.do_join = False
|
||||
self.conn_info: Optional[ADConnectionInfo] = None
|
||||
self.conn_info: Optional[AdConnectionInfo] = None
|
||||
|
||||
def set(self, info: ADConnectionInfo):
|
||||
def set(self, info: AdConnectionInfo):
|
||||
self.conn_info = info
|
||||
self.do_join = True
|
||||
|
||||
|
@ -39,7 +39,7 @@ class ADModel:
|
|||
self.conn_info.domain_name = domain
|
||||
|
||||
else:
|
||||
self.conn_info = ADConnectionInfo(domain_name=domain)
|
||||
self.conn_info = AdConnectionInfo(domain_name=domain)
|
||||
|
||||
async def target_packages(self):
|
||||
# NOTE Those packages must be present in the target system to allow
|
||||
|
|
|
@ -46,7 +46,7 @@ from subiquitycore.lsb_release import lsb_release
|
|||
from subiquity.common.resources import get_users_and_groups
|
||||
from subiquity.server.types import InstallerChannels
|
||||
|
||||
from .ad import ADModel
|
||||
from .ad import AdModel
|
||||
from .codecs import CodecsModel
|
||||
from .drivers import DriversModel
|
||||
from .filesystem import FilesystemModel
|
||||
|
@ -180,7 +180,7 @@ class SubiquityModel:
|
|||
self.target = root
|
||||
self.chroot_prefix = []
|
||||
|
||||
self.ad = ADModel()
|
||||
self.ad = AdModel()
|
||||
self.codecs = CodecsModel()
|
||||
self.debconf_selections = DebconfSelectionsModel()
|
||||
self.drivers = DriversModel()
|
||||
|
|
|
@ -21,7 +21,7 @@ from subprocess import CalledProcessError
|
|||
from subiquitycore.utils import arun_command, run_command
|
||||
from subiquity.server.curtin import run_curtin_command
|
||||
from subiquity.common.types import (
|
||||
ADConnectionInfo,
|
||||
AdConnectionInfo,
|
||||
AdJoinResult,
|
||||
)
|
||||
|
||||
|
@ -50,7 +50,7 @@ class AdJoinStrategy():
|
|||
def __init__(self, app):
|
||||
self.app = app
|
||||
|
||||
async def do_join(self, info: ADConnectionInfo, hostname: str, context) \
|
||||
async def do_join(self, info: AdConnectionInfo, hostname: str, context) \
|
||||
-> AdJoinResult:
|
||||
""" This method changes the hostname and perform a real AD join, thus
|
||||
should only run in a live session. """
|
||||
|
@ -109,7 +109,7 @@ class AdJoinStrategy():
|
|||
|
||||
|
||||
class StubStrategy(AdJoinStrategy):
|
||||
async def do_join(self, info: ADConnectionInfo, hostname: str, context) \
|
||||
async def do_join(self, info: AdConnectionInfo, hostname: str, context) \
|
||||
-> AdJoinResult:
|
||||
""" Enables testing without real join. The result depends on the
|
||||
domain name initial character, such that if it is:
|
||||
|
@ -135,7 +135,7 @@ class AdJoiner():
|
|||
else:
|
||||
self.strategy = AdJoinStrategy(app)
|
||||
|
||||
async def join_domain(self, info: ADConnectionInfo, hostname: str,
|
||||
async def join_domain(self, info: AdConnectionInfo, hostname: str,
|
||||
context) -> AdJoinResult:
|
||||
if hostname:
|
||||
self._result = await self.strategy.do_join(info, hostname, context)
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
# 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 .ad import ADController
|
||||
from .ad import AdController
|
||||
from .cmdlist import EarlyController, LateController, ErrorController
|
||||
from .codecs import CodecsController
|
||||
from .debconf import DebconfController
|
||||
|
@ -42,7 +42,7 @@ from .userdata import UserdataController
|
|||
from .zdev import ZdevController
|
||||
|
||||
__all__ = [
|
||||
'ADController',
|
||||
'AdController',
|
||||
'CodecsController',
|
||||
'DebconfController',
|
||||
'DriversController',
|
||||
|
|
|
@ -22,7 +22,7 @@ from subiquitycore.async_helpers import run_bg_task
|
|||
|
||||
from subiquity.common.apidef import API
|
||||
from subiquity.common.types import (
|
||||
ADConnectionInfo,
|
||||
AdConnectionInfo,
|
||||
AdAdminNameValidation,
|
||||
AdDomainNameValidation,
|
||||
AdJoinResult,
|
||||
|
@ -89,7 +89,7 @@ class StubDcPingStrategy(DcPingStrategy):
|
|||
return True
|
||||
|
||||
|
||||
class ADController(SubiquityController):
|
||||
class AdController(SubiquityController):
|
||||
""" Implements the server part of the Active Directory feature. """
|
||||
endpoint = API.active_directory
|
||||
# No auto install key and schema for now due password handling uncertainty.
|
||||
|
@ -119,7 +119,7 @@ class ADController(SubiquityController):
|
|||
if state is None:
|
||||
return
|
||||
if 'admin_name' in state and 'domain_name' in state:
|
||||
info = ADConnectionInfo(admin_name=state['admin_name'],
|
||||
info = AdConnectionInfo(admin_name=state['admin_name'],
|
||||
domain_name=state['domain_name'])
|
||||
self.model.set(info)
|
||||
|
||||
|
@ -153,11 +153,11 @@ class ADController(SubiquityController):
|
|||
if discovered_domain:
|
||||
self.model.set_domain(discovered_domain)
|
||||
|
||||
async def GET(self) -> Optional[ADConnectionInfo]:
|
||||
async def GET(self) -> Optional[AdConnectionInfo]:
|
||||
"""Returns the currently configured AD settings"""
|
||||
return self.model.conn_info
|
||||
|
||||
async def POST(self, data: ADConnectionInfo) -> None:
|
||||
async def POST(self, data: AdConnectionInfo) -> None:
|
||||
""" Configures this controller with the supplied info.
|
||||
Clients are required to validate the info before POST'ing """
|
||||
self.model.set(data)
|
||||
|
|
|
@ -412,7 +412,7 @@ class InstallController(SubiquityController):
|
|||
with open(self.tpath('etc/hostname'), 'r') as f:
|
||||
hostname = f.read().strip()
|
||||
|
||||
await self.app.controllers.AD.join_domain(hostname, context)
|
||||
await self.app.controllers.Ad.join_domain(hostname, context)
|
||||
|
||||
@with_context(description="configuring cloud-init")
|
||||
async def configure_cloud_init(self, context):
|
||||
|
|
|
@ -19,16 +19,16 @@ from unittest import (
|
|||
)
|
||||
from subiquity.common.types import (
|
||||
AdAdminNameValidation,
|
||||
ADConnectionInfo,
|
||||
AdConnectionInfo,
|
||||
AdDomainNameValidation,
|
||||
AdJoinResult,
|
||||
AdPasswordValidation,
|
||||
)
|
||||
from subiquity.server.controllers.ad import (
|
||||
ADController,
|
||||
AdController,
|
||||
AdValidators,
|
||||
)
|
||||
from subiquity.models.ad import ADModel
|
||||
from subiquity.models.ad import AdModel
|
||||
from subiquitycore.tests.mocks import make_app
|
||||
|
||||
|
||||
|
@ -134,8 +134,8 @@ class TestADValidation(TestCase):
|
|||
class TestAdJoin(IsolatedAsyncioTestCase):
|
||||
def setUp(self):
|
||||
self.app = make_app()
|
||||
self.controller = ADController(self.app)
|
||||
self.controller.model = ADModel()
|
||||
self.controller = AdController(self.app)
|
||||
self.controller.model = AdModel()
|
||||
|
||||
async def test_never_join(self):
|
||||
# Calling join_result_GET has no effect if the model is not set.
|
||||
|
@ -143,8 +143,8 @@ class TestAdJoin(IsolatedAsyncioTestCase):
|
|||
self.assertEqual(result, AdJoinResult.UNKNOWN)
|
||||
|
||||
async def test_join_Unknown(self):
|
||||
# Result remains UNKNOWN while ADController.join_domain is not called.
|
||||
self.controller.model.set(ADConnectionInfo(domain_name='ubuntu.com',
|
||||
# Result remains UNKNOWN while AdController.join_domain is not called.
|
||||
self.controller.model.set(AdConnectionInfo(domain_name='ubuntu.com',
|
||||
admin_name='Helper',
|
||||
password='1234'))
|
||||
|
||||
|
@ -153,7 +153,7 @@ class TestAdJoin(IsolatedAsyncioTestCase):
|
|||
|
||||
async def test_join_OK(self):
|
||||
# The equivalent of a successful POST
|
||||
self.controller.model.set(ADConnectionInfo(domain_name='ubuntu.com',
|
||||
self.controller.model.set(AdConnectionInfo(domain_name='ubuntu.com',
|
||||
admin_name='Helper',
|
||||
password='1234'))
|
||||
# Mimics a client requesting the join result. Blocking by default.
|
||||
|
@ -163,7 +163,7 @@ class TestAdJoin(IsolatedAsyncioTestCase):
|
|||
self.assertEqual(await result, AdJoinResult.OK)
|
||||
|
||||
async def test_join_Join_Error(self):
|
||||
self.controller.model.set(ADConnectionInfo(domain_name='jubuntu.com',
|
||||
self.controller.model.set(AdConnectionInfo(domain_name='jubuntu.com',
|
||||
admin_name='Helper',
|
||||
password='1234'))
|
||||
await self.controller.join_domain('this', 'AD Join')
|
||||
|
@ -171,7 +171,7 @@ class TestAdJoin(IsolatedAsyncioTestCase):
|
|||
self.assertEqual(result, AdJoinResult.JOIN_ERROR)
|
||||
|
||||
async def test_join_Pam_Error(self):
|
||||
self.controller.model.set(ADConnectionInfo(domain_name='pubuntu.com',
|
||||
self.controller.model.set(AdConnectionInfo(domain_name='pubuntu.com',
|
||||
admin_name='Helper',
|
||||
password='1234'))
|
||||
await self.controller.join_domain('this', 'AD Join')
|
||||
|
|
|
@ -259,7 +259,7 @@ class SubiquityServer(Application):
|
|||
"Identity",
|
||||
"SSH",
|
||||
"SnapList",
|
||||
"AD",
|
||||
"Ad",
|
||||
"Codecs",
|
||||
"Drivers",
|
||||
"TimeZone",
|
||||
|
|
Loading…
Reference in New Issue