Compare commits
No commits in common. "deef8d99f17fd6cc97b6769f83c44b3ef3acbba0" and "185d1cd9ad1465a07ae6bd935a4ad0e645ea8458" have entirely different histories.
deef8d99f1
...
185d1cd9ad
|
@ -150,6 +150,20 @@ public class ServerServiceImpl implements ServerService {
|
||||||
vendorId = Long.valueOf(paramMap.get("vendorId").toString());
|
vendorId = Long.valueOf(paramMap.get("vendorId").toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (null == vendorId) {
|
||||||
|
Integer totals = 0;
|
||||||
|
List<CloudVendor> vendorList = cloudVendorRepository.queryProxy().col(GenericEntity::getDeleted).eq(0).list();
|
||||||
|
List<Server> servers = new ArrayList<>();
|
||||||
|
for (CloudVendor cloudVendor : vendorList) {
|
||||||
|
vendorType = cloudVendor.getType();
|
||||||
|
int total = this.serverRepository.counts(params, labelContent, vendorType, clusterName, vdcName);
|
||||||
|
List<Server> list = this.serverRepository.list(page, rows, params, sorter, labelContent, vendorType, clusterName, vdcName);
|
||||||
|
getServerList(rows, params, cloudVendor, list);
|
||||||
|
servers.addAll(list);
|
||||||
|
totals += total;
|
||||||
|
}
|
||||||
|
gridBean = GridHelper.getBean(page, rows, totals, servers);
|
||||||
|
} else {
|
||||||
CloudVendor vendor = cloudVendorRepository.listById(vendorId);
|
CloudVendor vendor = cloudVendorRepository.listById(vendorId);
|
||||||
if (simple) {
|
if (simple) {
|
||||||
int total = this.serverRepository.count(params, labelContent, vendorType);
|
int total = this.serverRepository.count(params, labelContent, vendorType);
|
||||||
|
@ -158,81 +172,10 @@ public class ServerServiceImpl implements ServerService {
|
||||||
} else {
|
} else {
|
||||||
int total = this.serverRepository.counts(params, labelContent, vendorType, clusterName, vdcName);
|
int total = this.serverRepository.counts(params, labelContent, vendorType, clusterName, vdcName);
|
||||||
List<Server> list = this.serverRepository.list(page, rows, params, sorter, labelContent, vendorType, clusterName, vdcName);
|
List<Server> list = this.serverRepository.list(page, rows, params, sorter, labelContent, vendorType, clusterName, vdcName);
|
||||||
|
getServerList(rows, params, vendor, list);
|
||||||
String azUuid, azName, ratioDesc;
|
|
||||||
Long cpuUsed, cpuHz;
|
|
||||||
Double memoryCapacity, memUsed;
|
|
||||||
ServerConfig config;
|
|
||||||
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) {
|
|
||||||
if (null != vendor && "CLOUDTOWER".equals(vendor.getType())) {
|
|
||||||
server.setNicUuid(netMap.get(server.getId()));
|
|
||||||
}
|
|
||||||
azUuid = server.getAzUuid();
|
|
||||||
if (StringUtils.isNotEmpty(azUuid)) {
|
|
||||||
azName = allAzUuidNameMap.get(azUuid);
|
|
||||||
if (StringUtils.isNotEmpty(azName)) {
|
|
||||||
server.setAzName(azName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
List<NetworkCard> networkCards = networkCardRepository.listByHostIdAndSwitcherAvailable(server.getId(), true);
|
|
||||||
server.setNetcards(networkCards);
|
|
||||||
params.clear();
|
|
||||||
params.add(new Param(MapTools.simpleMap("hostId", server.getId()), Sign.EQ));
|
|
||||||
int vmNum = cloudServerRepository.count(params, 0L);
|
|
||||||
params.add(new Param(MapTools.simpleMap("isTemplate", 1), Sign.EQ));
|
|
||||||
int templateNum = cloudServerRepository.count(params, 0L);
|
|
||||||
server.setVmNum(vmNum - templateNum);
|
|
||||||
server.setTemplateNum(templateNum);
|
|
||||||
if (!StringUtils.isEmpty(server.getResourceGroup())) {
|
|
||||||
Dictionary dictionary = dictionaryRepository.query(server.getResourceGroup(), "RESOURCE_GROUP");
|
|
||||||
if (null != dictionary) {
|
|
||||||
server.setResourceGroupName(dictionary.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 设置这个物理机的资源池
|
|
||||||
if (ServerAssetCategory.X86_SERVER.name().equals(server.getAssetCategory())) {
|
|
||||||
// 这是一个x86物理机
|
|
||||||
server.setGroupName(poolGroupRepository.getGroupNameByResourceTarget(server.getId(),
|
|
||||||
ResourceCategory.Computer.name(), ResourceCatalog.PHYSICAL.name()));
|
|
||||||
}
|
|
||||||
Optional.ofNullable(this.serverConfigRepository.getBySid(server.getId()))
|
|
||||||
.ifPresent(server::setConfig);
|
|
||||||
config = server.getConfig();
|
|
||||||
|
|
||||||
Optional.ofNullable(server.getRole()).ifPresent(role -> {
|
|
||||||
server.setRoles(new ArrayList<>(Arrays.asList(role.split(","))));
|
|
||||||
server.getRoles().remove("nfs_gateway");
|
|
||||||
});
|
|
||||||
|
|
||||||
// 深信服6.8宿主机下拉框增加CPU和内存利用率(非实时数据,以上次同步时候的数据计算)
|
|
||||||
if ("6.8".equalsIgnoreCase(vendor.getVersion()) && CloudProvider.SANGFOR.name().equals(vendor.getType()) && rows == 9999) {
|
|
||||||
ratioDesc = "(CPU" + new BigDecimal(server.getCpuRatio()).multiply(new BigDecimal(100)).setScale(0, RoundingMode.HALF_UP).toString() + "%" + "-内存" + new BigDecimal(server.getMemRatio()).multiply(new BigDecimal(100)).setScale(0, RoundingMode.HALF_UP).toString() + "%)";
|
|
||||||
server.setName(server.getName() + ratioDesc);
|
|
||||||
}
|
|
||||||
// vmware宿主机下拉框增加CPU和内存利用率(非实时数据,以上次同步时候的数据计算)
|
|
||||||
if (CloudProvider.VMWARE.name().equals(vendor.getType()) && rows >= 9999 && config != null) {
|
|
||||||
cpuUsed = (config.getCpuUsed() != null ? config.getCpuUsed() : 0L);
|
|
||||||
cpuHz = (config.getCpuHz() != null ? config.getCpuHz() : 0L);
|
|
||||||
memUsed = (config.getMemUsed() != null ? config.getMemUsed() : 0D);
|
|
||||||
memoryCapacity = (config.getMemoryCapacity() != null ? config.getMemoryCapacity() : 0D);
|
|
||||||
if (cpuHz > 0L && memoryCapacity > 0D) {
|
|
||||||
ratioDesc = "(CPU" + new BigDecimal(cpuUsed * 1.0D / cpuHz).multiply(new BigDecimal(100)).setScale(0, RoundingMode.HALF_UP).toString() + "%" + "-内存" + new BigDecimal(memUsed / memoryCapacity).multiply(new BigDecimal(100)).setScale(0, RoundingMode.HALF_UP).toString() + "%)";
|
|
||||||
server.setName(server.getName() + ratioDesc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
gridBean = GridHelper.getBean(page, rows, total, list);
|
gridBean = GridHelper.getBean(page, rows, total, list);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return new BocloudResult(true, gridBean, "查询成功");
|
return new BocloudResult(true, gridBean, "查询成功");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Query server list fail:", e);
|
logger.error("Query server list fail:", e);
|
||||||
|
|
|
@ -2,10 +2,8 @@ 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.entity.bean.GenericEntity;
|
||||||
import com.bocloud.ims.entity.resource.CloudVendor;
|
|
||||||
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.entity.resource.Server;
|
||||||
import com.bocloud.ims.repository.resource.CloudVendorRepository;
|
|
||||||
import com.bocloud.ims.repository.resource.IpRepository;
|
import com.bocloud.ims.repository.resource.IpRepository;
|
||||||
import com.bocloud.ims.repository.resource.ServerRepository;
|
import com.bocloud.ims.repository.resource.ServerRepository;
|
||||||
import com.bocloud.rpc.interfaces.ims.ImsRpcService;
|
import com.bocloud.rpc.interfaces.ims.ImsRpcService;
|
||||||
|
@ -18,7 +16,6 @@ import org.springframework.util.Assert;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@ -31,8 +28,6 @@ public class ImsRpcServiceImpl implements ImsRpcService {
|
||||||
IpRepository ipRepository;
|
IpRepository ipRepository;
|
||||||
@Autowired
|
@Autowired
|
||||||
private ServerRepository serverRepository;
|
private ServerRepository serverRepository;
|
||||||
@Autowired
|
|
||||||
private CloudVendorRepository cloudVendorRepositoryl;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void preemptOrFreeIp(List<String> ipsToPreempt, List<String> ipsToFree) {
|
public void preemptOrFreeIp(List<String> ipsToPreempt, List<String> ipsToFree) {
|
||||||
|
@ -71,16 +66,4 @@ public class ImsRpcServiceImpl implements ImsRpcService {
|
||||||
.col(Server::getVendorId).eq(vendorId)
|
.col(Server::getVendorId).eq(vendorId)
|
||||||
.col(GenericEntity::getDeleted).eq(false).list();
|
.col(GenericEntity::getDeleted).eq(false).list();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Server> getServerAll(Set<Long> vendorIds) throws Exception {
|
|
||||||
// 获取云平台
|
|
||||||
List<CloudVendor> vendorList = cloudVendorRepositoryl.queryProxy().col(GenericEntity::getDeleted).eq(0).list();
|
|
||||||
List<Server> servers = new ArrayList<>();
|
|
||||||
for (CloudVendor cloudVendor : vendorList) {
|
|
||||||
List<Server> list = this.serverRepository.list(1, 100000, null, null, null, cloudVendor.getType(), null, null);
|
|
||||||
servers.addAll(list);
|
|
||||||
}
|
|
||||||
return servers;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue