diff options
author | HuabingZhao <zhao.huabing@zte.com.cn> | 2017-09-14 16:16:29 +0800 |
---|---|---|
committer | HuabingZhao <zhao.huabing@zte.com.cn> | 2017-09-14 16:16:33 +0800 |
commit | 8d5c71111540792f904d0edaef0678d020c0326b (patch) | |
tree | 7eca4e96fc4b7ffcd7d5f99c5f471044b3205192 /sdclient/discovery-service/src/main | |
parent | 4457208c37c772eeb6a0a87339a56880b9b5563d (diff) |
Add https service registration support
Issue-Id: MSB-76
Change-Id: I14665c50b6c8994589e5e5671a85c263194946a9
Signed-off-by: HuabingZhao <zhao.huabing@zte.com.cn>
Diffstat (limited to 'sdclient/discovery-service/src/main')
3 files changed, 24 insertions, 8 deletions
diff --git a/sdclient/discovery-service/src/main/java/org/onap/msb/sdclient/core/Service.java b/sdclient/discovery-service/src/main/java/org/onap/msb/sdclient/core/Service.java index b158663..059bd5e 100644 --- a/sdclient/discovery-service/src/main/java/org/onap/msb/sdclient/core/Service.java +++ b/sdclient/discovery-service/src/main/java/org/onap/msb/sdclient/core/Service.java @@ -27,7 +27,7 @@ public class Service<T> implements Serializable { private static final long serialVersionUID = 1L; // 服务名 @ApiModelProperty(example = "test", required = true) - private String serviceName; + private String serviceName = ""; // 版本号 @ApiModelProperty(example = "v1", required = true) private String version = ""; @@ -65,6 +65,8 @@ public class Service<T> implements Serializable { @ApiModelProperty(hidden = true) private String path = ""; + @ApiModelProperty(value = "enable ssl", allowableValues = "true,false", example = "false") + private boolean enable_ssl = false; // true:https:开启SSL加密, false:http @ApiModelProperty(required = true) @@ -193,4 +195,12 @@ public class Service<T> implements Serializable { public void setNetwork_plane_type(String network_plane_type) { this.network_plane_type = network_plane_type; } + + public boolean isEnable_ssl() { + return enable_ssl; + } + + public void setEnable_ssl(boolean enable_ssl) { + this.enable_ssl = enable_ssl; + } } diff --git a/sdclient/discovery-service/src/main/java/org/onap/msb/sdclient/resources/MicroServiceResource.java b/sdclient/discovery-service/src/main/java/org/onap/msb/sdclient/resources/MicroServiceResource.java index 12fd8df..ed428f4 100644 --- a/sdclient/discovery-service/src/main/java/org/onap/msb/sdclient/resources/MicroServiceResource.java +++ b/sdclient/discovery-service/src/main/java/org/onap/msb/sdclient/resources/MicroServiceResource.java @@ -105,7 +105,7 @@ public class MicroServiceResource { required = false) @QueryParam("createOrUpdate") @DefaultValue("true") boolean createOrUpdate, @ApiParam(value = "is_manual", required = false) @QueryParam("is_manual") @DefaultValue("false") boolean is_manual) { - + LOGGER.error("**** json string:" + microServiceInfo); String ip = DiscoverUtil.getRealIp(request); try { diff --git a/sdclient/discovery-service/src/main/java/org/onap/msb/sdclient/wrapper/ConsulServiceWrapper.java b/sdclient/discovery-service/src/main/java/org/onap/msb/sdclient/wrapper/ConsulServiceWrapper.java index 73a2790..2d3900c 100644 --- a/sdclient/discovery-service/src/main/java/org/onap/msb/sdclient/wrapper/ConsulServiceWrapper.java +++ b/sdclient/discovery-service/src/main/java/org/onap/msb/sdclient/wrapper/ConsulServiceWrapper.java @@ -298,7 +298,7 @@ public class ConsulServiceWrapper { String ms_url = "", ms_version = "", ms_protocol = "", ms_status = "", ms_publish_port = "", ms_is_manual = "", ms_visualRange = "1", ms_network_plane_type = "", ms_lb_policy = "", - ms_host = "", ms_path = ""; + ms_host = "", ms_path = "", ms_enable_ssl = ""; List<KeyVaulePair> ms_metadata = new ArrayList<KeyVaulePair>(); List<String> nodeLabels = new ArrayList<String>(); @@ -327,13 +327,15 @@ public class ConsulServiceWrapper { ms_protocol = (baseMap.get("protocol") == null ? "" : baseMap.get("protocol")); ms_status = (baseMap.get("status") == null ? "1" : baseMap.get("status")); + if (baseMap.get("enable_ssl") != null) { + ms_enable_ssl = (baseMap.get("enable_ssl")); + } if (baseMap.get("publish_port") != null) { ms_publish_port = (baseMap.get("publish_port")); } if (baseMap.get("is_manual") != null) { ms_is_manual = baseMap.get("is_manual"); - } if (baseMap.get("ha_role") != null) { @@ -528,6 +530,7 @@ public class ConsulServiceWrapper { microServiceInfo.setNamespace(namespace); microServiceInfo.setHost(ms_host); microServiceInfo.setPath(ms_path); + microServiceInfo.setEnable_ssl(Boolean.parseBoolean(ms_enable_ssl)); } @@ -637,6 +640,7 @@ public class ConsulServiceWrapper { baseMap.put("status", "1"); baseMap.put("is_manual", Boolean.toString(is_manual)); + baseMap.put("enable_ssl", Boolean.toString(microServiceInfo.isEnable_ssl())); // TCP和UDP协议保存 nginx端口和负载均衡策略 if (StringUtils.isNotBlank(microServiceInfo.getPublish_port())) { @@ -1333,7 +1337,7 @@ public class ConsulServiceWrapper { String ms_url = "", ms_version = "", ms_protocol = "", ms_status = "", ms_publish_port = "", ms_is_manual = "", ms_visualRange = "1", ms_network_plane_type = "", ms_lb_policy = "", - ms_host = "", ms_path = ""; + ms_host = "", ms_path = "", ms_enable_ssl = ""; List<KeyVaulePair> ms_metadata = new ArrayList<KeyVaulePair>(); List<String> nodeLabels = new ArrayList<String>(); @@ -1383,6 +1387,10 @@ public class ConsulServiceWrapper { ms_path = baseMap.get("path"); } + if (baseMap.get("enable_ssl") != null) { + ms_publish_port = (baseMap.get("enable_ssl")); + } + continue; } @@ -1554,6 +1562,7 @@ public class ConsulServiceWrapper { microServiceInfo.setLb_policy(ms_lb_policy); microServiceInfo.setHost(ms_host); microServiceInfo.setPath(ms_path); + microServiceInfo.setEnable_ssl(Boolean.parseBoolean(ms_enable_ssl)); microServiceInfo.setMetadata(ms_metadata); microServiceInfo.setNamespace(namespace); @@ -1903,7 +1912,4 @@ public class ConsulServiceWrapper { } } } - - - } |