49 lines
1.3 KiB
Python
49 lines
1.3 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):
|
|
if self.rattail_config.production():
|
|
return ['ssh', 'demo.rattailproject.org', 'sudo service demo-tempmon-client restart']
|
|
# just mock it out when testing
|
|
return ['sleep', '2']
|
|
|
|
|
|
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')
|