From 12609204760b9b06dbb2ec2c214ca5f96fde0921 Mon Sep 17 00:00:00 2001 From: Vincent Fournier Date: Wed, 20 May 2015 12:19:44 -0400 Subject: [PATCH] Remove adagios backend Change-Id: Ib6be5235c026fcd527f6db7ac305d8e739afae54 --- .gitignore | 2 - Dockerfile | 4 +- Gruntfile.js | 65 ++-- Makefile | 4 +- README.rst | 8 - app/components/live/adagios.js | 377 -------------------- app/components/live/adagios_test.js | 25 -- app/components/live/{surveil.js => live.js} | 0 container/configure.sh | 4 - 9 files changed, 23 insertions(+), 466 deletions(-) delete mode 100644 app/components/live/adagios.js delete mode 100644 app/components/live/adagios_test.js rename app/components/live/{surveil.js => live.js} (100%) diff --git a/.gitignore b/.gitignore index 9e6467f..be82e53 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,4 @@ out/ dist/ .tmp/ -app/components/live/live.js - app/components/config/developmentConfig.json diff --git a/Dockerfile b/Dockerfile index 9898f94..e172fb2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,13 +31,11 @@ RUN cd /opt/bansho/ && npm install --unsafe-perm ADD /app /opt/bansho/app # Override those variables at runtime to point Bansho to another backend -ENV BANSHO_BACKEND surveil ENV BANSHO_PROD true ENV BANSHO_SURVEIL_URL http://surveil:8080/ -ENV BANSHO_ADAGIOS_URL http://demo.kaji-project.org/ ENV BANSHO_AUTH_URL http://surveil:8080/v2/auth/ CMD ./configure.sh && \ cd /opt/bansho && \ - bash -c "if [ $BANSHO_PROD = true ] ; then grunt production:$BANSHO_BACKEND ; fi" && \ + bash -c "if [ $BANSHO_PROD = true ] ; then grunt production ; fi" && \ bash -c "source /etc/apache2/envvars && exec /usr/sbin/apache2 -DFOREGROUND" diff --git a/Gruntfile.js b/Gruntfile.js index db446fb..cbaec83 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -53,22 +53,6 @@ module.exports = function (grunt) { } ] }, - adagios: { - files: [ - { - src: '<%= project.app %>/components/live/adagios.js', - dest: '<%= project.app %>/components/live/live.js' - } - ] - }, - surveil: { - files: [ - { - src: '<%= project.app %>/components/live/surveil.js', - dest: '<%= project.app %>/components/live/live.js' - } - ] - } }, sass: { @@ -106,8 +90,6 @@ module.exports = function (grunt) { '<%= project.app %>/app.js', '<%= project.app %>/**/*.js', '!<%= project.app %>/bower_components/**', - '!<%= project.app %>/**/live.js', - '!<%= project.app %>/**/adagios.js' ] }, @@ -141,32 +123,21 @@ module.exports = function (grunt) { }, watch: { - adagios: { + development: { files: [ '<%= project.app %>/**/*.js', '<%= project.app %>/**/*.html', - '<%= project.app %>/components/live/adagios.js', '<%= project.assets %>/sass/{,*/}*.{scss,sass}' ], - tasks: ['copy:adagios', 'sass:dev', 'jshint:all'] - }, - surveil: { - files: [ - '<%= project.app %>/**/*.js', - '<%= project.app %>/**/*.html', - '<%= project.app %>/components/live/surveil.js', - '<%= project.assets %>/sass/{,*/}*.{scss,sass}' - ], - tasks: ['copy:surveil', 'sass:dev', 'jshint:all'] + tasks: ['sass:dev', 'jshint:all'] }, staging: { files: [ '<%= project.app %>/**/*.js', '<%= project.app %>/**/*.html', - '<%= project.app %>/components/live/surveil.js', '<%= project.assets %>/sass/{,*/}*.{scss,sass}' ], - tasks: ['production:surveil'] + tasks: ['production'] }, options: { livereload: true @@ -174,22 +145,26 @@ module.exports = function (grunt) { } }); - grunt.registerTask('default', ['watch']); + grunt.registerTask('default', ['development']); - grunt.registerTask('development:adagios', [ - 'sass', 'copy:adagios', 'jshint:all', 'watch:adagios' + grunt.registerTask('development', [ + 'sass', + 'jshint:all', + 'watch:development' ]); - grunt.registerTask('development:surveil', [ - 'sass', 'copy:surveil', 'jshint:all', 'watch:surveil' + grunt.registerTask('staging', [ + 'production', + 'watch:development' ]); - grunt.registerTask('staging:surveil', [ - 'production:surveil', 'watch:staging']); - - grunt.registerTask('production:adagios', [ - 'clean', 'sass', 'copy:prod', 'copy:adagios', 'useminPrepare:html', 'concat:generated', 'uglify:generated', 'usemin:html']); - - grunt.registerTask('production:surveil', [ - 'clean', 'sass', 'copy:prod', 'copy:surveil', 'useminPrepare:html', 'concat:generated', 'uglify:generated', 'usemin:html']); + grunt.registerTask('production', [ + 'clean', + 'sass', + 'copy:prod' , + 'useminPrepare:html', + 'concat:generated', + 'uglify:generated', + 'usemin:html' + ]); }; diff --git a/Makefile b/Makefile index 310acc9..e162fe7 100644 --- a/Makefile +++ b/Makefile @@ -13,14 +13,14 @@ interactive: daemon: sudo docker run -p 8888:8888 --link surveil_surveil_1:surveil -v $(shell pwd)/app:/opt/bansho/dist -e BANSHO_PROD=false -d -t --name bansho bansho - grunt development:surveil + grunt development production: sudo docker run -p 8888:8888 --link surveil_surveil_1:surveil -d -t --name bansho bansho staging: sudo docker run -p 8888:8888 --link surveil_surveil_1:surveil -v $(shell pwd)/dist:/opt/bansho/dist -e BANSHO_PROD=false -d -t --name bansho bansho - grunt staging:surveil + grunt staging kill: sudo docker kill bansho diff --git a/README.rst b/README.rst index 171a608..965f03a 100644 --- a/README.rst +++ b/README.rst @@ -57,14 +57,6 @@ Start the Docker container (be sure to have a surveil container available at thi make daemon -Bansho supports only surveil. -To select the proper backend and compile sass for surveil run : - -:: - - grunt development:surveil - - If you wish to develop in a docker container, here is how to proceed (assuming you already have docker installed) : diff --git a/app/components/live/adagios.js b/app/components/live/adagios.js deleted file mode 100644 index e98cf11..0000000 --- a/app/components/live/adagios.js +++ /dev/null @@ -1,377 +0,0 @@ -// Deprecated! -// To support this backend format to the same format as the surveil.js to inject a backendClient. -'use strict'; - -angular.module('bansho.live', []) - - .constant('filterSuffixes', { contains: '__contains', - has_field: '__has_field', - startswith: '__startswith', - endswith: '__endswith', - exists: '__exists', - in: '__in', - isnot: '__isnot', - regex: '__regex' - }) - - .service('backendClient', ['$http', 'filterSuffixes', 'hostMiddleware', function ($http, filterSuffixes, hostMiddleware) { - this.getObjects = function (fields, filters, apiName, additionnalFields) { - var filtersQuery = '', - additionnalQuery = ''; - - function createFiltersQuery(filters) { - var builtQuery = ''; - angular.forEach(filters, function (value, key) { - var filterType = filterSuffixes[key]; - angular.forEach(value, function (fieldValues, fieldName) { - var filter = fieldName + filterType; - angular.forEach(fieldValues, function (_value) { - var filterQuery = '&' + filter + '=' + _value; - builtQuery += filterQuery; - }); - }); - }); - - return builtQuery; - } - - function createAdditionnalQuery(additionnalFields) { - var query = ''; - angular.forEach(additionnalFields, function (value, key) { - query += '&' + key + '=' + value; - }); - - return query; - } - - filtersQuery = createFiltersQuery(filters); - additionnalQuery = createAdditionnalQuery(additionnalFields); - - function appendTransform(defaults, transform) { - // We can't guarantee that the default transformation is an array - defaults = angular.isArray(defaults) ? defaults : [defaults]; - - return defaults.concat(transform); - }; - - - function transformations(data) { - if (apiName === 'hosts') { - hostMiddleware(data); - } - return data; - } - - return $http({ - url: '/adagios/rest/status/json/' + apiName + '/?fields=' + fields + filtersQuery + additionnalQuery, - method: 'GET', - transformResponse: appendTransform($http.defaults.transformResponse, transformations) - }).error(function () { - throw new Error('getObjects : GET Request failed'); - }); - }; - }]) - - .service('getObjects', ['$http', 'filterSuffixes', 'hostMiddleware', - function ($http, filterSuffixes, hostMiddleware) { - return function (fields, filters, apiName, additionnalFields) { - var filtersQuery = '', - additionnalQuery = ''; - - function createFiltersQuery(filters) { - var builtQuery = ''; - angular.forEach(filters, function (value, key) { - var filterType = filterSuffixes[key]; - angular.forEach(value, function (fieldValues, fieldName) { - var filter = fieldName + filterType; - angular.forEach(fieldValues, function (_value) { - var filterQuery = '&' + filter + '=' + _value; - builtQuery += filterQuery; - }); - }); - }); - - return builtQuery; - } - - function createAdditionnalQuery(additionnalFields) { - var query = ''; - angular.forEach(additionnalFields, function (value, key) { - query += '&' + key + '=' + value; - }); - - return query; - } - - filtersQuery = createFiltersQuery(filters); - additionnalQuery = createAdditionnalQuery(additionnalFields); - - function appendTransform(defaults, transform) { - // We can't guarantee that the default transformation is an array - defaults = angular.isArray(defaults) ? defaults : [defaults]; - - return defaults.concat(transform); - }; - - - function transformations(data) { - if (apiName === 'hosts') { - hostMiddleware(data); - } - return data; - } - - return $http({ - url: '/adagios/rest/status/json/' + apiName + '/?fields=' + fields + filtersQuery + additionnalQuery, - method: 'GET', - transformResponse: appendTransform($http.defaults.transformResponse, transformations) - }).error(function () { - throw new Error('getObjects : GET Request failed'); - }); - }; - }]) - - .service('getService', ['$http', - function ($http) { - return function (hostName, description) { - return $http.get('/adagios/rest/status/json/services/?host_name=' + hostName + '&description=' + description) - .error(function () { - throw new Error('getService : GET Request failed'); - }); - }; - }]) - - // This service is used to count the number of host open problems - .service('getHostOpenProblems', ['$http', 'getObjects', - function ($http, getObjects) { - return function () { - var fields = ['state'], - filters = {}, - apiName = 'hosts', - additionnalQueryFields = {'acknowledged': 0, 'state': 1}; - - return getObjects(fields, filters, apiName, additionnalQueryFields) - .error(function () { - throw new Error('getHostOpenProblems : GET Request failed'); - }); - }; - }]) - - // This service is used to count the number of service open problems - .service('getServiceOpenProblems', ['$http', '$q', 'getObjects', - function ($http, $q, getObjects) { - return function () { - var fields = ['state'], - filters = { "isnot": { "state": [0], "host_state": [2] }}, - apiName = 'services', - additionnalQueryFields = {'acknowledged': 0}, - responsePromise = $q.defer(); - - getObjects(fields, filters, apiName, additionnalQueryFields) - .success(function (data) { - responsePromise.resolve(data); - }) - .error(function () { - throw new Error('getServiceOpenProblems : GET Request failed'); - }); - - return responsePromise.promise; - }; - }]) - - // This service is used to count the number of host problems - .service('getHostProblems', ['$http', 'getObjects', - function ($http, getObjects) { - return function () { - var fields = ['state'], - filters = { 'isnot': {'state': [0]} }, - apiName = 'hosts', - additionnalQueryFields = {}; - - return getObjects(fields, filters, apiName, additionnalQueryFields) - .error(function () { - throw new Error('getHostProblems : GET Request failed'); - }); - }; - }]) - - // This service is used to count the number of service problems - .service('getServiceProblems', ['$http', 'getObjects', - function ($http, getObjects) { - return function () { - var fields = ['state'], - filters = { 'isnot': {'state': [0]} }, - apiName = 'services', - additionnalQueryFields = {}; - - return getObjects(fields, filters, apiName, additionnalQueryFields) - .error(function () { - throw new Error('getServiceOpenProblems : GET Request failed'); - }); - }; - }]) - - // This service is used to count the number of hosts - .service('getTotalHosts', ['$http', 'getObjects', - function ($http, getObjects) { - return function () { - var fields = ['name'], - filters = {}, - apiName = 'hosts', - additionnalQueryFields = {}; - - return getObjects(fields, filters, apiName, additionnalQueryFields) - .error(function () { - throw new Error('getTotalHosts : GET Request failed'); - }); - }; - }]) - - // This service is used to count the number of services - .service('getTotalServices', ['$http', 'getObjects', - function ($http, getObjects) { - return function () { - var fields = ['name'], - filters = {}, - apiName = 'services', - additionnalQueryFields = {}; - - return getObjects(fields, filters, apiName, additionnalQueryFields) - .error(function () { - throw new Error('getTotalServices : GET Request failed'); - }); - }; - }]) - - .service('getObjectId', ['$http', function ($http) { - return function (objectType, objectIdentifier) { - - var postString, req; - - postString = "with_fields=id&object_type=" + objectType; - angular.forEach(objectIdentifier, function (value, key) { - if (key === "description") { - key = "service_description"; - } - postString += "&" + key + "=" + value; - }); - - req = { - method: 'POST', - url: '/adagios/rest/pynag/json/get_objects', - headers: { - 'Content-Type': 'application/x-www-form-urlencoded' - }, - data: postString - }; - - return $http(req) - .error(function () { - throw new Error('getObjectId : POST Request failed'); - }); - }; - }]) - - .service('getObjectById', ['$http', function ($http) { - return function (objectId) { - - var postString, req; - - postString = "with_fields=&id=" + objectId; - - req = { - method: 'POST', - url: '/adagios/rest/pynag/json/get_object', - headers: { - 'Content-Type': 'application/x-www-form-urlencoded' - }, - data: postString - }; - - - return $http(req) - .error(function () { - throw new Error('getHostById : POST Request failed'); - }); - }; - }]) - - // Add object of specified type to $scope.data - .service('getHost', ['$http', '$q', 'getObjectId', 'getObjectById', - function ($http, $q, getObjectId, getObjectById) { - return function (objectType, objectIdentifier) { - var objectData = {}, - url = "/adagios/rest/status/json/", - firstParameter = true, - endpoints = { - "host" : "hosts", - "service" : "services" - }, - response = {}, - responsePromise = $q.defer(); - - url += endpoints[objectType]; - url += "/?"; - - angular.forEach(objectIdentifier, function (value, key) { - if (!firstParameter) { - url += "&"; - } - url += key + "=" + value; - firstParameter = false; - - }); - - $http.get(url) - .success(function (data) { - response.live = data[0]; - getObjectId(objectType, objectIdentifier) - .success(function (data) { - var objectId = data[0].id; - getObjectById(objectId) - .success(function (data) { - response.config = data; - responsePromise.resolve(response); - }); - }); - }); - - return responsePromise.promise; - }; - }]) - - // Modify response object to conform to web ui - .service('hostMiddleware', function() { - return function(data) { - var i = 0, - conversions = { - 'name': 'host_name', - 'state': 'host_state' - }; - - for (i = 0; i < data.length; i += 1) { - angular.forEach(data[i], function (value, field) { - if (field in conversions) { - data[i][conversions[field]] = value; - delete data[i][field]; - } - }); - } - }; - }) - - .service('getTableData', ['$q', 'getObjects', - function ($q, getObjects) { - return function (fields, filters, apiName, additionnalFields) { - var responsePromise = $q.defer(); - - getObjects(fields, filters, apiName, additionnalFields) - .error(function () { - throw new Error('getTotalHosts : GET Request failed'); - }).success(function (data) { - responsePromise.resolve(data); - }); - - return responsePromise.promise; - } - }]); diff --git a/app/components/live/adagios_test.js b/app/components/live/adagios_test.js deleted file mode 100644 index 0324f3c..0000000 --- a/app/components/live/adagios_test.js +++ /dev/null @@ -1,25 +0,0 @@ -'use strict'; - -describe('In Adagios Live', function () { - var $httpBackend; - - beforeEach(module('bansho.live')); - - beforeEach(inject(function (_$httpBackend_) { - $httpBackend = _$httpBackend_; - })); - - describe('getObjects', function () { - - it('should send the proper GET request', inject(function (getObjects) { - var fields = ['host_name', 'host_state', 'description'], - filters = { contains: { host_name: ['srv', 'a'], plugin_output: ['SWAP'] }, - startswith: { host_name: ['srv'] } }, - apiName = 'services'; - - getObjects(fields, filters, apiName); - $httpBackend.expectGET('/rest/status/json/services/?fields=host_name,host_state,description&host_name__contains=srv&host_name__contains=a&plugin_output__contains=SWAP&host_name__startswith=srv').respond(''); - $httpBackend.flush(); - })); - }); -}); diff --git a/app/components/live/surveil.js b/app/components/live/live.js similarity index 100% rename from app/components/live/surveil.js rename to app/components/live/live.js diff --git a/container/configure.sh b/container/configure.sh index 5fc8adf..7b4ff57 100755 --- a/container/configure.sh +++ b/container/configure.sh @@ -8,10 +8,6 @@ echo "=> Configuring apache ProxyPass ..." sed -i "s|ProxyPass /surveil/ .*|ProxyPass /surveil/ ${BANSHO_SURVEIL_URL}|g" ${CONFIG_FILE} sed -i "s|ProxyPassReverse /surveil/ .*|ProxyPassReverse /surveil/ ${BANSHO_SURVEIL_URL}|g" ${CONFIG_FILE} -# Adagios URLS -sed -i "s|ProxyPass /adagios/.*|ProxyPass /adagios/ ${BANSHO_ADAGIOS_URL}|g" ${CONFIG_FILE} -sed -i "s|ProxyPassReverse /adagios/.*|ProxyPassReverse /adagios/ ${BANSHO_ADAGIOS_URL}|g" ${CONFIG_FILE} - # Bansho auth URL sed -i "s|ProxyPass /surveil/v2/auth/.*|ProxyPass /surveil/v2/auth/ ${BANSHO_AUTH_URL}|g" ${CONFIG_FILE} sed -i "s|ProxyPassReverse /surveil/v2/auth/.*|ProxyPass /surveil/v2/auth/ ${BANSHO_AUTH_URL}|g" ${CONFIG_FILE}