diff --git a/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/controller/ContainerController.java b/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/controller/ContainerController.java index 03a64145..c65466e7 100644 --- a/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/controller/ContainerController.java +++ b/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/controller/ContainerController.java @@ -1,6 +1,6 @@ package com.bocloud.ctstack.plugin.controller; -import com.bocloud.ctstack.plugin.domain.model.ContainerClusterModel; +import com.bocloud.ctstack.plugin.domain.model.container.ContainerClusterModel; import com.bocloud.ctstack.plugin.entity.ContainerCluster; import com.bocloud.ctstack.plugin.service.ContainerService; import com.megatron.common.model.GeneralResult; @@ -41,10 +41,10 @@ public class ContainerController { * @param context * @return */ -// @Operation(tags = {"CMC", "CSC"}, summary = "创建集群") -// @PostMapping -// public GeneralResult create(@RequestBody ContainerClusterModel model, -// @Value(Common.REQ_CONTEXT) RequestContext context) { -// return containerService.create(model, context); -// } + @Operation(tags = {"CMC", "CSC"}, summary = "创建集群") + @PostMapping + public GeneralResult create(@RequestBody ContainerClusterModel model, + @Value(Common.REQ_CONTEXT) RequestContext context) { + return containerService.create(model, context); + } } diff --git a/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/domain/model/TianyiSyncModel.java b/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/domain/model/TianyiSyncModel.java index b5813128..a8f5755f 100644 --- a/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/domain/model/TianyiSyncModel.java +++ b/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/domain/model/TianyiSyncModel.java @@ -1,5 +1,6 @@ package com.bocloud.ctstack.plugin.domain.model; +import com.bocloud.ctstack.plugin.domain.model.container.ContainerClusterModel; import com.bocloud.ctstack.plugin.domain.model.database.RdsModel; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/domain/model/ContainerClusterModel.java b/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/domain/model/container/ContainerClusterModel.java similarity index 51% rename from bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/domain/model/ContainerClusterModel.java rename to bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/domain/model/container/ContainerClusterModel.java index 7330ecb6..6ad68505 100644 --- a/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/domain/model/ContainerClusterModel.java +++ b/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/domain/model/container/ContainerClusterModel.java @@ -1,6 +1,5 @@ -package com.bocloud.ctstack.plugin.domain.model; +package com.bocloud.ctstack.plugin.domain.model.container; -import cn.hutool.core.date.DateTime; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @@ -32,4 +31,28 @@ public class ContainerClusterModel { private Long businessId; private List nodeModels; private List nodePoolModels; + + // 平台相同数据 + private Long vendorId; + private String subnetUuid; + private String networkPlugin; + private String clusterDomain; + private String securityGroupUuid; + private Long startPort; + private Long endPort; + private String elbProdCode; + private String billMode; // 计费模式:1为包周期,2为按需 + private String containerRuntime; + private String timezone; + private String deployType; + private String azInfo; + private String kubeProxy; + private String hostType; + private String mirrorCategoryName; + private String clusterSeries; + + // 主节点信息 + private ContainerHostModel masterHost; + // 从节点信息 + private ContainerHostModel slaveHost; } diff --git a/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/domain/model/container/ContainerEBSVoModel.java b/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/domain/model/container/ContainerEBSVoModel.java new file mode 100644 index 00000000..1519d753 --- /dev/null +++ b/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/domain/model/container/ContainerEBSVoModel.java @@ -0,0 +1,16 @@ +package com.bocloud.ctstack.plugin.domain.model.container; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class ContainerEBSVoModel { + private Long itemDefId; // 系统盘id + private String itemDefName; // 系统盘名字 + private String itemDefType; // 系统盘类型 + private String resType; // 主机类型 + private Integer size; // 系统盘大小,单位为Gs +} diff --git a/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/domain/model/container/ContainerHostModel.java b/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/domain/model/container/ContainerHostModel.java new file mode 100644 index 00000000..6538b997 --- /dev/null +++ b/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/domain/model/container/ContainerHostModel.java @@ -0,0 +1,18 @@ +package com.bocloud.ctstack.plugin.domain.model.container; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class ContainerHostModel { + private Long cpu; + private Long memory; + private String itemDefType; + private String resType; + private String size; + private ContainerEBSVoModel sysEBSVo; + private ContainerEBSVoModel dataEBSVo; +} diff --git a/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/domain/model/ContainerNodeModel.java b/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/domain/model/container/ContainerNodeModel.java similarity index 86% rename from bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/domain/model/ContainerNodeModel.java rename to bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/domain/model/container/ContainerNodeModel.java index 7e2d09b2..289537cc 100644 --- a/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/domain/model/ContainerNodeModel.java +++ b/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/domain/model/container/ContainerNodeModel.java @@ -1,4 +1,4 @@ -package com.bocloud.ctstack.plugin.domain.model; +package com.bocloud.ctstack.plugin.domain.model.container; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/domain/model/ContainerNodePoolModel.java b/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/domain/model/container/ContainerNodePoolModel.java similarity index 93% rename from bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/domain/model/ContainerNodePoolModel.java rename to bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/domain/model/container/ContainerNodePoolModel.java index 6cfd1eea..143e06f2 100644 --- a/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/domain/model/ContainerNodePoolModel.java +++ b/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/domain/model/container/ContainerNodePoolModel.java @@ -1,4 +1,4 @@ -package com.bocloud.ctstack.plugin.domain.model; +package com.bocloud.ctstack.plugin.domain.model.container; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/provider/common/TianyiLocationProvider.java b/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/provider/common/TianyiLocationProvider.java index 77034d4e..b5fd7142 100644 --- a/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/provider/common/TianyiLocationProvider.java +++ b/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/provider/common/TianyiLocationProvider.java @@ -5,6 +5,9 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.bocloud.cmp.domain.Butler; import com.bocloud.ctstack.plugin.domain.model.*; +import com.bocloud.ctstack.plugin.domain.model.container.ContainerClusterModel; +import com.bocloud.ctstack.plugin.domain.model.container.ContainerNodeModel; +import com.bocloud.ctstack.plugin.domain.model.container.ContainerNodePoolModel; import com.bocloud.ctstack.plugin.domain.model.database.ProjectModel; import com.bocloud.ctstack.plugin.domain.model.database.RdsModel; import com.bocloud.ctstack.plugin.provider.TianyiProvider; diff --git a/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/provider/container/TianYiContainerClusterProvider.java b/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/provider/container/TianYiContainerClusterProvider.java index d80bc366..40631b93 100644 --- a/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/provider/container/TianYiContainerClusterProvider.java +++ b/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/provider/container/TianYiContainerClusterProvider.java @@ -3,7 +3,7 @@ package com.bocloud.ctstack.plugin.provider.container; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.bocloud.cmp.domain.Butler; -import com.bocloud.ctstack.plugin.domain.model.ContainerClusterModel; +import com.bocloud.ctstack.plugin.domain.model.container.ContainerClusterModel; import com.bocloud.ctstack.plugin.provider.TianyiProvider; import com.bocloud.ctstack.plugin.provider.tianyiconvertor.BeanConvertor; import com.bocloud.ctstack.plugin.provider.tianyiconvertor.ContainerClusterConvertor; @@ -80,12 +80,53 @@ public class TianYiContainerClusterProvider extends TianyiProvider { body.put("resPoolId", model.getResourceGroupUuid()); // clusterBaseV2VO参数 JSONObject clusterBaseV2VO = new JSONObject(); + clusterBaseV2VO.put("subnetUuid", model.getSubnetUuid()); + clusterBaseV2VO.put("networkPlugin", model.getNetworkPlugin()); + clusterBaseV2VO.put("clusterDomain", model.getClusterDomain()); + clusterBaseV2VO.put("securityGroupUuid", model.getSecurityGroupUuid()); + clusterBaseV2VO.put("startPort", model.getStartPort()); + clusterBaseV2VO.put("endPort", model.getEndPort()); + clusterBaseV2VO.put("elbProdCode", model.getElbProdCode()); + clusterBaseV2VO.put("billMode", model.getBillMode()); + clusterBaseV2VO.put("containerRuntime", model.getContainerRuntime()); + clusterBaseV2VO.put("timezone", model.getTimezone()); + clusterBaseV2VO.put("clusterVersion", model.getVersion()); + clusterBaseV2VO.put("deployType", model.getDeployType()); + clusterBaseV2VO.put("azInfo", model.getAzInfo()); + clusterBaseV2VO.put("vpcUuid", model.getVpcUuid()); + clusterBaseV2VO.put("clusterName", model.getClusterUuid()); + clusterBaseV2VO.put("kubeProxy", model.getKubeProxy()); + clusterBaseV2VO.put("hostType", model.getHostType()); + clusterBaseV2VO.put("mirrorCategoryName", model.getMirrorCategoryName()); + clusterBaseV2VO.put("clusterSeries", model.getClusterSeries()); body.put("clusterBaseV2VO", clusterBaseV2VO); // masterHost参数 JSONObject masterHost = new JSONObject(); + masterHost.put("cpu", model.getMasterHost().getCpu()); + masterHost.put("mem", model.getMasterHost().getMemory()); + masterHost.put("itemDefType", model.getMasterHost().getItemDefType()); + masterHost.put("resType", model.getMasterHost().getResType()); + masterHost.put("size", model.getMasterHost().getSize()); + JSONObject sysEBSVo = new JSONObject(); + sysEBSVo.put("size", model.getMasterHost().getSysEBSVo().getSize()); + masterHost.put("sysEBSVo", sysEBSVo); + JSONObject dataEBSVo = new JSONObject(); + dataEBSVo.put("size", model.getMasterHost().getDataEBSVo().getSize()); + masterHost.put("dataEBSVo", dataEBSVo); body.put("masterHost", masterHost); // slaveHost参数 JSONObject slaveHost = new JSONObject(); + slaveHost.put("cpu", model.getSlaveHost().getCpu()); + slaveHost.put("mem", model.getSlaveHost().getMemory()); + slaveHost.put("itemDefType", model.getSlaveHost().getItemDefType()); + slaveHost.put("resType", model.getSlaveHost().getResType()); + slaveHost.put("size", model.getSlaveHost().getSize()); + sysEBSVo = new JSONObject(); + sysEBSVo.put("size", model.getSlaveHost().getSysEBSVo().getSize()); + slaveHost.put("sysEBSVo", sysEBSVo); + dataEBSVo = new JSONObject(); + dataEBSVo.put("size", model.getSlaveHost().getDataEBSVo().getSize()); + slaveHost.put("dataEBSVo", dataEBSVo); body.put("slaveHost", slaveHost); Result result = doPost(url, headers, body); diff --git a/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/provider/container/TianYiContainerNodeProvider.java b/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/provider/container/TianYiContainerNodeProvider.java index 616a6d73..add15ca3 100644 --- a/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/provider/container/TianYiContainerNodeProvider.java +++ b/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/provider/container/TianYiContainerNodeProvider.java @@ -3,8 +3,8 @@ package com.bocloud.ctstack.plugin.provider.container; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.bocloud.cmp.domain.Butler; -import com.bocloud.ctstack.plugin.domain.model.ContainerNodeModel; -import com.bocloud.ctstack.plugin.domain.model.ContainerNodePoolModel; +import com.bocloud.ctstack.plugin.domain.model.container.ContainerNodeModel; +import com.bocloud.ctstack.plugin.domain.model.container.ContainerNodePoolModel; import com.bocloud.ctstack.plugin.provider.TianyiProvider; import com.bocloud.ctstack.plugin.provider.tianyiconvertor.BeanConvertor; import com.bocloud.ctstack.plugin.provider.tianyiconvertor.ContainerNodeConvertor; diff --git a/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/provider/tianyiconvertor/ContainerClusterConvertor.java b/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/provider/tianyiconvertor/ContainerClusterConvertor.java index cedb8c24..69033217 100644 --- a/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/provider/tianyiconvertor/ContainerClusterConvertor.java +++ b/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/provider/tianyiconvertor/ContainerClusterConvertor.java @@ -1,11 +1,8 @@ package com.bocloud.ctstack.plugin.provider.tianyiconvertor; import com.alibaba.fastjson.JSONObject; -import com.bocloud.ctstack.plugin.domain.model.ContainerClusterModel; +import com.bocloud.ctstack.plugin.domain.model.container.ContainerClusterModel; -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; import java.util.*; public class ContainerClusterConvertor implements BeanConvertor { diff --git a/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/provider/tianyiconvertor/ContainerNodeConvertor.java b/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/provider/tianyiconvertor/ContainerNodeConvertor.java index 54ac320d..9eb79141 100644 --- a/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/provider/tianyiconvertor/ContainerNodeConvertor.java +++ b/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/provider/tianyiconvertor/ContainerNodeConvertor.java @@ -1,7 +1,7 @@ package com.bocloud.ctstack.plugin.provider.tianyiconvertor; import com.alibaba.fastjson.JSONObject; -import com.bocloud.ctstack.plugin.domain.model.ContainerNodeModel; +import com.bocloud.ctstack.plugin.domain.model.container.ContainerNodeModel; import java.util.ArrayList; import java.util.List; diff --git a/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/provider/tianyiconvertor/ContainerNodePoolConvertor.java b/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/provider/tianyiconvertor/ContainerNodePoolConvertor.java index 7bb644dc..817ecaf6 100644 --- a/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/provider/tianyiconvertor/ContainerNodePoolConvertor.java +++ b/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/provider/tianyiconvertor/ContainerNodePoolConvertor.java @@ -1,7 +1,7 @@ package com.bocloud.ctstack.plugin.provider.tianyiconvertor; import com.alibaba.fastjson.JSONObject; -import com.bocloud.ctstack.plugin.domain.model.ContainerNodePoolModel; +import com.bocloud.ctstack.plugin.domain.model.container.ContainerNodePoolModel; import java.util.ArrayList; import java.util.List; diff --git a/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/service/ContainerService.java b/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/service/ContainerService.java index eb6e9245..0cb1db22 100644 --- a/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/service/ContainerService.java +++ b/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/service/ContainerService.java @@ -1,11 +1,15 @@ package com.bocloud.ctstack.plugin.service; +import com.bocloud.ctstack.plugin.domain.model.container.ContainerClusterModel; import com.bocloud.ctstack.plugin.entity.ContainerCluster; import com.megatron.common.model.GeneralResult; import com.megatron.common.model.GridBean; import com.megatron.common.model.Pager; +import com.megatron.common.model.RequestContext; public interface ContainerService { GeneralResult> list(Pager pager); + + GeneralResult create(ContainerClusterModel model, RequestContext context); } diff --git a/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/service/impl/ContainerServiceImpl.java b/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/service/impl/ContainerServiceImpl.java index 4f7a4c8d..a8df79df 100644 --- a/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/service/impl/ContainerServiceImpl.java +++ b/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/service/impl/ContainerServiceImpl.java @@ -1,27 +1,33 @@ package com.bocloud.ctstack.plugin.service.impl; -import com.bocloud.cmp.entity.Server; -import com.bocloud.cmp.entity.ServerConfig; -import com.bocloud.ctstack.plugin.entity.Cluster; +import com.alibaba.fastjson.JSONObject; +import com.bocloud.cmp.entity.CloudVendor; +import com.bocloud.cmp.repository.CloudVendorRepository; +import com.bocloud.cmp.util.ResourceEventPublisher; +import com.bocloud.ctstack.plugin.config.ButlerConfig; +import com.bocloud.ctstack.plugin.domain.model.VpcModel; +import com.bocloud.ctstack.plugin.domain.model.container.ContainerClusterModel; +import com.bocloud.ctstack.plugin.domain.model.database.CreateRdsModel; +import com.bocloud.ctstack.plugin.domain.model.database.RdsModel; import com.bocloud.ctstack.plugin.entity.ContainerCluster; +import com.bocloud.ctstack.plugin.provider.container.TianYiContainerClusterProvider; +import com.bocloud.ctstack.plugin.provider.database.TianyiRdsProvider; import com.bocloud.ctstack.plugin.repository.ContainerClusterRepository; import com.bocloud.ctstack.plugin.service.ContainerService; -import com.megatron.common.model.GeneralResult; -import com.megatron.common.model.GridBean; -import com.megatron.common.model.Pager; -import com.megatron.common.model.SimpleBean; +import com.megatron.common.model.*; import com.megatron.common.utils.Common; import com.megatron.common.utils.GridHelper; import com.megatron.common.utils.ListTool; +import com.megatron.common.utils.MapTools; import lombok.extern.slf4j.Slf4j; +import org.springframework.amqp.core.AmqpTemplate; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.stereotype.Service; +import org.springframework.util.Assert; -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; @Slf4j @Service("containerService") @@ -30,6 +36,21 @@ public class ContainerServiceImpl implements ContainerService { @Autowired private ContainerClusterRepository containerClusterRepository; + @Autowired + private ResourceEventPublisher resourceEventPublisher; + + @Autowired + private CloudVendorRepository cloudVendorRepository; + + @Autowired + private ThreadPoolTaskExecutor taskExecutor; + + @Autowired + private ButlerConfig butlerConfig; + + @Autowired + private AmqpTemplate amqpTemplate; + @Override public GeneralResult> list(Pager pager) { GridBean gridBean = null; @@ -49,4 +70,56 @@ public class ContainerServiceImpl implements ContainerService { return new GeneralResult<>(false, "查询容器集群失败"); } } + + public GeneralResult create(ContainerClusterModel model, RequestContext context) { + try { + CloudVendor vendor = cloudVendorRepository.query(model.getVendorId()); + Assert.notNull(vendor, "指定云平台不存在"); + + taskExecutor.submit(() -> { + String operate = vendor.getType().toLowerCase() + ".cloudrds"; + String content = "容器集群创建成功!"; + boolean result = true; + try { + TianYiContainerClusterProvider provider = + new TianYiContainerClusterProvider(butlerConfig.regionButler(vendor.getUuid(), model.getRegionId())); + GeneralResult createResult = provider.create(model); + if (createResult.isFailed()) { + result = false; + content = createResult.getMessage(); + } else { + // 保存新创建的容器集群信息。 + ContainerClusterModel clusterModel = + JSONObject.parseObject(JSONObject.toJSONString(createResult.getData()), ContainerClusterModel.class); + ContainerCluster containerCluster = new ContainerCluster(); + BeanUtils.copyProperties(clusterModel, containerCluster); + containerCluster.setVendorId(vendor.getId()); + containerCluster.setRegionId(model.getRegionId()); + containerCluster.setMenderId(context.getTarget()); + containerCluster.setCreatorId(context.getTarget()); + containerCluster.setTenantId(context.getTenant()); + containerCluster.setProjectId(context.getProject()); + containerClusterRepository.save(containerCluster); + + // TODO: 更新容器集群下的节点和节点池信息 + // 发送给云平台统计队列对云平台重新统计 + JSONObject jsonObject = new JSONObject(); + jsonObject.put(Common.VENDORID, vendor.getId()); + amqpTemplate.convertAndSend("vendor.statistics.queue", jsonObject); + } + } catch (Exception e) { + log.error("create cloud container failure:", e); + result = false; + content = e.getMessage(); + } + resourceEventPublisher.send(new OperateResult(result, content, operate, + MapTools.simpleMap(Common.VENDORID, vendor.getId()), + OperateResult.OperateCategory.ResourceEvent, context)); + }); + return new GeneralResult<>(true, "任务已下发,正在执行..."); + } catch (Exception e) { + log.error("create container cluster failure:", e); + return new GeneralResult(false, "创建容器集群失败", null, null); + } + } } diff --git a/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/service/impl/TianyiTransporter.java b/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/service/impl/TianyiTransporter.java index 4e468ad4..ac5dcd41 100644 --- a/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/service/impl/TianyiTransporter.java +++ b/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/service/impl/TianyiTransporter.java @@ -8,6 +8,9 @@ import com.bocloud.cmp.entity.PhysicalServer; import com.bocloud.cmp.entity.Server; import com.bocloud.cmp.entity.ServerConfig; import com.bocloud.cmp.enums.ResourceCategory; +import com.bocloud.ctstack.plugin.domain.model.container.ContainerClusterModel; +import com.bocloud.ctstack.plugin.domain.model.container.ContainerNodeModel; +import com.bocloud.ctstack.plugin.domain.model.container.ContainerNodePoolModel; import com.bocloud.ctstack.plugin.repository.PhysicalServerRepository; import com.bocloud.cmp.repository.ServerRepository; import com.bocloud.ctstack.plugin.config.ButlerConfig;