- 앱 배포 docker MQTT 메시지 페이로드 수정
This commit is contained in:
parent
f9af91c688
commit
f30f914283
|
@ -16,7 +16,7 @@ import org.springframework.stereotype.Service;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
@ -46,7 +46,7 @@ public class DefaultDeployerService implements DeployerService{
|
||||||
log.info("[publish] deployMessage = {}, assetCode = {}", deployMessage, assetCode);
|
log.info("[publish] deployMessage = {}, assetCode = {}", deployMessage, assetCode);
|
||||||
final String url = filePath + deployMessage.getFileId();
|
final String url = filePath + deployMessage.getFileId();
|
||||||
final String deviceType = "ecn";
|
final String deviceType = "ecn";
|
||||||
HashMap<String, String> cmdInfo = new HashMap<>();
|
HashMap<String, Object> cmdInfo = new HashMap<>();
|
||||||
String cmdType = "";
|
String cmdType = "";
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
@ -62,18 +62,17 @@ public class DefaultDeployerService implements DeployerService{
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
if(!deployMessage.getCommand().isEmpty()) {
|
if(!deployMessage.getCommand().isEmpty()) {
|
||||||
cmdInfo.put("Cmd", deployMessage.getCommand());
|
cmdInfo.put("cmd", deployMessage.getCommand());
|
||||||
cmdInfo.put("FileUrl", url);
|
cmdInfo.put("fileUrl", url);
|
||||||
cmdInfo.put("FileType", "python");
|
cmdInfo.put("fileType", "python");
|
||||||
cmdType = String.valueOf(CommandType.deploy);
|
cmdType = String.valueOf(CommandType.deploy);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!deployMessage.getEnv().isEmpty()) {
|
if(!deployMessage.getEnv().isEmpty()) {
|
||||||
cmdInfo.put("Cmd", "run");
|
cmdInfo.put("cmd", "run");
|
||||||
cmdInfo.put("Image", url);
|
cmdInfo.put("image", url);
|
||||||
cmdInfo.put("Name", deployMessage.getName());
|
cmdInfo.put("name", deployMessage.getName());
|
||||||
cmdInfo.put("Env", convertToJson(deployMessage.getEnv()));
|
cmdInfo.put("options", deployMessage.getEnv());
|
||||||
cmdInfo.put("Ports", convertToJson(deployMessage.getPorts()));
|
|
||||||
cmdType = String.valueOf(CommandType.docker);
|
cmdType = String.valueOf(CommandType.docker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
package inc.sdt.blokworks.devicedeployer.domain;
|
package inc.sdt.blokworks.devicedeployer.domain;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class OutboundMessage {
|
public class OutboundMessage {
|
||||||
private String fileId;
|
private String fileId;
|
||||||
private String name;
|
private String name;
|
||||||
private Map<String, Object> env;
|
private LinkedHashMap<String, Object> env;
|
||||||
private List<Map<String, String>> ports;
|
|
||||||
private String command;
|
private String command;
|
||||||
private String requestId;
|
private String requestId;
|
||||||
private String deviceType;
|
private String deviceType;
|
||||||
|
@ -23,14 +21,10 @@ public class OutboundMessage {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Object> getEnv() {
|
public LinkedHashMap<String, Object> getEnv() {
|
||||||
return env;
|
return env;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Map<String, String>> getPorts() {
|
|
||||||
return ports;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCommand() {
|
public String getCommand() {
|
||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
@ -57,7 +51,6 @@ public class OutboundMessage {
|
||||||
"fileId='" + fileId + '\'' +
|
"fileId='" + fileId + '\'' +
|
||||||
", name='" + name + '\'' +
|
", name='" + name + '\'' +
|
||||||
", env=" + env +
|
", env=" + env +
|
||||||
", ports=" + ports +
|
|
||||||
", command='" + command + '\'' +
|
", command='" + command + '\'' +
|
||||||
", requestId='" + requestId + '\'' +
|
", requestId='" + requestId + '\'' +
|
||||||
", deviceType='" + deviceType + '\'' +
|
", deviceType='" + deviceType + '\'' +
|
||||||
|
@ -72,8 +65,7 @@ public class OutboundMessage {
|
||||||
public static final class Builder {
|
public static final class Builder {
|
||||||
private String fileId;
|
private String fileId;
|
||||||
private String name;
|
private String name;
|
||||||
private Map<String, Object> env;
|
private LinkedHashMap<String, Object> env;
|
||||||
private List<Map<String, String>> ports;
|
|
||||||
private String command;
|
private String command;
|
||||||
private String requestId;
|
private String requestId;
|
||||||
private String deviceType;
|
private String deviceType;
|
||||||
|
@ -89,16 +81,11 @@ public class OutboundMessage {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder env(Map<String, Object> env) {
|
public Builder env(LinkedHashMap<String, Object> env) {
|
||||||
this.env = env;
|
this.env = env;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder ports(List<Map<String, String>> ports) {
|
|
||||||
this.ports = ports;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder command(String command) {
|
public Builder command(String command) {
|
||||||
this.command = command;
|
this.command = command;
|
||||||
return this;
|
return this;
|
||||||
|
@ -126,7 +113,6 @@ public class OutboundMessage {
|
||||||
deployMessage.env = this.env;
|
deployMessage.env = this.env;
|
||||||
deployMessage.command = this.command;
|
deployMessage.command = this.command;
|
||||||
deployMessage.requestId = this.requestId;
|
deployMessage.requestId = this.requestId;
|
||||||
deployMessage.ports = this.ports;
|
|
||||||
deployMessage.deviceType = this.deviceType;
|
deployMessage.deviceType = this.deviceType;
|
||||||
deployMessage.commandType = this.commandType;
|
deployMessage.commandType = this.commandType;
|
||||||
return deployMessage;
|
return deployMessage;
|
||||||
|
|
|
@ -3,11 +3,11 @@ package inc.sdt.blokworks.devicedeployer.infrastructure.mqtt;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
public record OutboundMessagePayload(
|
public record OutboundMessagePayload(
|
||||||
HashMap<String, String> CmdInfo,
|
HashMap<String, Object> cmdInfo,
|
||||||
String CmdType,
|
String cmdType,
|
||||||
|
|
||||||
String AssetCode,
|
String assetCode,
|
||||||
String DeviceType,
|
String deviceType,
|
||||||
String RequestId
|
String requestId
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,10 +6,12 @@ import inc.sdt.blokworks.devicedeployer.infrastructure.amqp.ResourceMapping;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
|
|
|
@ -4,6 +4,7 @@ import inc.sdt.blokworks.devicedeployer.domain.CommandType;
|
||||||
import org.wildfly.common.annotation.NotNull;
|
import org.wildfly.common.annotation.NotNull;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
|
||||||
record OutboundMessageResource(
|
record OutboundMessageResource(
|
||||||
@NotNull
|
@NotNull
|
||||||
|
@ -11,7 +12,7 @@ record OutboundMessageResource(
|
||||||
@NotNull
|
@NotNull
|
||||||
String name,
|
String name,
|
||||||
String command,
|
String command,
|
||||||
String env,
|
LinkedHashMap<String, Object> env,
|
||||||
String deviceType,
|
String deviceType,
|
||||||
CommandType commandType
|
CommandType commandType
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -9,10 +9,7 @@ import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class OutboundMessageResourceConverter {
|
public class OutboundMessageResourceConverter {
|
||||||
|
@ -23,14 +20,13 @@ public class OutboundMessageResourceConverter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public OutboundMessage fromResource(OutboundMessageResource resource) {
|
public OutboundMessage fromResource(OutboundMessageResource resource) {
|
||||||
final Map<String, Object> cmdInfo = resource.env().isEmpty() ? new HashMap<>() : convertToMap(resource.env());
|
//final Map<String, Object> cmdInfo = resource.env().isEmpty() ? new HashMap<>() : convertToMap(resource.env());
|
||||||
|
|
||||||
return OutboundMessage.builder()
|
return OutboundMessage.builder()
|
||||||
.fileId(resource.fileId())
|
.fileId(resource.fileId())
|
||||||
.name(resource.name())
|
.name(resource.name())
|
||||||
.command(resource.command())
|
.command(resource.command())
|
||||||
.env(cmdInfo.isEmpty() ? new HashMap<>() : (Map<String, Object>) cmdInfo.get("env"))
|
.env(resource.env() != null ? resource.env() : new LinkedHashMap<>())
|
||||||
.ports(cmdInfo.isEmpty() ? new ArrayList<>() : (List<Map<String, String>>) cmdInfo.get("ports"))
|
|
||||||
.deviceType(resource.deviceType())
|
.deviceType(resource.deviceType())
|
||||||
.commandType(resource.commandType() == null ? CommandType.deploy : resource.commandType())
|
.commandType(resource.commandType() == null ? CommandType.deploy : resource.commandType())
|
||||||
.build();
|
.build();
|
||||||
|
|
Loading…
Reference in New Issue