1
|
package com.monitor.cmdb.ctrl;
|
1
|
package com.monitor.cmdb.ctrl;
|
2
|
|
2
|
|
|
|
3
|
+import com.fasterxml.jackson.databind.deser.Deserializers;
|
3
|
import com.model.HostGroup;
|
4
|
import com.model.HostGroup;
|
4
|
import com.model.HostInfo;
|
5
|
import com.model.HostInfo;
|
5
|
import com.model.MObjectInfo;
|
6
|
import com.model.MObjectInfo;
|
|
@@ -47,10 +48,21 @@ public class MObjectInfoCtrl { |
|
@@ -47,10 +48,21 @@ public class MObjectInfoCtrl { |
47
|
ITypeInfoService typeInfoService;
|
48
|
ITypeInfoService typeInfoService;
|
48
|
|
49
|
|
49
|
@RequestMapping(value = "/queryHost", method = RequestMethod.POST)
|
50
|
@RequestMapping(value = "/queryHost", method = RequestMethod.POST)
|
50
|
- public BaseResponse queryMObject(@RequestBody MObjectHostInfoReq request) {
|
51
|
+ public BaseResponse queryMObjectHost(@RequestBody MObjectHostInfoReq request) {
|
51
|
|
52
|
|
52
|
- DEBUG.debug("Query mobject host info by request: {}", request.getSelectIp());
|
53
|
+ DEBUG.debug("Query mobject host info by request: {}", request);
|
53
|
|
54
|
|
|
|
55
|
+ BaseResponse response = null;
|
|
|
56
|
+
|
|
|
57
|
+ if (0 == request.getIsGroup()) {
|
|
|
58
|
+ response = queryMHostInfoByIp(request);
|
|
|
59
|
+ } else {
|
|
|
60
|
+ response = queryMHostInfoByGroup(request);
|
|
|
61
|
+ }
|
|
|
62
|
+ return response;
|
|
|
63
|
+ }
|
|
|
64
|
+
|
|
|
65
|
+ private BaseResponse queryMHostInfoByIp(MObjectHostInfoReq request) {
|
54
|
BaseResponse response = new BaseResponse();
|
66
|
BaseResponse response = new BaseResponse();
|
55
|
|
67
|
|
56
|
MObjectHostInfoModel model = new MObjectHostInfoModel();
|
68
|
MObjectHostInfoModel model = new MObjectHostInfoModel();
|
|
@@ -72,10 +84,11 @@ public class MObjectInfoCtrl { |
|
@@ -72,10 +84,11 @@ public class MObjectInfoCtrl { |
72
|
|
84
|
|
73
|
selectIp = info.getHostIp();
|
85
|
selectIp = info.getHostIp();
|
74
|
|
86
|
|
75
|
- selectGroup = info.getGroupName();
|
|
|
76
|
-
|
|
|
77
|
selectGroupId = info.getGroupId();
|
87
|
selectGroupId = info.getGroupId();
|
78
|
|
88
|
|
|
|
89
|
+ selectGroup = groupService.getHostGroupById(selectGroupId).getData().getGroupName();
|
|
|
90
|
+
|
|
|
91
|
+
|
79
|
} else {
|
92
|
} else {
|
80
|
if (sourceGroupList.size() > 0) {
|
93
|
if (sourceGroupList.size() > 0) {
|
81
|
selectGroup = sourceGroupList.get(0).getGroupName();
|
94
|
selectGroup = sourceGroupList.get(0).getGroupName();
|
|
@@ -111,6 +124,50 @@ public class MObjectInfoCtrl { |
|
@@ -111,6 +124,50 @@ public class MObjectInfoCtrl { |
111
|
}
|
124
|
}
|
112
|
|
125
|
|
113
|
|
126
|
|
|
|
127
|
+ private BaseResponse queryMHostInfoByGroup(MObjectHostInfoReq request) {
|
|
|
128
|
+ BaseResponse response = new BaseResponse();
|
|
|
129
|
+
|
|
|
130
|
+ MObjectHostInfoModel model = new MObjectHostInfoModel();
|
|
|
131
|
+
|
|
|
132
|
+ List<String> groupList = new ArrayList<>();
|
|
|
133
|
+
|
|
|
134
|
+ List<String> ipList = new ArrayList<>();
|
|
|
135
|
+
|
|
|
136
|
+ String selectIp = "";
|
|
|
137
|
+
|
|
|
138
|
+ String selectGroup = "";
|
|
|
139
|
+
|
|
|
140
|
+ int selectGroupId = 0;
|
|
|
141
|
+
|
|
|
142
|
+ List<HostGroup> sourceGroupList = groupService.getListGroups();
|
|
|
143
|
+
|
|
|
144
|
+ for (HostGroup group : sourceGroupList) {
|
|
|
145
|
+ if (StringUtils.equals(group.getGroupName(), request.getSelectGroup())) {
|
|
|
146
|
+ selectGroupId = group.getId();
|
|
|
147
|
+ selectGroup = group.getGroupName();
|
|
|
148
|
+ }
|
|
|
149
|
+ }
|
|
|
150
|
+
|
|
|
151
|
+ for (HostGroup group : sourceGroupList) {
|
|
|
152
|
+ groupList.add(group.getGroupName());
|
|
|
153
|
+ }
|
|
|
154
|
+
|
|
|
155
|
+ if (StringUtils.isNotBlank(selectGroup)) {
|
|
|
156
|
+ for (HostInfo info : hostInfoService.getHostInfosByGroupId(selectGroupId)) {
|
|
|
157
|
+ ipList.add(info.getHostIp());
|
|
|
158
|
+ }
|
|
|
159
|
+ }
|
|
|
160
|
+
|
|
|
161
|
+ selectIp = ipList.get(0);
|
|
|
162
|
+ model.setSelectIp(selectIp);
|
|
|
163
|
+ model.setSelectGroup(selectGroup);
|
|
|
164
|
+ model.setIpList(ipList);
|
|
|
165
|
+ model.setGroupList(groupList);
|
|
|
166
|
+ response.setData(model);
|
|
|
167
|
+ return response;
|
|
|
168
|
+ }
|
|
|
169
|
+
|
|
|
170
|
+
|
114
|
@RequestMapping(value = "/query", method = RequestMethod.POST)
|
171
|
@RequestMapping(value = "/query", method = RequestMethod.POST)
|
115
|
public BaseResponse queryMObject(@RequestBody MObjectInfoReq request) {
|
172
|
public BaseResponse queryMObject(@RequestBody MObjectInfoReq request) {
|
116
|
|
173
|
|