alarams graph link broken

this change also has a fair bit of pep8 cleanup

Change-Id: I469246014a45c62150ec6841d2001523f11a6063
Closes-Bug:  #1437457
This commit is contained in:
eric 2015-03-27 12:55:58 -06:00
parent 6096575e27
commit 7b4c0a78e8
3 changed files with 110 additions and 18 deletions

View File

@ -1,6 +1,84 @@
CHANGES
=======
* Allow dynamic dashboard links
1.0.24
------
* correct tokens present in url requests
1.0.23
------
* Fixed display of HTTP exceptions
* Format timestamp to be easier to read and sortable
1.0.22
------
* Handle api returning dict rather than list
* Reformat info so it displays well with older horizon versions
* move alarm defintion name to be second column since it is useful to recognize alarm
* Added Pagerduty to Notification UI
* Added a config file for documentation generation using Markdown and readthedocs.org
1.0.21
------
* Clear leftover text when focus moves from dimension chooser
* Add general alarm information to top of alarm history
* Adding common alarm metrics dimensions to state change history
* Since API does not support actions_enabled on create, don't show in form
* Change layout of alarmdef detail to match the latest horizon CSS
* Show dashboard buttons on the same line
1.0.20
------
* Sort alarms by status initially
* Show label with status icon. Improves sorting as well
* Modify README to include steps to set up dev environment
* Outputting common dimensions for multiple metrics
* Added a button for the Monasca Health dashboard https://blueprints.launchpad.net/monasca/+spec/monitoring-of-monitoring
* Fix filter action logic to allow server side filtering in future
* Fixed a dead link in the documentation to alarm expressions. Changed it to the github repo docs
* Remove some old unused code
1.0.19
------
* Allow edits to threshold value
* Use relative path from overview to alarm drill down
* Add support for non-default WSGIScriptAlias
* Ensure that dimensions do not extend beyond field
* Backout change for dimension length. No break characters
* Allow bulk delete of notifications
* Fix layout of metrics with long dimension
* Adding option to select WEBHOOK notification
1.0.18
------
* Cleanup up templates and docs for forms
* Fix validation of notification fields
* Clean up some small changes
1.0.17
------
* Pass in monasca-api endpoint to grafana
* Only show panesl when the service is in catalog
* Pare down requirements.txt to minimum
* Added monasca-ui permissions policy
* Moved files for better egg packaging
1.0.16
------
* Allow service type to be customized
* Fix bug where we were not saving threshold values in expression editor
1.0.15
------

View File

