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());