Пример #1
0
    def adminInterface(self, request):
        from freenasUI.network.models import GlobalConfiguration
        from freenasUI.system.models import Advanced

        view = appPool.hook_app_index('freeadmin', request)
        view = filter(None, view)
        if view:
            return view[0]

        try:
            console = Advanced.objects.all().order_by('-id')[0].adv_consolemsg
        except:
            console = False
        try:
            hostname = GlobalConfiguration.objects.order_by(
                '-id')[0].gc_hostname
        except:
            hostname = None
        sw_version = get_sw_version()
        return render(request, 'freeadmin/index.html', {
            'consolemsg': console,
            'hostname': hostname,
            'sw_name': get_sw_name(),
            'sw_version': sw_version,
            'cache_hash': hashlib.md5(sw_version).hexdigest(),
            'css_hook': appPool.get_base_css(request),
            'js_hook': appPool.get_base_js(request),
            'menu_hook': appPool.get_top_menu(request),
        })
Пример #2
0
    def adminInterface(self, request):
        from freenasUI.network.models import GlobalConfiguration
        from freenasUI.system.models import Advanced, Settings
        from freenasUI.middleware.client import client

        view = appPool.hook_app_index('freeadmin', request)
        view = filter(None, view)
        if view:
            return view[0]

        try:
            console = Advanced.objects.all().order_by('-id')[0].adv_consolemsg
        except:
            console = False
        try:
            hostname = GlobalConfiguration.objects.order_by(
                '-id')[0].get_hostname()
        except:
            hostname = None

        try:
            settings = Settings.objects.all().order_by('-id')[0]
            wizard = not settings.stg_wizardshown
            if settings.stg_wizardshown is False:
                settings.stg_wizardshown = True
                settings.save()
        except:
            wizard = False
        sw_version = get_sw_version()

        try:
            with client as c:
                middleware_token = c.call('auth.generate_token', timeout=10)
        except Exception:
            middleware_token = None
            extra_data = {
                'sw_version': sw_version,
            }
            if os.path.exists('/var/log/middlewared.log'):
                with open('/var/log/middlewared.log', 'r') as f:
                    extra_data['middlewaredlog'] = f.read()[-10240:]
            rollbar.report_exc_info(
                sys.exc_info(),
                request,
                extra_data=extra_data,
            )

        return render(
            request, 'freeadmin/index.html', {
                'consolemsg': console,
                'hostname': hostname,
                'sw_name': get_sw_name(),
                'sw_version': sw_version,
                'cache_hash': hashlib.md5(sw_version).hexdigest(),
                'css_hook': appPool.get_base_css(request),
                'js_hook': appPool.get_base_js(request),
                'menu_hook': appPool.get_top_menu(request),
                'wizard': wizard,
                'middleware_token': middleware_token,
            })
Пример #3
0
    def adminInterface(self, request):
        from freenasUI.network.models import GlobalConfiguration
        from freenasUI.system.models import Advanced

        view = appPool.hook_app_index('freeadmin', request)
        view = filter(None, view)
        if view:
            return view[0]

        try:
            console = Advanced.objects.all().order_by('-id')[0].adv_consolemsg
        except:
            console = False
        try:
            hostname = GlobalConfiguration.objects.order_by(
                '-id')[0].gc_hostname
        except:
            hostname = None
        sw_version = get_sw_version()
        return render(
            request, 'freeadmin/index.html', {
                'consolemsg': console,
                'hostname': hostname,
                'sw_name': get_sw_name(),
                'sw_version': sw_version,
                'cache_hash': hashlib.md5(sw_version).hexdigest(),
                'css_hook': appPool.get_base_css(request),
                'js_hook': appPool.get_base_js(request),
                'menu_hook': appPool.get_top_menu(request),
            })
Пример #4
0
    def adminInterface(self, request):
        from freenasUI.network.models import GlobalConfiguration
        from freenasUI.system.models import Advanced

        view = appPool.hook_app_index("freeadmin", request)
        view = filter(None, view)
        if view:
            return view[0]

        try:
            console = Advanced.objects.all().order_by("-id")[0].adv_consolemsg
        except:
            console = False
        try:
            hostname = GlobalConfiguration.objects.order_by("-id")[0].gc_hostname
        except:
            hostname = None
        sw_version = get_sw_version()
        return render(
            request,
            "freeadmin/index.html",
            {
                "consolemsg": console,
                "hostname": hostname,
                "sw_name": get_sw_name(),
                "sw_version": sw_version,
                "cache_hash": hashlib.md5(sw_version).hexdigest(),
                "css_hook": appPool.get_base_css(request),
                "js_hook": appPool.get_base_js(request),
                "menu_hook": appPool.get_top_menu(request),
            },
        )
Пример #5
0
    def adminInterface(self, request):
        from freenasUI.network.models import GlobalConfiguration
        from freenasUI.system.models import Advanced, Settings
        from freenasUI.middleware.client import client

        view = appPool.hook_app_index('freeadmin', request)
        view = filter(None, view)
        if view:
            return view[0]

        try:
            console = Advanced.objects.all().order_by('-id')[0].adv_consolemsg
        except:
            console = False
        try:
            hostname = GlobalConfiguration.objects.order_by(
                '-id')[0].get_hostname()
        except:
            hostname = None

        try:
            settings = Settings.objects.all().order_by('-id')[0]
            wizard = not settings.stg_wizardshown
            if settings.stg_wizardshown is False:
                settings.stg_wizardshown = True
                settings.save()
        except:
            wizard = False
        sw_version = get_sw_version()

        try:
            with client as c:
                middleware_token = c.call('auth.generate_token', timeout=10)
        except Exception:
            middleware_token = None
            extra_data = {
                'sw_version': sw_version,
            }
            if os.path.exists('/var/log/middlewared.log'):
                with open('/var/log/middlewared.log', 'r') as f:
                    extra_data['middlewaredlog'] = f.read()[-10240:]
            rollbar.report_exc_info(
                sys.exc_info(),
                request,
                extra_data=extra_data,
            )

        return render(request, 'freeadmin/index.html', {
            'consolemsg': console,
            'hostname': hostname,
            'sw_name': get_sw_name(),
            'sw_version': sw_version,
            'cache_hash': hashlib.md5(sw_version).hexdigest(),
            'css_hook': appPool.get_base_css(request),
            'js_hook': appPool.get_base_js(request),
            'menu_hook': appPool.get_top_menu(request),
            'wizard': wizard,
            'middleware_token': middleware_token,
        })
