Commit 1cab677e authored by clauseliu's avatar clauseliu
Browse files

修改了serverDao和TaskService两处,没有经过测试。可能有坑

parent 63f173ec
Showing with 96 additions and 14 deletions
+96 -14
......@@ -50,8 +50,8 @@ const serverConfStruct = {
DeployServerController.deployServer = async(ctx) => {
var params = ctx.paramsObj;
try {
let panshiRegister = await PanshiService.register(params);
let rst = await ServerService.addServerConf(params);
let panshiRegister = await PanshiService.register(params);
rst.server_conf = util.viewFilter(rst.server_conf, serverConfStruct);
ctx.makeResObj(200, '', rst);
} catch (e) {
......
......@@ -16,12 +16,16 @@
const logger = require('../../logger');
const PanshiService = require('../../service/panshi/PanshiService');
const ServerService = require('../../service/server/ServerService');
const AuthService = require('../../service/auth/AuthService');
const TaskService = require('../../service/task/TaskService');
const util = require('../../tools/util');
const PageController = {
const PanshiController = {
};
PageController.queryService = async (ctx) => {
PanshiController.queryService = async (ctx) => {
try {
let data = await PanshiService.queryService();
ctx.makeResObj(200, '', data);
......@@ -31,7 +35,7 @@ PageController.queryService = async (ctx) => {
}
};
PageController.querySystem = async (ctx) => {
PanshiController.querySystem = async (ctx) => {
let ServiceId = ctx.paramsObj.ServiceId;
try {
let data = await PanshiService.querySystem({ServiceId});
......@@ -42,7 +46,7 @@ PageController.querySystem = async (ctx) => {
}
};
PageController.queryModule = async (ctx) => {
PanshiController.queryModule = async (ctx) => {
let SystemId = ctx.paramsObj.SystemId;
try {
let data = await PanshiService.queryModule({SystemId});
......@@ -53,9 +57,46 @@ PageController.queryModule = async (ctx) => {
}
};
PanshiController.batchUndeployTars = async (ctx) => {
let {application, server_name, serial=true} = ctx.paramsObj;
try {
if (!await AuthService.hasDevAuth(application, server_name, ctx.uid)) {
ctx.makeNotAuthResObj();
} else {
let ret = await ServerService.getServerConfList4Tree({application, serverName:server_name});
let serverId = ret.map(item => item.id);
let data = {
status: 0, // 0找不到服务,1下线成功,2部分成功,3失败
total: 0,
failCount: 0,
succCount: 0,
failMsg: '',
succMsg: ''
};
if(!serverId.length){
ctx.makeResObj(200, '', data);
}else {
let task_no = util.getUUID().toString();
let items = [];
serverId.forEach(id => {
items.push({
server_id : id,
command : 'undeploy_tars',
parameters : ''
});
})
let ret = await TaskService.addTask({serial, items, task_no});
console.info(ret);
ctx.makeResObj(200, '', ret);
}
}
} catch (err) {
logger.error('[batchUndeployTars]', err, ctx);
ctx.makeResObj(500, err.message)
}
}
module.exports = PageController;
\ No newline at end of file
module.exports = PanshiController;
\ No newline at end of file
/**
* Tencent is pleased to support the open source community by making Tars available.
*
* Copyright (C) 2016THL A29 Limited, a Tencent company. All rights reserved.
*
* Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* https://opensource.org/licenses/BSD-3-Clause
*
* 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.
*/
const logger = require('../../logger');
const AuthService = require('../../service/auth/AuthService');
const AdminService = require('../../service/admin/AdminService');
const TokenController = {}
TokenController.getTokens = async (ctx) => {
try {
ctx.makeResObj(200, '', []);
}catch(e) {
logger.error('[TokenController.getTokens]:', e, ctx);
ctx.makeErrResObj(e);
}
}
module.exports = TokenController;
\ No newline at end of file
......@@ -52,12 +52,14 @@ ServerDao.getServerConf = async(params) => {
params.application != undefined && (where.application = params.application);
params.serverName != undefined && (where.server_name = params.serverName);
params.nodeName != undefined && (where.node_name = params.nodeName);
if (params.enableSet && params.enableSet == 'Y') {
params.setName && (where.set_name = params.setName);
params.setArea && (where.set_area = params.setArea);
params.setGroup && (where.set_group = params.setGroup);
}else{
where.enable_set = 'N'
if(params.enableSet) {
if(params.enableSet == 'Y') {
params.setName && (where.set_name = params.setName);
params.setArea && (where.set_area = params.setArea);
params.setGroup && (where.set_group = params.setGroup);
}else {
where.enable_set = 'N'
}
}
let options = {
where: where,
......
......@@ -34,6 +34,7 @@ const LocaleController = require('../controller/locale/LocaleController');
const InfTestController = require('../controller/infTest/InfTestController');
const CallChainController = require('../controller/callChain/CallChainController');
const PanshiController = require('../controller/panshi/PanshiController');
const TokenController = require('../controller/token/tokenController');
const pageConf = [
//首页
......@@ -158,6 +159,12 @@ const apiConf = [
['get', '/get_trace_list', CallChainController.getTraceList],
['get', '/get_trace_detail', CallChainController.getTraceDetailList, {id: 'notEmpty'}],
['get', '/get_topo', CallChainController.getTopo, {serviceName:'notEmpty', start:'notEmpty', end:'notEmpty'}],
//授权管理
['get', '/get_tokens', TokenController.getTokens, {application: 'notEmpty', server_name: 'notEmpty',}],
//与磐石系统联动而封装的接口
['get', '/batch_undeploy_tars', PanshiController.batchUndeployTars, {application: 'notEmpty', server_name: 'notEmpty',}],
];
module.exports = {pageConf, apiConf};
\ No newline at end of file
......@@ -99,7 +99,7 @@ TaskService.addTask = async (params) => {
serial : params.serial,
userName : params.user_name || ''
};
await AdminService.addTask(req).catch(e => {console.error('[AdminService.addTask]:',e)});
await AdminService.addTask(req);
return params.task_no;
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment