From e5551d64a9b2bbf6c2bc41174b413270fdbdbdb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=97=B6=E5=90=AF=E9=BE=99?= Date: Tue, 3 Sep 2024 17:56:02 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=A3=B8=E9=87=91=E5=B1=9E=E5=88=97?= =?UTF-8?q?=E8=A1=A8/=E4=BF=AE=E6=94=B9/=E5=88=9B=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webs/cmp-web/src/filters/resource.js | 52 +++- webs/cmp-web/src/validate/common.js | 53 ++++ .../ctstack/page/bareMetal/addBareMetal.vue | 240 ++++++++++-------- .../resource/ctstack/page/bareMetal/image.vue | 66 +++++ .../resource/ctstack/page/bareMetal/index.vue | 197 ++++++-------- .../ctstack/page/bareMetal/modifyName.vue | 65 +++++ .../views/resource/ctstack/services/bms.js | 44 ++-- .../resource/ctstack/services/flavors.js | 6 + .../views/resource/ctstack/services/image.js | 5 + .../views/resource/ctstack/services/volume.js | 6 + 10 files changed, 482 insertions(+), 252 deletions(-) create mode 100644 webs/cmp-web/src/views/resource/ctstack/page/bareMetal/image.vue create mode 100644 webs/cmp-web/src/views/resource/ctstack/page/bareMetal/modifyName.vue diff --git a/webs/cmp-web/src/filters/resource.js b/webs/cmp-web/src/filters/resource.js index 40553a8..608fde3 100644 --- a/webs/cmp-web/src/filters/resource.js +++ b/webs/cmp-web/src/filters/resource.js @@ -2091,29 +2091,73 @@ export function physicalLineProider(value) { } return obj[value] } - export function bareMetalState(value, type) { const obj = { RUNNING: '运行中', STOPPING: '关机中', + CREATING: '创建中', STOPPED: '已关机', STARTING: '开机中', REBOOTING: '重启中', PENDING: '生产中', - CREATE_FAILED: '创建失败' + CREATE_FAILED: '创建失败', + RESIZING: '变配中', + VERIFY_RESIZE: '确认变配中', + RESTARTING: '正在重启', + WAITING: '等待其他资源创建中', + DELETING: '退订中', + DELETE: '退订完成', + ERROR: '异常', + EXPIRED: '已过期', + REBUILD: '重装中', + CREATING_IMAGE: '创建镜像中', + SUSPENDED: '挂起', + SUSPENDING: '挂起中', + MIGRATING: '迁移中', + BUILD_BACKUP: '创建备份中', + EXPORT_IMAGE: '裸金属创建镜像中', + REINSTALLING: '重装中', + MODIFY_NETWORK: '裸金属重置网络中', + RESTORING: '恢复中', + BACKUPING: '创建备份中', + MOUNT_FILE_SYSTEM: '挂载文件系统中', + UNMOUNT_FILE_SYSTEM: '卸载文件系统中', + Rebuilding: '重建中' } return obj[value] } - export function bareMetalColor(value) { const obj = { RUNNING: 'success', STOPPING: 'warning', + CREATING: 'warning', STOPPED: 'danger', STARTING: 'warning', REBOOTING: 'warning', PENDING: 'info', - CREATE_FAILED: 'danger' + CREATE_FAILED: 'danger', + RESIZING: 'info', + VERIFY_RESIZE: 'info', + RESTARTING: 'info', + WAITING: 'info', + DELETING: 'danger', + DELETE: 'info', + ERROR: 'danger', + EXPIRED: 'warning', + REBUILD: 'info', + CREATING_IMAGE: 'info', + SUSPENDED: 'danger', + SUSPENDING: 'warning', + MIGRATING: 'info', + BUILD_BACKUP: 'info', + EXPORT_IMAGE: 'info', + REINSTALLING: 'info', + MODIFY_NETWORK: 'info', + RESTORING: 'info', + BACKUPING: 'info', + MOUNT_FILE_SYSTEM: 'info', + UNMOUNT_FILE_SYSTEM: 'info', + Rebuilding: 'info' } return obj[value] } diff --git a/webs/cmp-web/src/validate/common.js b/webs/cmp-web/src/validate/common.js index 6aa5902..4c8ed74 100644 --- a/webs/cmp-web/src/validate/common.js +++ b/webs/cmp-web/src/validate/common.js @@ -942,5 +942,58 @@ export default { } }, trigger: trigger + }, + ctstackBMSName: { + // 长度6到15位,可以为字母数字和中划线,首字符不能为中划线和数字,不能以中划线结尾 + validator: (rule, value, callback) => { + const reg = /^[a-zA-Z][a-zA-Z0-9\-]{4,13}[a-zA-Z0-9]$/ + if (reg.test(value)) { + callback() + } else { + callback(new Error('长度6到15位,可以为字母数字和中划线,首字符不能为中划线和数字,不能以中划线结尾')) + } + }, + trigger: trigger + }, + ctstackBMSPassword: { + // 密码校验8~30 个字符,必须包含大小写字母,同时必须包含一个数字或者特殊字符,且不能以斜线号(/)开头,不能包含连续字符 + validator: (rule, value, callback) => { + const message = new Error('密码校验8~30 个字符,必须包含大小写字母,同时必须包含一个数字或者特殊字符,且不能以斜线号(/)开头,不能包含连续字符') + // 检查长度要求 + if (value.length < 8 || value.length > 30) { + callback(message) + return + } + + // 检查不能以斜线 / 开头 + if (value.startsWith('/')) { + callback(message) + return + } + + // 检查是否包含大小写字母 + const hasUpperCase = /[A-Z]/.test(value) + const hasLowerCase = /[a-z]/.test(value) + if (!(hasUpperCase && hasLowerCase)) { + callback(message) + return + } + + // 检查是否包含数字或特殊字符 + const hasNumberOrSpecialChar = /[\d()~`!@#$%^&*_=|{}\[\]:;'"<>,.?/-]/.test(value) + if (!hasNumberOrSpecialChar) { + callback(message) + return + } + + // 检查是否含有连续字符 + for (let i = 0; i < value.length - 1; i++) { + if (value.charCodeAt(i) + 1 === value.charCodeAt(i + 1)) { + callback(message) + } + } + callback() + }, + trigger: trigger } } diff --git a/webs/cmp-web/src/views/resource/ctstack/page/bareMetal/addBareMetal.vue b/webs/cmp-web/src/views/resource/ctstack/page/bareMetal/addBareMetal.vue index 9c334b5..990e477 100644 --- a/webs/cmp-web/src/views/resource/ctstack/page/bareMetal/addBareMetal.vue +++ b/webs/cmp-web/src/views/resource/ctstack/page/bareMetal/addBareMetal.vue @@ -11,19 +11,44 @@ - + - - - - - + + + + + + + + + + + + + + + + + + - + @@ -33,14 +58,18 @@ - - - + + + - + + + + + - - - - - - - - - @@ -59,20 +47,14 @@

当前配置

- {{ reloadData.row.operatingSystemType }} - {{ reloadData.row.raidType }} + {{ reloadData.row.osTypeName }}

重装为

- {{ reloadData.row.operatingSystemType }} + {{ reloadData.row.osTypeName }} - - - - - 开启 关闭 @@ -90,75 +72,69 @@ 确定
+ diff --git a/webs/cmp-web/src/views/resource/ctstack/services/bms.js b/webs/cmp-web/src/views/resource/ctstack/services/bms.js index cc1d7ad..33c84d9 100644 --- a/webs/cmp-web/src/views/resource/ctstack/services/bms.js +++ b/webs/cmp-web/src/views/resource/ctstack/services/bms.js @@ -1,61 +1,59 @@ import { request } from '@cmp/cmp-element' import { wrapperParams } from 'utils' - +const baseUrl = '/cmp/plugins/ctstack/v1/physical/servers' export function getBareMetalList(params) { - return request.get('/cmp/plugins/ctstack/v1/bms', { + return request.get(baseUrl, { params }) } -// 新建 获取套餐列表 -export function getCombo(id, params) { - return request.post(`/cmp/plugins/ctstack/v1/bms/describeFlavors/${id}`, wrapperParams(params)) +// 修改BMS名称 +export function modifyBareMetal(params) { + return request.put(`${baseUrl}/${params.id}`, wrapperParams(params)) } -// 获取运营商 -export function getOperator(params) { - return request.post('/cmp/plugins/ctstack/v1/bms/describeEIPIspInfo', wrapperParams(params)) -} -// 获取子网 -export function getBareSubnet(id, params) { - return request.post(`/cmp/plugins/ctstack/v1/bms/describeSubnets/${id}`, wrapperParams(params)) + +export function bmsDelete(params) { + return request.delete(`${baseUrl}/${params.id}`) } // 新建BMS -export function addBMS(id, params) { - return request.post(`/cmp/plugins/ctstack/v1/bms/runInstances/${id}`, wrapperParams(params)) +export function addBMS(params) { + return request.post(baseUrl, wrapperParams(params)) } -// 修改BMS名称 -export function modifyBareMetal(params) { - return request.post(`/cmp/plugins/ctstack/v1/bms/modifyAttribute/${params.id}`, wrapperParams(params)) +// 假的 +export function getCombo(params) { + return request.get(baseUrl, { + params + }) } // 重启 export function bmsReboot(params) { - return request.patch(`/cmp/plugins/ctstack/v1/bms/reboot/${params.id}`) + return request.patch(`${baseUrl}/reboot/${params.id}`) } // 开机 export function bmsBootUp(params) { - return request.patch(`/cmp/plugins/ctstack/v1/bms/start/${params.id}`) + return request.patch(`${baseUrl}/start/${params.id}`) } // 关机 export function bmsStop(params) { - return request.patch(`/cmp/plugins/ctstack/v1/bms/stop/${params.id}`) + return request.patch(`${baseUrl}/stop/${params.id}`) } // 退还实例 export function bmsedt(params) { - return request.post('/cmp/plugins/ctstack/v1/bms/terminateInstances', wrapperParams(params)) + return request.post('${baseUrl}/terminateInstances', wrapperParams(params)) } // 获取硬盘列表 export function getDisk(params) { - return request.get(`/cmp/plugins/ctstack/v1/bms/disks/${params.id}`) + return request.get(`${baseUrl}/disks/${params.id}`) } // 重装 export function bmsReload(id, params) { - return request.post(`/cmp/plugins/ctstack/v1/bms/resetInstance/${id}`, wrapperParams(params)) + return request.post(`${baseUrl}/resetInstance/${id}`, wrapperParams(params)) } diff --git a/webs/cmp-web/src/views/resource/ctstack/services/flavors.js b/webs/cmp-web/src/views/resource/ctstack/services/flavors.js index 5ee6d39..f8cf2d1 100644 --- a/webs/cmp-web/src/views/resource/ctstack/services/flavors.js +++ b/webs/cmp-web/src/views/resource/ctstack/services/flavors.js @@ -45,3 +45,9 @@ export function unbindFlavor(params) { export function getFlavorListZone(id) { return request.get(`${url}/listZone/${id}`) } + +export function getBMSFlavor(params) { + return request.get(`${url}/listPhysical`, { + params + }) +} diff --git a/webs/cmp-web/src/views/resource/ctstack/services/image.js b/webs/cmp-web/src/views/resource/ctstack/services/image.js index 24553f2..1651524 100644 --- a/webs/cmp-web/src/views/resource/ctstack/services/image.js +++ b/webs/cmp-web/src/views/resource/ctstack/services/image.js @@ -84,3 +84,8 @@ export function patchImage(action, params) { export function volumeImage(id) { return request.get(`${imageUrl}/${id}/volumes`) } +export function getBMSImage(params) { + return request.get(`${imageUrl}/listPhysical`, { + params + }) +} diff --git a/webs/cmp-web/src/views/resource/ctstack/services/volume.js b/webs/cmp-web/src/views/resource/ctstack/services/volume.js index 13e8913..64fb054 100644 --- a/webs/cmp-web/src/views/resource/ctstack/services/volume.js +++ b/webs/cmp-web/src/views/resource/ctstack/services/volume.js @@ -45,3 +45,9 @@ export function getVolumeVms(params) { params: wrapperParams(params) }) } + +export function getRaids(params) { + return request.get(`${volumeUrl}/raids`, { + params: wrapperParams(params) + }) +}