新增获取磁盘主机的信息
This commit is contained in:
@@ -3,11 +3,12 @@ package com.mini.capi.job;
|
|||||||
|
|
||||||
import com.mini.capi.biz.domain.*;
|
import com.mini.capi.biz.domain.*;
|
||||||
import com.mini.capi.biz.service.*;
|
import com.mini.capi.biz.service.*;
|
||||||
|
import com.mini.capi.model.ApiResult;
|
||||||
import com.mini.capi.utils.HostInfo;
|
import com.mini.capi.utils.HostInfo;
|
||||||
import com.mini.capi.utils.vDate;
|
import com.mini.capi.utils.vDate;
|
||||||
import com.mini.capi.utils.vId;
|
import com.mini.capi.utils.vId;
|
||||||
|
import com.mini.capi.utils.vToken;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
@@ -37,9 +38,9 @@ public class taskEnable {
|
|||||||
private SysHostService sysHostService;
|
private SysHostService sysHostService;
|
||||||
|
|
||||||
|
|
||||||
@Scheduled(cron = "0 0/10 * * * ?")
|
|
||||||
@GetMapping("/getTaskDockerDiskInfo")
|
@GetMapping("/getTaskDockerDiskInfo")
|
||||||
public void jobHostDisk() {
|
public ApiResult<?> jobHostDisk(String token) {
|
||||||
|
if (vToken.isValidToken(token)) {
|
||||||
List<DockerHost> dockerHosts = dockerHostService.list();
|
List<DockerHost> dockerHosts = dockerHostService.list();
|
||||||
for (DockerHost host : dockerHosts) {
|
for (DockerHost host : dockerHosts) {
|
||||||
SshUser sshUser = sshUserService.getById(host.getUserId());
|
SshUser sshUser = sshUserService.getById(host.getUserId());
|
||||||
@@ -51,7 +52,6 @@ public class taskEnable {
|
|||||||
Integer.parseInt(sshInfo.getHostPort()),
|
Integer.parseInt(sshInfo.getHostPort()),
|
||||||
sshUser.getCUsername(),
|
sshUser.getCUsername(),
|
||||||
sshUser.getCPassword());
|
sshUser.getCPassword());
|
||||||
|
|
||||||
/* 2. 主机维度 saveOrUpdate */
|
/* 2. 主机维度 saveOrUpdate */
|
||||||
SysHost sysHost = r.host;
|
SysHost sysHost = r.host;
|
||||||
sysHost.setSysHostId(host.getHostId());
|
sysHost.setSysHostId(host.getHostId());
|
||||||
@@ -93,10 +93,13 @@ public class taskEnable {
|
|||||||
if (!delIds.isEmpty()) {
|
if (!delIds.isEmpty()) {
|
||||||
diskMountService.removeByIds(delIds);
|
diskMountService.removeByIds(delIds);
|
||||||
}
|
}
|
||||||
|
return ApiResult.success();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println(e.getMessage());
|
System.out.println(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return ApiResult.error();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user