From c682130232e9e80259ae4cefd33658245f84a7c1 Mon Sep 17 00:00:00 2001 From: yuemian <--list> Date: Mon, 9 Sep 2024 16:16:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=A9=E7=BF=BC=E4=BA=91=E4=B8=BB=E6=9C=BA?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=E5=8F=B0=E8=B7=B3=E8=BD=AC=E6=8B=BC=E6=8E=A5?= =?UTF-8?q?ip=20port?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/service/impl/VMExtendServiceImpl.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/service/impl/VMExtendServiceImpl.java b/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/service/impl/VMExtendServiceImpl.java index 1efbd801..12cf2e83 100644 --- a/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/service/impl/VMExtendServiceImpl.java +++ b/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/service/impl/VMExtendServiceImpl.java @@ -12,6 +12,7 @@ import com.bocloud.cmp.enums.BocloudStatus; import com.bocloud.cmp.enums.OrderItemStatus; import com.bocloud.cmp.enums.ResourceCategory; import com.bocloud.cmp.internal.CosInternalService; +import com.bocloud.cmp.internal.SmsSystemConfigService; import com.bocloud.cmp.repository.CloudVendorRepository; import com.bocloud.cmp.repository.ServerRepository; import com.bocloud.cmp.util.ResourceEventPublisher; @@ -164,6 +165,8 @@ public class VMExtendServiceImpl implements VMExtendService { private ButlerConfig butlerConfig; @Autowired private VpcRepository vpcRepository; + @Autowired + private SmsSystemConfigService smsSystemConfigService; @Override public GeneralResult stats(String range, Long hostId, RequestContext context) { @@ -305,7 +308,14 @@ public class VMExtendServiceImpl implements VMExtendService { Assert.notNull(vendor, "云平台不存在"); TianyiServerProvider serverProvider = new TianyiServerProvider(butlerConfig.regionButler(vendor.getUuid(), region)); GeneralResult result = serverProvider.vncConsole(serverId, server.getRegionId()); - return result.isSuccess() ? result : new GeneralResult<>(false, "vnc链接失败!"); + String token = (String) result.getData(); + String protocol = smsSystemConfigService.getByCode("vncProtocol"); + String host = smsSystemConfigService.getByCode("vncHost"); + String port = smsSystemConfigService.getByCode("vncPort"); + if (StringUtils.isNotBlank(protocol) && StringUtils.isNotBlank(host) && StringUtils.isNotBlank(port)) { + token = protocol + "://" + host + ":" + port + token; + } + return new GeneralResult<>(result.isSuccess(), token, "success"); } catch (Exception e) { log.error("查询数据失败:{}", e.getMessage()); return new GeneralResult<>(false, e.getMessage());