@riil-frontend/component-topology 9.0.0-a.11 → 9.0.0-a.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.js +9 -9
- package/es/core/editor/components/settings/core/updateElementProperty.js +6 -1
- package/es/core/editor/components/settings/propertyViews/node/data/BindIpInput.js +61 -0
- package/es/core/editor/components/settings/propertyViews/node/data/Data.js +27 -8
- package/es/core/hooks/useTopoEdit.js +133 -16
- package/es/core/models/TopoApp.js +1 -1
- package/es/core/models/utils/linkUtils.js +18 -0
- package/es/core/store/models/topoConfig.js +36 -7
- package/es/core/test/Test.js +52 -0
- package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/ResourceOverview.js +7 -78
- package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/hooks/useMetricPolling.js +27 -37
- package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/services/index.js +57 -1
- package/es/networkTopo/services/link.js +1 -1
- package/es/networkTopo/services/topo/basic.js +4 -3
- package/es/networkTopo/services/topo/networkLink.js +45 -3
- package/es/networkTopo/utils/exitLinkUtil.js +110 -0
- package/es/utils/htElementUtils.js +43 -21
- package/lib/core/editor/components/settings/core/updateElementProperty.js +6 -1
- package/lib/core/editor/components/settings/propertyViews/node/data/BindIpInput.js +74 -0
- package/lib/core/editor/components/settings/propertyViews/node/data/Data.js +28 -8
- package/lib/core/hooks/useTopoEdit.js +133 -15
- package/lib/core/models/TopoApp.js +1 -1
- package/lib/core/models/utils/linkUtils.js +21 -1
- package/lib/core/store/models/topoConfig.js +37 -7
- package/lib/core/test/Test.js +52 -0
- package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/ResourceOverview.js +6 -78
- package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/hooks/useMetricPolling.js +27 -36
- package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/services/index.js +58 -1
- package/lib/networkTopo/services/topo/basic.js +5 -3
- package/lib/networkTopo/services/topo/networkLink.js +45 -3
- package/lib/networkTopo/utils/exitLinkUtil.js +115 -0
- package/lib/utils/htElementUtils.js +45 -21
- package/package.json +2 -2
@@ -27,6 +27,8 @@ var _topoData = require("../../../utils/topoData");
|
|
27
27
|
|
28
28
|
var _topoData2 = require("../../../core/models/topoData");
|
29
29
|
|
30
|
+
var _networkLink = _interopRequireDefault(require("../../../networkTopo/services/topo/networkLink"));
|
31
|
+
|
30
32
|
var _getTopoData = require("../../../networkTopo/getTopoData");
|
31
33
|
|
32
34
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
@@ -264,19 +266,20 @@ function _default(topoApp) {
|
|
264
266
|
var _this2 = this;
|
265
267
|
|
266
268
|
return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
267
|
-
var editState, resources, _editState$groups, groups, _editState$exportLink, exportLinkIdList, query, data;
|
269
|
+
var editState, resources, _editState$groups, groups, _editState$exportLink, exportLinkIdList, _editState$ipNodes, ipNodes, query, data;
|
268
270
|
|
269
271
|
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
270
272
|
while (1) {
|
271
273
|
switch (_context2.prev = _context2.next) {
|
272
274
|
case 0:
|
273
275
|
editState = rootState.topoConfig;
|
274
|
-
resources = editState.resources, _editState$groups = editState.groups, groups = _editState$groups === void 0 ? [] : _editState$groups, _editState$exportLink = editState.exportLinkIdList, exportLinkIdList = _editState$exportLink === void 0 ? [] : _editState$exportLink;
|
276
|
+
resources = editState.resources, _editState$groups = editState.groups, groups = _editState$groups === void 0 ? [] : _editState$groups, _editState$exportLink = editState.exportLinkIdList, exportLinkIdList = _editState$exportLink === void 0 ? [] : _editState$exportLink, _editState$ipNodes = editState.ipNodes, ipNodes = _editState$ipNodes === void 0 ? [] : _editState$ipNodes;
|
275
277
|
query = {
|
276
278
|
id: rootState.topoMod.topoId,
|
277
279
|
resources: resources,
|
278
280
|
groups: groups,
|
279
|
-
exportLinkIdList: exportLinkIdList
|
281
|
+
exportLinkIdList: exportLinkIdList,
|
282
|
+
ipNodes: ipNodes
|
280
283
|
};
|
281
284
|
_context2.next = 5;
|
282
285
|
return _this2.getTopoByConditions(query);
|
@@ -330,14 +333,14 @@ function _default(topoApp) {
|
|
330
333
|
var _this4 = this;
|
331
334
|
|
332
335
|
return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
|
333
|
-
var topoId, resources, groups, exportLinkIdList, viewConditions, groupInfo, data, _yield$Promise$all, dataWithLinkDetail, _combTopoData, topoData, resAndMetrics, topoDataTrans;
|
336
|
+
var topoId, resources, groups, exportLinkIdList, ipNodes, viewConditions, groupInfo, data, _yield$Promise$all, dataWithLinkDetail, _combTopoData, topoData, resAndMetrics, topoDataTrans;
|
334
337
|
|
335
338
|
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
336
339
|
while (1) {
|
337
340
|
switch (_context4.prev = _context4.next) {
|
338
341
|
case 0:
|
339
342
|
// rlog.debug("getTopoByConditions--------", params);
|
340
|
-
topoId = params.id, resources = params.resources, groups = params.groups, exportLinkIdList = params.exportLinkIdList;
|
343
|
+
topoId = params.id, resources = params.resources, groups = params.groups, exportLinkIdList = params.exportLinkIdList, ipNodes = params.ipNodes;
|
341
344
|
viewConditions = (0, _topoData2.resToConditions)(resources);
|
342
345
|
groupInfo = (0, _utils.isAvailableArray)(groups) && groups.map(function (group) {
|
343
346
|
return (0, _extends2["default"])({}, group, {
|
@@ -347,7 +350,7 @@ function _default(topoApp) {
|
|
347
350
|
}); // rlog.debug("getTopoByConditions--------", viewConditions, groupInfo);
|
348
351
|
|
349
352
|
_context4.next = 5;
|
350
|
-
return topoApp.serverApi.getTopoDataByResource(topoId, viewConditions, groupInfo, exportLinkIdList);
|
353
|
+
return topoApp.serverApi.getTopoDataByResource(topoId, viewConditions, groupInfo, exportLinkIdList, ipNodes);
|
351
354
|
|
352
355
|
case 5:
|
353
356
|
data = _context4.sent;
|
@@ -416,7 +419,7 @@ function _default(topoApp) {
|
|
416
419
|
}))
|
417
420
|
};
|
418
421
|
|
419
|
-
_rlog["default"].debug(
|
422
|
+
_rlog["default"].debug("saveGlobalConfig", config);
|
420
423
|
|
421
424
|
_context5.next = 5;
|
422
425
|
return topoApp.serverApi.saveTopoSettings(topoApp.id, config);
|
@@ -485,6 +488,33 @@ function _default(topoApp) {
|
|
485
488
|
switchToViewMode: function switchToViewMode() {
|
486
489
|
this.reset();
|
487
490
|
dispatch.topoMod.switchToViewMode();
|
491
|
+
},
|
492
|
+
queryAllLinkByIp: function queryAllLinkByIp(data) {
|
493
|
+
return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee8() {
|
494
|
+
var _result$data;
|
495
|
+
|
496
|
+
var ids, ip, result;
|
497
|
+
return _regenerator["default"].wrap(function _callee8$(_context8) {
|
498
|
+
while (1) {
|
499
|
+
switch (_context8.prev = _context8.next) {
|
500
|
+
case 0:
|
501
|
+
ids = data.ids, ip = data.ip;
|
502
|
+
console.log("queryAllLinkByIp", ids, ip);
|
503
|
+
_context8.next = 4;
|
504
|
+
return _networkLink["default"].queryLinksByIp(ids, ip);
|
505
|
+
|
506
|
+
case 4:
|
507
|
+
result = _context8.sent;
|
508
|
+
console.log("queryAllLinkByIp-result", result);
|
509
|
+
return _context8.abrupt("return", (_result$data = result === null || result === void 0 ? void 0 : result.data) !== null && _result$data !== void 0 ? _result$data : []);
|
510
|
+
|
511
|
+
case 7:
|
512
|
+
case "end":
|
513
|
+
return _context8.stop();
|
514
|
+
}
|
515
|
+
}
|
516
|
+
}, _callee8);
|
517
|
+
}))();
|
488
518
|
}
|
489
519
|
};
|
490
520
|
}
|
package/lib/core/test/Test.js
CHANGED
@@ -27,6 +27,58 @@ var Test = /*#__PURE__*/function () {
|
|
27
27
|
_proto.onReady = function onReady() {// TODO 待移除测试代码
|
28
28
|
// this.iconManage.openUpload()
|
29
29
|
// this.topo.store.getModelDispatchers('linkDynamicStyleConfig').open({type: 'networkLink'});
|
30
|
+
}
|
31
|
+
/**
|
32
|
+
* 关联IP示例代码
|
33
|
+
*/
|
34
|
+
;
|
35
|
+
|
36
|
+
_proto.createExportLink = function createExportLink() {
|
37
|
+
var htTopo = this.topo.getHtTopo();
|
38
|
+
var dm = htTopo.getGraphView().dm(); // 设置节点关联IP
|
39
|
+
|
40
|
+
var nodeElement = htTopo.getGraphView().sm().fd();
|
41
|
+
var ip = {
|
42
|
+
'id': 'ip_1.1.1.1',
|
43
|
+
'name': '1.1.1.1',
|
44
|
+
customName: null,
|
45
|
+
// 'groupId': null,
|
46
|
+
// 'groupTag': null,
|
47
|
+
'ipAddress': '1.1.1.1',
|
48
|
+
// 'attributes': [],
|
49
|
+
// 'metrics': [],
|
50
|
+
'type': 'node' // 'dtype': 'device'
|
51
|
+
|
52
|
+
};
|
53
|
+
nodeElement.a(ip);
|
54
|
+
nodeElement.setTag('ip_1.1.1.1');
|
55
|
+
var link = {
|
56
|
+
'id': '0000000019b462d1',
|
57
|
+
'name': '172.17.160.116(Gi2/2/0/1) - 172.27.130.13(Gi 0/9)',
|
58
|
+
'source': '00000000029f9411',
|
59
|
+
'target': 'ip_1.1.1.1',
|
60
|
+
'operation': 'delete',
|
61
|
+
'interfaceSource': '0000000018080aee',
|
62
|
+
'interfaceTarget': '000000000341b015',
|
63
|
+
'ciType': 'network_link',
|
64
|
+
'attributes': [],
|
65
|
+
'manageStatus': 0,
|
66
|
+
'permission': {
|
67
|
+
'readable': true,
|
68
|
+
'writeable': true,
|
69
|
+
'deleteable': true
|
70
|
+
},
|
71
|
+
'metrics': [],
|
72
|
+
'type': 'link',
|
73
|
+
'dtype': 'link'
|
74
|
+
};
|
75
|
+
var createElementsData = {
|
76
|
+
groups: [],
|
77
|
+
nodes: [],
|
78
|
+
links: [link],
|
79
|
+
linkGroups: []
|
80
|
+
};
|
81
|
+
htTopo.createElements(createElementsData);
|
30
82
|
};
|
31
83
|
|
32
84
|
return Test;
|
@@ -53,8 +53,6 @@ var _LinkTopoCard = _interopRequireDefault(require("./components/LinkTopo/LinkTo
|
|
53
53
|
|
54
54
|
var _EventsCard = _interopRequireDefault(require("./EventsCard"));
|
55
55
|
|
56
|
-
var _services2 = require("./components/LinkTopo/services");
|
57
|
-
|
58
56
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
59
57
|
|
60
58
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
@@ -726,7 +724,7 @@ function ResourceOverview(props) {
|
|
726
724
|
_metricColChange = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee8(col) {
|
727
725
|
var _col2, _col3;
|
728
726
|
|
729
|
-
var codes, endTime, params, _ref5, times, metricList,
|
727
|
+
var codes, endTime, params, _ref5, times, metricList, metricLists;
|
730
728
|
|
731
729
|
return _regenerator["default"].wrap(function _callee8$(_context8) {
|
732
730
|
while (1) {
|
@@ -774,16 +772,7 @@ function ResourceOverview(props) {
|
|
774
772
|
|
775
773
|
case 11:
|
776
774
|
metricList = _context8.sent;
|
777
|
-
|
778
|
-
return queryMetricList({
|
779
|
-
'name': data.attributes.display_name
|
780
|
-
}, {
|
781
|
-
'id': data.attributes.name
|
782
|
-
});
|
783
|
-
|
784
|
-
case 14:
|
785
|
-
newMetricList = _context8.sent;
|
786
|
-
metricLists = metricList.concat(getNewMetricList(newMetricList));
|
775
|
+
metricLists = metricList.concat(getNewMetricList());
|
787
776
|
|
788
777
|
_rlog.rlog.debug('metricColChange', metricLists, monitorMetricModels);
|
789
778
|
|
@@ -811,7 +800,7 @@ function ResourceOverview(props) {
|
|
811
800
|
}, 60000);
|
812
801
|
}
|
813
802
|
|
814
|
-
case
|
803
|
+
case 17:
|
815
804
|
case "end":
|
816
805
|
return _context8.stop();
|
817
806
|
}
|
@@ -821,73 +810,12 @@ function ResourceOverview(props) {
|
|
821
810
|
return _metricColChange.apply(this, arguments);
|
822
811
|
}
|
823
812
|
|
824
|
-
function
|
825
|
-
return _queryMetricList.apply(this, arguments);
|
826
|
-
}
|
827
|
-
|
828
|
-
function _queryMetricList() {
|
829
|
-
_queryMetricList = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee9(data, param) {
|
830
|
-
var checkMenus, isOpen, list;
|
831
|
-
return _regenerator["default"].wrap(function _callee9$(_context9) {
|
832
|
-
while (1) {
|
833
|
-
switch (_context9.prev = _context9.next) {
|
834
|
-
case 0:
|
835
|
-
if (!(ciType !== 'network_link')) {
|
836
|
-
_context9.next = 2;
|
837
|
-
break;
|
838
|
-
}
|
839
|
-
|
840
|
-
return _context9.abrupt("return", []);
|
841
|
-
|
842
|
-
case 2:
|
843
|
-
_context9.next = 4;
|
844
|
-
return (0, _services2.checkMenu)();
|
845
|
-
|
846
|
-
case 4:
|
847
|
-
checkMenus = _context9.sent;
|
848
|
-
|
849
|
-
if (!(checkMenus[0].passed == 'PASS')) {
|
850
|
-
_context9.next = 14;
|
851
|
-
break;
|
852
|
-
}
|
853
|
-
|
854
|
-
_context9.next = 8;
|
855
|
-
return (0, _services2.isOpenFlow)(data);
|
856
|
-
|
857
|
-
case 8:
|
858
|
-
isOpen = _context9.sent;
|
859
|
-
|
860
|
-
if (!isOpen) {
|
861
|
-
_context9.next = 14;
|
862
|
-
break;
|
863
|
-
}
|
864
|
-
|
865
|
-
_context9.next = 12;
|
866
|
-
return (0, _services2.queryLastestValue)(param);
|
867
|
-
|
868
|
-
case 12:
|
869
|
-
list = _context9.sent;
|
870
|
-
return _context9.abrupt("return", list);
|
871
|
-
|
872
|
-
case 14:
|
873
|
-
return _context9.abrupt("return", []);
|
874
|
-
|
875
|
-
case 15:
|
876
|
-
case "end":
|
877
|
-
return _context9.stop();
|
878
|
-
}
|
879
|
-
}
|
880
|
-
}, _callee9);
|
881
|
-
}));
|
882
|
-
return _queryMetricList.apply(this, arguments);
|
883
|
-
}
|
884
|
-
|
885
|
-
var getNewMetricList = function getNewMetricList(data) {
|
813
|
+
var getNewMetricList = function getNewMetricList() {
|
886
814
|
return [{
|
887
815
|
errorMsg: null,
|
888
816
|
mainCiId: "netDelayRatio",
|
889
817
|
metricCode: "netDelayRatio",
|
890
|
-
metricValue:
|
818
|
+
metricValue: '0',
|
891
819
|
subCiId: '',
|
892
820
|
subCiType: null,
|
893
821
|
mainCiType: null
|
@@ -895,7 +823,7 @@ function ResourceOverview(props) {
|
|
895
823
|
errorMsg: null,
|
896
824
|
mainCiId: "retansRatio",
|
897
825
|
metricCode: "retansRatio",
|
898
|
-
metricValue:
|
826
|
+
metricValue: '0',
|
899
827
|
subCiId: '',
|
900
828
|
subCiType: null,
|
901
829
|
mainCiType: null
|
@@ -25,10 +25,10 @@ function useMetricPolling(_ref) {
|
|
25
25
|
linkMetricCodes = _ref.linkMetricCodes;
|
26
26
|
var linkId = linkCi.id;
|
27
27
|
var arr = ['netDelayRatio', 'retansRatio'];
|
28
|
-
var
|
29
|
-
var
|
28
|
+
var codes = [];
|
29
|
+
var retansRatioNetDelayRatioCodes = [];
|
30
30
|
linkMetricCodes.map(function (item) {
|
31
|
-
arr.indexOf(item) > -1 ?
|
31
|
+
arr.indexOf(item) > -1 ? retansRatioNetDelayRatioCodes.push(item) : codes.push(item);
|
32
32
|
});
|
33
33
|
|
34
34
|
var _useState = (0, _react.useState)({
|
@@ -42,35 +42,15 @@ function useMetricPolling(_ref) {
|
|
42
42
|
data = _useState[0],
|
43
43
|
setData = _useState[1];
|
44
44
|
|
45
|
-
var queryLastestValues = (0, _ahooks.useRequest)(_services.
|
45
|
+
var queryLastestValues = (0, _ahooks.useRequest)(_services.queryRetansRatioNetDelayRatio, {
|
46
46
|
pollingInterval: 1000 * 15,
|
47
47
|
pollingWhenHidden: false,
|
48
48
|
debounceInterval: 200,
|
49
49
|
manual: true,
|
50
50
|
onSuccess: function onSuccess(result) {
|
51
|
-
|
52
|
-
linkOther:
|
53
|
-
};
|
54
|
-
|
55
|
-
if (newCodes.includes('netDelayRatio')) {
|
56
|
-
datas.linkOther.push({
|
57
|
-
'code': 'netDelayRatio',
|
58
|
-
'name': '下行RTT时延',
|
59
|
-
'ts': result.time,
|
60
|
-
'value': result.upNetDelayRatio + ' ms' + '|' + result.downNetDelayRatio + ' ms'
|
61
|
-
});
|
62
|
-
}
|
63
|
-
|
64
|
-
if (newCodes.includes('retansRatio')) {
|
65
|
-
datas.linkOther.push({
|
66
|
-
'code': 'retansRatio',
|
67
|
-
'name': '重传率',
|
68
|
-
'ts': result.time,
|
69
|
-
'value': result.upRetransRatio + ' %' + '|' + result.downRetansRatio + ' %'
|
70
|
-
});
|
71
|
-
}
|
72
|
-
|
73
|
-
setData((0, _extends2["default"])({}, data, datas));
|
51
|
+
setData((0, _extends2["default"])({}, data, {
|
52
|
+
linkOther: result
|
53
|
+
}));
|
74
54
|
}
|
75
55
|
}); // 轮询hooks
|
76
56
|
|
@@ -96,27 +76,38 @@ function useMetricPolling(_ref) {
|
|
96
76
|
_rlog["default"].info('链路拓扑指标轮询 queryInterfaceMetricsRequest 结果', result);
|
97
77
|
}
|
98
78
|
});
|
99
|
-
var linkMetricCodesStr =
|
79
|
+
var linkMetricCodesStr = codes.map(function (item) {
|
100
80
|
return item;
|
101
81
|
}).sort().join(',');
|
102
82
|
(0, _react.useEffect)(function () {
|
103
83
|
if (linkId) {
|
104
84
|
_rlog["default"].info('链路拓扑指标轮询 切换', {
|
105
85
|
linkCi: linkCi,
|
106
|
-
|
86
|
+
codes: codes
|
107
87
|
});
|
108
88
|
|
109
|
-
queryLinkMetricsRequest.run(linkCi,
|
110
|
-
|
111
|
-
if (newCodes.length > 0) {
|
112
|
-
queryLastestValues.run({
|
113
|
-
'id': linkCi.attributes.name
|
114
|
-
});
|
115
|
-
}
|
89
|
+
queryLinkMetricsRequest.run(linkCi, codes);
|
116
90
|
}
|
117
91
|
|
118
92
|
return function () {};
|
119
93
|
}, [linkId, linkMetricCodesStr]);
|
94
|
+
var retansRatioNetDelayRatioCodesStr = retansRatioNetDelayRatioCodes.map(function (item) {
|
95
|
+
return item;
|
96
|
+
}).sort().join(',');
|
97
|
+
(0, _react.useEffect)(function () {
|
98
|
+
if (linkId) {
|
99
|
+
_rlog["default"].info('链路拓扑指标勾选rtt|重传率 轮询', {
|
100
|
+
linkCi: linkCi,
|
101
|
+
retansRatioNetDelayRatioCodes: retansRatioNetDelayRatioCodes
|
102
|
+
});
|
103
|
+
|
104
|
+
queryLastestValues.run({
|
105
|
+
'id': linkCi.attributes.name
|
106
|
+
}, retansRatioNetDelayRatioCodes);
|
107
|
+
}
|
108
|
+
|
109
|
+
return function () {};
|
110
|
+
}, [linkId, retansRatioNetDelayRatioCodesStr]);
|
120
111
|
(0, _react.useEffect)(function () {
|
121
112
|
if (linkId) {
|
122
113
|
_rlog["default"].info('链路拓扑指标轮询 queryInterfaceMetricsRequest 开始', {
|
@@ -10,6 +10,7 @@ exports.queryLastestValue = queryLastestValue;
|
|
10
10
|
exports.queryLatestMetrics = queryLatestMetrics;
|
11
11
|
exports.queryLinkInterfacesLatestMetrics = queryLinkInterfacesLatestMetrics;
|
12
12
|
exports.queryLinkLatestMetrics = queryLinkLatestMetrics;
|
13
|
+
exports.queryRetansRatioNetDelayRatio = queryRetansRatioNetDelayRatio;
|
13
14
|
|
14
15
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
15
16
|
|
@@ -276,7 +277,7 @@ function isOpenFlow(_x6) {
|
|
276
277
|
return _isOpenFlow.apply(this, arguments);
|
277
278
|
}
|
278
279
|
/**
|
279
|
-
* @name
|
280
|
+
* @name queryLastestValue 查指标值
|
280
281
|
* @returns
|
281
282
|
*/
|
282
283
|
|
@@ -319,4 +320,60 @@ function _queryLastestValue() {
|
|
319
320
|
}, _callee7);
|
320
321
|
}));
|
321
322
|
return _queryLastestValue.apply(this, arguments);
|
323
|
+
}
|
324
|
+
|
325
|
+
function queryRetansRatioNetDelayRatio(_x8, _x9) {
|
326
|
+
return _queryRetansRatioNetDelayRatio.apply(this, arguments);
|
327
|
+
}
|
328
|
+
|
329
|
+
function _queryRetansRatioNetDelayRatio() {
|
330
|
+
_queryRetansRatioNetDelayRatio = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee8(params, retansRatioNetDelayRatioCodes) {
|
331
|
+
var result, linkOther;
|
332
|
+
return _regenerator["default"].wrap(function _callee8$(_context8) {
|
333
|
+
while (1) {
|
334
|
+
switch (_context8.prev = _context8.next) {
|
335
|
+
case 0:
|
336
|
+
if (retansRatioNetDelayRatioCodes.length) {
|
337
|
+
_context8.next = 2;
|
338
|
+
break;
|
339
|
+
}
|
340
|
+
|
341
|
+
return _context8.abrupt("return", []);
|
342
|
+
|
343
|
+
case 2:
|
344
|
+
_context8.next = 4;
|
345
|
+
return queryLastestValue(params);
|
346
|
+
|
347
|
+
case 4:
|
348
|
+
result = _context8.sent;
|
349
|
+
linkOther = [];
|
350
|
+
|
351
|
+
if (retansRatioNetDelayRatioCodes.includes('netDelayRatio')) {
|
352
|
+
linkOther.push({
|
353
|
+
'code': 'netDelayRatio',
|
354
|
+
'name': '下行RTT时延',
|
355
|
+
'ts': result.time,
|
356
|
+
'value': (result.upNetDelayRatio * 1).toFixed() + ' ms' + '|' + (result.downNetDelayRatio * 1).toFixed() + ' ms'
|
357
|
+
});
|
358
|
+
}
|
359
|
+
|
360
|
+
if (retansRatioNetDelayRatioCodes.includes('retansRatio')) {
|
361
|
+
linkOther.push({
|
362
|
+
'code': 'retansRatio',
|
363
|
+
'name': '重传率',
|
364
|
+
'ts': result.time,
|
365
|
+
'value': (result.upRetransRatio * 1).toFixed() + ' %' + '|' + (result.downRetansRatio * 1).toFixed() + ' %'
|
366
|
+
});
|
367
|
+
}
|
368
|
+
|
369
|
+
return _context8.abrupt("return", linkOther);
|
370
|
+
|
371
|
+
case 9:
|
372
|
+
case "end":
|
373
|
+
return _context8.stop();
|
374
|
+
}
|
375
|
+
}
|
376
|
+
}, _callee8);
|
377
|
+
}));
|
378
|
+
return _queryRetansRatioNetDelayRatio.apply(this, arguments);
|
322
379
|
}
|
@@ -25,6 +25,8 @@ var _cmdb = require("../cmdb");
|
|
25
25
|
|
26
26
|
var _model = require("../model");
|
27
27
|
|
28
|
+
var _exitLinkUtil = require("../../utils/exitLinkUtil");
|
29
|
+
|
28
30
|
var _excluded = ["groups", "resources"];
|
29
31
|
var API_ROOT = _constants.TOPO_API_ROOT;
|
30
32
|
/**
|
@@ -432,13 +434,13 @@ var _default = (0, _extends2["default"])({
|
|
432
434
|
|
433
435
|
case 3:
|
434
436
|
result = _context12.sent;
|
435
|
-
return _context12.abrupt("return", (0, _extends2["default"])({}, result, {
|
437
|
+
return _context12.abrupt("return", (0, _exitLinkUtil.processExitLink)((0, _extends2["default"])({}, result, {
|
436
438
|
links: ((_result$links = result.links) !== null && _result$links !== void 0 ? _result$links : []).map(function (item) {
|
437
439
|
return (0, _extends2["default"])({}, item, {
|
438
440
|
ciType: 'network_link'
|
439
441
|
});
|
440
442
|
})
|
441
|
-
}));
|
443
|
+
})));
|
442
444
|
|
443
445
|
case 7:
|
444
446
|
_context12.prev = 7;
|
@@ -464,7 +466,7 @@ var _default = (0, _extends2["default"])({
|
|
464
466
|
* @param {Array} groups
|
465
467
|
* @returns
|
466
468
|
*/
|
467
|
-
getTopoDataByResource: function getTopoDataByResource(id, resources, groups, exportLinkIdList) {
|
469
|
+
getTopoDataByResource: function getTopoDataByResource(id, resources, groups, exportLinkIdList, ipNodes) {
|
468
470
|
return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee13() {
|
469
471
|
var _result$links2;
|
470
472
|
|
@@ -17,9 +17,9 @@ var API_ROOT = _constants.TOPO_API_ROOT;
|
|
17
17
|
var _default = {
|
18
18
|
/**
|
19
19
|
* 批量查询ci类型是否可创建链路
|
20
|
-
*
|
21
|
-
* @param {*} typeCodes
|
22
|
-
* @returns
|
20
|
+
*
|
21
|
+
* @param {*} typeCodes
|
22
|
+
* @returns
|
23
23
|
*/
|
24
24
|
getCiTypesConnectable: function getCiTypesConnectable(typeCodes) {
|
25
25
|
return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
@@ -40,6 +40,48 @@ var _default = {
|
|
40
40
|
}
|
41
41
|
}, _callee);
|
42
42
|
}))();
|
43
|
+
},
|
44
|
+
|
45
|
+
/**
|
46
|
+
* 通过ip查询关联链路
|
47
|
+
*
|
48
|
+
* @param {array} ciIds
|
49
|
+
*/
|
50
|
+
queryLinksByIp: function queryLinksByIp(ids, ip) {
|
51
|
+
return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
52
|
+
var stag, condition, parm, result;
|
53
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
54
|
+
while (1) {
|
55
|
+
switch (_context2.prev = _context2.next) {
|
56
|
+
case 0:
|
57
|
+
stag = "'" + ids.join("','") + "'";
|
58
|
+
condition = "type('network_link') && network_link.destination_ipv4 = '" + ip + "' && network_link.source_device_id in [" + stag + "]";
|
59
|
+
parm = {
|
60
|
+
condition: condition,
|
61
|
+
sort: "name asc",
|
62
|
+
currentPage: 1,
|
63
|
+
pageSize: 999
|
64
|
+
};
|
65
|
+
_context2.prev = 3;
|
66
|
+
_context2.next = 6;
|
67
|
+
return _componentTopologyUtils.request.post("/mdc/v1/api/cmdb/commonQueryCiData", parm);
|
68
|
+
|
69
|
+
case 6:
|
70
|
+
result = _context2.sent;
|
71
|
+
return _context2.abrupt("return", result);
|
72
|
+
|
73
|
+
case 10:
|
74
|
+
_context2.prev = 10;
|
75
|
+
_context2.t0 = _context2["catch"](3);
|
76
|
+
rlog.error("通过ip查询关联链路", _context2.t0);
|
77
|
+
|
78
|
+
case 13:
|
79
|
+
case "end":
|
80
|
+
return _context2.stop();
|
81
|
+
}
|
82
|
+
}
|
83
|
+
}, _callee2, null, [[3, 10]]);
|
84
|
+
}))();
|
43
85
|
}
|
44
86
|
};
|
45
87
|
exports["default"] = _default;
|
@@ -0,0 +1,115 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
|
5
|
+
exports.__esModule = true;
|
6
|
+
exports.processExitLink = processExitLink;
|
7
|
+
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
9
|
+
|
10
|
+
function findPingNode(nodes, ip) {
|
11
|
+
return nodes.find(function (node) {
|
12
|
+
return node.ciType === 'ping' && node.ipAddress === ip;
|
13
|
+
});
|
14
|
+
}
|
15
|
+
|
16
|
+
function buildIpNode(ip) {
|
17
|
+
return {
|
18
|
+
'id': "ip_" + ip,
|
19
|
+
'name': ip,
|
20
|
+
bindType: 'ip',
|
21
|
+
// 绑定资源类型。关联资源 值为空,关联IP ip
|
22
|
+
// TODO 所属区域,从序列化拿
|
23
|
+
// 'groupId': null,
|
24
|
+
// 'groupTag': null,
|
25
|
+
'ipAddress': '1.1.1.1',
|
26
|
+
// 'attributes': [],
|
27
|
+
// 'metrics': [],
|
28
|
+
'type': 'node',
|
29
|
+
// 'dtype': 'device'
|
30
|
+
'operation': 'delete'
|
31
|
+
};
|
32
|
+
}
|
33
|
+
|
34
|
+
function getHtSerialize(serialize) {
|
35
|
+
if (serialize) {
|
36
|
+
return JSON.parse(serialize);
|
37
|
+
}
|
38
|
+
|
39
|
+
return null;
|
40
|
+
}
|
41
|
+
|
42
|
+
function isExitLink(link) {
|
43
|
+
return link.attributes.destination_type === 'ip';
|
44
|
+
}
|
45
|
+
|
46
|
+
function processExitLink(topoData) {
|
47
|
+
var nodes = topoData.nodes,
|
48
|
+
links = topoData.links;
|
49
|
+
var serialize = (0, _extends2["default"])({}, getHtSerialize(topoData.serialize)); // 出口链路目的端为IP节点时(非ping资源),IP构造为node节点
|
50
|
+
|
51
|
+
var ipNodes = [];
|
52
|
+
var newLinks = links.map(function (link) {
|
53
|
+
// 非出口链路不处理
|
54
|
+
if (!isExitLink(link)) {
|
55
|
+
return link;
|
56
|
+
} // 如果链路目的端在资源节点列表存在,则不处理
|
57
|
+
|
58
|
+
|
59
|
+
if (link.target && nodes.find(function (node) {
|
60
|
+
return node.id === link.target;
|
61
|
+
})) {
|
62
|
+
return link;
|
63
|
+
} // IP节点构造为node,链路作为标准链路处理
|
64
|
+
|
65
|
+
|
66
|
+
var destinationIp = link.attributes['network_link.destination_ipv4'];
|
67
|
+
var pingNode = findPingNode(nodes, destinationIp); // 目的端为非ping资源的IP节点时,构造为node
|
68
|
+
|
69
|
+
if (!pingNode && !ipNodes.find(function (item) {
|
70
|
+
return item.id === "ip_" + destinationIp;
|
71
|
+
})) {
|
72
|
+
var targetIpNode = buildIpNode(destinationIp);
|
73
|
+
ipNodes.push(targetIpNode);
|
74
|
+
} // 出口链路目的端为 ping资源 时,设置target为ping资源id
|
75
|
+
// 出口链路目的端为 IP节点 时,设置target为ip
|
76
|
+
|
77
|
+
|
78
|
+
var target = pingNode ? pingNode.id : "ip_" + destinationIp; // 序列化升级
|
79
|
+
|
80
|
+
if (!pingNode && serialize) {
|
81
|
+
// 1. 链路在序列化存在且目的端不是IP节点时,序列化升级
|
82
|
+
// 判断目的端节点是否是IP节点
|
83
|
+
var isIpNode = serialize.d.find(function (item) {
|
84
|
+
return item.p.tag === "ip_" + destinationIp;
|
85
|
+
}); // 序列化数据升级图片节点。
|
86
|
+
|
87
|
+
var linkSerialize = serialize.d.find(function (item) {
|
88
|
+
return item.a.id === link.id;
|
89
|
+
});
|
90
|
+
|
91
|
+
if (!isIpNode && linkSerialize) {
|
92
|
+
// 根据链路序列化数据找目的端节点
|
93
|
+
// eslint-disable-next-line no-underscore-dangle
|
94
|
+
var nodeSerialize = serialize.d.find(function (item) {
|
95
|
+
return item.i === linkSerialize.p.target.__i;
|
96
|
+
});
|
97
|
+
nodeSerialize.a = (0, _extends2["default"])({}, nodeSerialize.a, buildIpNode(destinationIp), {
|
98
|
+
isbinding: true
|
99
|
+
});
|
100
|
+
nodeSerialize.p.tag = "ip_" + destinationIp;
|
101
|
+
} // 如果有相同ip的ping资源和图片节点,图片节点消失(从序列化数据删除IP节点)
|
102
|
+
// TODO
|
103
|
+
|
104
|
+
}
|
105
|
+
|
106
|
+
return (0, _extends2["default"])({}, link, {
|
107
|
+
target: target
|
108
|
+
});
|
109
|
+
});
|
110
|
+
return (0, _extends2["default"])({}, topoData, {
|
111
|
+
nodes: [].concat(nodes, ipNodes),
|
112
|
+
links: newLinks,
|
113
|
+
serialize: serialize
|
114
|
+
});
|
115
|
+
}
|