diff --git a/src/freenas/usr/local/bin/truenas-grub.py b/src/freenas/usr/local/bin/truenas-grub.py index 842bc414ae369..88403a022f1a9 100755 --- a/src/freenas/usr/local/bin/truenas-grub.py +++ b/src/freenas/usr/local/bin/truenas-grub.py @@ -3,10 +3,13 @@ import psutil import os import json +import logging from middlewared.utils.serial import serial_port_choices from middlewared.utils.db import query_config_table +from middlewared.utils.vendor import Vendors +logger = logging.getLogger(__name__) def get_serial_ports(): return {e['start']: e['name'].replace('uart', 'ttyS') for e in serial_port_choices()} @@ -16,12 +19,14 @@ def get_serial_ports(): advanced = query_config_table("system_advanced", prefix="adv_") kernel_extra_options = advanced.get("kernel_extra_options") or "" - # check for /data/.vendor + vendor = Vendors.TRUENAS_SCALE try: with open("/data/.vendor", "r") as f: - vendor = json.loads(f.read()).get("name", "TrueNAS Scale") + vendor = json.loads(f.read()).get("name", Vendors.TRUENAS_SCALE) except FileNotFoundError: - vendor = "TrueNAS Scale" + pass + except Exception: + logger.error("Failed to parse /data/.vendor", exc_info=True) # We need to allow tpm in grub as sedutil-cli requires it # `zfsforce=1` is needed because FreeBSD bootloader imports boot pool with hostid=0 while SCALE releases up to diff --git a/src/middlewared/middlewared/plugins/support.py b/src/middlewared/middlewared/plugins/support.py index c8a7735bc514f..e27e92ab173ac 100644 --- a/src/middlewared/middlewared/plugins/support.py +++ b/src/middlewared/middlewared/plugins/support.py @@ -108,6 +108,9 @@ async def is_available(self): Returns whether Proactive Support is available for this product type and current license. """ + if await self.middleware.call('system.vendor.name'): + return False + if not await self.middleware.call('system.is_enterprise'): return False @@ -224,6 +227,10 @@ async def new_ticket(self, job, data): For SCALE 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) + await self.middleware.call('network.general.will_perform_activity', 'support') job.set_progress(1, 'Gathering data')