diff --git a/monitoring/api/__init__.py b/monitoring/api/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/monitoring/api/__init__.pyc b/monitoring/api/__init__.pyc
new file mode 100644
index 00000000..35c10253
Binary files /dev/null and b/monitoring/api/__init__.pyc differ
diff --git a/monitoring/api/monitoring.py b/monitoring/api/monitoring.py
new file mode 100644
index 00000000..154d5d05
--- /dev/null
+++ b/monitoring/api/monitoring.py
@@ -0,0 +1,99 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import logging
+
+from django.conf import settings
+from monclient import client as mon_client
+from horizon.utils import functions as utils
+from openstack_dashboard.api import base
+
+LOG = logging.getLogger(__name__)
+
+
+class AttrStore:
+ pass
+
+def format_parameters(params):
+ parameters = {}
+ for count, p in enumerate(params, 1):
+ parameters['Parameters.member.%d.ParameterKey' % count] = p
+ parameters['Parameters.member.%d.ParameterValue' % count] = params[p]
+ return parameters
+
+
+def monclient(request, password=None):
+ api_version = "2_0"
+ insecure = getattr(settings, 'OPENSTACK_SSL_NO_VERIFY', False)
+ cacert = getattr(settings, 'OPENSTACK_SSL_CACERT', None)
+ endpoint = 'http://192.168.10.4:8080/v2.0' # base.url_for(request, 'orchestration')
+ LOG.debug('monclient connection created using token "%s" and url "%s"' %
+ (request.user.token.id, endpoint))
+ kwargs = {
+ 'token': request.user.token.id,
+ 'insecure': insecure,
+ 'ca_file': cacert,
+ 'username': request.user.username,
+ 'password': password
+ #'timeout': args.timeout,
+ #'ca_file': args.ca_file,
+ #'cert_file': args.cert_file,
+ #'key_file': args.key_file,
+ }
+ client = mon_client.Client(api_version, endpoint, **kwargs)
+ client.format_parameters = format_parameters
+ return client
+
+
+def alarm_list(request, marker=None, paginate=False):
+ limit = getattr(settings, 'API_RESULT_LIMIT', 1000)
+ page_size = utils.get_page_size(request)
+
+ if paginate:
+ request_size = page_size + 1
+ else:
+ request_size = limit
+
+ kwargs = {}
+ if marker:
+ kwargs['marker'] = marker
+ args = AttrStore()
+ args.runlocal = True
+ args.os_tenant_id = "12345678"
+ alarm_iter = monclient(request).alarms.list(args, **kwargs)
+
+ has_more_data = False
+ alarms = list(alarm_iter)
+ if paginate:
+ if len(alarms) > page_size:
+ alarms.pop()
+ has_more_data = True
+ return (alarms, has_more_data)
+
+
+def alarm_delete(request, alarm_id):
+ return monclient(request).alarm.delete(alarm_id)
+
+
+def alarm_get(request, alarm_id):
+ return monclient(request).alarm.get(alarm_id)
+
+
+def alarm_create(request, password=None, **kwargs):
+ return monclient(request, password).alarm.create(**kwargs)
+
+
+def alarm_update(request, alarm_id, **kwargs):
+ return monclient(request).alarm.update(alarm_id, **kwargs)
+
diff --git a/monitoring/api/monitoring.pyc b/monitoring/api/monitoring.pyc
new file mode 100644
index 00000000..2d6b81ad
Binary files /dev/null and b/monitoring/api/monitoring.pyc differ
diff --git a/monitoring/static/monitoring/js/alarms.html b/monitoring/static/monitoring/js/alarms.html
deleted file mode 100644
index df022d99..00000000
--- a/monitoring/static/monitoring/js/alarms.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/monitoring/static/monitoring/js/animation.html b/monitoring/static/monitoring/js/animation.html
deleted file mode 100644
index c84f2f5b..00000000
--- a/monitoring/static/monitoring/js/animation.html
+++ /dev/null
@@ -1,118 +0,0 @@
-
-
-
-
-CoverFlow
-
-
-
-
-
-
- value
-
-
-
\ No newline at end of file
diff --git a/monitoring/static/monitoring/js/animations.js b/monitoring/static/monitoring/js/animations.js
deleted file mode 100644
index b40ddb06..00000000
--- a/monitoring/static/monitoring/js/animations.js
+++ /dev/null
@@ -1,52 +0,0 @@
-var monitoringAnimations = angular.module('monitoring.animations', ['ngAnimate']);
-
-monitoringAnimations.animation('.phone', function() {
-
- var animateUp = function(element, className, done) {
- if(className != 'active') {
- return;
- }
- element.css({
- position: 'absolute',
- top: 500,
- left: 0,
- display: 'block'
- });
-
- jQuery(element).animate({
- top: 0
- }, done);
-
- return function(cancel) {
- if(cancel) {
- element.stop();
- }
- };
- }
-
- var animateDown = function(element, className, done) {
- if(className != 'active') {
- return;
- }
- element.css({
- position: 'absolute',
- left: 0,
- top: 0
- });
-
- jQuery(element).animate({
- top: -500
- }, done);
-
- return function(cancel) {
- if(cancel) {
- element.stop();
- }
- };
- }
-
- return {
- addClass: animateUp,
- removeClass: animateDown
- };
-});
diff --git a/monitoring/static/monitoring/js/controllers.js b/monitoring/static/monitoring/js/controllers.js
index 52283012..a432f8b1 100644
--- a/monitoring/static/monitoring/js/controllers.js
+++ b/monitoring/static/monitoring/js/controllers.js
@@ -1,61 +1,7 @@
'use strict';
angular.module('monitoring.controllers', [])
.controller('monitoringController', function ($scope, $http) {
- $scope._serviceModel = [{'name': 'Platform Services',
- 'services': [{'name': 'MaaS',
- 'display': 'MaaS'},
- {'name': 'DBaaS',
- 'display': 'DBaaS'},
- {'name': 'LBaaS',
- 'display': 'LBaaS'},
- {'name': 'DNSaaS',
- 'display': 'DNSaaS'},
- {'name': 'MSGaaS',
- 'display': 'MSGaaS'},
- ]},
- {'name': 'The OverCloud Services',
- 'services': [{'name': 'nova',
- 'display': 'Nova'},
- {'name': 'swift',
- 'display': 'Swift'},
- {'name': 'bock',
- 'display': 'Cinder'},
- {'name': 'glance',
- 'display': 'Glance'},
- {'name': 'quantum',
- 'display': 'Neutron'},
- {'name': 'mysql',
- 'display': 'MySQL'},
- {'name': 'rabbitmq',
- 'display': 'RabbitMQ'},
- ]},
- {'name': 'The UnderCloud Services',
- 'services': [{'name': 'nova',
- 'display': 'Nova'},
- {'name': 'swift',
- 'display': 'Cinder'},
- {'name': 'glance',
- 'display': 'Glance'},
- {'name': 'horizon',
- 'display': 'Horizon'},
- ]},
- {'name': 'Network Services',
- 'services': [{'name': 'dhcp',
- 'display': 'DHCP'},
- {'name': 'dns',
- 'display': 'DNS'},
- {'name': 'dns-servers',
- 'display': 'DNS Servers'},
- {'name': 'http',
- 'display': 'http'},
- {'name': 'web_proxy',
- 'display': 'Web Proxy'}
- ]}
- ]
- $scope.setStatus = function() {
- $scope.fetchStatus()
- };
- $scope.fetchStatus = function() {
+ $scope.fetchStatus = function() {
$http({method: 'GET', url: '/admin/monitoring/status'}).
success(function(data, status, headers, config) {
// this callback will be called asynchronously
@@ -76,22 +22,7 @@ angular.module('monitoring.controllers', [])
alert("error")
});
}
- $scope.serviceModel = function() {
- $scope.setStatus()
- return $scope._serviceModel
- }
- $scope.current = 1;
- $scope.showService = function(ev) {
- // href="#/alarms/{{service.name}}"
- console.log(ev.clientX, ev.clientY);
- //$("#current"+$scope.current)[0].style.webkitTransform = "scale3d(10, 10, +1)"
- //$("#current"+$scope.current).style.opacity = "0"
- //$("#current"+$scope.current).style.visibility = false
- $scope.current += 1;
- //$("#current"+$scope.current)[0].style.webkitTransform = "translate3d(0,-400px,-1)"
- };
- $scope.format = 'M/d/yy h:mm:ss a';
- })
+ })
.controller('alarmController', function($scope) {
$scope.myData = [{name: "API Response Time", status: 'Normal'},
{name: "System Health", status: 'Normal'},
@@ -102,23 +33,6 @@ angular.module('monitoring.controllers', [])
columnDefs: [{field:'name', displayName:'Name'}, {field:'status', displayName:'Status'}]};
});
-function getRandomStatusValue() {
- var distribution = [
- {prob:.04, value:'alert-error'},
- {prob:.04, value:'alert-warning'},
- {prob:.04, value:'alert-unknown'},
- {prob:.04, value:'alert-notfound'},
- {value:'alert-success'},
- ]
- var num = Math.random()
- for (var i=0; i < distribution.length - 1; i++) {
- if (num < distribution[i]["prob"])
- return distribution[i]["value"]
- num = num - distribution[i]["prob"]
- }
- return distribution[distribution.length - 1]["value"]
-}
-
function getIcon(status) {
if (status === 'alert-error')
return '/static/monitoring/img/critical-icon.png'
diff --git a/monitoring/templates/monitoring/_scripts.html b/monitoring/templates/monitoring/_scripts.html
index 544fc907..af34e863 100644
--- a/monitoring/templates/monitoring/_scripts.html
+++ b/monitoring/templates/monitoring/_scripts.html
@@ -1,5 +1,4 @@
+
-
-
\ No newline at end of file
diff --git a/monitoring/templates/monitoring/index.html b/monitoring/templates/monitoring/index.html
index 0c55f21e..5550f0c8 100644
--- a/monitoring/templates/monitoring/index.html
+++ b/monitoring/templates/monitoring/index.html
@@ -7,5 +7,5 @@
{% endblock page_header %}
{% load url from future %}
{% block main %}
- {% include 'admin/monitoring/monitorng.html' %}
+ {% include 'admin/monitoring/newmonitor.html' %}
{% endblock %}
\ No newline at end of file
diff --git a/monitoring/templates/monitoring/monitor.html b/monitoring/templates/monitoring/monitor.html
index 7b96fe53..e82af159 100644
--- a/monitoring/templates/monitoring/monitor.html
+++ b/monitoring/templates/monitoring/monitor.html
@@ -1,5 +1,4 @@
-
-
+
{% for group in service_groups %}
diff --git a/monitoring/static/monitoring/js/health.html b/monitoring/templates/monitoring/newmonitor.html
similarity index 52%
rename from monitoring/static/monitoring/js/health.html
rename to monitoring/templates/monitoring/newmonitor.html
index 1b31de4c..1041d3cf 100644
--- a/monitoring/static/monitoring/js/health.html
+++ b/monitoring/templates/monitoring/newmonitor.html
@@ -19,27 +19,28 @@ border-color: blue;
color: lightgrey;
}
.diagram {
- -webkit-transition: all 600ms ease-in-out;
- background-color: darkgray;
padding: 5px;
}
-
+
Current time is:
- {{ group.name }}
+ {$ group.name $}
+
+
+
+
diff --git a/monitoring/views.py b/monitoring/views.py
index 74fd1b9f..ece807a8 100644
--- a/monitoring/views.py
+++ b/monitoring/views.py
@@ -24,9 +24,11 @@ from django.utils.translation import ugettext as _
from django.views.generic import TemplateView
from horizon import tables
+
+from monitoring.api import monitoring
+
from .tables import AlertsTable
from .tables import AlertHistoryTable
-from openstack_dashboard import api
LOG = logging.getLogger(__name__)
@@ -140,7 +142,7 @@ class StatusView(TemplateView):
def get(self, request, *args, **kwargs):
services = ['MaaS',
]
- #api.monitoring.alarm_list(self.request)
+ #monitoring.alarm_list(self.request)
for group in SAMPLE:
for service in group['services']:
service['class'] = get_random_status()
@@ -151,21 +153,6 @@ class StatusView(TemplateView):
return HttpResponse(json.dumps(ret),
content_type='application/json')
-def get_random_status():
- distribution = [
- {'prob':.04, 'value':'alert-error'},
- {'prob':.04, 'value':'alert-warning'},
- {'prob':.04, 'value':'alert-unknown'},
- {'prob':.04, 'value':'alert-notfound'},
- {'prob':1.0, 'value':'alert-success'},
- ]
- num = random.random()
- for dist in distribution:
- if num < dist["prob"]:
- return dist["value"]
- num = num - dist["prob"]
- return distribution[len(distribution) - 1]["value"]
-
class AlertView(tables.DataTableView):
table_class = AlertsTable
@@ -224,3 +211,19 @@ class AlertHistoryView(tables.DataTableView):
class AlertMeterView(TemplateView):
template_name = 'admin/monitoring/alert_meter.html'
+
+
+def get_random_status():
+ distribution = [
+ {'prob':.04, 'value':'alert-error'},
+ {'prob':.04, 'value':'alert-warning'},
+ {'prob':.04, 'value':'alert-unknown'},
+ {'prob':.04, 'value':'alert-notfound'},
+ {'prob':1.0, 'value':'alert-success'},
+ ]
+ num = random.random()
+ for dist in distribution:
+ if num < dist["prob"]:
+ return dist["value"]
+ num = num - dist["prob"]
+ return distribution[len(distribution) - 1]["value"]
\ No newline at end of file