Fix all pep8 errors except demo code in views.
This commit is contained in:
parent
83cb98ac1c
commit
775ba50047
@ -16,4 +16,3 @@ ADD_INSTALLED_APPS = ['monitoring']
|
|||||||
|
|
||||||
# A list of angular modules to be added as dependencies to horizon app.
|
# A list of angular modules to be added as dependencies to horizon app.
|
||||||
#ADD_ANGULAR_MODULE = ['monitoringApp']
|
#ADD_ANGULAR_MODULE = ['monitoringApp']
|
||||||
|
|
||||||
|
@ -55,13 +55,16 @@ def monclient(request, password=None):
|
|||||||
def alarm_list(request, marker=None, paginate=False):
|
def alarm_list(request, marker=None, paginate=False):
|
||||||
return monclient(request).alarms.list()
|
return monclient(request).alarms.list()
|
||||||
|
|
||||||
|
|
||||||
def alarm_list_by_service(request, service_name, marker=None, paginate=False):
|
def alarm_list_by_service(request, service_name, marker=None, paginate=False):
|
||||||
service_dim = {'service' : service_name}
|
service_dim = {'service': service_name}
|
||||||
return monclient(request).alarms.list(dimensions=service_dim)
|
return monclient(request).alarms.list(dimensions=service_dim)
|
||||||
|
|
||||||
|
|
||||||
def alarm_delete(request, alarm_id):
|
def alarm_delete(request, alarm_id):
|
||||||
return monclient(request).alarms.delete(alarm_id=alarm_id)
|
return monclient(request).alarms.delete(alarm_id=alarm_id)
|
||||||
|
|
||||||
|
|
||||||
def alarm_get(request, alarm_id):
|
def alarm_get(request, alarm_id):
|
||||||
return monclient(request).alarms.get(alarm_id=alarm_id)
|
return monclient(request).alarms.get(alarm_id=alarm_id)
|
||||||
|
|
||||||
@ -83,7 +86,8 @@ def notification_delete(request, notification_id):
|
|||||||
|
|
||||||
|
|
||||||
def notification_get(request, notification_id):
|
def notification_get(request, notification_id):
|
||||||
return monclient(request).notifications.get(notification_id=notification_id)
|
return monclient(request).notifications. \
|
||||||
|
get(notification_id=notification_id)
|
||||||
|
|
||||||
|
|
||||||
def notification_create(request, **kwargs):
|
def notification_create(request, **kwargs):
|
||||||
@ -96,5 +100,3 @@ def notification_update(request, notification_id, **kwargs):
|
|||||||
|
|
||||||
def metrics_list(request, marker=None, paginate=False):
|
def metrics_list(request, marker=None, paginate=False):
|
||||||
return monclient(request).metrics.list()
|
return monclient(request).metrics.list()
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,8 +31,7 @@ class NotificationType(object):
|
|||||||
if choice[0] == key:
|
if choice[0] == key:
|
||||||
return choice[1]
|
return choice[1]
|
||||||
return key
|
return key
|
||||||
|
ß
|
||||||
OVERCLOUD_SERVICES = ["Nova","Swift","Cinder","Glance","Neutron","MySQL","RabbitMQ","Monitoring"]
|
|
||||||
|
|
||||||
PHONE_VALIDATOR = validators.RegexValidator(
|
PHONE_VALIDATOR = validators.RegexValidator(
|
||||||
regex=r"^\+[()0-9 ]{5,20}$",
|
regex=r"^\+[()0-9 ]{5,20}$",
|
||||||
|
@ -26,6 +26,7 @@ from horizon import messages
|
|||||||
from monitoring import api
|
from monitoring import api
|
||||||
from monitoring import constants
|
from monitoring import constants
|
||||||
|
|
||||||
|
|
||||||
def get_expression(meter):
|
def get_expression(meter):
|
||||||
expr = meter['name']
|
expr = meter['name']
|
||||||
args = None
|
args = None
|
||||||
@ -38,12 +39,14 @@ def get_expression(meter):
|
|||||||
args += "%s=%s" % (name, value)
|
args += "%s=%s" % (name, value)
|
||||||
return "%s{%s}" % (expr, args)
|
return "%s{%s}" % (expr, args)
|
||||||
|
|
||||||
|
|
||||||
class SimpleExpressionWidget(django_forms.MultiWidget):
|
class SimpleExpressionWidget(django_forms.MultiWidget):
|
||||||
def __init__(self, meters=None, attrs=None):
|
def __init__(self, meters=None, attrs=None):
|
||||||
choices = [(get_expression(m), get_expression(m)) for m in meters]
|
choices = [(get_expression(m), get_expression(m)) for m in meters]
|
||||||
|
comparators = [('>', '>'), ('<', '<'), ('=', '=')]
|
||||||
_widgets = (
|
_widgets = (
|
||||||
django_forms.widgets.Select(attrs=attrs, choices=choices),
|
django_forms.widgets.Select(attrs=attrs, choices=choices),
|
||||||
django_forms.widgets.Select(attrs=attrs, choices=[('>', '>'), ('<', '<'), ('=', '=')]),
|
django_forms.widgets.Select(attrs=attrs, choices=comparatorsß),
|
||||||
django_forms.widgets.TextInput(attrs=attrs),
|
django_forms.widgets.TextInput(attrs=attrs),
|
||||||
)
|
)
|
||||||
super(SimpleExpressionWidget, self).__init__(_widgets, attrs)
|
super(SimpleExpressionWidget, self).__init__(_widgets, attrs)
|
||||||
@ -218,7 +221,8 @@ class BaseAlarmForm(forms.SelfHandlingForm):
|
|||||||
self.fields['state'] = forms.CharField(label=_("State"),
|
self.fields['state'] = forms.CharField(label=_("State"),
|
||||||
required=False,
|
required=False,
|
||||||
widget=textWidget)
|
widget=textWidget)
|
||||||
self.fields['actions_enabled'] = forms.BooleanField(label=_("Notifications Enabled"),
|
self.fields['actions_enabled'] = \
|
||||||
|
forms.BooleanField(label=_("Notifications Enabled"),
|
||||||
required=False,
|
required=False,
|
||||||
initial=True)
|
initial=True)
|
||||||
self.fields['notifications'] = NotificationField(
|
self.fields['notifications'] = NotificationField(
|
||||||
|
@ -144,7 +144,8 @@ class AlarmsTable(tables.DataTable):
|
|||||||
service = tables.Column(transform=show_service, verbose_name=_('Service'))
|
service = tables.Column(transform=show_service, verbose_name=_('Service'))
|
||||||
state = tables.Column('state', verbose_name=_('State'))
|
state = tables.Column('state', verbose_name=_('State'))
|
||||||
expression = tables.Column('expression', verbose_name=_('Expression'))
|
expression = tables.Column('expression', verbose_name=_('Expression'))
|
||||||
enabled = tables.Column('actions_enabled', verbose_name=_('Notifications Enabled'))
|
enabled = tables.Column('actions_enabled',
|
||||||
|
verbose_name=_('Notifications Enabled'))
|
||||||
|
|
||||||
def get_object_id(self, obj):
|
def get_object_id(self, obj):
|
||||||
return obj['id']
|
return obj['id']
|
||||||
@ -152,7 +153,10 @@ class AlarmsTable(tables.DataTable):
|
|||||||
class Meta:
|
class Meta:
|
||||||
name = "alarms"
|
name = "alarms"
|
||||||
verbose_name = _("Alarms")
|
verbose_name = _("Alarms")
|
||||||
row_actions = (ShowAlarmHistory, ShowAlarmMeters, DeleteAlarm, EditAlarm, )
|
row_actions = (ShowAlarmHistory,
|
||||||
|
ShowAlarmMeters,
|
||||||
|
DeleteAlarm,
|
||||||
|
EditAlarm, )
|
||||||
table_actions = (CreateNotification, CreateAlarm, )
|
table_actions = (CreateNotification, CreateAlarm, )
|
||||||
status_columns = ['status']
|
status_columns = ['status']
|
||||||
|
|
||||||
|
@ -34,8 +34,16 @@ urlpatterns = patterns(
|
|||||||
url(r'^meters/(?P<service>[^/]+)$',
|
url(r'^meters/(?P<service>[^/]+)$',
|
||||||
views.AlarmMeterView.as_view(),
|
views.AlarmMeterView.as_view(),
|
||||||
name='meters'),
|
name='meters'),
|
||||||
url(r'^alarm_create$', views.AlarmCreateView.as_view(), name='alarm_create'),
|
url(r'^alarm_create$',
|
||||||
url(r'^(?P<id>[^/]+)/alarm_detail/$', views.AlarmDetailView.as_view(), name='alarm_detail'),
|
views.AlarmCreateView.as_view(),
|
||||||
url(r'^(?P<id>[^/]+)/alarm_edit/$', views.AlarmEditView.as_view(), name='alarm_edit'),
|
name='alarm_create'),
|
||||||
url(r'^notification_create$', views.NotificationCreateView.as_view(), name='notification_create'),
|
url(r'^(?P<id>[^/]+)/alarm_detail/$',
|
||||||
|
views.AlarmDetailView.as_view(),
|
||||||
|
name='alarm_detail'),
|
||||||
|
url(r'^(?P<id>[^/]+)/alarm_edit/$',
|
||||||
|
views.AlarmEditView.as_view(),
|
||||||
|
name='alarm_edit'),
|
||||||
|
url(r'^notification_create$',
|
||||||
|
views.NotificationCreateView.as_view(),
|
||||||
|
name='notification_create'),
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user