Skip to content

Commit

Permalink
feature: Job 支持容器执行 - 脚本任务 TencentBlueKing#2631
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyu096 committed Dec 7, 2023
1 parent cedc066 commit eec5a28
Show file tree
Hide file tree
Showing 36 changed files with 723 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

import com.tencent.bk.job.common.model.dto.HostDTO;
import com.tencent.bk.job.manage.model.inner.ServiceHostStatusDTO;
import com.tencent.bk.job.manage.model.web.request.ipchooser.BizTopoNode;
import com.tencent.bk.job.manage.model.web.request.chooser.host.BizTopoNode;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import com.tencent.bk.job.manage.model.inner.request.ServiceGetHostStatusByDynamicGroupReq;
import com.tencent.bk.job.manage.model.inner.request.ServiceGetHostStatusByHostReq;
import com.tencent.bk.job.manage.model.inner.request.ServiceGetHostStatusByNodeReq;
import com.tencent.bk.job.manage.model.web.request.ipchooser.BizTopoNode;
import com.tencent.bk.job.manage.model.web.request.chooser.host.BizTopoNode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
import com.tencent.bk.job.manage.model.inner.ServiceTaskStepDTO;
import com.tencent.bk.job.manage.model.inner.ServiceTaskTemplateDTO;
import com.tencent.bk.job.manage.model.inner.resp.ServiceApplicationDTO;
import com.tencent.bk.job.manage.model.web.request.ipchooser.BizTopoNode;
import com.tencent.bk.job.manage.model.web.request.chooser.host.BizTopoNode;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
/*
* Tencent is pleased to support the open source community by making BK-JOB蓝鲸智云作业平台 available.
*
* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
*
* BK-JOB蓝鲸智云作业平台 is licensed under the MIT License.
*
* License for BK-JOB蓝鲸智云作业平台:
* --------------------------------------------------------------------
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
* to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of
* the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
* THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/

package com.tencent.bk.job.manage.api.web;

import com.tencent.bk.job.common.annotation.WebAPI;
import com.tencent.bk.job.common.model.PageData;
import com.tencent.bk.job.common.model.Response;
import com.tencent.bk.job.common.model.dto.AppResourceScope;
import com.tencent.bk.job.manage.model.web.request.chooser.ListTopologyTreesReq;
import com.tencent.bk.job.manage.model.web.request.chooser.container.ContainerCheckReq;
import com.tencent.bk.job.manage.model.web.request.chooser.container.ContainerDetailReq;
import com.tencent.bk.job.manage.model.web.request.chooser.container.ContainerIdWithMeta;
import com.tencent.bk.job.manage.model.web.request.chooser.container.ListContainerByTopologyNodesReq;
import com.tencent.bk.job.manage.model.web.vo.chooser.container.ContainerTopologyNodeVO;
import com.tencent.bk.job.manage.model.web.vo.chooser.container.ContainerVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

/**
* 容器管理 WEB API
*/
@Api(tags = {"job-manage", "web", "container_management"})
@RequestMapping("/web")
@RestController
@WebAPI
public interface WebContainerResource {

// 容器选择器标准接口-1
@ApiOperation(value = "获取容器拓扑树(含各节点容器数)", produces = "application/json")
@PostMapping(value = {"/scope/{scopeType}/{scopeId}/topology/container"})
Response<List<ContainerTopologyNodeVO>> listTopologyTrees(
@ApiParam("用户名,网关自动传入")
@RequestHeader("username")
String username,
@ApiIgnore
@RequestAttribute(value = "appResourceScope")
AppResourceScope appResourceScope,
@ApiParam(value = "资源范围类型", required = true)
@PathVariable(value = "scopeType")
String scopeType,
@ApiParam(value = "资源范围ID", required = true)
@PathVariable(value = "scopeId")
String scopeId,
@ApiParam(value = "资源范围信息")
@RequestBody(required = false)
ListTopologyTreesReq req
);

// 容器选择器标准接口-2
@ApiOperation(value = "容器选择器根据拓扑节点集合获取容器列表", produces = "application/json")
@PostMapping(value = {"/scope/{scopeType}/{scopeId}/topology/containers/nodes"})
Response<PageData<ContainerVO>> listContainerByTopologyNodes(
@ApiParam("用户名,网关自动传入")
@RequestHeader("username")
String username,
@ApiIgnore
@RequestAttribute(value = "appResourceScope")
AppResourceScope appResourceScope,
@ApiParam(value = "资源范围类型", required = true)
@PathVariable(value = "scopeType")
String scopeType,
@ApiParam(value = "资源范围ID", required = true)
@PathVariable(value = "scopeId")
String scopeId,
@ApiParam(value = "拓扑节点集合与分页信息", required = true)
@RequestBody
ListContainerByTopologyNodesReq req
);

// 容器选择器标准接口-3
@ApiOperation(value = "容器选择器根据拓扑节点集合获取容器资源ID列表,用于跨页全选容器功能"
, produces = "application/json")
@PostMapping(value = {"/scope/{scopeType}/{scopeId}/topology/containerIds/nodes"})
Response<PageData<ContainerIdWithMeta>> listContainerIdByTopologyNodes(
@ApiParam("用户名,网关自动传入")
@RequestHeader("username")
String username,
@ApiIgnore
@RequestAttribute(value = "appResourceScope")
AppResourceScope appResourceScope,
@ApiParam(value = "资源范围类型", required = true)
@PathVariable(value = "scopeType")
String scopeType,
@ApiParam(value = "资源范围ID", required = true)
@PathVariable(value = "scopeId")
String scopeId,
@ApiParam(value = "拓扑节点集合与分页信息", required = true)
@RequestBody
ListContainerByTopologyNodesReq req
);


// 容器选择器标准接口-4
@ApiOperation(value = "根据用户选择/输入的容器信息获取容器")
@PostMapping(value = {"/scope/{scopeType}/{scopeId}/container/check"})
Response<List<ContainerVO>> checkContainers(
@ApiParam("用户名,网关自动传入")
@RequestHeader("username")
String username,
@ApiIgnore
@RequestAttribute(value = "appResourceScope")
AppResourceScope appResourceScope,
@ApiParam(value = "资源范围类型", required = true)
@PathVariable(value = "scopeType")
String scopeType,
@ApiParam(value = "资源范围ID", required = true)
@PathVariable(value = "scopeId")
String scopeId,
@ApiParam(value = "用户选择/输入的容器信息", required = true)
@RequestBody
ContainerCheckReq req
);

// 容器选择器标准接口-5
@ApiOperation(value = "根据容器资源 ID批量查询容器详情信息")
@PostMapping(value = {"/scope/{scopeType}/{scopeId}/containers/details"})
Response<List<ContainerVO>> getContainerDetails(
@ApiParam("用户名,网关自动传入")
@RequestHeader("username")
String username,
@ApiIgnore
@RequestAttribute(value = "appResourceScope")
AppResourceScope appResourceScope,
@ApiParam(value = "资源范围类型", required = true)
@PathVariable(value = "scopeType")
String scopeType,
@ApiParam(value = "资源范围ID", required = true)
@PathVariable(value = "scopeId")
String scopeId,
@ApiParam(value = "容器ID及元数据信息", required = true)
@RequestBody
ContainerDetailReq req
);

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@
import com.tencent.bk.job.common.model.vo.HostInfoVO;
import com.tencent.bk.job.manage.model.web.request.AgentStatisticsReq;
import com.tencent.bk.job.manage.model.web.request.HostCheckReq;
import com.tencent.bk.job.manage.model.web.request.ipchooser.GetHostAgentStatisticsByDynamicGroupsReq;
import com.tencent.bk.job.manage.model.web.request.ipchooser.GetHostAgentStatisticsByNodesReq;
import com.tencent.bk.job.manage.model.web.request.ipchooser.HostDetailReq;
import com.tencent.bk.job.manage.model.web.request.ipchooser.HostIdWithMeta;
import com.tencent.bk.job.manage.model.web.request.ipchooser.ListDynamicGroupsReq;
import com.tencent.bk.job.manage.model.web.request.ipchooser.ListHostByBizTopologyNodesReq;
import com.tencent.bk.job.manage.model.web.request.ipchooser.ListTopologyHostCountTreesReq;
import com.tencent.bk.job.manage.model.web.request.ipchooser.PageListHostsByDynamicGroupReq;
import com.tencent.bk.job.manage.model.web.request.ipchooser.QueryNodesPathReq;
import com.tencent.bk.job.manage.model.web.request.chooser.ListTopologyTreesReq;
import com.tencent.bk.job.manage.model.web.request.chooser.host.GetHostAgentStatisticsByDynamicGroupsReq;
import com.tencent.bk.job.manage.model.web.request.chooser.host.GetHostAgentStatisticsByNodesReq;
import com.tencent.bk.job.manage.model.web.request.chooser.host.HostDetailReq;
import com.tencent.bk.job.manage.model.web.request.chooser.host.HostIdWithMeta;
import com.tencent.bk.job.manage.model.web.request.chooser.host.ListDynamicGroupsReq;
import com.tencent.bk.job.manage.model.web.request.chooser.host.ListHostByBizTopologyNodesReq;
import com.tencent.bk.job.manage.model.web.request.chooser.host.PageListHostsByDynamicGroupReq;
import com.tencent.bk.job.manage.model.web.request.chooser.host.QueryNodesPathReq;
import com.tencent.bk.job.manage.model.web.vo.CcTopologyNodeVO;
import com.tencent.bk.job.manage.model.web.vo.DynamicGroupBasicVO;
import com.tencent.bk.job.manage.model.web.vo.common.AgentStatistics;
Expand Down Expand Up @@ -126,7 +126,7 @@ Response<List<CcTopologyNodeVO>> listTopologyHostCountTrees(
String scopeId,
@ApiParam(value = "资源范围信息")
@RequestBody(required = false)
ListTopologyHostCountTreesReq req
ListTopologyTreesReq req
);

// 标准接口2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

package com.tencent.bk.job.manage.model.inner.request;

import com.tencent.bk.job.manage.model.web.request.ipchooser.BizTopoNode;
import com.tencent.bk.job.manage.model.web.request.chooser.host.BizTopoNode;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
package com.tencent.bk.job.manage.model.web.request;

import com.tencent.bk.job.common.model.vo.DynamicGroupIdWithMeta;
import com.tencent.bk.job.manage.model.web.request.ipchooser.BizTopoNode;
import com.tencent.bk.job.manage.model.web.request.ipchooser.HostIdWithMeta;
import com.tencent.bk.job.manage.model.web.request.chooser.host.BizTopoNode;
import com.tencent.bk.job.manage.model.web.request.chooser.host.HostIdWithMeta;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,17 @@
* IN THE SOFTWARE.
*/

package com.tencent.bk.job.manage.model.web.request.ipchooser;
package com.tencent.bk.job.manage.model.web.request.chooser;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.List;

/**
* @Description
* @Date 2020/3/23
* @Version 1.0
*/
@Data
@ApiModel("获取含主机数量的拓扑树")
public class ListTopologyHostCountTreesReq {
@ApiModel("获取拓扑树请求")
public class ListTopologyTreesReq {

@ApiModelProperty(value = "是否获取所有资源范围的拓扑结构,默认为false", required = true)
Boolean allScope = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* IN THE SOFTWARE.
*/

package com.tencent.bk.job.manage.model.web.request.ipchooser;
package com.tencent.bk.job.manage.model.web.request.chooser;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Tencent is pleased to support the open source community by making BK-JOB蓝鲸智云作业平台 available.
*
* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
*
* BK-JOB蓝鲸智云作业平台 is licensed under the MIT License.
*
* License for BK-JOB蓝鲸智云作业平台:
* --------------------------------------------------------------------
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
* to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of
* the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
* THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/

package com.tencent.bk.job.manage.model.web.request.chooser.container;

import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
@ApiModel("容器检查请求报文")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ContainerCheckReq {

@ApiModelProperty(value = "容器Uid列表", required = true)
private List<String> containerUidList = new ArrayList<>();

}


Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Tencent is pleased to support the open source community by making BK-JOB蓝鲸智云作业平台 available.
*
* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
*
* BK-JOB蓝鲸智云作业平台 is licensed under the MIT License.
*
* License for BK-JOB蓝鲸智云作业平台:
* --------------------------------------------------------------------
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
* to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of
* the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
* THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/

package com.tencent.bk.job.manage.model.web.request.chooser.container;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
@ApiModel("容器详情请求报文")
public class ContainerDetailReq {

@ApiModelProperty(value = "containerId及元数据列表", required = true)
List<ContainerIdWithMeta> containerList = new ArrayList<>();

}


Loading

0 comments on commit eec5a28

Please sign in to comment.