# Copyright (c) 2015 iXsystems, Inc.
# All rights reserved.
# This file is a part of TrueNAS
# and may not be copied and/or distributed
# without the express permission of iXsystems.

from django.utils.translation import ugettext as _

from freenasUI.system.alert import alertPlugins, Alert, BaseAlert
from freenasUI.system.models import SystemDataset


class SystemDatasetAlert(BaseAlert):

    def run(self):
        sysds = SystemDataset.objects.order_by('-id')
        if not sysds.exists():
            return
        sysds = sysds[0]
        if sysds.sys_pool != 'freenas-boot':
            return [Alert(
                Alert.WARN,
                _('System dataset is recommended to be set to freenas-boot pool.')
            )]

alertPlugins.register(SystemDatasetAlert)
