Skip to content

Commit

Permalink
Merge pull request #2547 from wangyu096/issue_2494
Browse files Browse the repository at this point in the history
fix: 作业执行详情-步骤-主机信息需要显示主机快照数据,而不是当前的数据 #2494
  • Loading branch information
jsonwan authored Oct 26, 2023
2 parents f5b9713 + ee7e095 commit e0189e2
Show file tree
Hide file tree
Showing 34 changed files with 245 additions and 416 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
/**
* 管控区域 Client
*/

@Slf4j
public class BkNetClient {
private static final Map<Long, String> CLOUD_AREA_NAME_MAP = new ConcurrentHashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,8 @@ public class JobConstants {
* Job内置业务集的ID范围的最大值
*/
public static final long JOB_BUILD_IN_BIZ_SET_ID_MAX = 9999999L;
/**
* 未知的资源名称
*/
public static final String UNKNOWN_NAME = "Unknown";
}
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,15 @@ public HostDTO toHostDTO() {
HostDTO host = new HostDTO();
host.setHostId(hostId);
host.setBkCloudId(cloudAreaId);
host.setBkCloudName(cloudAreaName);
host.setIp(ip);
host.setIpv6(ipv6);
host.setAgentId(agentId);
host.setAlive(getAgentAliveValue());
host.setOsName(osName);
host.setOsType(osType);
host.setOsTypeName(osTypeName);
host.setHostname(hostName);
return host;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,40 @@ public class HostDTO implements Cloneable {
private String ipv6;

/**
* agent状态,0-异常,1-正常
* agent存活状态,0-异常,1-正常
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
private Integer alive;

/**
* 操作系统名称
*/
private String osName;

/**
* 操作系统类型
*/
private String osType;

/**
* 操作系统类型名称
*/
private String osTypeName;
/**
* 主机名称
*/
private String hostname;

/**
* 所属云厂商ID
*/
private String cloudVendorId;

/**
* 所属云厂商名称
*/
private String cloudVendorName;

@Deprecated
public HostDTO(Long bkCloudId, String ip) {
this.bkCloudId = bkCloudId;
Expand Down Expand Up @@ -159,23 +188,22 @@ public String toCloudIpv6() {
}
}

public static HostInfoVO toVO(HostDTO hostDTO) {
if (hostDTO == null) {
return null;
}
public HostInfoVO toHostInfoVO() {
HostInfoVO hostInfoVO = new HostInfoVO();
hostInfoVO.setHostId(hostDTO.getHostId());
hostInfoVO.setIp(hostDTO.getIp());
hostInfoVO.setIpv6(hostDTO.getIpv6());
hostInfoVO.setAgentStatus(hostDTO.getAlive());
CloudAreaInfoVO cloudAreaInfo = new CloudAreaInfoVO();
cloudAreaInfo.setId(hostDTO.getBkCloudId());
cloudAreaInfo.setName(hostDTO.getBkCloudName());
hostInfoVO.setCloudArea(cloudAreaInfo);
hostInfoVO.setHostId(hostId);
hostInfoVO.setCloudArea(new CloudAreaInfoVO(bkCloudId, bkCloudName));
hostInfoVO.setIp(ip);
hostInfoVO.setIpv6(ipv6);
hostInfoVO.setHostName(hostname);
hostInfoVO.setOsName(osName);
hostInfoVO.setOsTypeName(osTypeName);
hostInfoVO.setAlive(alive);
hostInfoVO.setAgentId(agentId);
hostInfoVO.setCloudVendorName(cloudVendorName);
return hostInfoVO;
}

public static HostDTO fromVO(HostInfoVO hostInfoVO) {
public static HostDTO fromHostInfoVO(HostInfoVO hostInfoVO) {
if (hostInfoVO == null) {
return null;
}
Expand All @@ -189,6 +217,8 @@ public static HostDTO fromVO(HostInfoVO hostInfoVO) {
hostDTO.setBkCloudName(cloudAreaInfo.getName());
}
hostDTO.setAlive(hostInfoVO.getAgentStatus());
hostDTO.setOsName(hostInfoVO.getOsName());
hostDTO.setOsTypeName(hostInfoVO.getOsTypeName());
return hostDTO;
}

Expand Down Expand Up @@ -263,4 +293,20 @@ public String toStringBasic() {
.add("ipv6='" + ipv6 + "'")
.toString();
}

public void updateByHost(HostDTO host) {
this.hostId = host.getHostId();
this.agentId = host.getAgentId();
this.bkCloudId = host.getBkCloudId();
this.bkCloudName = host.getBkCloudName();
this.ip = host.getIp();
this.ipv6 = host.getIpv6();
this.osName = host.getOsName();
this.osType = host.getOsType();
this.osTypeName = host.getOsTypeName();
this.alive = host.getAlive();
this.cloudVendorId = host.getCloudVendorId();
this.cloudVendorName = host.getCloudVendorName();
this.hostname = host.getHostname();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,13 @@
import com.tencent.bk.job.common.util.JobContextUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
* @since 13/12/2019 17:31
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel("云区域信息")
@JsonInclude(JsonInclude.Include.NON_NULL)
Expand All @@ -50,6 +48,11 @@ public class CloudAreaInfoVO {
@ApiModelProperty("云区域名称")
private String name;

public CloudAreaInfoVO(Long id, String name) {
this.id = id;
this.name = name;
}

public boolean validate(boolean isCreate) {
if (id != null && id >= 0) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,13 @@ public static boolean isGseV2AgentId(String agentId) {
return !isGseV1AgentId(agentId);
}

/**
* 对接 GSE V1 的 agentId 值为 云区域:ip(内部实现,产品上 GSE V1 Agent 并没有 AgentId 的概念)。
* 只有GSE V2 Agent 才会在 cmdb 注册真实的 agentId。
* 为了避免与cmdb 主机 AgentId 属性的理解上的歧义,需要把内部实现上的 GSE V1 agentId 隐藏
*/
public static String displayAsRealAgentId(String agentId) {
return AgentUtils.isGseV1AgentId(agentId) ? "" : agentId;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public static TaskTargetVO toTargetVO(ServerDTO server) {
// 聚合通过hostId与IP指定的主机信息
List<HostInfoVO> hostInfoVOList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(server.getIps())) {
hostInfoVOList.addAll(server.getIps().stream().map(HostDTO::toVO).collect(Collectors.toList()));
hostInfoVOList.addAll(server.getIps().stream().map(HostDTO::toHostInfoVO).collect(Collectors.toList()));
}
if (!hostInfoVOList.isEmpty()) {
taskHostNode.setHostList(hostInfoVOList);
Expand All @@ -111,7 +111,7 @@ public static ServerDTO fromTargetVO(TaskTargetVO taskTarget) {
TaskHostNodeVO hostNodeInfo = taskTarget.getHostNodeInfo();
if (CollectionUtils.isNotEmpty(hostNodeInfo.getHostList())) {
server.setIps(hostNodeInfo.getHostList().stream()
.map(HostDTO::fromVO).collect(Collectors.toList()));
.map(HostDTO::fromHostInfoVO).collect(Collectors.toList()));
}
if (CollectionUtils.isNotEmpty(hostNodeInfo.getDynamicGroupIdList())) {
server.setDynamicGroupIds(hostNodeInfo.getDynamicGroupIdList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

import com.fasterxml.jackson.annotation.JsonProperty;
import com.tencent.bk.job.common.constant.JobConstants;
import com.tencent.bk.job.execute.model.web.vo.ExecuteTargetVO;
import com.tencent.bk.job.common.model.vo.TaskTargetVO;
import com.tencent.bk.job.execute.model.web.vo.RollingConfigVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
Expand Down Expand Up @@ -94,7 +94,7 @@ public class WebFastExecuteScriptRequest {
/**
* 目标服务器
*/
private ExecuteTargetVO targetServers;
private TaskTargetVO targetServers;

/**
* 是否敏感参数 0-否,1-是
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
package com.tencent.bk.job.execute.model.web.vo;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.tencent.bk.job.common.model.vo.TaskTargetVO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

Expand All @@ -41,5 +42,5 @@ public class ExecuteFileDestinationInfoVO {
private String accountName;

@ApiModelProperty("目标机器列表")
private ExecuteTargetVO server;
private TaskTargetVO server;
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
package com.tencent.bk.job.execute.model.web.vo;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.tencent.bk.job.common.model.vo.TaskTargetVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
Expand All @@ -48,7 +49,7 @@ public class ExecuteFileSourceInfoVO {
private String fileSize;

@ApiModelProperty(value = "主机列表")
private ExecuteTargetVO host;
private TaskTargetVO host;

@ApiModelProperty(value = "主机账号")
@JsonProperty("account")
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
package com.tencent.bk.job.execute.model.web.vo;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.tencent.bk.job.common.model.vo.TaskTargetVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
Expand Down Expand Up @@ -62,7 +63,7 @@ public class ExecuteScriptStepVO {
private String accountName;

@ApiModelProperty("执行目标")
private ExecuteTargetVO executeTarget;
private TaskTargetVO executeTarget;

@ApiModelProperty("敏感参数")
private Integer secureParam;
Expand Down

This file was deleted.

Loading

0 comments on commit e0189e2

Please sign in to comment.