Skip to content

NAS-136285 / 25.10 / system.supported #16626

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/middlewared/middlewared/api/v25_10_0/system_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
"SystemVersionResult",
"SystemVersionShortArgs",
"SystemVersionShortResult",
"SystemSupportedArgs",
"SystemSupportedResult",
)


Expand Down Expand Up @@ -65,3 +67,11 @@ class SystemVersionShortArgs(BaseModel):

class SystemVersionShortResult(BaseModel):
result: str


class SystemSupportedArgs(BaseModel):
pass


class SystemSupportedResult(BaseModel):
result: bool
4 changes: 3 additions & 1 deletion src/middlewared/middlewared/plugins/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,13 @@ async def new_ticket(self, job, data):
For Community Edition, `criticality`, `environment`, `phone`, `name`, and `email` attributes are not required.
For Enterprise, `token` and `type` attributes are not required.
"""

vendor = await self.middleware.call('system.vendor.name')
if vendor:
raise CallError(f'Support is not available for this product ({vendor})', errno.EINVAL)

if not await self.middleware.call('system.supported'):
raise CallError('This TrueNAS build is not supported', errno.EINVAL)

await self.middleware.call('network.general.will_perform_activity', 'support')

job.set_progress(1, 'Gathering data')
Expand Down
13 changes: 13 additions & 0 deletions src/middlewared/middlewared/plugins/system/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
SystemVersionResult,
SystemVersionShortArgs,
SystemVersionShortResult,
SystemSupportedArgs,
SystemSupportedResult,
)
from middlewared.plugins.truenas import EULA_PENDING_PATH
from middlewared.service import CallError, private, Service, ValidationError
Expand Down Expand Up @@ -220,6 +222,17 @@ async def feature_enabled(self, name):
return True
return False

@api_method(
SystemSupportedArgs,
SystemSupportedResult,
roles=['SYSTEM_PRODUCT_READ']
)
async def supported(self):
"""
Return whether the current product is supported
"""
return sw_info()['supported']


async def hook_license_update(middleware, prev_product_type, *args, **kwargs):
if prev_product_type != 'ENTERPRISE' and await middleware.call('system.product_type') == 'ENTERPRISE':
Expand Down
1 change: 1 addition & 0 deletions src/middlewared/middlewared/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,7 @@ def sw_info():
'version': version,
'fullname': f'{BRAND}-{version}',
'buildtime': manifest['buildtime'],
'supported': manifest['supported'],
}


Expand Down
Loading