utils.js 26 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003
  1. import Vue from 'vue'
  2. import { typeClouds } from '@/utils/common/hypervisor'
  3. import i18n from '@/locales'
  4. import { sizestr } from '@/utils/utils'
  5. const __cpuNumaPinHVm = new Vue()
  6. const _cpuNumaPinH = (...args) => __cpuNumaPinHVm.$createElement(...args)
  7. const hypervisorMap = typeClouds.hypervisorMap
  8. const serverStatus = i18n.t('status.server')
  9. const _toArr = value => {
  10. if (!Array.isArray(value)) {
  11. value = [value]
  12. }
  13. return value
  14. }
  15. const _tran = enArr => {
  16. return enArr.map(v => serverStatus[v] || v).filter(v => v).join(',')
  17. }
  18. const actionEableMap = {
  19. start: {
  20. cn: i18n.t('compute.text_272'),
  21. brand: {
  22. azure: ['ready'],
  23. qcloud: ['ready'],
  24. aliyun: ['ready'],
  25. aws: ['ready'],
  26. onecloud: ['ready'],
  27. cloudpods: ['ready'],
  28. vmware: ['ready'],
  29. baremetal: ['ready'],
  30. huawei: ['ready'],
  31. hcso: ['ready'],
  32. hcs: ['ready'],
  33. openstack: ['ready'],
  34. zstack: ['ready'],
  35. dstack: ['ready'],
  36. ucloud: ['ready'],
  37. ctyun: ['ready'],
  38. google: ['ready'],
  39. apsara: ['ready'],
  40. jdcloud: ['ready'],
  41. ecloud: ['ready'],
  42. nutanix: ['ready'],
  43. proxmox: ['ready'],
  44. bingocloud: false,
  45. incloudsphere: ['ready'],
  46. volcengine: ['ready'],
  47. remotefile: false,
  48. sangfor: ['ready'],
  49. zettakit: ['ready'],
  50. uis: ['ready'],
  51. ksyun: ['ready'],
  52. cnware: ['ready'],
  53. baidu: ['ready'],
  54. },
  55. },
  56. stop: {
  57. cn: i18n.t('compute.text_273'),
  58. brand: {
  59. azure: ['running', 'stop_fail'],
  60. qcloud: ['running', 'stop_fail'],
  61. aliyun: ['running', 'stop_fail'],
  62. aws: ['running', 'stop_fail'],
  63. onecloud: ['running', 'stop_fail'],
  64. cloudpods: ['running', 'stop_fail'],
  65. vmware: ['running', 'stop_fail'],
  66. baremetal: ['running', 'stop_fail'],
  67. huawei: ['running', 'stop_fail'],
  68. hcso: ['running', 'stop_fail'],
  69. hcs: ['running', 'stop_fail'],
  70. openstack: ['running', 'stop_fail'],
  71. zstack: ['running', 'stop_fail'],
  72. dstack: ['running', 'stop_fail'],
  73. ucloud: ['running', 'stop_fail'],
  74. ctyun: ['running', 'stop_fail'],
  75. google: ['running', 'stop_fail'],
  76. apsara: ['running', 'stop_fail'],
  77. jdcloud: ['running', 'stop_fail'],
  78. ecloud: ['running', 'stop_fail'],
  79. nutanix: ['running', 'stop_fail'],
  80. proxmox: ['running', 'stop_fail'],
  81. bingocloud: false,
  82. incloudsphere: ['running', 'stop_fail'],
  83. remotefile: false,
  84. volcengine: ['running', 'stop_fail'],
  85. sangfor: ['running', 'stop_fail'],
  86. zettakit: ['running', 'stop_fail'],
  87. uis: ['running', 'stop_fail'],
  88. ksyun: ['running', 'stop_fail'],
  89. cnware: ['running', 'stop_fail'],
  90. baidu: ['running', 'stop_fail'],
  91. },
  92. },
  93. restart: {
  94. cn: i18n.t('compute.text_274'),
  95. brand: {
  96. azure: ['running', 'stop_fail'],
  97. qcloud: ['running', 'stop_fail'],
  98. aliyun: ['running', 'stop_fail'],
  99. aws: ['running', 'stop_fail'],
  100. onecloud: ['running', 'stop_fail'],
  101. cloudpods: ['running', 'stop_fail'],
  102. vmware: ['running', 'stop_fail'],
  103. baremetal: ['running', 'stop_fail'],
  104. huawei: ['running', 'stop_fail'],
  105. hcso: ['running', 'stop_fail'],
  106. hcs: ['running', 'stop_fail'],
  107. openstack: ['running', 'stop_fail'],
  108. zstack: ['running', 'stop_fail'],
  109. dstack: ['running', 'stop_fail'],
  110. ucloud: ['running', 'stop_fail'],
  111. ctyun: ['running', 'stop_fail'],
  112. google: ['running', 'stop_fail'],
  113. apsara: ['running', 'stop_fail'],
  114. jdcloud: ['running', 'stop_fail'],
  115. ecloud: ['running', 'stop_fail'],
  116. nutanix: ['running', 'stop_fail'],
  117. proxmox: ['running', 'stop_fail'],
  118. bingocloud: false,
  119. incloudsphere: ['running', 'stop_fail'],
  120. remotefile: false,
  121. volcengine: ['running', 'stop_fail'],
  122. sangfor: ['running', 'stop_fail'],
  123. zettakit: ['running', 'stop_fail'],
  124. uis: ['running', 'stop_fail'],
  125. ksyun: ['running', 'stop_fail'],
  126. cnware: ['running', 'stop_fail'],
  127. baidu: ['running', 'stop_fail'],
  128. },
  129. },
  130. rebuildRoot: {
  131. cn: i18n.t('compute.text_357'),
  132. brand: {
  133. azure: ['ready', 'running'],
  134. qcloud: ['ready', 'running'],
  135. aliyun: ['ready', 'running'],
  136. aws: ['ready', 'running'],
  137. onecloud: ['ready'],
  138. cloudpods: ['ready'],
  139. vmware: ['ready'],
  140. baremetal: ['ready', 'admin'],
  141. huawei: ['ready', 'rebuild_root_fail'],
  142. hcso: ['ready', 'rebuild_root_fail'],
  143. hcs: ['ready', 'rebuild_root_fail'],
  144. openstack: ['ready'],
  145. zstack: ['ready'],
  146. dstack: ['ready'],
  147. ucloud: ['ready'],
  148. ctyun: ['ready'],
  149. google: ['ready'],
  150. apsara: ['running', 'ready'],
  151. proxmox: false,
  152. nutanix: false,
  153. bingocloud: false,
  154. incloudsphere: false,
  155. remotefile: false,
  156. volcengine: false,
  157. sangfor: false,
  158. zettakit: ['running'],
  159. uis: ['running'],
  160. ksyun: ['ready'],
  161. cnware: false,
  162. baidu: ['ready', 'running'],
  163. },
  164. },
  165. resetPassword: {
  166. cn: i18n.t('compute.text_276'),
  167. brand: {
  168. azure: ['running'],
  169. qcloud: ['ready'],
  170. aliyun: ['ready'],
  171. aws: false,
  172. onecloud: ['running', 'ready'],
  173. cloudpods: ['ready'],
  174. vmware: ['ready'],
  175. baremetal: ['ready', 'admin'],
  176. huawei: ['ready'],
  177. hcso: ['ready'],
  178. hcs: ['ready'],
  179. openstack: ['running'],
  180. zstack: ['running'],
  181. dstack: ['running'],
  182. ucloud: ['ready'],
  183. ctyun: ['running'],
  184. google: ['ready'],
  185. apsara: ['running'],
  186. proxmox: false,
  187. nutanix: false,
  188. bingocloud: false,
  189. incloudsphere: ['running'],
  190. remotefile: false,
  191. volcengine: ['ready'],
  192. sangfor: false,
  193. zettakit: false,
  194. uis: false,
  195. ksyun: ['ready', 'running'],
  196. cnware: false,
  197. baidu: ['ready', 'running'],
  198. },
  199. },
  200. bindKeyPair: {
  201. cn: i18n.t('compute.text_361'),
  202. brand: {
  203. azure: ['running'],
  204. qcloud: ['ready'],
  205. aliyun: ['ready'],
  206. aws: false,
  207. onecloud: ['ready'],
  208. cloudpods: ['ready'],
  209. vmware: ['ready'],
  210. baremetal: ['ready', 'admin'],
  211. huawei: false,
  212. hcso: false,
  213. hcs: false,
  214. openstack: ['running'],
  215. zstack: ['running'],
  216. dstack: ['running'],
  217. ucloud: false,
  218. ctyun: ['ready', 'running'],
  219. google: ['ready'],
  220. apsara: ['running'],
  221. proxmox: false,
  222. nutanix: false,
  223. bingocloud: false,
  224. incloudsphere: ['running'],
  225. remotefile: false,
  226. volcengine: ['ready'],
  227. sangfor: false,
  228. zettakit: false,
  229. uis: false,
  230. ksyun: ['ready'],
  231. cnware: false,
  232. baidu: false,
  233. },
  234. },
  235. unBindKeyPair: {
  236. cn: i18n.t('compute.text_364'),
  237. brand: {
  238. azure: ['running'],
  239. qcloud: ['ready'],
  240. aliyun: ['ready'],
  241. aws: false,
  242. onecloud: ['ready'],
  243. cloudpods: ['ready'],
  244. vmware: ['ready'],
  245. baremetal: ['ready', 'admin'],
  246. huawei: false,
  247. hcso: false,
  248. hcs: false,
  249. openstack: ['running'],
  250. zstack: ['running'],
  251. dstack: ['running'],
  252. ucloud: false,
  253. ctyun: ['ready', 'running'],
  254. google: ['ready'],
  255. apsara: ['running'],
  256. proxmox: false,
  257. nutanix: false,
  258. bingocloud: false,
  259. incloudsphere: false,
  260. remotefile: false,
  261. volcengine: ['ready'],
  262. sangfor: false,
  263. zettakit: false,
  264. uis: false,
  265. ksyun: ['ready', 'running'],
  266. cnware: false,
  267. baidu: false,
  268. },
  269. },
  270. adjustConfig: {
  271. cn: i18n.t('compute.text_1100'),
  272. brand: {
  273. azure: ['ready', 'running'],
  274. qcloud: ['ready'],
  275. aliyun: ['ready', 'running'],
  276. aws: ['ready', 'running'],
  277. onecloud: ['ready', 'running'],
  278. cloudpods: ['ready', 'running'],
  279. vmware: ['ready', 'running'],
  280. baremetal: false,
  281. huawei: ['ready', 'running'],
  282. hcso: ['ready'],
  283. hcs: ['ready'],
  284. openstack: ['ready', 'running'],
  285. zstack: ['ready'],
  286. dstack: ['ready'],
  287. ucloud: ['ready'],
  288. ctyun: ['ready', 'running'],
  289. google: ['ready', 'running'],
  290. apsara: ['ready'],
  291. nutanix: ['ready'],
  292. proxmox: ['ready', 'running'],
  293. bingocloud: false,
  294. incloudsphere: ['ready', 'running'],
  295. remotefile: false,
  296. volcengine: ['ready', 'running'],
  297. sangfor: ['ready'],
  298. zettakit: ['ready'],
  299. uis: ['ready'],
  300. ksyun: ['ready', 'running'],
  301. cnware: false,
  302. baidu: ['ready', 'running'],
  303. },
  304. },
  305. vnc: {
  306. cn: 'vnc',
  307. brand: {
  308. azure: false,
  309. qcloud: ['running'],
  310. aliyun: ['running'],
  311. aws: false,
  312. onecloud: ['running', 'block_stream', 'live_migrating'],
  313. cloudpods: ['running'],
  314. vmware: ['running'],
  315. baremetal: false,
  316. huawei: ['running'],
  317. hcso: ['running'],
  318. hcs: ['running'],
  319. openstack: ['running'],
  320. zstack: ['running'],
  321. dstack: ['running'],
  322. ucloud: false,
  323. ctyun: ['running'],
  324. google: false,
  325. apsara: ['running'],
  326. jdcloud: ['running'],
  327. ecloud: ['running'],
  328. proxmox: ['running'],
  329. nutanix: false,
  330. bingocloud: false,
  331. incloudsphere: ['running'],
  332. remotefile: false,
  333. volcengine: ['running'],
  334. sangfor: ['running'],
  335. zettakit: ['running'],
  336. uis: ['running'],
  337. ksyun: ['running'],
  338. cnware: ['running'],
  339. baidu: ['running'],
  340. },
  341. },
  342. 'EIP SSH': {
  343. cn: 'EIP SSH',
  344. brand: {
  345. azure: ['running'],
  346. qcloud: ['running'],
  347. aliyun: ['running'],
  348. aws: ['running'],
  349. onecloud: ['running'],
  350. cloudpods: ['running'],
  351. vmware: ['running'],
  352. baremetal: ['running'],
  353. huawei: ['running'],
  354. hcso: ['running'],
  355. hcs: ['running'],
  356. openstack: ['running'],
  357. zstack: ['running'],
  358. dstack: ['running'],
  359. ucloud: ['running'],
  360. ctyun: ['running'],
  361. google: ['running'],
  362. apsara: ['running'],
  363. jdcloud: ['running'],
  364. ecloud: ['running'],
  365. nutanix: ['running'],
  366. proxmox: false,
  367. bingocloud: false,
  368. remotefile: false,
  369. volcengine: ['running'],
  370. sangfor: ['running'],
  371. zettakit: ['running'],
  372. uis: ['running'],
  373. ksyun: ['running'],
  374. cnware: false,
  375. baidu: ['running'],
  376. },
  377. },
  378. 'IP SSH': {
  379. cn: 'IP SSH',
  380. brand: {
  381. azure: false, // 暂时网络未打通
  382. qcloud: false, // 暂时网络未打通
  383. aliyun: false, // 暂时网络未打通
  384. aws: false, // 暂时网络未打通
  385. onecloud: ['running'],
  386. cloudpods: ['running'],
  387. vmware: ['running'],
  388. baremetal: ['running'],
  389. huawei: false, // 暂时网络未打通
  390. hcso: false, // 暂时网络未打通
  391. hcs: false, // 暂时网络未打通
  392. openstack: ['running'],
  393. zstack: false,
  394. dstack: false,
  395. ucloud: false,
  396. ctyun: false,
  397. google: false,
  398. apsara: false,
  399. jdcloud: false,
  400. ecloud: false,
  401. nutanix: ['running'],
  402. bingocloud: false,
  403. incloudsphere: ['running'],
  404. proxmox: false,
  405. remotefile: false,
  406. volcengine: ['running'],
  407. sangfor: ['running'],
  408. zettakit: ['running'],
  409. uis: ['running'],
  410. ksyun: false,
  411. cnware: false,
  412. baidu: ['running'],
  413. },
  414. },
  415. createSnapshot: {
  416. cn: i18n.t('compute.text_1276'),
  417. brand: {
  418. azure: ['running', 'ready'],
  419. qcloud: ['running', 'ready'],
  420. aliyun: ['running', 'ready'],
  421. aws: ['running', 'ready'],
  422. onecloud: ['running', 'ready'],
  423. cloudpods: ['running', 'ready'],
  424. vmware: ['running', 'ready'],
  425. baremetal: ['running', 'ready'],
  426. huawei: ['running', 'ready'],
  427. hcso: ['running', 'ready'],
  428. hcs: ['running', 'ready'],
  429. openstack: ['running', 'ready'],
  430. zstack: ['running', 'ready'],
  431. dstack: ['running', 'ready'],
  432. ucloud: false,
  433. ctyun: false,
  434. google: ['running', 'ready'],
  435. apsara: false,
  436. proxmox: false,
  437. nutanix: false,
  438. bingocloud: false,
  439. incloudsphere: false,
  440. remotefile: false,
  441. volcengine: false,
  442. sangfor: false,
  443. zettakit: false,
  444. uis: false,
  445. ksyun: false,
  446. cnware: ['running', 'ready'],
  447. baidu: ['running', 'ready'],
  448. },
  449. },
  450. createBackup: {
  451. cn: i18n.t('compute.text_1276'),
  452. brand: {
  453. azure: false,
  454. qcloud: false,
  455. aliyun: false,
  456. aws: false,
  457. onecloud: ['running', 'ready'],
  458. cloudpods: false,
  459. vmware: false,
  460. baremetal: false,
  461. huawei: false,
  462. hcso: false,
  463. hcs: false,
  464. openstack: false,
  465. zstack: false,
  466. dstack: false,
  467. ucloud: false,
  468. ctyun: false,
  469. google: false,
  470. apsara: false,
  471. nutanix: false,
  472. bingocloud: false,
  473. proxmox: false,
  474. incloudsphere: false,
  475. remotefile: false,
  476. volcengine: false,
  477. sangfor: false,
  478. zettakit: false,
  479. uis: false,
  480. ksyun: false,
  481. cnware: false,
  482. baidu: false,
  483. },
  484. },
  485. transfer: {
  486. cn: i18n.t('compute.text_1127'),
  487. brand: {
  488. azure: false,
  489. qcloud: false,
  490. aliyun: false,
  491. aws: false,
  492. onecloud: ['running', 'ready'],
  493. cloudpods: ['running', 'ready'],
  494. vmware: ['running', 'ready'],
  495. baremetal: false,
  496. huawei: false,
  497. hcso: false,
  498. hcs: false,
  499. openstack: true,
  500. zstack: false,
  501. dstack: false,
  502. ucloud: false,
  503. ctyun: false,
  504. google: false,
  505. apsara: false,
  506. nutanix: false,
  507. proxmox: false,
  508. bingocloud: false,
  509. incloudsphere: false,
  510. remotefile: false,
  511. volcengine: false,
  512. sangfor: false,
  513. zettakit: false,
  514. uis: false,
  515. ksyun: false,
  516. cnware: false,
  517. baidu: false,
  518. },
  519. },
  520. v2vTransfer: {
  521. cn: i18n.t('compute.v2vtransfer.label'),
  522. brand: {
  523. azure: false,
  524. qcloud: false,
  525. aliyun: false,
  526. aws: false,
  527. onecloud: false,
  528. cloudpods: ['ready'],
  529. vmware: ['ready'],
  530. baremetal: false,
  531. huawei: false,
  532. hcso: false,
  533. hcs: false,
  534. openstack: false,
  535. zstack: false,
  536. dstack: false,
  537. ucloud: false,
  538. ctyun: false,
  539. google: false,
  540. apsara: false,
  541. proxmox: false,
  542. nutanix: false,
  543. bingocloud: false,
  544. incloudsphere: false,
  545. remotefile: false,
  546. volcengine: false,
  547. sangfor: false,
  548. zettakit: false,
  549. uis: false,
  550. ksyun: false,
  551. cnware: false,
  552. baidu: false,
  553. },
  554. },
  555. assignSecgroup: {
  556. cn: i18n.t('compute.text_1116'),
  557. brand: {
  558. azure: true,
  559. qcloud: true,
  560. aliyun: true,
  561. aws: true,
  562. onecloud: true,
  563. cloudpods: true,
  564. vmware: false,
  565. baremetal: true,
  566. huawei: true,
  567. hcso: true,
  568. hcs: true,
  569. openstack: true,
  570. zstack: true,
  571. dstack: true,
  572. ucloud: true,
  573. ctyun: true,
  574. google: true,
  575. apsara: false,
  576. proxmox: false,
  577. nutanix: false,
  578. bingocloud: false,
  579. incloudsphere: false,
  580. remotefile: false,
  581. volcengine: true,
  582. sangfor: false,
  583. zettakit: false,
  584. uis: false,
  585. ksyun: false,
  586. cnware: false,
  587. baidu: false,
  588. },
  589. },
  590. insertiso: {
  591. cn: i18n.t('compute.text_366'),
  592. brand: {
  593. azure: true,
  594. qcloud: true,
  595. aliyun: true,
  596. aws: true,
  597. onecloud: true,
  598. vmware: true,
  599. baremetal: true,
  600. huawei: true,
  601. hcso: true,
  602. hcs: true,
  603. openstack: false,
  604. zstack: false,
  605. dstack: false,
  606. ucloud: false,
  607. ctyun: false,
  608. google: false,
  609. apsara: false,
  610. proxmox: false,
  611. nutanix: false,
  612. bingocloud: false,
  613. incloudsphere: false,
  614. remotefile: false,
  615. volcengine: false,
  616. sangfor: false,
  617. zettakit: false,
  618. uis: false,
  619. ksyun: false,
  620. cnware: false,
  621. baidu: false,
  622. },
  623. },
  624. ejectiso: {
  625. cn: i18n.t('compute.text_367'),
  626. brand: {
  627. azure: true,
  628. qcloud: true,
  629. aliyun: true,
  630. aws: true,
  631. onecloud: true,
  632. vmware: true,
  633. baremetal: true,
  634. huawei: true,
  635. hcso: true,
  636. hcs: true,
  637. openstack: true,
  638. zstack: false,
  639. dstack: false,
  640. ucloud: false,
  641. ctyun: false,
  642. google: false,
  643. apsara: false,
  644. proxmox: false,
  645. nutanix: false,
  646. bingocloud: false,
  647. incloudsphere: false,
  648. remotefile: false,
  649. volcengine: false,
  650. sangfor: false,
  651. zettakit: false,
  652. uis: false,
  653. ksyun: false,
  654. cnware: false,
  655. baidu: false,
  656. },
  657. },
  658. bindEip: {
  659. cn: i18n.t('compute.text_1302'),
  660. brand: {
  661. azure: ['running', 'ready'],
  662. qcloud: ['running', 'ready'],
  663. aliyun: ['running', 'ready'],
  664. aws: ['running', 'ready'],
  665. onecloud: ['running', 'ready'],
  666. cloudpods: ['running', 'ready'],
  667. vmware: false,
  668. baremetal: false,
  669. huawei: ['running', 'ready'],
  670. hcso: ['running', 'ready'],
  671. hcs: ['running', 'ready'],
  672. openstack: ['running', 'ready'],
  673. zstack: ['running', 'ready'],
  674. dstack: ['running', 'ready'],
  675. ucloud: ['running', 'ready'],
  676. ctyun: ['running', 'ready'],
  677. google: ['running', 'ready'],
  678. apsara: false,
  679. proxmox: false,
  680. nutanix: false,
  681. bingocloud: false,
  682. incloudsphere: false,
  683. remotefile: false,
  684. volcengine: ['running', 'ready'],
  685. sangfor: false,
  686. zettakit: false,
  687. uis: false,
  688. ksyun: ['running', 'ready'],
  689. cnware: false,
  690. baidu: ['running', 'ready'],
  691. },
  692. },
  693. unbindEip: {
  694. cn: i18n.t('compute.text_1303'),
  695. brand: {
  696. azure: ['running', 'ready'],
  697. qcloud: ['running', 'ready'],
  698. aliyun: ['running', 'ready'],
  699. aws: ['running', 'ready'],
  700. onecloud: ['running', 'ready'],
  701. cloudpods: ['running', 'ready'],
  702. vmware: false,
  703. baremetal: false,
  704. huawei: ['running', 'ready'],
  705. hcso: ['running', 'ready'],
  706. hcs: ['running', 'ready'],
  707. openstack: ['running', 'ready'],
  708. zstack: ['running', 'ready'],
  709. dstack: ['running', 'ready'],
  710. ucloud: ['running', 'ready'],
  711. ctyun: ['running', 'ready'],
  712. google: ['running', 'ready'],
  713. apsara: false,
  714. nutanix: false,
  715. proxmox: false,
  716. bingocloud: false,
  717. incloudsphere: false,
  718. remotefile: false,
  719. volcengine: ['running', 'ready'],
  720. sangfor: false,
  721. zettakit: false,
  722. uis: false,
  723. ksyun: ['running', 'ready'],
  724. cnware: false,
  725. baidu: ['running', 'ready'],
  726. },
  727. },
  728. acttachGpu: {
  729. cn: i18n.t('compute.text_1304'),
  730. brand: {
  731. onecloud: ['ready', 'running'],
  732. vmware: false,
  733. bingocloud: false,
  734. incloudsphere: false,
  735. remotefile: false,
  736. volcengine: false,
  737. sangfor: false,
  738. zettakit: false,
  739. uis: false,
  740. cloudpods: false,
  741. baidu: false,
  742. },
  743. },
  744. acttachUsb: {
  745. cn: i18n.t('compute.text_1399'),
  746. brand: {
  747. onecloud: ['ready', 'running'],
  748. vmware: false,
  749. bingocloud: false,
  750. incloudsphere: false,
  751. remotefile: false,
  752. volcengine: false,
  753. sangfor: false,
  754. zettakit: false,
  755. uis: false,
  756. cloudpods: false,
  757. baidu: false,
  758. },
  759. },
  760. publicIpToEip: {
  761. cn: i18n.t('compute.text_1305'),
  762. brand: {
  763. qcloud: ['running', 'ready'],
  764. aliyun: ['running', 'ready'],
  765. google: false,
  766. aws: false,
  767. bingocloud: false,
  768. incloudsphere: false,
  769. remotefile: false,
  770. volcengine: false,
  771. sangfor: false,
  772. zettakit: false,
  773. uis: false,
  774. baidu: false,
  775. },
  776. },
  777. changeBlockStorage: {
  778. cn: i18n.t('compute.vminstance.change_disk_storage'),
  779. brand: {
  780. onecloud: ['ready', 'running'],
  781. remotefile: false,
  782. volcengine: false,
  783. sangfor: false,
  784. zettakit: false,
  785. uis: false,
  786. baidu: false,
  787. },
  788. },
  789. addBackup: {
  790. cn: i18n.t('compute.text_1162'),
  791. brand: {
  792. onecloud: ['ready'],
  793. volcengine: false,
  794. sangfor: false,
  795. zettakit: false,
  796. uis: false,
  797. baidu: false,
  798. },
  799. },
  800. }
  801. export const commonEnabled = (value, statusArr = ['ready']) => {
  802. return statusArr.includes(value.status)
  803. }
  804. export const commonTip = (obj, statusArr = ['ready']) => {
  805. if (statusArr.includes(obj.status)) {
  806. return null
  807. } else {
  808. return i18n.t('compute.text_1306', [_tran(statusArr)])
  809. }
  810. }
  811. export const commonUnabled = (value, statusArr = ['sched_fail', 'net_fail', 'disk_fail']) => {
  812. return statusArr.includes(value.status)
  813. }
  814. export const cloudEnabled = (action, value, othersEabledStatus = ['ready']) => {
  815. value = _toArr(value)
  816. if (!value || !value.length) return false
  817. const actionItem = actionEableMap[action] && actionEableMap[action].brand
  818. return value.every(obj => {
  819. let H = obj.brand ? obj.brand.toLowerCase() : obj.hypervisor.toLowerCase() // 兼容没有brand的情况
  820. if (H === 'kvm') H = 'onecloud' // 兼容没有brand的情况
  821. if (H === 'esxi') H = 'vmware' // 兼容没有brand的情况
  822. if (actionItem === undefined) { // 不是 actionEnableMap 中的一种
  823. return commonEnabled(obj)
  824. } else if (Array.isArray(actionItem[H])) { // 是 actionEnableMap 中的一种,且状态是数组
  825. return actionItem[H].includes(obj.status)
  826. } else if (actionItem[H] === undefined) { // 新接入的平台
  827. return commonEnabled(obj)
  828. } else { // 是 actionEnableMap 中的一种,且状态是 boolean
  829. if (actionItem[H] === true) {
  830. return true
  831. } else if (actionItem[H] === undefined) { // 且不是 aliyun、azure、qcloud、aws 的一种
  832. return commonEnabled(obj, othersEabledStatus)
  833. } else {
  834. return false
  835. }
  836. }
  837. })
  838. }
  839. export const cloudUnabledTip = (action, value, othersEabledStatus = ['ready']) => {
  840. value = _toArr(value)
  841. if (!value || !value.length) return i18n.t('compute.text_1307')
  842. let errorMsg = null
  843. const actionItem = actionEableMap[action] && actionEableMap[action].brand
  844. const valid = value.every(obj => {
  845. let H = obj.brand ? obj.brand.toLowerCase() : obj.hypervisor.toLowerCase() // 兼容没有brand的情况
  846. if (H === 'kvm') H = 'onecloud' // 兼容没有brand的情况
  847. if (H === 'esxi') H = 'vmware' // 兼容没有brand的情况
  848. if (actionItem === undefined) { // 不是 actionEnableMap 中的一种
  849. if (commonEnabled(obj)) {
  850. return true
  851. } else {
  852. errorMsg = i18n.t('compute.text_1308')
  853. return false
  854. }
  855. } else if (Array.isArray(actionItem[H])) { // 是 actionEnableMap 中的一种,且状态是数组
  856. if (actionItem[H].includes(obj.status)) {
  857. return true
  858. } else {
  859. errorMsg = i18n.t('compute.text_1309', [_tran(actionItem[H])])
  860. return false
  861. }
  862. } else if (actionItem[H] === undefined) { // 新接入的平台
  863. if (commonEnabled(obj)) {
  864. return true
  865. } else {
  866. errorMsg = commonTip(obj, othersEabledStatus)
  867. return false
  868. }
  869. } else { // 是 actionEnableMap 中的一种,且状态是 boolean
  870. if (actionItem[H] === true) {
  871. return true
  872. } else if (actionItem[H] === undefined) { // 且不是 aliyun、azure、qcloud、aws 的一种
  873. errorMsg = commonTip(obj, othersEabledStatus)
  874. return false
  875. } else {
  876. if (H === 'onecloud') H = 'kvm'
  877. if (H === 'vmware') H = 'esxi'
  878. const tooltip = hypervisorMap[H].label
  879. errorMsg = i18n.t('compute.text_1287', [tooltip])
  880. return false
  881. }
  882. }
  883. })
  884. if (valid) {
  885. return null
  886. } else {
  887. return errorMsg
  888. }
  889. }
  890. export const isSameDate = (date1, date2) => {
  891. let isSame = true
  892. if (date1.getFullYear() !== date2.getFullYear()) {
  893. isSame = false
  894. }
  895. if (date1.getMonth() !== date2.getMonth()) {
  896. isSame = false
  897. }
  898. if (date1.getDate() !== date2.getDate()) {
  899. isSame = false
  900. }
  901. return isSame
  902. }
  903. export const validateRescueMode = (val) => {
  904. const ret = { validate: true }
  905. if (Array.isArray(val)) {
  906. const isSomeRescueMode = val.some(item => item.rescue_mode === true)
  907. if (isSomeRescueMode) {
  908. ret.validate = false
  909. ret.tooltip = i18n.t('compute.start_rescue.validate_tooltip')
  910. }
  911. } else {
  912. if (val?.rescue_mode === true) {
  913. ret.validate = false
  914. ret.tooltip = i18n.t('compute.start_rescue.validate_tooltip')
  915. }
  916. }
  917. return ret
  918. }
  919. /** cpu_numa_pin:每项一行;内存 sizestr;绑定 CPU 取全部 pcpu 排序后合并连续区间 */
  920. export const formatSortedPcpuRanges = (sortedPcpus) => {
  921. if (!sortedPcpus.length) return '-'
  922. const parts = []
  923. let start = sortedPcpus[0]
  924. let end = sortedPcpus[0]
  925. for (let i = 1; i < sortedPcpus.length; i++) {
  926. const cur = sortedPcpus[i]
  927. if (cur === end + 1) {
  928. end = cur
  929. } else {
  930. parts.push(start === end ? String(start) : `${start}-${end}`)
  931. start = cur
  932. end = cur
  933. }
  934. }
  935. parts.push(start === end ? String(start) : `${start}-${end}`)
  936. return parts.join(',')
  937. }
  938. const getCpuNumaPinLineData = (item) => {
  939. const nodeId = item.node_id
  940. const sizeMb = item.size_mb
  941. const pin = item.vcpu_pin || []
  942. const pcpus = [...new Set(
  943. pin
  944. .filter(p => p && typeof p.pcpu === 'number')
  945. .map(p => p.pcpu),
  946. )].sort((a, b) => a - b)
  947. const cpuStr = formatSortedPcpuRanges(pcpus)
  948. const memStr = sizestr(sizeMb, 'M', 1024)
  949. return { nodeId, memStr, cpuStr }
  950. }
  951. export const formatCpuNumaPinLine = (item) => {
  952. const { nodeId, memStr, cpuStr } = getCpuNumaPinLineData(item)
  953. return `node:${nodeId} mem: ${memStr} cpu: ${cpuStr}`
  954. }
  955. const CPU_NUMA_PIN_LINE_GAP = '12px'
  956. export const formatCpuNumaPin = (row) => {
  957. const raw = row.cpu_numa_pin
  958. if (raw === undefined || raw === null || raw === '') return '-'
  959. let arr = raw
  960. if (typeof raw === 'string') {
  961. try {
  962. arr = JSON.parse(raw)
  963. } catch (e) {
  964. return '-'
  965. }
  966. }
  967. if (!Array.isArray(arr) || arr.length === 0) return '-'
  968. return _cpuNumaPinH('div', arr.map((item, idx) => {
  969. const { nodeId, memStr, cpuStr } = getCpuNumaPinLineData(item)
  970. return _cpuNumaPinH('div', {
  971. key: idx,
  972. style: {
  973. display: 'flex',
  974. flexWrap: 'wrap',
  975. alignItems: 'center',
  976. columnGap: CPU_NUMA_PIN_LINE_GAP,
  977. rowGap: '4px',
  978. },
  979. }, [
  980. _cpuNumaPinH('span', `node: ${nodeId}`),
  981. _cpuNumaPinH('span', `mem: ${memStr}`),
  982. _cpuNumaPinH('span', `cpu: ${cpuStr}`),
  983. ])
  984. }))
  985. }