Skip to content

Commit

Permalink
Cleanup dead code and remove extra parameters (#14044)
Browse files Browse the repository at this point in the history
This commit removes final clustering-related endpoints from middleware
that were potentially being used by older versions of TrueCommand to
detect whether TrueNAS was clustered.

It also removes special extra parameters usage from user/group.query
to specify getting additional information that is now provided by
default.
  • Loading branch information
anodos325 authored Jul 19, 2024
1 parent 8ecbeec commit 137411a
Show file tree
Hide file tree
Showing 10 changed files with 9 additions and 964 deletions.
9 changes: 2 additions & 7 deletions src/middlewared/middlewared/plugins/account_/2fa.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,11 @@ async def translate_username(self, username):
Translates `username` to a user object.
"""
try:
user = await self.middleware.call('user.get_user_obj', {'username': username, 'sid_info': True})
user = await self.middleware.call('user.get_user_obj', {'username': username})
except KeyError:
raise CallError(f'User {username!r} does not exist', errno.ENOENT)

return await self.middleware.call(
'user.query', [['username', '=', user['pw_name']]], {
'get': True,
'extra': {'additional_information': ['SMB']},
}
)
return await self.middleware.call('user.query', [['username', '=', user['pw_name']]], {'get': True})

@accepts(Str('username'))
@returns()
Expand Down
11 changes: 2 additions & 9 deletions src/middlewared/middlewared/plugins/account_/privilege.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,7 @@ async def _validate(self, schema_name, data, id_=None):
verrors.check()

async def _groups(self):
groups = await self.middleware.call(
"group.query",
[],
{"extra": {"additional_information": ["DS", "SMB"]}},
)
groups = await self.middleware.call("group.query")
by_gid = {group["gid"]: group for group in groups}
by_sid = {
group["sid"]: group
Expand Down Expand Up @@ -296,10 +292,7 @@ async def _ds_groups(self, groups, ds_groups, *, include_nonexistent=True):
group = await self.middleware.call(
"group.query",
[["gid", "=", gid]],
{
"extra": {"additional_information": ["DS", "SMB"]},
"get": True,
},
{"get": True},
)
except MatchNotFound:
if include_nonexistent:
Expand Down
8 changes: 4 additions & 4 deletions src/middlewared/middlewared/plugins/auth_/2fa.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from middlewared.schema import accepts, Bool, Dict, Int, Patch
from middlewared.service import CallError, ConfigService, periodic, private
from middlewared.utils.directoryservices.constants import DSStatus, DSType
from middlewared.validators import Range


Expand Down Expand Up @@ -116,9 +117,7 @@ def get_users_config(self):
users = []
mapping = {
user['sid']: user for user in self.middleware.call_sync(
'user.query', [['local', '=', False], ['sid', '!=', None]], {
'extra': {'additional_information': ['DS', 'SMB']},
}
'user.query', [['local', '=', False], ['sid', '!=', None]]
)
}
for config in self.middleware.call_sync(
Expand Down Expand Up @@ -155,7 +154,8 @@ async def get_ad_users(self):
@periodic(interval=86400, run_on_start=False)
@private
async def remove_expired_secrets(self):
if (await self.middleware.call('directoryservices.get_state'))['activedirectory'] != 'HEALTHY':
ds = await self.middleware.call('directoryservices.status')
if ds['type'] != DSType.AD.value or ds['status'] != DSStatus.HEALTHY.name:
return

ad_users = await self.get_ad_users()
Expand Down
Empty file.
132 changes: 0 additions & 132 deletions src/middlewared/middlewared/plugins/cluster_linux/ctdb_event.py

This file was deleted.

This file was deleted.

Loading

0 comments on commit 137411a

Please sign in to comment.