|
|
|
@@ -1,11 +1,13 @@ |
|
|
|
package com.ruoyi.platform.service.impl; |
|
|
|
|
|
|
|
import com.ruoyi.common.core.utils.StringUtils; |
|
|
|
import com.ruoyi.common.redis.service.RedisService; |
|
|
|
import com.ruoyi.common.security.utils.SecurityUtils; |
|
|
|
import com.ruoyi.platform.domain.PodStatus; |
|
|
|
import com.ruoyi.platform.service.TensorBoardService; |
|
|
|
import com.ruoyi.platform.utils.K8sClientUtil; |
|
|
|
import com.ruoyi.platform.vo.FrameLogPathVo; |
|
|
|
import com.ruoyi.platform.vo.TensorboardStatusVo; |
|
|
|
import com.ruoyi.system.api.model.LoginUser; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
@@ -23,12 +25,16 @@ public class TensorBoardServiceImpl implements TensorBoardService { |
|
|
|
@Value("${tensorBoard.masterIp}") |
|
|
|
private String masterIp; |
|
|
|
@Resource |
|
|
|
private RedisService redisService; |
|
|
|
@Resource |
|
|
|
private K8sClientUtil k8sClientUtil; |
|
|
|
@Override |
|
|
|
public String getTensorBoardStatus(FrameLogPathVo frameLogPathVo){ |
|
|
|
public TensorboardStatusVo getTensorBoardStatus(FrameLogPathVo frameLogPathVo){ |
|
|
|
String status = PodStatus.Terminated.getName(); |
|
|
|
TensorboardStatusVo tensorboardStatusVo = new TensorboardStatusVo(); |
|
|
|
tensorboardStatusVo.setStatus(status); |
|
|
|
if (StringUtils.isEmpty(frameLogPathVo.getPath())){ |
|
|
|
return status; |
|
|
|
return tensorboardStatusVo; |
|
|
|
} |
|
|
|
LoginUser loginUser = SecurityUtils.getLoginUser(); |
|
|
|
String podName = loginUser.getUsername().toLowerCase()+"-"+frameLogPathVo.getPath().split("/")[2]+ "-tensorboard-pod"; |
|
|
|
@@ -42,9 +48,12 @@ public class TensorBoardServiceImpl implements TensorBoardService { |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
return PodStatus.Terminated.getName(); |
|
|
|
return tensorboardStatusVo; |
|
|
|
} |
|
|
|
return status; |
|
|
|
String url = redisService.getCacheObject(podName); |
|
|
|
tensorboardStatusVo.setStatus(status); |
|
|
|
tensorboardStatusVo.setUrl(url); |
|
|
|
return tensorboardStatusVo; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@@ -55,6 +64,7 @@ public class TensorBoardServiceImpl implements TensorBoardService { |
|
|
|
LoginUser loginUser = SecurityUtils.getLoginUser(); |
|
|
|
String podName = loginUser.getUsername().toLowerCase()+"-"+frameLogPathVo.getPath().split("/")[2]+ "-tensorboard-pod"; |
|
|
|
Integer podPort = k8sClientUtil.createPodWithSubPath(podName, StringUtils.isEmpty(frameLogPathVo.getNamespace())?"default":frameLogPathVo.getNamespace(), port, mountPath,frameLogPathVo.getPath(), frameLogPathVo.getPvcName(), image); |
|
|
|
redisService.setCacheObject(podName,masterIp + ":" + podPort); |
|
|
|
return masterIp + ":" + podPort; |
|
|
|
} |
|
|
|
} |