46 lines
1.2 KiB
Python
46 lines
1.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""
|
|
Tempmon views
|
|
"""
|
|
|
|
from __future__ import unicode_literals, absolute_import
|
|
|
|
from tailbone.views.tempmon.clients import TempmonClientView as BaseTempmonClientView
|
|
from tailbone.views.tempmon.probes import TempmonProbeView as BaseTempmonProbeView
|
|
|
|
|
|
class TempmonClientView(BaseTempmonClientView):
|
|
"""
|
|
Prevent edit/delete for 'demo' client
|
|
"""
|
|
|
|
def editable_instance(self, client):
|
|
return client.config_key != 'demo'
|
|
|
|
def deletable_instance(self, client):
|
|
return client.config_key != 'demo'
|
|
|
|
def restartable_client(self, client):
|
|
return client.config_key == 'demo'
|
|
|
|
def get_restart_cmd(self, client):
|
|
return ['ssh', 'demo.rattailproject.org', 'sudo service demo-tempmon-client restart']
|
|
|
|
|
|
class TempmonProbeView(BaseTempmonProbeView):
|
|
"""
|
|
Prevent edit/delete for 'demo' probe
|
|
"""
|
|
|
|
def editable_instance(self, probe):
|
|
return probe.config_key != 'demo'
|
|
|
|
def deletable_instance(self, probe):
|
|
return probe.config_key != 'demo'
|
|
|
|
|
|
def includeme(config):
|
|
TempmonClientView.defaults(config)
|
|
TempmonProbeView.defaults(config)
|
|
config.include('tailbone.views.tempmon.readings')
|