| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003 |
- import Vue from 'vue'
- import { typeClouds } from '@/utils/common/hypervisor'
- import i18n from '@/locales'
- import { sizestr } from '@/utils/utils'
- const __cpuNumaPinHVm = new Vue()
- const _cpuNumaPinH = (...args) => __cpuNumaPinHVm.$createElement(...args)
- const hypervisorMap = typeClouds.hypervisorMap
- const serverStatus = i18n.t('status.server')
- const _toArr = value => {
- if (!Array.isArray(value)) {
- value = [value]
- }
- return value
- }
- const _tran = enArr => {
- return enArr.map(v => serverStatus[v] || v).filter(v => v).join(',')
- }
- const actionEableMap = {
- start: {
- cn: i18n.t('compute.text_272'),
- brand: {
- azure: ['ready'],
- qcloud: ['ready'],
- aliyun: ['ready'],
- aws: ['ready'],
- onecloud: ['ready'],
- cloudpods: ['ready'],
- vmware: ['ready'],
- baremetal: ['ready'],
- huawei: ['ready'],
- hcso: ['ready'],
- hcs: ['ready'],
- openstack: ['ready'],
- zstack: ['ready'],
- dstack: ['ready'],
- ucloud: ['ready'],
- ctyun: ['ready'],
- google: ['ready'],
- apsara: ['ready'],
- jdcloud: ['ready'],
- ecloud: ['ready'],
- nutanix: ['ready'],
- proxmox: ['ready'],
- bingocloud: false,
- incloudsphere: ['ready'],
- volcengine: ['ready'],
- remotefile: false,
- sangfor: ['ready'],
- zettakit: ['ready'],
- uis: ['ready'],
- ksyun: ['ready'],
- cnware: ['ready'],
- baidu: ['ready'],
- },
- },
- stop: {
- cn: i18n.t('compute.text_273'),
- brand: {
- azure: ['running', 'stop_fail'],
- qcloud: ['running', 'stop_fail'],
- aliyun: ['running', 'stop_fail'],
- aws: ['running', 'stop_fail'],
- onecloud: ['running', 'stop_fail'],
- cloudpods: ['running', 'stop_fail'],
- vmware: ['running', 'stop_fail'],
- baremetal: ['running', 'stop_fail'],
- huawei: ['running', 'stop_fail'],
- hcso: ['running', 'stop_fail'],
- hcs: ['running', 'stop_fail'],
- openstack: ['running', 'stop_fail'],
- zstack: ['running', 'stop_fail'],
- dstack: ['running', 'stop_fail'],
- ucloud: ['running', 'stop_fail'],
- ctyun: ['running', 'stop_fail'],
- google: ['running', 'stop_fail'],
- apsara: ['running', 'stop_fail'],
- jdcloud: ['running', 'stop_fail'],
- ecloud: ['running', 'stop_fail'],
- nutanix: ['running', 'stop_fail'],
- proxmox: ['running', 'stop_fail'],
- bingocloud: false,
- incloudsphere: ['running', 'stop_fail'],
- remotefile: false,
- volcengine: ['running', 'stop_fail'],
- sangfor: ['running', 'stop_fail'],
- zettakit: ['running', 'stop_fail'],
- uis: ['running', 'stop_fail'],
- ksyun: ['running', 'stop_fail'],
- cnware: ['running', 'stop_fail'],
- baidu: ['running', 'stop_fail'],
- },
- },
- restart: {
- cn: i18n.t('compute.text_274'),
- brand: {
- azure: ['running', 'stop_fail'],
- qcloud: ['running', 'stop_fail'],
- aliyun: ['running', 'stop_fail'],
- aws: ['running', 'stop_fail'],
- onecloud: ['running', 'stop_fail'],
- cloudpods: ['running', 'stop_fail'],
- vmware: ['running', 'stop_fail'],
- baremetal: ['running', 'stop_fail'],
- huawei: ['running', 'stop_fail'],
- hcso: ['running', 'stop_fail'],
- hcs: ['running', 'stop_fail'],
- openstack: ['running', 'stop_fail'],
- zstack: ['running', 'stop_fail'],
- dstack: ['running', 'stop_fail'],
- ucloud: ['running', 'stop_fail'],
- ctyun: ['running', 'stop_fail'],
- google: ['running', 'stop_fail'],
- apsara: ['running', 'stop_fail'],
- jdcloud: ['running', 'stop_fail'],
- ecloud: ['running', 'stop_fail'],
- nutanix: ['running', 'stop_fail'],
- proxmox: ['running', 'stop_fail'],
- bingocloud: false,
- incloudsphere: ['running', 'stop_fail'],
- remotefile: false,
- volcengine: ['running', 'stop_fail'],
- sangfor: ['running', 'stop_fail'],
- zettakit: ['running', 'stop_fail'],
- uis: ['running', 'stop_fail'],
- ksyun: ['running', 'stop_fail'],
- cnware: ['running', 'stop_fail'],
- baidu: ['running', 'stop_fail'],
- },
- },
- rebuildRoot: {
- cn: i18n.t('compute.text_357'),
- brand: {
- azure: ['ready', 'running'],
- qcloud: ['ready', 'running'],
- aliyun: ['ready', 'running'],
- aws: ['ready', 'running'],
- onecloud: ['ready'],
- cloudpods: ['ready'],
- vmware: ['ready'],
- baremetal: ['ready', 'admin'],
- huawei: ['ready', 'rebuild_root_fail'],
- hcso: ['ready', 'rebuild_root_fail'],
- hcs: ['ready', 'rebuild_root_fail'],
- openstack: ['ready'],
- zstack: ['ready'],
- dstack: ['ready'],
- ucloud: ['ready'],
- ctyun: ['ready'],
- google: ['ready'],
- apsara: ['running', 'ready'],
- proxmox: false,
- nutanix: false,
- bingocloud: false,
- incloudsphere: false,
- remotefile: false,
- volcengine: false,
- sangfor: false,
- zettakit: ['running'],
- uis: ['running'],
- ksyun: ['ready'],
- cnware: false,
- baidu: ['ready', 'running'],
- },
- },
- resetPassword: {
- cn: i18n.t('compute.text_276'),
- brand: {
- azure: ['running'],
- qcloud: ['ready'],
- aliyun: ['ready'],
- aws: false,
- onecloud: ['running', 'ready'],
- cloudpods: ['ready'],
- vmware: ['ready'],
- baremetal: ['ready', 'admin'],
- huawei: ['ready'],
- hcso: ['ready'],
- hcs: ['ready'],
- openstack: ['running'],
- zstack: ['running'],
- dstack: ['running'],
- ucloud: ['ready'],
- ctyun: ['running'],
- google: ['ready'],
- apsara: ['running'],
- proxmox: false,
- nutanix: false,
- bingocloud: false,
- incloudsphere: ['running'],
- remotefile: false,
- volcengine: ['ready'],
- sangfor: false,
- zettakit: false,
- uis: false,
- ksyun: ['ready', 'running'],
- cnware: false,
- baidu: ['ready', 'running'],
- },
- },
- bindKeyPair: {
- cn: i18n.t('compute.text_361'),
- brand: {
- azure: ['running'],
- qcloud: ['ready'],
- aliyun: ['ready'],
- aws: false,
- onecloud: ['ready'],
- cloudpods: ['ready'],
- vmware: ['ready'],
- baremetal: ['ready', 'admin'],
- huawei: false,
- hcso: false,
- hcs: false,
- openstack: ['running'],
- zstack: ['running'],
- dstack: ['running'],
- ucloud: false,
- ctyun: ['ready', 'running'],
- google: ['ready'],
- apsara: ['running'],
- proxmox: false,
- nutanix: false,
- bingocloud: false,
- incloudsphere: ['running'],
- remotefile: false,
- volcengine: ['ready'],
- sangfor: false,
- zettakit: false,
- uis: false,
- ksyun: ['ready'],
- cnware: false,
- baidu: false,
- },
- },
- unBindKeyPair: {
- cn: i18n.t('compute.text_364'),
- brand: {
- azure: ['running'],
- qcloud: ['ready'],
- aliyun: ['ready'],
- aws: false,
- onecloud: ['ready'],
- cloudpods: ['ready'],
- vmware: ['ready'],
- baremetal: ['ready', 'admin'],
- huawei: false,
- hcso: false,
- hcs: false,
- openstack: ['running'],
- zstack: ['running'],
- dstack: ['running'],
- ucloud: false,
- ctyun: ['ready', 'running'],
- google: ['ready'],
- apsara: ['running'],
- proxmox: false,
- nutanix: false,
- bingocloud: false,
- incloudsphere: false,
- remotefile: false,
- volcengine: ['ready'],
- sangfor: false,
- zettakit: false,
- uis: false,
- ksyun: ['ready', 'running'],
- cnware: false,
- baidu: false,
- },
- },
- adjustConfig: {
- cn: i18n.t('compute.text_1100'),
- brand: {
- azure: ['ready', 'running'],
- qcloud: ['ready'],
- aliyun: ['ready', 'running'],
- aws: ['ready', 'running'],
- onecloud: ['ready', 'running'],
- cloudpods: ['ready', 'running'],
- vmware: ['ready', 'running'],
- baremetal: false,
- huawei: ['ready', 'running'],
- hcso: ['ready'],
- hcs: ['ready'],
- openstack: ['ready', 'running'],
- zstack: ['ready'],
- dstack: ['ready'],
- ucloud: ['ready'],
- ctyun: ['ready', 'running'],
- google: ['ready', 'running'],
- apsara: ['ready'],
- nutanix: ['ready'],
- proxmox: ['ready', 'running'],
- bingocloud: false,
- incloudsphere: ['ready', 'running'],
- remotefile: false,
- volcengine: ['ready', 'running'],
- sangfor: ['ready'],
- zettakit: ['ready'],
- uis: ['ready'],
- ksyun: ['ready', 'running'],
- cnware: false,
- baidu: ['ready', 'running'],
- },
- },
- vnc: {
- cn: 'vnc',
- brand: {
- azure: false,
- qcloud: ['running'],
- aliyun: ['running'],
- aws: false,
- onecloud: ['running', 'block_stream', 'live_migrating'],
- cloudpods: ['running'],
- vmware: ['running'],
- baremetal: false,
- huawei: ['running'],
- hcso: ['running'],
- hcs: ['running'],
- openstack: ['running'],
- zstack: ['running'],
- dstack: ['running'],
- ucloud: false,
- ctyun: ['running'],
- google: false,
- apsara: ['running'],
- jdcloud: ['running'],
- ecloud: ['running'],
- proxmox: ['running'],
- nutanix: false,
- bingocloud: false,
- incloudsphere: ['running'],
- remotefile: false,
- volcengine: ['running'],
- sangfor: ['running'],
- zettakit: ['running'],
- uis: ['running'],
- ksyun: ['running'],
- cnware: ['running'],
- baidu: ['running'],
- },
- },
- 'EIP SSH': {
- cn: 'EIP SSH',
- brand: {
- azure: ['running'],
- qcloud: ['running'],
- aliyun: ['running'],
- aws: ['running'],
- onecloud: ['running'],
- cloudpods: ['running'],
- vmware: ['running'],
- baremetal: ['running'],
- huawei: ['running'],
- hcso: ['running'],
- hcs: ['running'],
- openstack: ['running'],
- zstack: ['running'],
- dstack: ['running'],
- ucloud: ['running'],
- ctyun: ['running'],
- google: ['running'],
- apsara: ['running'],
- jdcloud: ['running'],
- ecloud: ['running'],
- nutanix: ['running'],
- proxmox: false,
- bingocloud: false,
- remotefile: false,
- volcengine: ['running'],
- sangfor: ['running'],
- zettakit: ['running'],
- uis: ['running'],
- ksyun: ['running'],
- cnware: false,
- baidu: ['running'],
- },
- },
- 'IP SSH': {
- cn: 'IP SSH',
- brand: {
- azure: false, // 暂时网络未打通
- qcloud: false, // 暂时网络未打通
- aliyun: false, // 暂时网络未打通
- aws: false, // 暂时网络未打通
- onecloud: ['running'],
- cloudpods: ['running'],
- vmware: ['running'],
- baremetal: ['running'],
- huawei: false, // 暂时网络未打通
- hcso: false, // 暂时网络未打通
- hcs: false, // 暂时网络未打通
- openstack: ['running'],
- zstack: false,
- dstack: false,
- ucloud: false,
- ctyun: false,
- google: false,
- apsara: false,
- jdcloud: false,
- ecloud: false,
- nutanix: ['running'],
- bingocloud: false,
- incloudsphere: ['running'],
- proxmox: false,
- remotefile: false,
- volcengine: ['running'],
- sangfor: ['running'],
- zettakit: ['running'],
- uis: ['running'],
- ksyun: false,
- cnware: false,
- baidu: ['running'],
- },
- },
- createSnapshot: {
- cn: i18n.t('compute.text_1276'),
- brand: {
- azure: ['running', 'ready'],
- qcloud: ['running', 'ready'],
- aliyun: ['running', 'ready'],
- aws: ['running', 'ready'],
- onecloud: ['running', 'ready'],
- cloudpods: ['running', 'ready'],
- vmware: ['running', 'ready'],
- baremetal: ['running', 'ready'],
- huawei: ['running', 'ready'],
- hcso: ['running', 'ready'],
- hcs: ['running', 'ready'],
- openstack: ['running', 'ready'],
- zstack: ['running', 'ready'],
- dstack: ['running', 'ready'],
- ucloud: false,
- ctyun: false,
- google: ['running', 'ready'],
- apsara: false,
- proxmox: false,
- nutanix: false,
- bingocloud: false,
- incloudsphere: false,
- remotefile: false,
- volcengine: false,
- sangfor: false,
- zettakit: false,
- uis: false,
- ksyun: false,
- cnware: ['running', 'ready'],
- baidu: ['running', 'ready'],
- },
- },
- createBackup: {
- cn: i18n.t('compute.text_1276'),
- brand: {
- azure: false,
- qcloud: false,
- aliyun: false,
- aws: false,
- onecloud: ['running', 'ready'],
- cloudpods: false,
- vmware: false,
- baremetal: false,
- huawei: false,
- hcso: false,
- hcs: false,
- openstack: false,
- zstack: false,
- dstack: false,
- ucloud: false,
- ctyun: false,
- google: false,
- apsara: false,
- nutanix: false,
- bingocloud: false,
- proxmox: false,
- incloudsphere: false,
- remotefile: false,
- volcengine: false,
- sangfor: false,
- zettakit: false,
- uis: false,
- ksyun: false,
- cnware: false,
- baidu: false,
- },
- },
- transfer: {
- cn: i18n.t('compute.text_1127'),
- brand: {
- azure: false,
- qcloud: false,
- aliyun: false,
- aws: false,
- onecloud: ['running', 'ready'],
- cloudpods: ['running', 'ready'],
- vmware: ['running', 'ready'],
- baremetal: false,
- huawei: false,
- hcso: false,
- hcs: false,
- openstack: true,
- zstack: false,
- dstack: false,
- ucloud: false,
- ctyun: false,
- google: false,
- apsara: false,
- nutanix: false,
- proxmox: false,
- bingocloud: false,
- incloudsphere: false,
- remotefile: false,
- volcengine: false,
- sangfor: false,
- zettakit: false,
- uis: false,
- ksyun: false,
- cnware: false,
- baidu: false,
- },
- },
- v2vTransfer: {
- cn: i18n.t('compute.v2vtransfer.label'),
- brand: {
- azure: false,
- qcloud: false,
- aliyun: false,
- aws: false,
- onecloud: false,
- cloudpods: ['ready'],
- vmware: ['ready'],
- baremetal: false,
- huawei: false,
- hcso: false,
- hcs: false,
- openstack: false,
- zstack: false,
- dstack: false,
- ucloud: false,
- ctyun: false,
- google: false,
- apsara: false,
- proxmox: false,
- nutanix: false,
- bingocloud: false,
- incloudsphere: false,
- remotefile: false,
- volcengine: false,
- sangfor: false,
- zettakit: false,
- uis: false,
- ksyun: false,
- cnware: false,
- baidu: false,
- },
- },
- assignSecgroup: {
- cn: i18n.t('compute.text_1116'),
- brand: {
- azure: true,
- qcloud: true,
- aliyun: true,
- aws: true,
- onecloud: true,
- cloudpods: true,
- vmware: false,
- baremetal: true,
- huawei: true,
- hcso: true,
- hcs: true,
- openstack: true,
- zstack: true,
- dstack: true,
- ucloud: true,
- ctyun: true,
- google: true,
- apsara: false,
- proxmox: false,
- nutanix: false,
- bingocloud: false,
- incloudsphere: false,
- remotefile: false,
- volcengine: true,
- sangfor: false,
- zettakit: false,
- uis: false,
- ksyun: false,
- cnware: false,
- baidu: false,
- },
- },
- insertiso: {
- cn: i18n.t('compute.text_366'),
- brand: {
- azure: true,
- qcloud: true,
- aliyun: true,
- aws: true,
- onecloud: true,
- vmware: true,
- baremetal: true,
- huawei: true,
- hcso: true,
- hcs: true,
- openstack: false,
- zstack: false,
- dstack: false,
- ucloud: false,
- ctyun: false,
- google: false,
- apsara: false,
- proxmox: false,
- nutanix: false,
- bingocloud: false,
- incloudsphere: false,
- remotefile: false,
- volcengine: false,
- sangfor: false,
- zettakit: false,
- uis: false,
- ksyun: false,
- cnware: false,
- baidu: false,
- },
- },
- ejectiso: {
- cn: i18n.t('compute.text_367'),
- brand: {
- azure: true,
- qcloud: true,
- aliyun: true,
- aws: true,
- onecloud: true,
- vmware: true,
- baremetal: true,
- huawei: true,
- hcso: true,
- hcs: true,
- openstack: true,
- zstack: false,
- dstack: false,
- ucloud: false,
- ctyun: false,
- google: false,
- apsara: false,
- proxmox: false,
- nutanix: false,
- bingocloud: false,
- incloudsphere: false,
- remotefile: false,
- volcengine: false,
- sangfor: false,
- zettakit: false,
- uis: false,
- ksyun: false,
- cnware: false,
- baidu: false,
- },
- },
- bindEip: {
- cn: i18n.t('compute.text_1302'),
- brand: {
- azure: ['running', 'ready'],
- qcloud: ['running', 'ready'],
- aliyun: ['running', 'ready'],
- aws: ['running', 'ready'],
- onecloud: ['running', 'ready'],
- cloudpods: ['running', 'ready'],
- vmware: false,
- baremetal: false,
- huawei: ['running', 'ready'],
- hcso: ['running', 'ready'],
- hcs: ['running', 'ready'],
- openstack: ['running', 'ready'],
- zstack: ['running', 'ready'],
- dstack: ['running', 'ready'],
- ucloud: ['running', 'ready'],
- ctyun: ['running', 'ready'],
- google: ['running', 'ready'],
- apsara: false,
- proxmox: false,
- nutanix: false,
- bingocloud: false,
- incloudsphere: false,
- remotefile: false,
- volcengine: ['running', 'ready'],
- sangfor: false,
- zettakit: false,
- uis: false,
- ksyun: ['running', 'ready'],
- cnware: false,
- baidu: ['running', 'ready'],
- },
- },
- unbindEip: {
- cn: i18n.t('compute.text_1303'),
- brand: {
- azure: ['running', 'ready'],
- qcloud: ['running', 'ready'],
- aliyun: ['running', 'ready'],
- aws: ['running', 'ready'],
- onecloud: ['running', 'ready'],
- cloudpods: ['running', 'ready'],
- vmware: false,
- baremetal: false,
- huawei: ['running', 'ready'],
- hcso: ['running', 'ready'],
- hcs: ['running', 'ready'],
- openstack: ['running', 'ready'],
- zstack: ['running', 'ready'],
- dstack: ['running', 'ready'],
- ucloud: ['running', 'ready'],
- ctyun: ['running', 'ready'],
- google: ['running', 'ready'],
- apsara: false,
- nutanix: false,
- proxmox: false,
- bingocloud: false,
- incloudsphere: false,
- remotefile: false,
- volcengine: ['running', 'ready'],
- sangfor: false,
- zettakit: false,
- uis: false,
- ksyun: ['running', 'ready'],
- cnware: false,
- baidu: ['running', 'ready'],
- },
- },
- acttachGpu: {
- cn: i18n.t('compute.text_1304'),
- brand: {
- onecloud: ['ready', 'running'],
- vmware: false,
- bingocloud: false,
- incloudsphere: false,
- remotefile: false,
- volcengine: false,
- sangfor: false,
- zettakit: false,
- uis: false,
- cloudpods: false,
- baidu: false,
- },
- },
- acttachUsb: {
- cn: i18n.t('compute.text_1399'),
- brand: {
- onecloud: ['ready', 'running'],
- vmware: false,
- bingocloud: false,
- incloudsphere: false,
- remotefile: false,
- volcengine: false,
- sangfor: false,
- zettakit: false,
- uis: false,
- cloudpods: false,
- baidu: false,
- },
- },
- publicIpToEip: {
- cn: i18n.t('compute.text_1305'),
- brand: {
- qcloud: ['running', 'ready'],
- aliyun: ['running', 'ready'],
- google: false,
- aws: false,
- bingocloud: false,
- incloudsphere: false,
- remotefile: false,
- volcengine: false,
- sangfor: false,
- zettakit: false,
- uis: false,
- baidu: false,
- },
- },
- changeBlockStorage: {
- cn: i18n.t('compute.vminstance.change_disk_storage'),
- brand: {
- onecloud: ['ready', 'running'],
- remotefile: false,
- volcengine: false,
- sangfor: false,
- zettakit: false,
- uis: false,
- baidu: false,
- },
- },
- addBackup: {
- cn: i18n.t('compute.text_1162'),
- brand: {
- onecloud: ['ready'],
- volcengine: false,
- sangfor: false,
- zettakit: false,
- uis: false,
- baidu: false,
- },
- },
- }
- export const commonEnabled = (value, statusArr = ['ready']) => {
- return statusArr.includes(value.status)
- }
- export const commonTip = (obj, statusArr = ['ready']) => {
- if (statusArr.includes(obj.status)) {
- return null
- } else {
- return i18n.t('compute.text_1306', [_tran(statusArr)])
- }
- }
- export const commonUnabled = (value, statusArr = ['sched_fail', 'net_fail', 'disk_fail']) => {
- return statusArr.includes(value.status)
- }
- export const cloudEnabled = (action, value, othersEabledStatus = ['ready']) => {
- value = _toArr(value)
- if (!value || !value.length) return false
- const actionItem = actionEableMap[action] && actionEableMap[action].brand
- return value.every(obj => {
- let H = obj.brand ? obj.brand.toLowerCase() : obj.hypervisor.toLowerCase() // 兼容没有brand的情况
- if (H === 'kvm') H = 'onecloud' // 兼容没有brand的情况
- if (H === 'esxi') H = 'vmware' // 兼容没有brand的情况
- if (actionItem === undefined) { // 不是 actionEnableMap 中的一种
- return commonEnabled(obj)
- } else if (Array.isArray(actionItem[H])) { // 是 actionEnableMap 中的一种,且状态是数组
- return actionItem[H].includes(obj.status)
- } else if (actionItem[H] === undefined) { // 新接入的平台
- return commonEnabled(obj)
- } else { // 是 actionEnableMap 中的一种,且状态是 boolean
- if (actionItem[H] === true) {
- return true
- } else if (actionItem[H] === undefined) { // 且不是 aliyun、azure、qcloud、aws 的一种
- return commonEnabled(obj, othersEabledStatus)
- } else {
- return false
- }
- }
- })
- }
- export const cloudUnabledTip = (action, value, othersEabledStatus = ['ready']) => {
- value = _toArr(value)
- if (!value || !value.length) return i18n.t('compute.text_1307')
- let errorMsg = null
- const actionItem = actionEableMap[action] && actionEableMap[action].brand
- const valid = value.every(obj => {
- let H = obj.brand ? obj.brand.toLowerCase() : obj.hypervisor.toLowerCase() // 兼容没有brand的情况
- if (H === 'kvm') H = 'onecloud' // 兼容没有brand的情况
- if (H === 'esxi') H = 'vmware' // 兼容没有brand的情况
- if (actionItem === undefined) { // 不是 actionEnableMap 中的一种
- if (commonEnabled(obj)) {
- return true
- } else {
- errorMsg = i18n.t('compute.text_1308')
- return false
- }
- } else if (Array.isArray(actionItem[H])) { // 是 actionEnableMap 中的一种,且状态是数组
- if (actionItem[H].includes(obj.status)) {
- return true
- } else {
- errorMsg = i18n.t('compute.text_1309', [_tran(actionItem[H])])
- return false
- }
- } else if (actionItem[H] === undefined) { // 新接入的平台
- if (commonEnabled(obj)) {
- return true
- } else {
- errorMsg = commonTip(obj, othersEabledStatus)
- return false
- }
- } else { // 是 actionEnableMap 中的一种,且状态是 boolean
- if (actionItem[H] === true) {
- return true
- } else if (actionItem[H] === undefined) { // 且不是 aliyun、azure、qcloud、aws 的一种
- errorMsg = commonTip(obj, othersEabledStatus)
- return false
- } else {
- if (H === 'onecloud') H = 'kvm'
- if (H === 'vmware') H = 'esxi'
- const tooltip = hypervisorMap[H].label
- errorMsg = i18n.t('compute.text_1287', [tooltip])
- return false
- }
- }
- })
- if (valid) {
- return null
- } else {
- return errorMsg
- }
- }
- export const isSameDate = (date1, date2) => {
- let isSame = true
- if (date1.getFullYear() !== date2.getFullYear()) {
- isSame = false
- }
- if (date1.getMonth() !== date2.getMonth()) {
- isSame = false
- }
- if (date1.getDate() !== date2.getDate()) {
- isSame = false
- }
- return isSame
- }
- export const validateRescueMode = (val) => {
- const ret = { validate: true }
- if (Array.isArray(val)) {
- const isSomeRescueMode = val.some(item => item.rescue_mode === true)
- if (isSomeRescueMode) {
- ret.validate = false
- ret.tooltip = i18n.t('compute.start_rescue.validate_tooltip')
- }
- } else {
- if (val?.rescue_mode === true) {
- ret.validate = false
- ret.tooltip = i18n.t('compute.start_rescue.validate_tooltip')
- }
- }
- return ret
- }
- /** cpu_numa_pin:每项一行;内存 sizestr;绑定 CPU 取全部 pcpu 排序后合并连续区间 */
- export const formatSortedPcpuRanges = (sortedPcpus) => {
- if (!sortedPcpus.length) return '-'
- const parts = []
- let start = sortedPcpus[0]
- let end = sortedPcpus[0]
- for (let i = 1; i < sortedPcpus.length; i++) {
- const cur = sortedPcpus[i]
- if (cur === end + 1) {
- end = cur
- } else {
- parts.push(start === end ? String(start) : `${start}-${end}`)
- start = cur
- end = cur
- }
- }
- parts.push(start === end ? String(start) : `${start}-${end}`)
- return parts.join(',')
- }
- const getCpuNumaPinLineData = (item) => {
- const nodeId = item.node_id
- const sizeMb = item.size_mb
- const pin = item.vcpu_pin || []
- const pcpus = [...new Set(
- pin
- .filter(p => p && typeof p.pcpu === 'number')
- .map(p => p.pcpu),
- )].sort((a, b) => a - b)
- const cpuStr = formatSortedPcpuRanges(pcpus)
- const memStr = sizestr(sizeMb, 'M', 1024)
- return { nodeId, memStr, cpuStr }
- }
- export const formatCpuNumaPinLine = (item) => {
- const { nodeId, memStr, cpuStr } = getCpuNumaPinLineData(item)
- return `node:${nodeId} mem: ${memStr} cpu: ${cpuStr}`
- }
- const CPU_NUMA_PIN_LINE_GAP = '12px'
- export const formatCpuNumaPin = (row) => {
- const raw = row.cpu_numa_pin
- if (raw === undefined || raw === null || raw === '') return '-'
- let arr = raw
- if (typeof raw === 'string') {
- try {
- arr = JSON.parse(raw)
- } catch (e) {
- return '-'
- }
- }
- if (!Array.isArray(arr) || arr.length === 0) return '-'
- return _cpuNumaPinH('div', arr.map((item, idx) => {
- const { nodeId, memStr, cpuStr } = getCpuNumaPinLineData(item)
- return _cpuNumaPinH('div', {
- key: idx,
- style: {
- display: 'flex',
- flexWrap: 'wrap',
- alignItems: 'center',
- columnGap: CPU_NUMA_PIN_LINE_GAP,
- rowGap: '4px',
- },
- }, [
- _cpuNumaPinH('span', `node: ${nodeId}`),
- _cpuNumaPinH('span', `mem: ${memStr}`),
- _cpuNumaPinH('span', `cpu: ${cpuStr}`),
- ])
- }))
- }
|