rattail-demo/rattail_demo/web/views/tempmon.py

49 lines
1.3 KiB
Python
Raw Normal View History

2016-12-10 11:24:01 -06:00
# -*- 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']
2016-12-10 11:24:01 -06:00
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')