@riil-frontend/component-topology 9.0.0-a.10 → 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/1.js +2 -2
- package/build/2.js +1 -1
- package/build/index.css +1 -1
- package/build/index.js +17 -17
- package/es/components/VerticalIconTab/VerticalIconTab.module.scss +11 -5
- package/es/core/editor/components/BackgroundView/index.module.scss +3 -0
- package/es/core/editor/components/Sidebar/Sidebar.module.scss +7 -7
- package/es/core/editor/components/Sidebar/views/CanvasPanel/CanvasPanel.module.scss +1 -0
- package/es/core/editor/components/Sidebar/views/ComponentPanel.js +1 -1
- package/es/core/editor/components/Sidebar/views/ImagePanel/ImagePanel.js +2 -1
- package/es/core/editor/components/Sidebar/views/LinkPanel.js +1 -1
- 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/components/VerticalIconTab/VerticalIconTab.module.scss +11 -5
- package/lib/core/editor/components/BackgroundView/index.module.scss +3 -0
- package/lib/core/editor/components/Sidebar/Sidebar.module.scss +7 -7
- package/lib/core/editor/components/Sidebar/views/CanvasPanel/CanvasPanel.module.scss +1 -0
- package/lib/core/editor/components/Sidebar/views/ComponentPanel.js +1 -1
- package/lib/core/editor/components/Sidebar/views/ImagePanel/ImagePanel.js +2 -1
- package/lib/core/editor/components/Sidebar/views/LinkPanel.js +1 -1
- 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
package/es/core/test/Test.js
CHANGED
@@ -22,6 +22,58 @@ var Test = /*#__PURE__*/function () {
|
|
22
22
|
_proto.onReady = function onReady() {// TODO 待移除测试代码
|
23
23
|
// this.iconManage.openUpload()
|
24
24
|
// this.topo.store.getModelDispatchers('linkDynamicStyleConfig').open({type: 'networkLink'});
|
25
|
+
}
|
26
|
+
/**
|
27
|
+
* 关联IP示例代码
|
28
|
+
*/
|
29
|
+
;
|
30
|
+
|
31
|
+
_proto.createExportLink = function createExportLink() {
|
32
|
+
var htTopo = this.topo.getHtTopo();
|
33
|
+
var dm = htTopo.getGraphView().dm(); // 设置节点关联IP
|
34
|
+
|
35
|
+
var nodeElement = htTopo.getGraphView().sm().fd();
|
36
|
+
var ip = {
|
37
|
+
'id': 'ip_1.1.1.1',
|
38
|
+
'name': '1.1.1.1',
|
39
|
+
customName: null,
|
40
|
+
// 'groupId': null,
|
41
|
+
// 'groupTag': null,
|
42
|
+
'ipAddress': '1.1.1.1',
|
43
|
+
// 'attributes': [],
|
44
|
+
// 'metrics': [],
|
45
|
+
'type': 'node' // 'dtype': 'device'
|
46
|
+
|
47
|
+
};
|
48
|
+
nodeElement.a(ip);
|
49
|
+
nodeElement.setTag('ip_1.1.1.1');
|
50
|
+
var link = {
|
51
|
+
'id': '0000000019b462d1',
|
52
|
+
'name': '172.17.160.116(Gi2/2/0/1) - 172.27.130.13(Gi 0/9)',
|
53
|
+
'source': '00000000029f9411',
|
54
|
+
'target': 'ip_1.1.1.1',
|
55
|
+
'operation': 'delete',
|
56
|
+
'interfaceSource': '0000000018080aee',
|
57
|
+
'interfaceTarget': '000000000341b015',
|
58
|
+
'ciType': 'network_link',
|
59
|
+
'attributes': [],
|
60
|
+
'manageStatus': 0,
|
61
|
+
'permission': {
|
62
|
+
'readable': true,
|
63
|
+
'writeable': true,
|
64
|
+
'deleteable': true
|
65
|
+
},
|
66
|
+
'metrics': [],
|
67
|
+
'type': 'link',
|
68
|
+
'dtype': 'link'
|
69
|
+
};
|
70
|
+
var createElementsData = {
|
71
|
+
groups: [],
|
72
|
+
nodes: [],
|
73
|
+
links: [link],
|
74
|
+
linkGroups: []
|
75
|
+
};
|
76
|
+
htTopo.createElements(createElementsData);
|
25
77
|
};
|
26
78
|
|
27
79
|
return Test;
|
@@ -29,8 +29,7 @@ import useCiAttrAndMetricData from "./useCiAttrAndMetricData";
|
|
29
29
|
import Configurator from "./components/Configurator";
|
30
30
|
import { formatMetric } from "../../../../../../models/attributeFormatter";
|
31
31
|
import LinkTopoCard from "./components/LinkTopo/LinkTopoCard";
|
32
|
-
import EventsCard from "./EventsCard";
|
33
|
-
import { checkMenu, isOpenFlow, queryLastestValue } from "./components/LinkTopo/services"; // url 处理,UICBB 的地址需截取前缀
|
32
|
+
import EventsCard from "./EventsCard"; // url 处理,UICBB 的地址需截取前缀
|
34
33
|
|
35
34
|
function formatUrl(url) {
|
36
35
|
var _window, _window$location;
|
@@ -692,7 +691,7 @@ export default function ResourceOverview(props) {
|
|
692
691
|
_metricColChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(col) {
|
693
692
|
var _col2, _col3;
|
694
693
|
|
695
|
-
var codes, endTime, params, _ref5, times, metricList,
|
694
|
+
var codes, endTime, params, _ref5, times, metricList, metricLists;
|
696
695
|
|
697
696
|
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
698
697
|
while (1) {
|
@@ -740,16 +739,7 @@ export default function ResourceOverview(props) {
|
|
740
739
|
|
741
740
|
case 11:
|
742
741
|
metricList = _context8.sent;
|
743
|
-
|
744
|
-
return queryMetricList({
|
745
|
-
'name': data.attributes.display_name
|
746
|
-
}, {
|
747
|
-
'id': data.attributes.name
|
748
|
-
});
|
749
|
-
|
750
|
-
case 14:
|
751
|
-
newMetricList = _context8.sent;
|
752
|
-
metricLists = metricList.concat(getNewMetricList(newMetricList));
|
742
|
+
metricLists = metricList.concat(getNewMetricList());
|
753
743
|
rlog.debug('metricColChange', metricLists, monitorMetricModels);
|
754
744
|
setMetric(col.map(function (item, key) {
|
755
745
|
return {
|
@@ -775,7 +765,7 @@ export default function ResourceOverview(props) {
|
|
775
765
|
}, 60000);
|
776
766
|
}
|
777
767
|
|
778
|
-
case
|
768
|
+
case 17:
|
779
769
|
case "end":
|
780
770
|
return _context8.stop();
|
781
771
|
}
|
@@ -785,73 +775,12 @@ export default function ResourceOverview(props) {
|
|
785
775
|
return _metricColChange.apply(this, arguments);
|
786
776
|
}
|
787
777
|
|
788
|
-
function
|
789
|
-
return _queryMetricList.apply(this, arguments);
|
790
|
-
}
|
791
|
-
|
792
|
-
function _queryMetricList() {
|
793
|
-
_queryMetricList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(data, param) {
|
794
|
-
var checkMenus, isOpen, list;
|
795
|
-
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
796
|
-
while (1) {
|
797
|
-
switch (_context9.prev = _context9.next) {
|
798
|
-
case 0:
|
799
|
-
if (!(ciType !== 'network_link')) {
|
800
|
-
_context9.next = 2;
|
801
|
-
break;
|
802
|
-
}
|
803
|
-
|
804
|
-
return _context9.abrupt("return", []);
|
805
|
-
|
806
|
-
case 2:
|
807
|
-
_context9.next = 4;
|
808
|
-
return checkMenu();
|
809
|
-
|
810
|
-
case 4:
|
811
|
-
checkMenus = _context9.sent;
|
812
|
-
|
813
|
-
if (!(checkMenus[0].passed == 'PASS')) {
|
814
|
-
_context9.next = 14;
|
815
|
-
break;
|
816
|
-
}
|
817
|
-
|
818
|
-
_context9.next = 8;
|
819
|
-
return isOpenFlow(data);
|
820
|
-
|
821
|
-
case 8:
|
822
|
-
isOpen = _context9.sent;
|
823
|
-
|
824
|
-
if (!isOpen) {
|
825
|
-
_context9.next = 14;
|
826
|
-
break;
|
827
|
-
}
|
828
|
-
|
829
|
-
_context9.next = 12;
|
830
|
-
return queryLastestValue(param);
|
831
|
-
|
832
|
-
case 12:
|
833
|
-
list = _context9.sent;
|
834
|
-
return _context9.abrupt("return", list);
|
835
|
-
|
836
|
-
case 14:
|
837
|
-
return _context9.abrupt("return", []);
|
838
|
-
|
839
|
-
case 15:
|
840
|
-
case "end":
|
841
|
-
return _context9.stop();
|
842
|
-
}
|
843
|
-
}
|
844
|
-
}, _callee9);
|
845
|
-
}));
|
846
|
-
return _queryMetricList.apply(this, arguments);
|
847
|
-
}
|
848
|
-
|
849
|
-
var getNewMetricList = function getNewMetricList(data) {
|
778
|
+
var getNewMetricList = function getNewMetricList() {
|
850
779
|
return [{
|
851
780
|
errorMsg: null,
|
852
781
|
mainCiId: "netDelayRatio",
|
853
782
|
metricCode: "netDelayRatio",
|
854
|
-
metricValue:
|
783
|
+
metricValue: '0',
|
855
784
|
subCiId: '',
|
856
785
|
subCiType: null,
|
857
786
|
mainCiType: null
|
@@ -859,7 +788,7 @@ export default function ResourceOverview(props) {
|
|
859
788
|
errorMsg: null,
|
860
789
|
mainCiId: "retansRatio",
|
861
790
|
metricCode: "retansRatio",
|
862
|
-
metricValue:
|
791
|
+
metricValue: '0',
|
863
792
|
subCiId: '',
|
864
793
|
subCiType: null,
|
865
794
|
mainCiType: null
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
2
|
import React, { useEffect, useState } from 'react';
|
3
3
|
import { useRequest } from 'ahooks';
|
4
|
-
import { queryLinkInterfacesLatestMetrics, queryLinkLatestMetrics,
|
4
|
+
import { queryLinkInterfacesLatestMetrics, queryLinkLatestMetrics, queryRetansRatioNetDelayRatio } from "../services";
|
5
5
|
import rlog from '@riil-frontend/component-topology-utils/es/rlog'; // 资源节点上方色块展示资源的发送速率发送带宽利用率、接收速率发送接收利用率、总错包数
|
6
6
|
|
7
7
|
export default function useMetricPolling(_ref) {
|
@@ -9,10 +9,10 @@ export default function useMetricPolling(_ref) {
|
|
9
9
|
linkMetricCodes = _ref.linkMetricCodes;
|
10
10
|
var linkId = linkCi.id;
|
11
11
|
var arr = ['netDelayRatio', 'retansRatio'];
|
12
|
-
var
|
13
|
-
var
|
12
|
+
var codes = [];
|
13
|
+
var retansRatioNetDelayRatioCodes = [];
|
14
14
|
linkMetricCodes.map(function (item) {
|
15
|
-
arr.indexOf(item) > -1 ?
|
15
|
+
arr.indexOf(item) > -1 ? retansRatioNetDelayRatioCodes.push(item) : codes.push(item);
|
16
16
|
});
|
17
17
|
|
18
18
|
var _useState = useState({
|
@@ -26,35 +26,15 @@ export default function useMetricPolling(_ref) {
|
|
26
26
|
data = _useState[0],
|
27
27
|
setData = _useState[1];
|
28
28
|
|
29
|
-
var queryLastestValues = useRequest(
|
29
|
+
var queryLastestValues = useRequest(queryRetansRatioNetDelayRatio, {
|
30
30
|
pollingInterval: 1000 * 15,
|
31
31
|
pollingWhenHidden: false,
|
32
32
|
debounceInterval: 200,
|
33
33
|
manual: true,
|
34
34
|
onSuccess: function onSuccess(result) {
|
35
|
-
|
36
|
-
linkOther:
|
37
|
-
};
|
38
|
-
|
39
|
-
if (newCodes.includes('netDelayRatio')) {
|
40
|
-
datas.linkOther.push({
|
41
|
-
'code': 'netDelayRatio',
|
42
|
-
'name': '下行RTT时延',
|
43
|
-
'ts': result.time,
|
44
|
-
'value': result.upNetDelayRatio + ' ms' + '|' + result.downNetDelayRatio + ' ms'
|
45
|
-
});
|
46
|
-
}
|
47
|
-
|
48
|
-
if (newCodes.includes('retansRatio')) {
|
49
|
-
datas.linkOther.push({
|
50
|
-
'code': 'retansRatio',
|
51
|
-
'name': '重传率',
|
52
|
-
'ts': result.time,
|
53
|
-
'value': result.upRetransRatio + ' %' + '|' + result.downRetansRatio + ' %'
|
54
|
-
});
|
55
|
-
}
|
56
|
-
|
57
|
-
setData(_extends({}, data, datas));
|
35
|
+
setData(_extends({}, data, {
|
36
|
+
linkOther: result
|
37
|
+
}));
|
58
38
|
}
|
59
39
|
}); // 轮询hooks
|
60
40
|
|
@@ -78,26 +58,36 @@ export default function useMetricPolling(_ref) {
|
|
78
58
|
rlog.info('链路拓扑指标轮询 queryInterfaceMetricsRequest 结果', result);
|
79
59
|
}
|
80
60
|
});
|
81
|
-
var linkMetricCodesStr =
|
61
|
+
var linkMetricCodesStr = codes.map(function (item) {
|
82
62
|
return item;
|
83
63
|
}).sort().join(',');
|
84
64
|
useEffect(function () {
|
85
65
|
if (linkId) {
|
86
66
|
rlog.info('链路拓扑指标轮询 切换', {
|
87
67
|
linkCi: linkCi,
|
88
|
-
|
68
|
+
codes: codes
|
89
69
|
});
|
90
|
-
queryLinkMetricsRequest.run(linkCi,
|
91
|
-
|
92
|
-
if (newCodes.length > 0) {
|
93
|
-
queryLastestValues.run({
|
94
|
-
'id': linkCi.attributes.name
|
95
|
-
});
|
96
|
-
}
|
70
|
+
queryLinkMetricsRequest.run(linkCi, codes);
|
97
71
|
}
|
98
72
|
|
99
73
|
return function () {};
|
100
74
|
}, [linkId, linkMetricCodesStr]);
|
75
|
+
var retansRatioNetDelayRatioCodesStr = retansRatioNetDelayRatioCodes.map(function (item) {
|
76
|
+
return item;
|
77
|
+
}).sort().join(',');
|
78
|
+
useEffect(function () {
|
79
|
+
if (linkId) {
|
80
|
+
rlog.info('链路拓扑指标勾选rtt|重传率 轮询', {
|
81
|
+
linkCi: linkCi,
|
82
|
+
retansRatioNetDelayRatioCodes: retansRatioNetDelayRatioCodes
|
83
|
+
});
|
84
|
+
queryLastestValues.run({
|
85
|
+
'id': linkCi.attributes.name
|
86
|
+
}, retansRatioNetDelayRatioCodes);
|
87
|
+
}
|
88
|
+
|
89
|
+
return function () {};
|
90
|
+
}, [linkId, retansRatioNetDelayRatioCodesStr]);
|
101
91
|
useEffect(function () {
|
102
92
|
if (linkId) {
|
103
93
|
rlog.info('链路拓扑指标轮询 queryInterfaceMetricsRequest 开始', {
|
@@ -245,7 +245,7 @@ export function isOpenFlow(_x6) {
|
|
245
245
|
return _isOpenFlow.apply(this, arguments);
|
246
246
|
}
|
247
247
|
/**
|
248
|
-
* @name
|
248
|
+
* @name queryLastestValue 查指标值
|
249
249
|
* @returns
|
250
250
|
*/
|
251
251
|
|
@@ -287,4 +287,60 @@ function _queryLastestValue() {
|
|
287
287
|
}, _callee7);
|
288
288
|
}));
|
289
289
|
return _queryLastestValue.apply(this, arguments);
|
290
|
+
}
|
291
|
+
|
292
|
+
export function queryRetansRatioNetDelayRatio(_x8, _x9) {
|
293
|
+
return _queryRetansRatioNetDelayRatio.apply(this, arguments);
|
294
|
+
}
|
295
|
+
|
296
|
+
function _queryRetansRatioNetDelayRatio() {
|
297
|
+
_queryRetansRatioNetDelayRatio = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(params, retansRatioNetDelayRatioCodes) {
|
298
|
+
var result, linkOther;
|
299
|
+
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
300
|
+
while (1) {
|
301
|
+
switch (_context8.prev = _context8.next) {
|
302
|
+
case 0:
|
303
|
+
if (retansRatioNetDelayRatioCodes.length) {
|
304
|
+
_context8.next = 2;
|
305
|
+
break;
|
306
|
+
}
|
307
|
+
|
308
|
+
return _context8.abrupt("return", []);
|
309
|
+
|
310
|
+
case 2:
|
311
|
+
_context8.next = 4;
|
312
|
+
return queryLastestValue(params);
|
313
|
+
|
314
|
+
case 4:
|
315
|
+
result = _context8.sent;
|
316
|
+
linkOther = [];
|
317
|
+
|
318
|
+
if (retansRatioNetDelayRatioCodes.includes('netDelayRatio')) {
|
319
|
+
linkOther.push({
|
320
|
+
'code': 'netDelayRatio',
|
321
|
+
'name': '下行RTT时延',
|
322
|
+
'ts': result.time,
|
323
|
+
'value': (result.upNetDelayRatio * 1).toFixed() + ' ms' + '|' + (result.downNetDelayRatio * 1).toFixed() + ' ms'
|
324
|
+
});
|
325
|
+
}
|
326
|
+
|
327
|
+
if (retansRatioNetDelayRatioCodes.includes('retansRatio')) {
|
328
|
+
linkOther.push({
|
329
|
+
'code': 'retansRatio',
|
330
|
+
'name': '重传率',
|
331
|
+
'ts': result.time,
|
332
|
+
'value': (result.upRetransRatio * 1).toFixed() + ' %' + '|' + (result.downRetansRatio * 1).toFixed() + ' %'
|
333
|
+
});
|
334
|
+
}
|
335
|
+
|
336
|
+
return _context8.abrupt("return", linkOther);
|
337
|
+
|
338
|
+
case 9:
|
339
|
+
case "end":
|
340
|
+
return _context8.stop();
|
341
|
+
}
|
342
|
+
}
|
343
|
+
}, _callee8);
|
344
|
+
}));
|
345
|
+
return _queryRetansRatioNetDelayRatio.apply(this, arguments);
|
290
346
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
2
2
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
3
|
-
import { request } from
|
3
|
+
import { request } from "@riil-frontend/component-topology-utils";
|
4
4
|
import rlog from "@riil-frontend/component-topology-utils/es/rlog";
|
5
5
|
export default {
|
6
6
|
/**
|
@@ -9,6 +9,7 @@ import blackList from "./blacklist";
|
|
9
9
|
import { TOPO_API_ROOT } from "./constants";
|
10
10
|
import { commonQuery } from "../cmdb";
|
11
11
|
import { getBatchCi as _getBatchCi, getBatchCiMetric as _getBatchCiMetric } from "../model";
|
12
|
+
import { processExitLink } from "../../utils/exitLinkUtil";
|
12
13
|
var API_ROOT = TOPO_API_ROOT;
|
13
14
|
/**
|
14
15
|
* 拓扑图(看做一个容器)的“父容器”ID
|
@@ -413,13 +414,13 @@ export default _extends({
|
|
413
414
|
|
414
415
|
case 3:
|
415
416
|
result = _context12.sent;
|
416
|
-
return _context12.abrupt("return", _extends({}, result, {
|
417
|
+
return _context12.abrupt("return", processExitLink(_extends({}, result, {
|
417
418
|
links: ((_result$links = result.links) !== null && _result$links !== void 0 ? _result$links : []).map(function (item) {
|
418
419
|
return _extends({}, item, {
|
419
420
|
ciType: 'network_link'
|
420
421
|
});
|
421
422
|
})
|
422
|
-
}));
|
423
|
+
})));
|
423
424
|
|
424
425
|
case 7:
|
425
426
|
_context12.prev = 7;
|
@@ -443,7 +444,7 @@ export default _extends({
|
|
443
444
|
* @param {Array} groups
|
444
445
|
* @returns
|
445
446
|
*/
|
446
|
-
getTopoDataByResource: function getTopoDataByResource(id, resources, groups, exportLinkIdList) {
|
447
|
+
getTopoDataByResource: function getTopoDataByResource(id, resources, groups, exportLinkIdList, ipNodes) {
|
447
448
|
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13() {
|
448
449
|
var _result$links2;
|
449
450
|
|
@@ -6,9 +6,9 @@ var API_ROOT = TOPO_API_ROOT;
|
|
6
6
|
export default {
|
7
7
|
/**
|
8
8
|
* 批量查询ci类型是否可创建链路
|
9
|
-
*
|
10
|
-
* @param {*} typeCodes
|
11
|
-
* @returns
|
9
|
+
*
|
10
|
+
* @param {*} typeCodes
|
11
|
+
* @returns
|
12
12
|
*/
|
13
13
|
getCiTypesConnectable: function getCiTypesConnectable(typeCodes) {
|
14
14
|
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
@@ -29,5 +29,47 @@ export default {
|
|
29
29
|
}
|
30
30
|
}, _callee);
|
31
31
|
}))();
|
32
|
+
},
|
33
|
+
|
34
|
+
/**
|
35
|
+
* 通过ip查询关联链路
|
36
|
+
*
|
37
|
+
* @param {array} ciIds
|
38
|
+
*/
|
39
|
+
queryLinksByIp: function queryLinksByIp(ids, ip) {
|
40
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
41
|
+
var stag, condition, parm, result;
|
42
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
43
|
+
while (1) {
|
44
|
+
switch (_context2.prev = _context2.next) {
|
45
|
+
case 0:
|
46
|
+
stag = "'" + ids.join("','") + "'";
|
47
|
+
condition = "type('network_link') && network_link.destination_ipv4 = '" + ip + "' && network_link.source_device_id in [" + stag + "]";
|
48
|
+
parm = {
|
49
|
+
condition: condition,
|
50
|
+
sort: "name asc",
|
51
|
+
currentPage: 1,
|
52
|
+
pageSize: 999
|
53
|
+
};
|
54
|
+
_context2.prev = 3;
|
55
|
+
_context2.next = 6;
|
56
|
+
return request.post("/mdc/v1/api/cmdb/commonQueryCiData", parm);
|
57
|
+
|
58
|
+
case 6:
|
59
|
+
result = _context2.sent;
|
60
|
+
return _context2.abrupt("return", result);
|
61
|
+
|
62
|
+
case 10:
|
63
|
+
_context2.prev = 10;
|
64
|
+
_context2.t0 = _context2["catch"](3);
|
65
|
+
rlog.error("通过ip查询关联链路", _context2.t0);
|
66
|
+
|
67
|
+
case 13:
|
68
|
+
case "end":
|
69
|
+
return _context2.stop();
|
70
|
+
}
|
71
|
+
}
|
72
|
+
}, _callee2, null, [[3, 10]]);
|
73
|
+
}))();
|
32
74
|
}
|
33
75
|
};
|
@@ -0,0 +1,110 @@
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
2
|
+
|
3
|
+
function findPingNode(nodes, ip) {
|
4
|
+
return nodes.find(function (node) {
|
5
|
+
return node.ciType === 'ping' && node.ipAddress === ip;
|
6
|
+
});
|
7
|
+
}
|
8
|
+
|
9
|
+
function buildIpNode(ip) {
|
10
|
+
return {
|
11
|
+
'id': "ip_" + ip,
|
12
|
+
'name': ip,
|
13
|
+
bindType: 'ip',
|
14
|
+
// 绑定资源类型。关联资源 值为空,关联IP ip
|
15
|
+
// TODO 所属区域,从序列化拿
|
16
|
+
// 'groupId': null,
|
17
|
+
// 'groupTag': null,
|
18
|
+
'ipAddress': '1.1.1.1',
|
19
|
+
// 'attributes': [],
|
20
|
+
// 'metrics': [],
|
21
|
+
'type': 'node',
|
22
|
+
// 'dtype': 'device'
|
23
|
+
'operation': 'delete'
|
24
|
+
};
|
25
|
+
}
|
26
|
+
|
27
|
+
function getHtSerialize(serialize) {
|
28
|
+
if (serialize) {
|
29
|
+
return JSON.parse(serialize);
|
30
|
+
}
|
31
|
+
|
32
|
+
return null;
|
33
|
+
}
|
34
|
+
|
35
|
+
function isExitLink(link) {
|
36
|
+
return link.attributes.destination_type === 'ip';
|
37
|
+
}
|
38
|
+
|
39
|
+
export function processExitLink(topoData) {
|
40
|
+
var nodes = topoData.nodes,
|
41
|
+
links = topoData.links;
|
42
|
+
|
43
|
+
var serialize = _extends({}, getHtSerialize(topoData.serialize)); // 出口链路目的端为IP节点时(非ping资源),IP构造为node节点
|
44
|
+
|
45
|
+
|
46
|
+
var ipNodes = [];
|
47
|
+
var newLinks = links.map(function (link) {
|
48
|
+
// 非出口链路不处理
|
49
|
+
if (!isExitLink(link)) {
|
50
|
+
return link;
|
51
|
+
} // 如果链路目的端在资源节点列表存在,则不处理
|
52
|
+
|
53
|
+
|
54
|
+
if (link.target && nodes.find(function (node) {
|
55
|
+
return node.id === link.target;
|
56
|
+
})) {
|
57
|
+
return link;
|
58
|
+
} // IP节点构造为node,链路作为标准链路处理
|
59
|
+
|
60
|
+
|
61
|
+
var destinationIp = link.attributes['network_link.destination_ipv4'];
|
62
|
+
var pingNode = findPingNode(nodes, destinationIp); // 目的端为非ping资源的IP节点时,构造为node
|
63
|
+
|
64
|
+
if (!pingNode && !ipNodes.find(function (item) {
|
65
|
+
return item.id === "ip_" + destinationIp;
|
66
|
+
})) {
|
67
|
+
var targetIpNode = buildIpNode(destinationIp);
|
68
|
+
ipNodes.push(targetIpNode);
|
69
|
+
} // 出口链路目的端为 ping资源 时,设置target为ping资源id
|
70
|
+
// 出口链路目的端为 IP节点 时,设置target为ip
|
71
|
+
|
72
|
+
|
73
|
+
var target = pingNode ? pingNode.id : "ip_" + destinationIp; // 序列化升级
|
74
|
+
|
75
|
+
if (!pingNode && serialize) {
|
76
|
+
// 1. 链路在序列化存在且目的端不是IP节点时,序列化升级
|
77
|
+
// 判断目的端节点是否是IP节点
|
78
|
+
var isIpNode = serialize.d.find(function (item) {
|
79
|
+
return item.p.tag === "ip_" + destinationIp;
|
80
|
+
}); // 序列化数据升级图片节点。
|
81
|
+
|
82
|
+
var linkSerialize = serialize.d.find(function (item) {
|
83
|
+
return item.a.id === link.id;
|
84
|
+
});
|
85
|
+
|
86
|
+
if (!isIpNode && linkSerialize) {
|
87
|
+
// 根据链路序列化数据找目的端节点
|
88
|
+
// eslint-disable-next-line no-underscore-dangle
|
89
|
+
var nodeSerialize = serialize.d.find(function (item) {
|
90
|
+
return item.i === linkSerialize.p.target.__i;
|
91
|
+
});
|
92
|
+
nodeSerialize.a = _extends({}, nodeSerialize.a, buildIpNode(destinationIp), {
|
93
|
+
isbinding: true
|
94
|
+
});
|
95
|
+
nodeSerialize.p.tag = "ip_" + destinationIp;
|
96
|
+
} // 如果有相同ip的ping资源和图片节点,图片节点消失(从序列化数据删除IP节点)
|
97
|
+
// TODO
|
98
|
+
|
99
|
+
}
|
100
|
+
|
101
|
+
return _extends({}, link, {
|
102
|
+
target: target
|
103
|
+
});
|
104
|
+
});
|
105
|
+
return _extends({}, topoData, {
|
106
|
+
nodes: [].concat(nodes, ipNodes),
|
107
|
+
links: newLinks,
|
108
|
+
serialize: serialize
|
109
|
+
});
|
110
|
+
}
|