迁移cloudTower监控告警

develop
bayuzhen 2024-05-28 18:37:47 +08:00
parent ac490ab0ea
commit 3116e622ef
7 changed files with 43 additions and 2 deletions

View File

@ -478,6 +478,8 @@ public class CloudServer extends GenericEntity implements VendorEntity {
private List<Volume> diskList; private List<Volume> diskList;
@IgnoreAll @IgnoreAll
private String statusName; private String statusName;
@IgnoreAll
private String nicUuid;
@Column("local_id") @Column("local_id")

View File

@ -142,6 +142,8 @@ public class Server extends GenericEntity {
@IgnoreAll @IgnoreAll
private ServerConfig config; private ServerConfig config;
@IgnoreAll @IgnoreAll
private String nicUuid;
@IgnoreAll
private ServerAssets assets; private ServerAssets assets;
@IgnoreAll @IgnoreAll
private List<Switcher> switchers; private List<Switcher> switchers;

View File

@ -17,6 +17,7 @@ import com.bocloud.database.utils.QueryBuilder;
import com.bocloud.ims.entity.resource.Rack; import com.bocloud.ims.entity.resource.Rack;
import com.bocloud.ims.entity.resource.Room; import com.bocloud.ims.entity.resource.Room;
import com.bocloud.ims.entity.resource.Server; import com.bocloud.ims.entity.resource.Server;
import com.bocloud.orm.OrmGenericDaoImpl;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
@ -32,7 +33,7 @@ import java.util.*;
* @since 2020515 * @since 2020515
*/ */
@Repository("serverRepository") @Repository("serverRepository")
public class ServerRepository extends BasicGenericDao<Server, Long> { public class ServerRepository extends OrmGenericDaoImpl<Server, Long> {
public ServerRepository(JdbcTemplate jdbcTemplate, NamedParameterJdbcTemplate npJdbcTemplate) { public ServerRepository(JdbcTemplate jdbcTemplate, NamedParameterJdbcTemplate npJdbcTemplate) {
super(jdbcTemplate, npJdbcTemplate); super(jdbcTemplate, npJdbcTemplate);

View File

@ -437,7 +437,19 @@ public class CloudServerServiceImpl implements CloudServerService, InitializingB
}); });
}); });
String azUuid, azName; String azUuid, azName;
Map<Long, String> netMap = new HashMap<>();
CloudVendor cloudVendor = cloudVendorRepository.query(vendorId);
if (null != cloudVendor && "CLOUDTOWER".equals(cloudVendor.getType())) {
List<Long> collect = list.stream().map(CloudServer::getId).collect(Collectors.toList());
List<NetworkCard> networkCardList = networkCardRepository.queryProxy().col(NetworkCard::getHostId).in(collect)
.col(NetworkCard::getCategory).eq("VM")
.col(GenericEntity::getDeleted).eq(false).list();
netMap = networkCardList.stream().collect(Collectors.toMap(NetworkCard::getHostId, NetworkCard::getInstanceId, (existingValue, newValue) -> newValue));
}
for (CloudServer server : list) { for (CloudServer server : list) {
if (null != cloudVendor && "CLOUDTOWER".equals(cloudVendor.getType())) {
server.setNicUuid(netMap.get(server.getId()));
}
azUuid = server.getAzUuid(); azUuid = server.getAzUuid();
if (StringUtils.isNotEmpty(azUuid)) { if (StringUtils.isNotEmpty(azUuid)) {
azName = allAzUuidNameMap.get(azUuid); azName = allAzUuidNameMap.get(azUuid);

View File

@ -16,6 +16,7 @@ import com.bocloud.cmp.model.sangfor.SangforVsModel;
import com.bocloud.common.enums.ResourceCatalog; import com.bocloud.common.enums.ResourceCatalog;
import com.bocloud.common.model.*; import com.bocloud.common.model.*;
import com.bocloud.common.utils.*; import com.bocloud.common.utils.*;
import com.bocloud.entity.bean.GenericEntity;
import com.bocloud.ims.entity.common.Dictionary; import com.bocloud.ims.entity.common.Dictionary;
import com.bocloud.ims.entity.resource.*; import com.bocloud.ims.entity.resource.*;
import com.bocloud.ims.interfaces.resource.ServerService; import com.bocloud.ims.interfaces.resource.ServerService;
@ -163,8 +164,18 @@ public class ServerServiceImpl implements ServerService {
Double memoryCapacity, memUsed; Double memoryCapacity, memUsed;
ServerConfig config; ServerConfig config;
Map<String, String> allAzUuidNameMap = sangforAzService.getAllAzUuidNameMap(); Map<String, String> allAzUuidNameMap = sangforAzService.getAllAzUuidNameMap();
Map<Long, String> netMap = new HashMap<>();
if (null != vendor && "CLOUDTOWER".equals(vendor.getType())) {
List<Long> collect = list.stream().map(Server::getId).collect(Collectors.toList());
List<NetworkCard> networkCardList = networkCardRepository.queryProxy().col(NetworkCard::getHostId).in(collect)
.col(NetworkCard::getCategory).eq("PM")
.col(GenericEntity::getDeleted).eq(false).list();
netMap = networkCardList.stream().collect(Collectors.toMap(NetworkCard::getHostId, NetworkCard::getInstanceId, (existingValue, newValue) -> newValue));
}
for (Server server : list) { for (Server server : list) {
if (null != vendor && "CLOUDTOWER".equals(vendor.getType())) {
server.setNicUuid(netMap.get(server.getId()));
}
azUuid = server.getAzUuid(); azUuid = server.getAzUuid();
if (StringUtils.isNotEmpty(azUuid)) { if (StringUtils.isNotEmpty(azUuid)) {
azName = allAzUuidNameMap.get(azUuid); azName = allAzUuidNameMap.get(azUuid);

View File

@ -1,8 +1,11 @@
package com.bocloud.ims.service.rpc; package com.bocloud.ims.service.rpc;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.bocloud.entity.bean.GenericEntity;
import com.bocloud.ims.entity.resource.Ip; import com.bocloud.ims.entity.resource.Ip;
import com.bocloud.ims.entity.resource.Server;
import com.bocloud.ims.repository.resource.IpRepository; import com.bocloud.ims.repository.resource.IpRepository;
import com.bocloud.ims.repository.resource.ServerRepository;
import com.bocloud.rpc.interfaces.ims.ImsRpcService; import com.bocloud.rpc.interfaces.ims.ImsRpcService;
import com.bocloud.service.lock.BocloudACLock; import com.bocloud.service.lock.BocloudACLock;
import com.bocloud.service.lock.LockFactory; import com.bocloud.service.lock.LockFactory;
@ -23,6 +26,8 @@ public class ImsRpcServiceImpl implements ImsRpcService {
@Autowired @Autowired
IpRepository ipRepository; IpRepository ipRepository;
@Autowired
private ServerRepository serverRepository;
@Override @Override
public void preemptOrFreeIp(List<String> ipsToPreempt, List<String> ipsToFree) { public void preemptOrFreeIp(List<String> ipsToPreempt, List<String> ipsToFree) {
@ -54,4 +59,11 @@ public class ImsRpcServiceImpl implements ImsRpcService {
log.error("Get error message", e); log.error("Get error message", e);
} }
} }
@Override
public List<Server> getServerByName(List<String> serverNameList, Long vendorId) {
return serverRepository.queryProxy().col(GenericEntity::getName).in(serverNameList)
.col(Server::getVendorId).eq(vendorId)
.col(GenericEntity::getDeleted).eq(false).list();
}
} }

View File

@ -2502,6 +2502,7 @@ public class CmpStatsServiceImpl implements CmpStatsService {
if("VMWARE".equalsIgnoreCase(vendor)) { if("VMWARE".equalsIgnoreCase(vendor)) {
diskType = "PB"; diskType = "PB";
} }
diskTotal = new BigDecimal(diskTotal).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
diskMap.put("name", "磁盘"); diskMap.put("name", "磁盘");
diskMap.put("value", disk); diskMap.put("value", disk);
diskMap.put("total", diskTotal + diskType); diskMap.put("total", diskTotal + diskType);