Remove adagios backend

Change-Id: Ib6be5235c026fcd527f6db7ac305d8e739afae54
This commit is contained in:
Vincent Fournier 2015-05-20 12:19:44 -04:00 committed by aviau
parent 59a5fb561d
commit 1260920476
9 changed files with 23 additions and 466 deletions

2
.gitignore vendored
View File

@ -19,6 +19,4 @@ out/
dist/ dist/
.tmp/ .tmp/
app/components/live/live.js
app/components/config/developmentConfig.json app/components/config/developmentConfig.json

View File

@ -31,13 +31,11 @@ RUN cd /opt/bansho/ && npm install --unsafe-perm
ADD /app /opt/bansho/app ADD /app /opt/bansho/app
# Override those variables at runtime to point Bansho to another backend # Override those variables at runtime to point Bansho to another backend
ENV BANSHO_BACKEND surveil
ENV BANSHO_PROD true ENV BANSHO_PROD true
ENV BANSHO_SURVEIL_URL http://surveil:8080/ 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/ ENV BANSHO_AUTH_URL http://surveil:8080/v2/auth/
CMD ./configure.sh && \ CMD ./configure.sh && \
cd /opt/bansho && \ 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" bash -c "source /etc/apache2/envvars && exec /usr/sbin/apache2 -DFOREGROUND"

View File

@ -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: { sass: {
@ -106,8 +90,6 @@ module.exports = function (grunt) {
'<%= project.app %>/app.js', '<%= project.app %>/app.js',
'<%= project.app %>/**/*.js', '<%= project.app %>/**/*.js',
'!<%= project.app %>/bower_components/**', '!<%= project.app %>/bower_components/**',
'!<%= project.app %>/**/live.js',
'!<%= project.app %>/**/adagios.js'
] ]
}, },
@ -141,32 +123,21 @@ module.exports = function (grunt) {
}, },
watch: { watch: {
adagios: { development: {
files: [ files: [
'<%= project.app %>/**/*.js', '<%= project.app %>/**/*.js',
'<%= project.app %>/**/*.html', '<%= project.app %>/**/*.html',
'<%= project.app %>/components/live/adagios.js',
'<%= project.assets %>/sass/{,*/}*.{scss,sass}' '<%= project.assets %>/sass/{,*/}*.{scss,sass}'
], ],
tasks: ['copy:adagios', 'sass:dev', 'jshint:all'] tasks: ['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']
}, },
staging: { staging: {
files: [ files: [
'<%= project.app %>/**/*.js', '<%= project.app %>/**/*.js',
'<%= project.app %>/**/*.html', '<%= project.app %>/**/*.html',
'<%= project.app %>/components/live/surveil.js',
'<%= project.assets %>/sass/{,*/}*.{scss,sass}' '<%= project.assets %>/sass/{,*/}*.{scss,sass}'
], ],
tasks: ['production:surveil'] tasks: ['production']
}, },
options: { options: {
livereload: true livereload: true
@ -174,22 +145,26 @@ module.exports = function (grunt) {
} }
}); });
grunt.registerTask('default', ['watch']); grunt.registerTask('default', ['development']);
grunt.registerTask('development:adagios', [ grunt.registerTask('development', [
'sass', 'copy:adagios', 'jshint:all', 'watch:adagios' 'sass',
'jshint:all',
'watch:development'
]); ]);
grunt.registerTask('development:surveil', [ grunt.registerTask('staging', [
'sass', 'copy:surveil', 'jshint:all', 'watch:surveil' 'production',
'watch:development'
]); ]);
grunt.registerTask('staging:surveil', [ grunt.registerTask('production', [
'production:surveil', 'watch:staging']); 'clean',
'sass',
grunt.registerTask('production:adagios', [ 'copy:prod' ,
'clean', 'sass', 'copy:prod', 'copy:adagios', 'useminPrepare:html', 'concat:generated', 'uglify:generated', 'usemin:html']); 'useminPrepare:html',
'concat:generated',
grunt.registerTask('production:surveil', [ 'uglify:generated',
'clean', 'sass', 'copy:prod', 'copy:surveil', 'useminPrepare:html', 'concat:generated', 'uglify:generated', 'usemin:html']); 'usemin:html'
]);
}; };

View File

@ -13,14 +13,14 @@ interactive:
daemon: 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 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: production:
sudo docker run -p 8888:8888 --link surveil_surveil_1:surveil -d -t --name bansho bansho sudo docker run -p 8888:8888 --link surveil_surveil_1:surveil -d -t --name bansho bansho
staging: 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 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: kill:
sudo docker kill bansho sudo docker kill bansho

View File

@ -57,14 +57,6 @@ Start the Docker container (be sure to have a surveil container available at thi
make daemon 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 If you wish to develop in a docker container, here is how to proceed (assuming
you already have docker installed) : you already have docker installed) :

View File

@ -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;
}
}]);

View File

@ -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();
}));
});
});

View File

@ -8,10 +8,6 @@ echo "=> Configuring apache ProxyPass ..."
sed -i "s|ProxyPass /surveil/ .*|ProxyPass /surveil/ ${BANSHO_SURVEIL_URL}|g" ${CONFIG_FILE} 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} 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 # Bansho auth URL
sed -i "s|ProxyPass /surveil/v2/auth/.*|ProxyPass /surveil/v2/auth/ ${BANSHO_AUTH_URL}|g" ${CONFIG_FILE} 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} sed -i "s|ProxyPassReverse /surveil/v2/auth/.*|ProxyPass /surveil/v2/auth/ ${BANSHO_AUTH_URL}|g" ${CONFIG_FILE}