@ -17,14 +17,17 @@
import logging
from django.core import urlresolvers
from django.core.urlresolvers import reverse_lazy
from django import template
from django.utils.translation import ugettext_lazy as _ # noqa
from horizon import tables
from monitoring.alarms import constants
from monitoring.overview import constants as ov_constants
from monitoring import api
LOG = logging.getLogger(__name__)
@ -78,15 +81,19 @@ def show_metric_dimensions(data):
commondimensions = data['metrics'][0]['dimensions']
for metric in data['metrics'][1:]:
for k in commondimensions.keys():
if k not in metric['dimensions'].keys() or commondimensions[k] != metric['dimensions'][k]:
if k not in metric['dimensions'].keys() or \
commondimensions[k] != metric['dimensions'][k]:
del commondimensions[k]
return ','.join(["%s=%s" % (n, v) for n,v in commondimensions.items()])
return ','.join(["%s=%s" % (n, v) for n, v
in commondimensions.items()])
else:
return ','.join(["%s=%s" % (n, v) for n,v in data['metrics'][0]['dimensions'].items()])
return ','.join(["%s=%s" % (n, v) for n, v
in data['metrics'][0]['dimensions'].items()])
def get_service(data):
if len(data['metrics']) == 1 and 'service' in data['metrics'][0]['dimensions']:
if len(data['metrics']) == 1 and 'service'in\
data['metrics'][0]['dimensions']:
return data['metrics'][0]['dimensions']['service']
else:
return ''
@ -99,7 +106,8 @@ class ShowAlarmHistory(tables.LinkAction):
def get_link_url(self, datum):
return urlresolvers.reverse(constants.URL_PREFIX + 'history',
args=(datum['alarm_definition']['id'], datum['id'], ))
args=(datum['alarm_definition']['id'],
datum['id'], ))
def allowed(self, request, datum=None):
return True
@ -147,12 +155,12 @@ class GraphMetric(tables.LinkAction):
def get_link_url(self, datum):
name = datum['metrics'][0]['name']
threshold = datum['metrics']
token = self.table.request.user.token.id
endpoint = api.monitor.monasca_endpoint(self.table.request)
endpoint = str(reverse_lazy(ov_constants.URL_PREFIX + 'proxy'))
endpoint = self.table.request.build_absolute_uri(endpoint)
self.attrs['target'] = '_blank'
url = '/static/grafana/index.html#/dashboard/script/detail.js'
query = "?token=%s&name=%s&threshold=%s&api=%s" % \
(token, name, threshold, endpoint)
query = "?name=%s&threshold=%s&api=%s" % \
(name, threshold, endpoint)
return url + query
def allowed(self, request, datum=None):
@ -164,8 +172,9 @@ class ShowAlarmDefinition(tables.LinkAction):
verbose_name = _("Show Alarm Definition")
def get_link_url(self, datum=None):
return urlresolvers.reverse_lazy('horizon:monitoring:alarmdefs:alarm_detail',
args=(datum['alarm_definition']['id'],))
url = 'horizon:monitoring:alarmdefs:alarm_detail'
args = (datum['alarm_definition']['id'],)
return urlresolvers.reverse_lazy(url, args=args)
class DeleteAlarm(tables.DeleteAction):
@ -191,11 +200,13 @@ class AlarmsFilterAction(tables.FilterAction):
class AlarmsTable(tables.DataTable):
state = tables.Column(transform=show_severity, verbose_name=_('Status'),
status_choices={(show_status('OK'), True)},
filters=[show_status, template.defaultfilters.safe])
status_choices={(show_status('OK'), True)},
filters=[show_status, template.defaultfilters.safe])
name = tables.Column(transform=show_def_name, verbose_name=_('Name'))
metrics = tables.Column(transform=show_metric_name, verbose_name=_('Metric Name'))
dimensions = tables.Column(transform=show_metric_dimensions, verbose_name=_('Metric Dimensions'))
metrics = tables.Column(transform=show_metric_name,
verbose_name=_('Metric Name'))
dimensions = tables.Column(transform=show_metric_dimensions,
verbose_name=_('Metric Dimensions'))
def get_object_id(self, obj):
return obj['id']
@ -213,7 +224,7 @@ class AlarmsTable(tables.DataTable):
)
table_actions = (AlarmsFilterAction,
DeleteAlarm,
)
)
def show_timestamp(data):
@ -221,10 +232,12 @@ def show_timestamp(data):
class AlarmHistoryTable(tables.DataTable):
timestamp = tables.Column(transform=show_timestamp, verbose_name=_('Timestamp'))
timestamp = tables.Column(transform=show_timestamp,
verbose_name=_('Timestamp'))
old_state = tables.Column('old_state', verbose_name=_('Old State'))
new_state = tables.Column('new_state', verbose_name=_('New State'))
alarmDimensions = tables.Column(transform=show_metric_dimensions, verbose_name=_('Alarm Metric Dimensions'))
alarmDimensions = tables.Column(transform=show_metric_dimensions,
verbose_name=_('Alarm Metric Dimensions'))
reason = tables.Column('reason', verbose_name=_('Reason'))
# reason_data = tables.Column('reason_data', verbose_name=_('Reason Data'))

View File

@ -1 +1,2 @@
python-monascaclient
django<1.8