Skip to content

Commit

Permalink
新增支持批量开机功能
Browse files Browse the repository at this point in the history
  • Loading branch information
Yohann0617 committed Nov 15, 2024
1 parent 33b397c commit 1cb499c
Show file tree
Hide file tree
Showing 13 changed files with 76 additions and 9 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

1. 同时管理多个租户配置信息,支持模糊搜索、状态筛选。
2. 根据多个CIDR网段更换实例公共IP,遇到请求频繁等异常会直接忽略,不影响下一次执行,直至更换到指定IP段的IP。
3. 多租户同时开机,后台一直运行,直至开机成功。
3. 多租户同时批量开机,后台一直运行,直至开机成功。
4. 支持断点续抢,配置以及抢机任务都保存在本地数据库,服务重启会继续执行抢机任务,无需重复配置。
5. 支持多区号(配置项以`region`区分),例:我有一个4区号,则新增4个配置,修改`region`即可,其他配置项都一样。

Expand Down Expand Up @@ -65,13 +65,15 @@ docker compose pull && docker compose up -d

## 页面展示

![image.png](https://pic1.58cdn.com.cn/nowater/webim/big/n_v26a2f3e2cd0ea4ac787723191f4f32f36.png)
![image.png](https://pic2.58cdn.com.cn/nowater/webim/big/n_v2dbe45607168944718bb0ccb5e53b41f8.png)

![image.png](https://pic4.58cdn.com.cn/nowater/webim/big/n_v290443ddeb885445399561ab6eb1d7a09.png)

![image.png](https://pic1.58cdn.com.cn/nowater/webim/big/n_v2543323ea3d274c2ca435e2b5dcc3074f.png)

![image.png](https://pic3.58cdn.com.cn/nowater/webim/big/n_v2e3c93ccfcbd6442b8093d11fec370ee1.png)

![image.png](https://pic6.58cdn.com.cn/nowater/webim/big/n_v2c5608c6436cd4d0d8e90fa53c1ad8fe3.png)

![image.png](https://pic7.58cdn.com.cn/nowater/webim/big/n_v2a47b5866e28344e695b25a84f568ba05.png)

Binary file modified oci-helper.db
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.yohann.ocihelper.bean.params;

import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
* @projectName: oci-helper
* @package: com.yohann.ocihelper.bean.params
* @className: CreateInstanceBatchParams
* @author: Yohann
* @date: 2024/11/16 0:04
*/
@Data
public class CreateInstanceBatchParams {

@NotEmpty(message = "用户配置id列表不能为空")
private List<String> userIds;

private InstanceInfo instanceInfo;

@Data
public static class InstanceInfo {
@NotBlank(message = "CPU不能为空")
private String ocpus;
@NotBlank(message = "内存不能为空")
private String memory;
@NotBlank(message = "磁盘空间不能为空")
private String disk;
@NotBlank(message = "系统架构不能为空")
private String architecture;
@NotNull(message = "时间间隔不能为空")
private Integer interval;
@NotNull(message = "创建数目不能为空")
private Integer createNumbers;
@NotNull(message = "系统类型不能为空")
private String operationSystem;
@NotNull(message = "root密码不能为空")
private String rootPassword;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,12 @@ public ResponseData<Void> stopCreateBatch(@Validated @RequestBody IdListParams p
ociService.stopCreateBatch(params);
return ResponseData.successData("批量停止开机任务成功");
}

@PostMapping(path = "/createInstanceBatch")
public ResponseData<Void> createInstanceBatch(@Validated @RequestBody CreateInstanceBatchParams params,
BindingResult bindingResult) {
CommonUtils.checkAndThrow(bindingResult);
ociService.createInstanceBatch(params);
return ResponseData.successData("批量新增开机任务成功");
}
}
2 changes: 2 additions & 0 deletions src/main/java/com/yohann/ocihelper/service/IOciService.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ public interface IOciService {
Page<CreateTaskRsp> createTaskPage(CreateTaskPageParams params);

void stopCreateBatch(IdListParams params);

void createInstanceBatch(CreateInstanceBatchParams params);
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.yohann.ocihelper.utils.CommonUtils;
import com.yohann.ocihelper.utils.MessageServiceFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

Expand Down Expand Up @@ -284,4 +285,14 @@ public Page<CreateTaskRsp> createTaskPage(CreateTaskPageParams params) {
public void stopCreateBatch(IdListParams params) {
createTaskService.removeBatchByIds(params.getIdList());
}

@Override
public void createInstanceBatch(CreateInstanceBatchParams params) {
params.getUserIds().stream().map(userId -> {
CreateInstanceParams instanceParams = new CreateInstanceParams();
BeanUtils.copyProperties(params.getInstanceInfo(), instanceParams);
instanceParams.setUserId(userId);
return instanceParams;
}).collect(Collectors.toList()).parallelStream().forEach(this::createInstance);
}
}
2 changes: 1 addition & 1 deletion src/main/resources/dist/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>oci-helper</title><script defer="defer" src="/js/chunk-vendors.7cf7f0ca.js"></script><script defer="defer" src="/js/app.39604cf9.js"></script><link href="/css/chunk-vendors.ddc93c7c.css" rel="stylesheet"><link href="/css/app.c1dc950f.css" rel="stylesheet"></head><body><div id="app"></div></body></html>
<!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>oci-helper</title><script defer="defer" src="/js/chunk-vendors.079fba90.js"></script><script defer="defer" src="/js/app.ffa9df77.js"></script><link href="/css/chunk-vendors.ddc93c7c.css" rel="stylesheet"><link href="/css/app.c1dc950f.css" rel="stylesheet"></head><body><div id="app"></div></body></html>
2 changes: 0 additions & 2 deletions src/main/resources/dist/js/app.39604cf9.js

This file was deleted.

1 change: 0 additions & 1 deletion src/main/resources/dist/js/app.39604cf9.js.map

This file was deleted.

2 changes: 2 additions & 0 deletions src/main/resources/dist/js/app.ffa9df77.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/main/resources/dist/js/app.ffa9df77.js.map

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

0 comments on commit 1cb499c

Please sign in to comment.