Browse Source

(*)节点资源 接入数据统计参数放到变量中

master
peng.peng 1 year ago
parent
commit
aae3f8c640
  1. 3
      api/.vscode/launch.json
  2. 9
      api/app/lib/controllers/homepage/index.js
  3. 9
      api/config.js

3
api/.vscode/launch.json

@ -27,6 +27,9 @@
"--tf http://91mogo.com/onecity/v5",
"--axyApi https://openapi.anxinyun.cn/api/v1",
"--axyPumpProject 1a271f12-52f2-4d16-8dad-ec0c92d3e0cc/03bzzdh/123456", //
"--kubesphereUserName admin",
"--kubespherePassword Fashion123",
"--statistics https://statistics.anxinyun.cn/statistic"
]
},
{

9
api/app/lib/controllers/homepage/index.js

@ -95,11 +95,11 @@ function getDataTotalTop5(opts) {
async function queryToken_(ctx) {
let rslt = null;
try {
const { k8s } = ctx;
const { k8s, k8sUserName, k8sPassword } = ctx;
const params = {
grant_type: 'password',
username: 'admin',
password: 'Fashion123',
username: k8sUserName || 'admin',
password: k8sPassword || 'Fashion123',
client_id: 'kubesphere',
client_secret: 'kubesphere',
}
@ -214,8 +214,9 @@ function getRestfulInfo(opts) {
function getAccessData(opts) {
return async function (ctx, next) {
try {
const { statistics } = opts;
const projects = '2,35,37,45,70,111,170,187,210,275,276,279'
const url = 'https://statistics.anxinyun.cn/statistic?projects=' + projects
const url = statistics + '?projects=' + projects
let res = await request.get(url)
ctx.status = 200;
ctx.body = { res: res.body || {}, projects };

9
api/config.js

@ -21,6 +21,9 @@ args.option('axyPumpProject', '安心云泵站项目信息');
args.option('yingshiKey', '萤石 KEY')
args.option('yingshiSecret', '萤石 SECRET')
args.option('kubesphereUserName', 'k8s用户名')
args.option('kubespherePassword', 'k8s密码')
args.option('statistics', 'statistics接口地址')
const flags = args.parse(process.argv);
@ -34,6 +37,9 @@ const QINIU_SK = process.env.ANXINCLOUD_QINIU_SECRETKEY || flags.qnsk;
const BACKUPS_URL = process.env.BACKUPS_URL || flags.backups;
const KUBESPHERE_URL = process.env.KUBESPHERE_URL || flags.kubesphere;
const KUBESPHERE_USERNAME = process.env.KUBESPHERE_URL || flags.kubesphereUserName;
const KUBESPHERE_PASSWORD = process.env.KUBESPHERE_URL || flags.kubespherePassword;
const AXY_STATISTICS = process.env.AXY_STATISTICS || flags.statistics;
const DATABASE_CONFIG = process.env.DATABASE_HOST || flags.dbconfig;//同步数据库配置
const WATER_URL = process.env.WATER_URL || flags.water;
const WORKSAFETY_URL = process.env.WORKSAFETY_URL || flags.worksafety;
@ -98,9 +104,12 @@ const product = {
},
backupsUrl: BACKUPS_URL,
k8s: KUBESPHERE_URL,
k8sUserName: KUBESPHERE_USERNAME,
k8sPassword: KUBESPHERE_PASSWORD,
dbConfig: DATABASE_CONFIG,
tfApi: THIRD_FIRECONTROL,
axyPumpProject: AXY_PUMP_PROJECT,
statistics: AXY_STATISTICS,
pssaRequest: [{// name 会作为一个 request 出现在 ctx.app.fs
name: 'anxinyun',
root: AXY_API_URL

Loading…
Cancel
Save