Пример #6
0
    def adminInterface(self, request):
        from freenasUI.network.models import GlobalConfiguration
        from freenasUI.system.models import Advanced, Settings
        from freenasUI.middleware.client import client

        view = appPool.hook_app_index('freeadmin', request)
        view = [_f for _f in view if _f]
        if view:
            return view[0]

        try:
            console = Advanced.objects.all().order_by('-id')[0].adv_consolemsg
        except:
            console = False
        try:
            hostname = GlobalConfiguration.objects.order_by(
                '-id')[0].get_hostname()
        except:
            hostname = None

        try:
            settings = Settings.objects.all().order_by('-id')[0]
            wizard = not settings.stg_wizardshown
            if settings.stg_wizardshown is False:
                settings.stg_wizardshown = True
                settings.save()
        except:
            wizard = False
        sw_version = get_sw_version()
        sw_version_footer = get_sw_version(strip_build_num=True).split('-',
                                                                       1)[-1]

        try:
            with client as c:
                middleware_token = c.call('auth.generate_token', timeout=10)
        except Exception:
            middleware_token = None
            extra_log_files = (('/var/log/middlewared.log',
                                'middlewared_log'), )
            self.trace.rollbar_report(sys.exc_info(), request, sw_version,
                                      extra_log_files)

        return render(
            request, 'freeadmin/index.html', {
                'consolemsg': console,
                'hostname': hostname,
                'sw_name': get_sw_name(),
                'sw_version': sw_version,
                'sw_version_footer': sw_version_footer,
                'cache_hash': hashlib.md5(
                    sw_version.encode('utf8')).hexdigest(),
                'css_hook': appPool.get_base_css(request),
                'js_hook': appPool.get_base_js(request),
                'menu_hook': appPool.get_top_menu(request),
                'wizard': wizard,
                'middleware_token': middleware_token,
            })
Пример #7
0
    def adminInterface(self, request):
        from freenasUI.network.models import GlobalConfiguration
        from freenasUI.system.models import Advanced, Settings

        view = appPool.hook_app_index('freeadmin', request)
        view = [_f for _f in view if _f]
        if view:
            return view[0]

        try:
            console = Advanced.objects.all().order_by('-id')[0].adv_consolemsg
        except:
            console = False
        try:
            hostname = GlobalConfiguration.objects.order_by(
                '-id')[0].get_hostname()
        except:
            hostname = None

        try:
            settings = Settings.objects.all().order_by('-id')[0]
            wizard = not settings.stg_wizardshown
            if settings.stg_wizardshown is False:
                settings.stg_wizardshown = True
                settings.save()
        except:
            wizard = False
        sw_version = get_sw_version()
        version = get_sw_version(strip_build_num=True)
        sw_version_footer = version.split('-', 1)[-1]
        sw_version_major = version.split('-')[1]

        return render(
            request, 'freeadmin/index.html', {
                'consolemsg': console,
                'hostname': hostname,
                'sw_name': get_sw_name(),
                'sw_year': get_sw_year(),
                'sw_version': sw_version,
                'sw_version_footer': sw_version_footer,
                'sw_version_major': sw_version_major,
                'cache_hash': hashlib.md5(
                    sw_version.encode('utf8')).hexdigest(),
                'css_hook': appPool.get_base_css(request),
                'js_hook': appPool.get_base_js(request),
                'menu_hook': appPool.get_top_menu(request),
                'wizard': wizard,
            })
Пример #8
0
    def adminInterface(self, request):
        from freenasUI.network.models import GlobalConfiguration
        from freenasUI.system.models import Advanced, Settings

        view = appPool.hook_app_index('freeadmin', request)
        view = [_f for _f in view if _f]
        if view:
            return view[0]

        try:
            console = Advanced.objects.all().order_by('-id')[0].adv_consolemsg
        except:
            console = False
        try:
            hostname = GlobalConfiguration.objects.order_by(
                '-id')[0].get_hostname()
        except:
            hostname = None

        try:
            settings = Settings.objects.all().order_by('-id')[0]
            wizard = not settings.stg_wizardshown
            if settings.stg_wizardshown is False:
                settings.stg_wizardshown = True
                settings.save()
        except:
            wizard = False
        sw_version = get_sw_version()
        sw_version_footer = get_sw_version(strip_build_num=True).split('-', 1)[-1]

        return render(request, 'freeadmin/index.html', {
            'consolemsg': console,
            'hostname': hostname,
            'sw_name': get_sw_name(),
            'sw_year': get_sw_year(),
            'sw_version': sw_version,
            'sw_version_footer': sw_version_footer,
            'cache_hash': hashlib.md5(sw_version.encode('utf8')).hexdigest(),
            'css_hook': appPool.get_base_css(request),
            'js_hook': appPool.get_base_js(request),
            'menu_hook': appPool.get_top_menu(request),
            'wizard': wizard,
        })