天翼云主机控制台跳转拼接ip port

develop
yuemian 2024-09-09 16:16:07 +08:00
parent 5e0fdf4016
commit c682130232
1 changed files with 11 additions and 1 deletions

View File

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