V_1.3.0
This commit is contained in:
parent
fe163ae6ad
commit
92e5814d5c
|
@ -1 +1 @@
|
|||
2
|
||||
1
|
|
@ -6,10 +6,11 @@ var select = require('xpath.js');
|
|||
//var dataDetailPath = "/home/server_data/data-detail.xml"
|
||||
//var dataPath = "/home/server_data/data.xml"
|
||||
//var versionPath = "/home/server_data/version.txt"
|
||||
var allDataPath = process.env.ALL_DATA || '/home/all_data';
|
||||
|
||||
var dataDetailPath = "/home/server_data/data-detail.xml"
|
||||
var dataPath = "/home/server_data/data.xml"
|
||||
var versionPath = "/home/server_data/version.txt"
|
||||
var dataDetailPath = allDataPath + "/collecting_data/data-detail.xml"
|
||||
var dataPath = allDataPath + "/collecting_data/data.xml"
|
||||
var versionPath = allDataPath+ "/collecting_data/version.txt"
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>fileId<49><64><EFBFBD><EFBFBD>ȡ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>ŵ<EFBFBD>λ<EFBFBD><CEBB>
|
||||
function getVersionPath(fileId){
|
||||
|
|
|
@ -203,8 +203,9 @@ declare module Kubernetes {
|
|||
function currentUserName(): any;
|
||||
function createNamespace(ns: any, client?: any): void;
|
||||
function createRC(obj: any, onCompleteFn?: any): void;
|
||||
function connectOracle($http: any, $timeout: any, url: any, connectParam: any, rcName: any, delayTime: any): void;
|
||||
function connectOracle($http: any, $timeout: any, url: any, operation: any, rcName: any, delayTime: any): void;
|
||||
function getOracleStatus(labels: any): number;
|
||||
function getExtractStatus(labels: any): number;
|
||||
function getOracleName(name: string): string;
|
||||
function extractDataToOracle($http: any, selectedReplicationControllers: any, targetReplicationController: any): void;
|
||||
function checkoutOracleRCIsRunning(rc: any): boolean;
|
||||
|
|
|
@ -1,7 +1,28 @@
|
|||
/// <reference path="d.ts/includes.d.ts"/>
|
||||
/// <reference path="d.ts/kubernetes/ts/kubernetesInterfaces.d.ts"/>
|
||||
/// <reference path="d.ts/kubernetes/ts/kubernetesHelpers.d.ts"/>
|
||||
/// <reference path="d.ts/developer/ts/developerEnrichers.d.ts"/>
|
||||
/// <reference path="d.ts/developer/ts/developerHelpers.d.ts"/>
|
||||
/// <reference path="d.ts/developer/ts/developerNavigation.d.ts"/>
|
||||
/// <reference path="d.ts/developer/ts/FileMode.d.ts"/>
|
||||
/// <reference path="d.ts/developer/ts/developerPlugin.d.ts"/>
|
||||
/// <reference path="d.ts/developer/ts/environmentPanel.d.ts"/>
|
||||
/// <reference path="d.ts/developer/ts/home.d.ts"/>
|
||||
/// <reference path="d.ts/developer/ts/jenkinsJob.d.ts"/>
|
||||
/// <reference path="d.ts/developer/ts/jenkinsJobs.d.ts"/>
|
||||
/// <reference path="d.ts/kubernetes/ts/kubernetesPlugin.d.ts"/>
|
||||
/// <reference path="d.ts/kubernetes/ts/kubernetesModel.d.ts"/>
|
||||
/// <reference path="d.ts/developer/ts/jenkinsLog.d.ts"/>
|
||||
/// <reference path="d.ts/developer/ts/jenkinsMetrics.d.ts"/>
|
||||
/// <reference path="d.ts/developer/ts/navbar.d.ts"/>
|
||||
/// <reference path="d.ts/developer/ts/pipeline.d.ts"/>
|
||||
/// <reference path="d.ts/developer/ts/pipelineDirective.d.ts"/>
|
||||
/// <reference path="d.ts/developer/ts/pipelines.d.ts"/>
|
||||
/// <reference path="d.ts/developer/ts/project.d.ts"/>
|
||||
/// <reference path="d.ts/developer/ts/projectSelector.d.ts"/>
|
||||
/// <reference path="d.ts/developer/ts/projects.d.ts"/>
|
||||
/// <reference path="d.ts/developer/ts/workspace.d.ts"/>
|
||||
/// <reference path="d.ts/developer/ts/workspaces.d.ts"/>
|
||||
/// <reference path="d.ts/kubernetes/ts/apps.d.ts"/>
|
||||
/// <reference path="d.ts/kubernetes/ts/breadcrumbs.d.ts"/>
|
||||
/// <reference path="d.ts/kubernetes/ts/build.d.ts"/>
|
||||
|
@ -15,7 +36,6 @@
|
|||
/// <reference path="d.ts/kubernetes/ts/deploymentConfig.d.ts"/>
|
||||
/// <reference path="d.ts/kubernetes/ts/deploymentConfigs.d.ts"/>
|
||||
/// <reference path="d.ts/kubernetes/ts/events.d.ts"/>
|
||||
/// <reference path="d.ts/kubernetes/ts/kubernetesModel.d.ts"/>
|
||||
/// <reference path="d.ts/kubernetes/ts/host.d.ts"/>
|
||||
/// <reference path="d.ts/kubernetes/ts/utilHelpers.d.ts"/>
|
||||
/// <reference path="d.ts/kubernetes/ts/hosts.d.ts"/>
|
||||
|
@ -48,24 +68,4 @@
|
|||
/// <reference path="d.ts/kubernetes/ts/sharedControllers.d.ts"/>
|
||||
/// <reference path="d.ts/kubernetes/ts/tabs.d.ts"/>
|
||||
/// <reference path="d.ts/kubernetes/ts/templates.d.ts"/>
|
||||
/// <reference path="d.ts/developer/ts/developerEnrichers.d.ts"/>
|
||||
/// <reference path="d.ts/developer/ts/developerHelpers.d.ts"/>
|
||||
/// <reference path="d.ts/developer/ts/developerNavigation.d.ts"/>
|
||||
/// <reference path="d.ts/developer/ts/FileMode.d.ts"/>
|
||||
/// <reference path="d.ts/developer/ts/developerPlugin.d.ts"/>
|
||||
/// <reference path="d.ts/developer/ts/environmentPanel.d.ts"/>
|
||||
/// <reference path="d.ts/developer/ts/home.d.ts"/>
|
||||
/// <reference path="d.ts/developer/ts/jenkinsJob.d.ts"/>
|
||||
/// <reference path="d.ts/developer/ts/jenkinsJobs.d.ts"/>
|
||||
/// <reference path="d.ts/developer/ts/jenkinsLog.d.ts"/>
|
||||
/// <reference path="d.ts/developer/ts/jenkinsMetrics.d.ts"/>
|
||||
/// <reference path="d.ts/developer/ts/navbar.d.ts"/>
|
||||
/// <reference path="d.ts/developer/ts/pipeline.d.ts"/>
|
||||
/// <reference path="d.ts/developer/ts/pipelineDirective.d.ts"/>
|
||||
/// <reference path="d.ts/developer/ts/pipelines.d.ts"/>
|
||||
/// <reference path="d.ts/developer/ts/project.d.ts"/>
|
||||
/// <reference path="d.ts/developer/ts/projectSelector.d.ts"/>
|
||||
/// <reference path="d.ts/developer/ts/projects.d.ts"/>
|
||||
/// <reference path="d.ts/developer/ts/workspace.d.ts"/>
|
||||
/// <reference path="d.ts/developer/ts/workspaces.d.ts"/>
|
||||
/// <reference path="d.ts/navigation/ts/navigationPlugin.d.ts"/>
|
||||
|
|
|
@ -203,6 +203,9 @@ legend {
|
|||
.k8s-badge-target {
|
||||
background-color: Red;
|
||||
}
|
||||
.badge-remind {
|
||||
background-color: Red;
|
||||
}
|
||||
|
||||
.environment-row a {
|
||||
color: black;
|
||||
|
@ -953,6 +956,9 @@ a:hover.data_file_btn {
|
|||
.pod-log-lines * .white {
|
||||
color: #ddd;
|
||||
}
|
||||
.top-bottom-middle {
|
||||
line-height: 34px;
|
||||
}
|
||||
|
||||
.terminal-window {
|
||||
position: fixed;
|
||||
|
|
File diff suppressed because one or more lines are too long
210
gulpfile.js
210
gulpfile.js
|
@ -18,18 +18,18 @@ var gulp = require('gulp'),
|
|||
app = hawtio.app,
|
||||
shellprocess = require('child_process'),
|
||||
xmloperation = require('./app/xmloperation'),
|
||||
rootdir = process.env.STORAGE_PATH || '/home/server_data/',
|
||||
K8s = require('k8s'),
|
||||
crontab = require('node-crontab'),
|
||||
async = require('async'),
|
||||
myjs=require('./app/my.js');
|
||||
|
||||
var oracledb = require('oracledb');
|
||||
|
||||
var plugins = gulpLoadPlugins({});
|
||||
var pkg = require('./package.json');
|
||||
var time =0;
|
||||
var schedule = [];
|
||||
|
||||
var allDataPath = process.env.ALL_DATA || '/home/all_data';
|
||||
var rootdir = allDataPath + "/collecting_data/";
|
||||
var kubectl = K8s.kubectl({
|
||||
endpoint: process.env.KUBERNETES_MASTER,
|
||||
binary: '/usr/bin/kubectl'
|
||||
|
@ -313,7 +313,7 @@ gulp.task('connect', ['watch'], function() {
|
|||
if(req.method=='POST') {
|
||||
var data = [];
|
||||
var parser = new xml2js.Parser();
|
||||
fs.readFile(rootdir + 'data.xml', function(err, xml) {
|
||||
fs.readFile(rootdir + '/data.xml', function(err, xml) {
|
||||
parser.parseString(xml, function (err, result) {
|
||||
myjs.Recursion(result.node);
|
||||
data.push(result.node);
|
||||
|
@ -324,9 +324,9 @@ gulp.task('connect', ['watch'], function() {
|
|||
});
|
||||
|
||||
hawtio.use("/oracleAppPath",function(req,res){
|
||||
var dataPath = "/home/ubuntu/data/";
|
||||
var tmpPath = "/home/ubuntu/tmp/app";
|
||||
var appSource="/home/app";
|
||||
var dataPath = allDataPath + "/tabulate_data/";
|
||||
var tmpPath = allDataPath + "/tmp_data/app";
|
||||
var appSource=allDataPath + "/template/app";
|
||||
if(req.method="POST"){
|
||||
var timestamp=new Date();
|
||||
if((timestamp.getTime() - time) >= 2*60*1000){
|
||||
|
@ -337,7 +337,7 @@ gulp.task('connect', ['watch'], function() {
|
|||
fs.mkdirSync(dataPath);
|
||||
//path.exists(tmpPath,function(exists){if(exists) console.log("exists");});
|
||||
fs.renameSync(tmpPath, dataPath+"app");
|
||||
console.log("move 'home/ubuntu/tmp/app' to " + dataPath);
|
||||
console.log("move '" + tmpPath + "' to " + dataPath);
|
||||
xmloperation.savehuizong(timestamp.Format('yyyy-MM-dd hh:mm:ss'), '10', id, "汇总数据库("+ id +")", dataPath, dirName);
|
||||
fs.writeFileSync('./app/version.txt', 2);
|
||||
res.send(200,{path: dataPath+"app/", name: dirName});
|
||||
|
@ -352,6 +352,18 @@ gulp.task('connect', ['watch'], function() {
|
|||
//}
|
||||
});
|
||||
|
||||
hawtio.use('/oracleExtractLog', function(req,res){
|
||||
var path = allDataPath + "/tabulate_logs/" + req.query.rcName;
|
||||
if(fs.existsSync(path)){
|
||||
var log = fs.readFileSync(path, 'utf-8');
|
||||
res.send(200,{logContent: log.toString()});
|
||||
res.end();
|
||||
}else{
|
||||
res.send(200,{logContent: "当前没有日志可以查看!"});
|
||||
res.end();
|
||||
}
|
||||
});
|
||||
|
||||
hawtio.use('/uploadfiles',function(req,res){
|
||||
if(req.method==="POST"){
|
||||
var relativePath = req.body.resumableRelativePath;
|
||||
|
@ -572,6 +584,7 @@ gulp.task('connect', ['watch'], function() {
|
|||
console.log(err);
|
||||
crontab.cancelJob(task.taskCrontab);
|
||||
cancelOracleConectionTask(task.rcName);
|
||||
return;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -598,7 +611,7 @@ gulp.task('connect', ['watch'], function() {
|
|||
console.log("connection failed! message" + err.message);
|
||||
return;
|
||||
}
|
||||
console.log("connect success!");
|
||||
|
||||
kubectl.rc.command("label --overwrite rc " + task.taskName + " status=2", function(err, data){
|
||||
if(err){
|
||||
console.log(err);
|
||||
|
@ -609,9 +622,10 @@ gulp.task('connect', ['watch'], function() {
|
|||
if (err){
|
||||
console.error(err.message);
|
||||
}
|
||||
console.log(rcName + "connect success!");
|
||||
crontab.cancelJob(task.taskCrontab);
|
||||
cancelOracleConectionTask(task.rcName);
|
||||
console.log("connection closed!");
|
||||
console.log(rcName + "connection closed!");
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -628,16 +642,190 @@ gulp.task('connect', ['watch'], function() {
|
|||
res.end();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
hawtio.use('/cancelOracleConection', function(req,res){
|
||||
var rcName = req.query.oracleName;
|
||||
var operation = req.query.operation;
|
||||
if(operation !== 'stop')
|
||||
cancelOracleConectionTask(rcName);
|
||||
else{
|
||||
kubectl.rc.command("label --overwrite rc " + rcName + " status=0", function(err, data){
|
||||
if(err)
|
||||
console.error(err.message);
|
||||
console.log("update replicationControllers " + rcName + " success");
|
||||
cancelOracleConectionTask(rcName);
|
||||
});
|
||||
}
|
||||
res.send(200,"Ok");
|
||||
res.end();
|
||||
});
|
||||
|
||||
hawtio.use('/extractOracleData', function(req,res){
|
||||
var data = req.query.param;
|
||||
console.log(data);
|
||||
var poolOracle;
|
||||
var collectOracle = [];
|
||||
data.forEach(function(item){
|
||||
var obj = JSON.parse(item);
|
||||
if(obj.isTarget)
|
||||
poolOracle = obj;
|
||||
else{
|
||||
var names = obj.OracleName.split("-");
|
||||
kubectl.rc.command("label --overwrite rc " + obj.OracleName + " isExtract=1", function(err, data){
|
||||
if(err)
|
||||
console.error(err);
|
||||
console.log("update replicationControllers " + obj.OracleName + " success");
|
||||
});
|
||||
obj["name"] = "J" + names[0] + "_" + names[1];
|
||||
collectOracle.push(obj);
|
||||
}
|
||||
});
|
||||
var poolOracleParam = poolOracle.connectHost + ":" +poolOracle.connectPort;
|
||||
var logMessage = "";
|
||||
|
||||
oracledb.getConnection({
|
||||
user : "system",
|
||||
password : "oracle",
|
||||
connectString : poolOracleParam + "/orcl"
|
||||
}, function(err, connection){
|
||||
if (err) {
|
||||
console.error(err.message);
|
||||
return;
|
||||
}
|
||||
var logPath = allDataPath + "/tabulate_logs/";
|
||||
async.eachSeries(collectOracle, function(item, callback){
|
||||
var strTUser = item.name + "_20152016";
|
||||
var message = "-------------------------------------------采集库:" + item.name + "执行汇总-------------------------------------------";
|
||||
console.log(message);
|
||||
fs.appendFileSync(logPath + poolOracle.OracleName, message + "\n\n");
|
||||
async.waterfall([
|
||||
function(cb){
|
||||
var dbLinkSql = "create public database link linkTo" + item.name + " connect to system IDENTIFIED BY oracle using "
|
||||
+"'(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = "
|
||||
+ item.connectHost + ")(PORT = " + item.connectPort + ")))(CONNECT_DATA = (SERVICE_NAME = orcl)))'";
|
||||
fs.appendFileSync(logPath + poolOracle.OracleName, "SQL> " + dbLinkSql + "\n\n");
|
||||
connection.execute(dbLinkSql, function(err, result){
|
||||
if(err){
|
||||
fs.appendFileSync(logPath + poolOracle.OracleName, err + "\n\n");
|
||||
cb(null);
|
||||
return;
|
||||
}
|
||||
fs.appendFileSync(logPath + poolOracle.OracleName, "数据库链接已创建。" + "\n\n");
|
||||
cb(null);
|
||||
});
|
||||
},
|
||||
function(cb){
|
||||
connection.execute("select TABLESPACE_NAME from dba_tablespaces where TABLESPACE_NAME = 'TS_JSSJBS'", function(err, result){
|
||||
if(err){
|
||||
console.log(err);
|
||||
return;
|
||||
}
|
||||
if(result.rows.length !== 0)
|
||||
cb(null, false);
|
||||
else
|
||||
cb(null, true);
|
||||
});
|
||||
},
|
||||
function(arg, cb){
|
||||
if(!arg){
|
||||
cb(null);
|
||||
return;
|
||||
}
|
||||
var sql = "create tablespace TS_JSSJBS datafile '/opt/oracle/app/oradata/orcl/ts_jssjbs.dbf' size 512M autoextend on next 512M maxsize unlimited";
|
||||
fs.appendFileSync(logPath + poolOracle.OracleName, "SQL> " + sql + ";\n\n");
|
||||
connection.execute(sql, function(err, result){
|
||||
if (err){
|
||||
fs.appendFileSync(logPath + poolOracle.OracleName, err + "\n\n");
|
||||
cb(null);
|
||||
return;
|
||||
}
|
||||
fs.appendFileSync(logPath + poolOracle.OracleName, "表空间已创建。" + "\n\n");
|
||||
cb(null);
|
||||
});
|
||||
},
|
||||
function(cb){
|
||||
var sql = "Create user " + strTUser + " default tablespace TS_JSSJBS identified by 1";
|
||||
fs.appendFileSync(logPath + poolOracle.OracleName, "SQL> " + sql + ";\n\n");
|
||||
connection.execute(sql, function(err, result){
|
||||
if (err){
|
||||
fs.appendFileSync(logPath + poolOracle.OracleName, err + "\n\n");
|
||||
cb(null);
|
||||
return;
|
||||
}
|
||||
fs.appendFileSync(logPath + poolOracle.OracleName, "用户已创建。" + "\n\n");
|
||||
//console.log("create us");
|
||||
cb(null);
|
||||
});
|
||||
},
|
||||
function(cb){
|
||||
var sql = "grant connect, resource, dba to " + strTUser;
|
||||
fs.appendFileSync(logPath + poolOracle.OracleName, "SQL> " + sql + ";\n\n");
|
||||
connection.execute(sql, function(err, result){
|
||||
if(err)
|
||||
fs.appendFileSync(logPath + poolOracle.OracleName, err + "\n\n");
|
||||
fs.appendFileSync(logPath + poolOracle.OracleName, "授权成功。" + "\n\n");
|
||||
//console.log("grant dba");
|
||||
cb(null);
|
||||
});
|
||||
},
|
||||
function(cb){
|
||||
var sql = "SELECT 'create table " + strTUser + ".J'|| substr(t.OWNER||'_'||t.TABLE_NAME,0,29)||' as select * from '||t.OWNER||'.'||t.TABLE_NAME||"
|
||||
+"'@linkTo" + item.name + ";' FROM dba_tables@linkTo" + item.name + " t WHERE t.TABLESPACE_NAME NOT IN ('SYSTEM','SYSAUX')"
|
||||
+ " and t.owner||t.table_name not in (select owner||table_name from dba_tables@linkTo" + item.name + " where 'data_type'='CLOB')";
|
||||
fs.appendFileSync(logPath + poolOracle.OracleName, "SQL> " + sql + ";\n\n");
|
||||
connection.execute(sql, function(err, result){
|
||||
if(err){
|
||||
fs.appendFileSync(logPath + poolOracle.OracleName, err + "\n\n");
|
||||
return;
|
||||
}
|
||||
preSql = [];
|
||||
result.rows.forEach(function(row){
|
||||
row.forEach(function(it){
|
||||
preSql.push(it.replace(/;$/, ""));
|
||||
fs.appendFileSync(logPath + poolOracle.OracleName, it + "\n");
|
||||
});
|
||||
});
|
||||
fs.appendFileSync(logPath + poolOracle.OracleName, "\n");
|
||||
cb(null, preSql);
|
||||
});
|
||||
},
|
||||
function(arg, cb){
|
||||
async.eachSeries(arg, function(sql, cback){
|
||||
fs.appendFileSync(logPath + poolOracle.OracleName, "SQL> " + sql + ";\n\n");
|
||||
connection.execute(sql, function(err, result){
|
||||
if(err){
|
||||
fs.appendFileSync(logPath + poolOracle.OracleName, err + "\n\n");
|
||||
cback(null, !err);
|
||||
return;
|
||||
}
|
||||
fs.appendFileSync(logPath + poolOracle.OracleName, "表已创建。" + "\n\n");
|
||||
cback(null, !err);
|
||||
});
|
||||
}, function(err, result){
|
||||
cb(null);
|
||||
});
|
||||
}
|
||||
], function(err, result){
|
||||
if(err)
|
||||
console.error(err);
|
||||
kubectl.rc.command("label --overwrite rc " + item.OracleName + " isExtract=2", function(err, data){
|
||||
if(err)
|
||||
console.err(err);
|
||||
console.log("update replicationControllers " + item.OracleName + " success");
|
||||
callback(null);
|
||||
});
|
||||
});
|
||||
}, function(err, result){
|
||||
if(err)
|
||||
console.error(err);
|
||||
connection.close(function(err){
|
||||
if(err)
|
||||
console.log(err);
|
||||
});
|
||||
});
|
||||
});
|
||||
res.send(200,"Ok");
|
||||
res.end();
|
||||
});
|
||||
|
||||
hawtio.listen(function(server) {
|
||||
|
|
Binary file not shown.
|
@ -29,6 +29,7 @@
|
|||
"yargs": "^3.32.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"async": "^2.0.0-rc.6",
|
||||
"connect-multiparty": "^2.0.0",
|
||||
"hawtio-node-backend": "^2.1.0",
|
||||
"k8s": "^0.2.7",
|
||||
|
|
|
@ -364,7 +364,7 @@ module Developer {
|
|||
}
|
||||
|
||||
$scope.downLoadFiles = ()=>{
|
||||
Kubernetes.connectOracle($http, $timeout, "192.168.0.103:64182", "320614-54-1", 500);
|
||||
//Kubernetes.connectOracle($http, $timeout, "192.168.0.103:64182", "320614-54-1", 500);
|
||||
}
|
||||
|
||||
$scope.isSelected= (node)=>{
|
||||
|
@ -394,8 +394,8 @@ module Developer {
|
|||
var Obj = createRCObj($scope.model.selecteditems[id]);
|
||||
if(!checkIsRunning(KubernetesModel.replicationControllers,Obj)){
|
||||
Kubernetes.createRC(Obj, (rc) =>{
|
||||
console.log(rc.metadata.name);
|
||||
Kubernetes.connectOracle($http, $timeout, "/connectToOracle", "", rc.metadata.name, 0);
|
||||
console.log(rc);
|
||||
Kubernetes.connectOracle($http, $timeout, "/connectToOracle", "create", rc.metadata.name, 0);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,22 @@
|
|||
</a>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/ng-template" id="dataSummaryTemplate.html">
|
||||
<div class="ngCellText" ng-init="entity=row.entity" >
|
||||
<a ng-show="row.entity.$podCounters.podsLink" title="pods status">
|
||||
<span ng-show="row.entity.$extractStatus === 0" class="badge badge-info" href=""> 未汇总</span>
|
||||
<span ng-show="row.entity.$extractStatus === 1" class="badge badge-success" href=""> 正在汇总</span>
|
||||
<span ng-show="row.entity.$extractStatus === 2" class="badge" href=""> 已完成</span>
|
||||
<span ng-show="row.entity.$extractStatus === 3" class="badge badge-warning" href=""> 失败</span>
|
||||
<div ng-show="row.entity.$extractStatus === 10">
|
||||
<span class="badge badge-remind"> 汇总数据库</span>
|
||||
<span ng-include = "'oracleLogTemplate.html'"></span>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/ng-template" id="labelTemplate.html">
|
||||
<div class="ngCellText" ng-init="entity=row.entity" ng-controller="Kubernetes.Labels">
|
||||
<p ng-show="data"><strong>Labels</strong></p>
|
||||
|
@ -135,6 +151,12 @@
|
|||
</span>
|
||||
</script>
|
||||
|
||||
<script type="text/ng-template" id="oracleLogTemplate.html">
|
||||
<span ng-controller="Kubernetes.PodLogLinkController">
|
||||
<i class="fa fa-file-text" title="打开{{entity.$oracleName}}的汇总日志" ng-click="openLogs(entity)"></i>
|
||||
</span>
|
||||
</script>
|
||||
|
||||
<script type="text/ng-template" id="connectParamTemplate.html">
|
||||
<div class="ngCellText" ng-init="entity=row.entity">
|
||||
<p ng-show="row.entity.$pods.length"><strong>{{row.entity.$pods[0].$host}}:{{row.entity.$pods[0].spec.containers[0].ports[0].hostPort}}/orcl</strong></p>
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
<span class="fa fa-caret-down"></span>
|
||||
</div>
|
||||
<div class="terminal-title" ng-mousedown="mouseDown($event)" ng-mouseup="mouseUp($event)" ng-mousemove="mouseMove($event)">
|
||||
<h5>{{containerName}} logs</h5>
|
||||
<h5 class="top-bottom-middle">{{containerName}}的汇总日志</h5>
|
||||
<i class="fa fa-remove pull-right clickable" title="Close and exit this log" ng-click="close()"></i>
|
||||
<i class="fa fa-square-o pull-right clickable" title="Maximize this log" ng-click="maximize($event)"></i>
|
||||
<i class="fa fa-sort-desc pull-right clickable" ng-hide="maximized()" title="Minimize this log" ng-click="minimize($event)"></i>
|
||||
</div>
|
||||
<div class="terminal-body" scroll-glue ng-model="atBottom">
|
||||
<pod-log-display></pod-log-display>
|
||||
</div>
|
||||
<!--<div class="terminal-body" scroll-glue ng-model="atBottom" style="overflow-y:hidden"> -->
|
||||
<textarea style="height:100%; width:100%" disabled="disabled">{{logs}}</textarea>
|
||||
<!--</div>-->
|
||||
</div>
|
||||
|
|
|
@ -115,7 +115,7 @@
|
|||
</select>
|
||||
|
||||
<span class="help-block" ng-show="filterReplicationControllers.length == 0">
|
||||
当前没有汇总数据库可以选择,请先创建,可以点击创建汇总数据库按钮进行创建!
|
||||
当前没有汇总数据库可以选择,请先创建,可以点击创建汇总数据库按钮进行创建或从汇总页面中的服务器数据列表中启动已创建的汇总数据库!
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -29,3 +29,7 @@
|
|||
color: #ddd;
|
||||
}
|
||||
}
|
||||
|
||||
.top-bottom-middle{
|
||||
line-height: 34px;
|
||||
}
|
||||
|
|
|
@ -1739,23 +1739,23 @@ module Kubernetes {
|
|||
var rcTemplate = RCTemplate.createRC(obj);
|
||||
//console.log(rcTemplate);
|
||||
client.put(rcTemplate, function(obj) {
|
||||
console.log("Created: ", obj);
|
||||
//console.log("Created: ", obj);
|
||||
if (angular.isFunction(onCompleteFn)) {
|
||||
onCompleteFn(obj);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function connectOracle($http, $timeout, url, connectParam, rcName, delayTime){
|
||||
export function connectOracle($http, $timeout, url, operation, rcName, delayTime){
|
||||
$timeout(() => {
|
||||
$http({
|
||||
url: url,
|
||||
method:'POST',
|
||||
params:{oracleName: rcName, param: connectParam}
|
||||
params:{oracleName: rcName, operation: operation}
|
||||
}).success(function(data,header,config,status){
|
||||
console.log("success");
|
||||
}).error(function(data,header,config,status){
|
||||
log.warn("Failed to connect " + connectParam + " " + data + " " + status);
|
||||
//log.warn("Failed to connect " + connectParam + " " + data + " " + status);
|
||||
});
|
||||
}, delayTime);
|
||||
}
|
||||
|
@ -1780,6 +1780,14 @@ module Kubernetes {
|
|||
return answer;
|
||||
}
|
||||
|
||||
export function getExtractStatus(labels){
|
||||
if(labels.isTarget === 'false'){
|
||||
return parseInt(labels.isExtract);
|
||||
}else{
|
||||
return 10;
|
||||
}
|
||||
}
|
||||
|
||||
export function getOracleName(name:string):string {
|
||||
var results = name.split("-");
|
||||
if(results.length === 2){
|
||||
|
@ -1808,10 +1816,10 @@ module Kubernetes {
|
|||
if(getName(rc) !== getName(targetReplicationController)){
|
||||
answer = answer && checkoutOracleRCIsRunning(rc);
|
||||
oracleConnectParam.push({
|
||||
OracleName: getName(rc),
|
||||
connectHost: getHost(rc.$pods[0]),
|
||||
connectPort: rc.$pods[0].spec.containers[0].ports[0].hostPort,
|
||||
isTarget: false
|
||||
"OracleName": getName(rc),
|
||||
"connectHost": getHost(rc.$pods[0]),
|
||||
"connectPort": rc.$pods[0].spec.containers[0].ports[0].hostPort,
|
||||
"isTarget": false
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -1819,6 +1827,7 @@ module Kubernetes {
|
|||
if(answer){
|
||||
$http({
|
||||
url: '/extractOracleData',
|
||||
dataType: 'json',
|
||||
method:'POST',
|
||||
params:{param: oracleConnectParam}
|
||||
}).success(function(data,header,config,status){
|
||||
|
|
|
@ -357,6 +357,8 @@ module Kubernetes {
|
|||
replicationController.$oracleName = getOracleName(getName(replicationController));
|
||||
//console.log(getName(replicationController));
|
||||
replicationController.$oracleStatus = getOracleStatus(getLabels(replicationController));
|
||||
replicationController.$extractStatus = getExtractStatus(getLabels(replicationController));
|
||||
|
||||
|
||||
var selectedPods = replicationController.$pods;
|
||||
replicationController.connectTo = selectedPods.map((pod) => {
|
||||
|
|
|
@ -183,7 +183,7 @@ module Kubernetes {
|
|||
})
|
||||
.href(() => context)
|
||||
.title(() => '服务集群')
|
||||
.tabs(controllers, events)
|
||||
.tabs(controllers, pods, events)
|
||||
.build();
|
||||
HawtioNav.add(mainTab);
|
||||
|
||||
|
|
|
@ -45,11 +45,11 @@ module Kubernetes {
|
|||
});
|
||||
});
|
||||
|
||||
_module.controller("Kubernetes.PodLogLinkController", ($scope, TerminalService, $templateCache) => {
|
||||
_module.controller("Kubernetes.PodLogLinkController", ($scope, $interval, TerminalService, $templateCache) => {
|
||||
|
||||
$scope.openLogs = (entity) => {
|
||||
log.debug("Open logs: ", entity);
|
||||
TerminalService.newTerminal(entity.metadata.selfLink, entity.metadata.name, $templateCache.get(UrlHelpers.join(templatePath, 'logShell.html')));
|
||||
TerminalService.newTerminal($interval, entity.metadata.selfLink, entity.$oracleName, entity,$templateCache.get(UrlHelpers.join(templatePath, 'logShell.html')));
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -61,6 +61,10 @@ module Kubernetes {
|
|||
return 1;
|
||||
}
|
||||
}
|
||||
},
|
||||
{ field: '$extractStatus',
|
||||
displayName: '数据汇总状态',
|
||||
cellTemplate: $templateCache.get("dataSummaryTemplate.html")
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -89,7 +93,7 @@ module Kubernetes {
|
|||
log.debug("deleted: ", getName(next));
|
||||
if(next.metadata.labels.style === "oracle"){
|
||||
console.log("delete " + next.metadata.name);
|
||||
Kubernetes.connectOracle($http, $timeout, "/cancelOracleConection", "", getName(next), 0);
|
||||
Kubernetes.connectOracle($http, $timeout, "/cancelOracleConection", "delete", getName(next), 0);
|
||||
}
|
||||
deleteSelected(selected, selected.shift());
|
||||
}, (error) => {
|
||||
|
@ -151,7 +155,7 @@ module Kubernetes {
|
|||
}).error(function(data,header,config,status){
|
||||
console.log("error");
|
||||
});
|
||||
Kubernetes.connectOracle($http, $timeout, "/connectToOracle", "", getName(rc), 0);
|
||||
Kubernetes.connectOracle($http, $timeout, "/connectToOracle", "create", getName(rc), 0);
|
||||
});
|
||||
}else if(xhr.status == 403){
|
||||
alert("两次创建oracle服务时间间隔需要超过2分钟!");
|
||||
|
@ -180,7 +184,7 @@ module Kubernetes {
|
|||
Kubernetes.resizeController($http, KubernetesApiURL, next, 0, () => {
|
||||
if(next.metadata.labels.style === "oracle"){
|
||||
console.log("stop " + next.metadata.name);
|
||||
Kubernetes.connectOracle($http, $timeout, "/cancelOracleConection", "", getName(next), 0);
|
||||
Kubernetes.connectOracle($http, $timeout, "/cancelOracleConection", "stop", getName(next), 0);
|
||||
}
|
||||
stopSelected(selected, selected.shift());
|
||||
});
|
||||
|
@ -205,7 +209,7 @@ module Kubernetes {
|
|||
if(next.$replicas === 0)
|
||||
Kubernetes.resizeController($http, KubernetesApiURL, next, 1, () => {
|
||||
console.log("restart " + next.metadata.name);
|
||||
Kubernetes.connectOracle($http, $timeout, "/connectToOracle", "", getName(next), 0);
|
||||
Kubernetes.connectOracle($http, $timeout, "/connectToOracle", "reStart", getName(next), 0);
|
||||
startSelected(selected, selected.shift());
|
||||
});
|
||||
}
|
||||
|
|
|
@ -97,9 +97,9 @@ module Kubernetes {
|
|||
|
||||
//服务状态过滤
|
||||
export var Status = controller('Status', ["$scope", "$http", "$interval", "$location", "KubernetesApiURL", ($scope, $http, $interval, $location, KubernetesApiURL) => {
|
||||
// $scope.$watch('entity', (newValue, oldValue) => {
|
||||
// if(newValue)
|
||||
// console.log(newValue);
|
||||
// },true);
|
||||
/*$scope.$watch('entity', (newValue, oldValue) => {
|
||||
if(newValue)
|
||||
console.log(newValue);
|
||||
},true);*/
|
||||
}]);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ module Kubernetes {
|
|||
};
|
||||
});
|
||||
|
||||
_module.service('TerminalService', ($rootScope, $document, $compile, $templateCache) => {
|
||||
_module.service('TerminalService', ($rootScope, $document, $compile, $interval, $templateCache) => {
|
||||
var body = $document.find('body');
|
||||
function positionTerminals(terminals) {
|
||||
var total = _.keys(terminals).length;
|
||||
|
@ -42,7 +42,8 @@ module Kubernetes {
|
|||
positionTerminals(self.terminals);
|
||||
},
|
||||
terminals: {},
|
||||
newTerminal: (podLink, containerName, template = defaultTemplate) => {
|
||||
httpTask: {},
|
||||
newTerminal: ($interval, podLink, containerName, entity, template = defaultTemplate) => {
|
||||
var terminalId = UrlHelpers.join(podLink, containerName);
|
||||
if (terminalId in self.terminals) {
|
||||
log.debug("Already a terminal with id: ", terminalId);
|
||||
|
@ -50,10 +51,19 @@ module Kubernetes {
|
|||
return terminalId;
|
||||
}
|
||||
var scope = $rootScope.$new();
|
||||
getLogs(entity, scope);
|
||||
scope.podLink = podLink;
|
||||
scope.containerName = containerName;
|
||||
scope.id = terminalId;
|
||||
scope.docked = true;
|
||||
if(terminalId in self.httpTask){
|
||||
self.raiseTerminal(terminalId);
|
||||
return terminalId;
|
||||
}else{
|
||||
self.httpTask[terminalId] = $interval(() =>{
|
||||
getLogs(entity, scope);
|
||||
},2000);
|
||||
}
|
||||
var el = $($compile(template)(scope));
|
||||
var term = {
|
||||
scope: scope,
|
||||
|
@ -66,6 +76,11 @@ module Kubernetes {
|
|||
},
|
||||
closeTerminal: (id) => {
|
||||
var term = self.terminals[id];
|
||||
var timer = self.httpTask[id];
|
||||
if(timer){
|
||||
$interval.cancel(timer);
|
||||
delete self.httpTask[id];
|
||||
}
|
||||
if (term) {
|
||||
term.el.remove();
|
||||
delete self.terminals[id];
|
||||
|
@ -284,5 +299,25 @@ module Kubernetes {
|
|||
}
|
||||
};
|
||||
});
|
||||
|
||||
function getLogs(rc, scope){
|
||||
console.log(scope);
|
||||
var xhr= new XMLHttpRequest();
|
||||
xhr.onreadystatechange = () => {
|
||||
if(xhr.readyState == 4){
|
||||
if (xhr.status == 200){
|
||||
var obj=JSON.parse(xhr.responseText);
|
||||
var text = obj.logContent.replace(/\\n/gmi, '\r\n');
|
||||
scope.logs = text;
|
||||
//return ({text: "aaaaaa"});
|
||||
|
||||
}else{
|
||||
//log = "当前没有可以查看的日志!";
|
||||
}
|
||||
}
|
||||
}
|
||||
xhr.open("POST", "/oracleExtractLog?rcName=" + getName(rc),false);
|
||||
xhr.send(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -254,4 +254,7 @@ legend {
|
|||
.k8s-badge-target {
|
||||
background-color: Red;
|
||||
}
|
||||
.badge-remind{
|
||||
background-color: Red;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue