diff --git a/bocloud.ims.entity/src/main/java/com/bocloud/ims/entity/resource/CloudServer.java b/bocloud.ims.entity/src/main/java/com/bocloud/ims/entity/resource/CloudServer.java index 43da1bc..2f9c7a5 100644 --- a/bocloud.ims.entity/src/main/java/com/bocloud/ims/entity/resource/CloudServer.java +++ b/bocloud.ims.entity/src/main/java/com/bocloud/ims/entity/resource/CloudServer.java @@ -478,6 +478,8 @@ public class CloudServer extends GenericEntity implements VendorEntity { private List diskList; @IgnoreAll private String statusName; + @IgnoreAll + private String nicUuid; @Column("local_id") diff --git a/bocloud.ims.entity/src/main/java/com/bocloud/ims/entity/resource/Server.java b/bocloud.ims.entity/src/main/java/com/bocloud/ims/entity/resource/Server.java index b750324..1b6a0de 100644 --- a/bocloud.ims.entity/src/main/java/com/bocloud/ims/entity/resource/Server.java +++ b/bocloud.ims.entity/src/main/java/com/bocloud/ims/entity/resource/Server.java @@ -142,6 +142,8 @@ public class Server extends GenericEntity { @IgnoreAll private ServerConfig config; @IgnoreAll + private String nicUuid; + @IgnoreAll private ServerAssets assets; @IgnoreAll private List switchers; diff --git a/bocloud.ims.repository/src/main/java/com/bocloud/ims/repository/resource/ServerRepository.java b/bocloud.ims.repository/src/main/java/com/bocloud/ims/repository/resource/ServerRepository.java index 6772133..584d36d 100644 --- a/bocloud.ims.repository/src/main/java/com/bocloud/ims/repository/resource/ServerRepository.java +++ b/bocloud.ims.repository/src/main/java/com/bocloud/ims/repository/resource/ServerRepository.java @@ -17,6 +17,7 @@ import com.bocloud.database.utils.QueryBuilder; import com.bocloud.ims.entity.resource.Rack; import com.bocloud.ims.entity.resource.Room; import com.bocloud.ims.entity.resource.Server; +import com.bocloud.orm.OrmGenericDaoImpl; import org.apache.commons.lang3.StringUtils; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; @@ -32,7 +33,7 @@ import java.util.*; * @since 2020年5月15日 */ @Repository("serverRepository") -public class ServerRepository extends BasicGenericDao { +public class ServerRepository extends OrmGenericDaoImpl { public ServerRepository(JdbcTemplate jdbcTemplate, NamedParameterJdbcTemplate npJdbcTemplate) { super(jdbcTemplate, npJdbcTemplate); diff --git a/bocloud.ims.service/src/main/java/com/bocloud/ims/service/resource/CloudServerServiceImpl.java b/bocloud.ims.service/src/main/java/com/bocloud/ims/service/resource/CloudServerServiceImpl.java index ce68593..7a9b920 100644 --- a/bocloud.ims.service/src/main/java/com/bocloud/ims/service/resource/CloudServerServiceImpl.java +++ b/bocloud.ims.service/src/main/java/com/bocloud/ims/service/resource/CloudServerServiceImpl.java @@ -437,7 +437,19 @@ public class CloudServerServiceImpl implements CloudServerService, InitializingB }); }); String azUuid, azName; + Map netMap = new HashMap<>(); + CloudVendor cloudVendor = cloudVendorRepository.query(vendorId); + if (null != cloudVendor && "CLOUDTOWER".equals(cloudVendor.getType())) { + List collect = list.stream().map(CloudServer::getId).collect(Collectors.toList()); + List 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) { + if (null != cloudVendor && "CLOUDTOWER".equals(cloudVendor.getType())) { + server.setNicUuid(netMap.get(server.getId())); + } azUuid = server.getAzUuid(); if (StringUtils.isNotEmpty(azUuid)) { azName = allAzUuidNameMap.get(azUuid); diff --git a/bocloud.ims.service/src/main/java/com/bocloud/ims/service/resource/server/ServerServiceImpl.java b/bocloud.ims.service/src/main/java/com/bocloud/ims/service/resource/server/ServerServiceImpl.java index ee854fc..566a313 100644 --- a/bocloud.ims.service/src/main/java/com/bocloud/ims/service/resource/server/ServerServiceImpl.java +++ b/bocloud.ims.service/src/main/java/com/bocloud/ims/service/resource/server/ServerServiceImpl.java @@ -16,6 +16,7 @@ import com.bocloud.cmp.model.sangfor.SangforVsModel; import com.bocloud.common.enums.ResourceCatalog; import com.bocloud.common.model.*; import com.bocloud.common.utils.*; +import com.bocloud.entity.bean.GenericEntity; import com.bocloud.ims.entity.common.Dictionary; import com.bocloud.ims.entity.resource.*; import com.bocloud.ims.interfaces.resource.ServerService; @@ -163,8 +164,18 @@ public class ServerServiceImpl implements ServerService { Double memoryCapacity, memUsed; ServerConfig config; Map allAzUuidNameMap = sangforAzService.getAllAzUuidNameMap(); - + Map netMap = new HashMap<>(); + if (null != vendor && "CLOUDTOWER".equals(vendor.getType())) { + List collect = list.stream().map(Server::getId).collect(Collectors.toList()); + List 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) { + if (null != vendor && "CLOUDTOWER".equals(vendor.getType())) { + server.setNicUuid(netMap.get(server.getId())); + } azUuid = server.getAzUuid(); if (StringUtils.isNotEmpty(azUuid)) { azName = allAzUuidNameMap.get(azUuid); diff --git a/bocloud.ims.service/src/main/java/com/bocloud/ims/service/rpc/ImsRpcServiceImpl.java b/bocloud.ims.service/src/main/java/com/bocloud/ims/service/rpc/ImsRpcServiceImpl.java index 4ee7a11..cf1c585 100644 --- a/bocloud.ims.service/src/main/java/com/bocloud/ims/service/rpc/ImsRpcServiceImpl.java +++ b/bocloud.ims.service/src/main/java/com/bocloud/ims/service/rpc/ImsRpcServiceImpl.java @@ -1,8 +1,11 @@ package com.bocloud.ims.service.rpc; import com.alibaba.fastjson.JSON; +import com.bocloud.entity.bean.GenericEntity; 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.ServerRepository; import com.bocloud.rpc.interfaces.ims.ImsRpcService; import com.bocloud.service.lock.BocloudACLock; import com.bocloud.service.lock.LockFactory; @@ -23,6 +26,8 @@ public class ImsRpcServiceImpl implements ImsRpcService { @Autowired IpRepository ipRepository; + @Autowired + private ServerRepository serverRepository; @Override public void preemptOrFreeIp(List ipsToPreempt, List ipsToFree) { @@ -54,4 +59,11 @@ public class ImsRpcServiceImpl implements ImsRpcService { log.error("Get error message", e); } } + + @Override + public List getServerByName(List serverNameList, Long vendorId) { + return serverRepository.queryProxy().col(GenericEntity::getName).in(serverNameList) + .col(Server::getVendorId).eq(vendorId) + .col(GenericEntity::getDeleted).eq(false).list(); + } } diff --git a/bocloud.ims.service/src/main/java/com/bocloud/ims/service/stats/CmpStatsServiceImpl.java b/bocloud.ims.service/src/main/java/com/bocloud/ims/service/stats/CmpStatsServiceImpl.java index 0b1d53d..9bd9960 100644 --- a/bocloud.ims.service/src/main/java/com/bocloud/ims/service/stats/CmpStatsServiceImpl.java +++ b/bocloud.ims.service/src/main/java/com/bocloud/ims/service/stats/CmpStatsServiceImpl.java @@ -2502,6 +2502,7 @@ public class CmpStatsServiceImpl implements CmpStatsService { if("VMWARE".equalsIgnoreCase(vendor)) { diskType = "PB"; } + diskTotal = new BigDecimal(diskTotal).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); diskMap.put("name", "磁盘"); diskMap.put("value", disk); diskMap.put("total", diskTotal + diskType);