|
|
package com.monitor.cmdb.ctrl;
|
|
|
|
|
|
import com.fasterxml.jackson.databind.deser.Deserializers;
|
|
|
import com.model.HostGroup;
|
|
|
import com.model.HostInfo;
|
|
|
import com.model.MObjectInfo;
|
...
|
...
|
@@ -47,10 +48,21 @@ public class MObjectInfoCtrl { |
|
|
ITypeInfoService typeInfoService;
|
|
|
|
|
|
@RequestMapping(value = "/queryHost", method = RequestMethod.POST)
|
|
|
public BaseResponse queryMObject(@RequestBody MObjectHostInfoReq request) {
|
|
|
public BaseResponse queryMObjectHost(@RequestBody MObjectHostInfoReq request) {
|
|
|
|
|
|
DEBUG.debug("Query mobject host info by request: {}", request.getSelectIp());
|
|
|
DEBUG.debug("Query mobject host info by request: {}", request);
|
|
|
|
|
|
BaseResponse response = null;
|
|
|
|
|
|
if (0 == request.getIsGroup()) {
|
|
|
response = queryMHostInfoByIp(request);
|
|
|
} else {
|
|
|
response = queryMHostInfoByGroup(request);
|
|
|
}
|
|
|
return response;
|
|
|
}
|
|
|
|
|
|
private BaseResponse queryMHostInfoByIp(MObjectHostInfoReq request) {
|
|
|
BaseResponse response = new BaseResponse();
|
|
|
|
|
|
MObjectHostInfoModel model = new MObjectHostInfoModel();
|
...
|
...
|
@@ -72,10 +84,11 @@ public class MObjectInfoCtrl { |
|
|
|
|
|
selectIp = info.getHostIp();
|
|
|
|
|
|
selectGroup = info.getGroupName();
|
|
|
|
|
|
selectGroupId = info.getGroupId();
|
|
|
|
|
|
selectGroup = groupService.getHostGroupById(selectGroupId).getData().getGroupName();
|
|
|
|
|
|
|
|
|
} else {
|
|
|
if (sourceGroupList.size() > 0) {
|
|
|
selectGroup = sourceGroupList.get(0).getGroupName();
|
...
|
...
|
@@ -111,6 +124,50 @@ public class MObjectInfoCtrl { |
|
|
}
|
|
|
|
|
|
|
|
|
private BaseResponse queryMHostInfoByGroup(MObjectHostInfoReq request) {
|
|
|
BaseResponse response = new BaseResponse();
|
|
|
|
|
|
MObjectHostInfoModel model = new MObjectHostInfoModel();
|
|
|
|
|
|
List<String> groupList = new ArrayList<>();
|
|
|
|
|
|
List<String> ipList = new ArrayList<>();
|
|
|
|
|
|
String selectIp = "";
|
|
|
|
|
|
String selectGroup = "";
|
|
|
|
|
|
int selectGroupId = 0;
|
|
|
|
|
|
List<HostGroup> sourceGroupList = groupService.getListGroups();
|
|
|
|
|
|
for (HostGroup group : sourceGroupList) {
|
|
|
if (StringUtils.equals(group.getGroupName(), request.getSelectGroup())) {
|
|
|
selectGroupId = group.getId();
|
|
|
selectGroup = group.getGroupName();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
for (HostGroup group : sourceGroupList) {
|
|
|
groupList.add(group.getGroupName());
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isNotBlank(selectGroup)) {
|
|
|
for (HostInfo info : hostInfoService.getHostInfosByGroupId(selectGroupId)) {
|
|
|
ipList.add(info.getHostIp());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
selectIp = ipList.get(0);
|
|
|
model.setSelectIp(selectIp);
|
|
|
model.setSelectGroup(selectGroup);
|
|
|
model.setIpList(ipList);
|
|
|
model.setGroupList(groupList);
|
|
|
response.setData(model);
|
|
|
return response;
|
|
|
}
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/query", method = RequestMethod.POST)
|
|
|
public BaseResponse queryMObject(@RequestBody MObjectInfoReq request) {
|
|
|
|
...
|
...
|
|