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 1ded508..6e335e0 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 @@ -5,8 +5,10 @@ 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.Server; +import com.bocloud.ims.entity.resource.ServerConfig; import com.bocloud.ims.repository.resource.CloudVendorRepository; import com.bocloud.ims.repository.resource.IpRepository; +import com.bocloud.ims.repository.resource.ServerConfigRepository; import com.bocloud.ims.repository.resource.ServerRepository; import com.bocloud.rpc.interfaces.ims.ImsRpcService; import com.bocloud.service.lock.BocloudACLock; @@ -16,10 +18,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.Assert; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; +import java.util.*; import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; @Slf4j @Service @@ -33,6 +34,8 @@ public class ImsRpcServiceImpl implements ImsRpcService { private ServerRepository serverRepository; @Autowired private CloudVendorRepository cloudVendorRepositoryl; + @Autowired + private ServerConfigRepository serverConfigRepository; @Override public void preemptOrFreeIp(List ipsToPreempt, List ipsToFree) { @@ -79,8 +82,15 @@ public class ImsRpcServiceImpl implements ImsRpcService { .col(CloudVendor::getId).in(vendorIds) .list(); List servers = new ArrayList<>(); + // 获取serverConfig + List serverConfigList = serverConfigRepository.queryProxy().list(); + Map serverConfigMap = serverConfigList.stream() + .collect(Collectors.toMap(ServerConfig::getServerId, serverConfig -> serverConfig)); for (CloudVendor cloudVendor : vendorList) { List list = this.serverRepository.list(1, 100000, null, null, null, cloudVendor.getType(), null, null); + for (Server server : list) { + server.setConfig(serverConfigMap.get(server.getId())); + } servers.addAll(list); } return servers;