Detail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. <template>
  2. <detail
  3. :on-manager="onManager"
  4. :data="itemData"
  5. :base-info="baseInfo"
  6. :extra-info="extraInfo"
  7. resource="hosts"
  8. status-module="host" />
  9. </template>
  10. <script>
  11. import {
  12. getUserTagColumn,
  13. getExtTagColumn,
  14. } from '@/utils/common/detailColumn'
  15. import { getEnabledTableColumn, getCopyWithContentTableColumn, getPublicScopeTableColumn } from '@/utils/common/tableColumn'
  16. import { sizestr } from '@/utils/utils'
  17. import i18n from '@/locales'
  18. import WindowsMixin from '@/mixins/windows'
  19. import { getMaintenanceTableColumn } from '../utils/columns'
  20. const storageType = {
  21. rotate: i18n.t('compute.text_47'),
  22. ssd: i18n.t('compute.text_48'),
  23. hybrid: i18n.t('compute.text_578'),
  24. }
  25. export default {
  26. name: 'PhysicalmachineDetail',
  27. mixins: [WindowsMixin],
  28. props: {
  29. hostInfo: {
  30. type: Object,
  31. required: true,
  32. },
  33. onManager: {
  34. type: Function,
  35. required: true,
  36. },
  37. columns: Array,
  38. },
  39. data () {
  40. return {
  41. itemData: {
  42. status: 'ready',
  43. host_status: 'ready',
  44. enabled: true,
  45. },
  46. storageColumns: [
  47. {
  48. field: 'adapter',
  49. title: this.$t('compute.text_579'),
  50. width: 70,
  51. },
  52. {
  53. field: 'driver',
  54. title: this.$t('compute.text_378'),
  55. width: 140,
  56. },
  57. {
  58. field: 'model',
  59. title: this.$t('compute.text_580'),
  60. showOverflow: 'ellipsis',
  61. minWidth: 200,
  62. },
  63. {
  64. field: 'rotate',
  65. title: this.$t('compute.text_175'),
  66. width: 80,
  67. formatter: ({ cellValue, row }) => {
  68. if (cellValue === true) return this.$t('compute.text_581')
  69. return 'SSD'
  70. },
  71. },
  72. {
  73. field: 'size',
  74. title: this.$t('compute.text_397'),
  75. formatter: ({ cellValue, row }) => {
  76. return sizestr(cellValue, 'M', 1024)
  77. },
  78. },
  79. ],
  80. hostColumns: [
  81. {
  82. field: 'mac',
  83. title: this.$t('compute.text_385'),
  84. showOverflow: 'ellipsis',
  85. width: 200,
  86. formatter: ({ cellValue, row }) => {
  87. return cellValue || '-'
  88. },
  89. },
  90. {
  91. field: 'nic_type',
  92. width: 100,
  93. title: this.$t('compute.text_175'),
  94. },
  95. {
  96. field: 'ip_addr',
  97. title: 'IP',
  98. width: 160,
  99. formatter: ({ cellValue, row }) => {
  100. if (row.ip_addr) {
  101. return row.ip_addr + '/' + row.masklen
  102. } else {
  103. return '-'
  104. }
  105. },
  106. },
  107. {
  108. field: 'net',
  109. title: this.$t('compute.text_106'),
  110. },
  111. {
  112. field: 'wire',
  113. title: this.$t('compute.text_844'),
  114. },
  115. {
  116. field: 'rate',
  117. title: this.$t('compute.text_584'),
  118. },
  119. {
  120. field: 'link_up',
  121. title: this.$t('compute.netif_linkup_status'),
  122. },
  123. ],
  124. baseInfo: [
  125. getUserTagColumn({ onManager: this.onManager, resource: 'host', columns: () => this.columns, tipName: this.$t('compute.text_112') }),
  126. getExtTagColumn({ onManager: this.onManager, resource: 'host', columns: () => this.columns, tipName: this.$t('compute.text_112') }),
  127. getPublicScopeTableColumn({ vm: this, resource: 'hosts' }),
  128. getEnabledTableColumn(),
  129. getMaintenanceTableColumn(),
  130. {
  131. field: 'access_ip',
  132. title: 'IP',
  133. },
  134. getCopyWithContentTableColumn({
  135. field: 'server',
  136. title: this.$t('compute.text_602'),
  137. hideField: true,
  138. slotCallback: row => {
  139. if (!row.server) return '-'
  140. return [
  141. <a onClick={ () => this.$emit('tab-change', 'baremetal-list') }>{row.server}</a>,
  142. ]
  143. },
  144. }),
  145. getCopyWithContentTableColumn({ field: 'server', title: this.$t('compute.text_602') }),
  146. {
  147. field: 'access_mac',
  148. title: this.$t('compute.text_385'),
  149. formatter: ({ cellValue, row }) => {
  150. return cellValue || '-'
  151. },
  152. },
  153. {
  154. field: 'schedtags',
  155. title: this.$t('compute.text_311'),
  156. formatter: ({ cellValue, row }) => {
  157. if (row.schedtags && row.schedtags.length > 0) {
  158. const schedtags = row.schedtags.map(v => v.name)
  159. return schedtags.join(',')
  160. }
  161. return '-'
  162. },
  163. },
  164. {
  165. field: 'version',
  166. title: this.$t('compute.text_585'),
  167. },
  168. {
  169. field: 'kvm_module',
  170. title: this.$t('compute.text_586'),
  171. formatter: ({ cellData, row }) => {
  172. const kvmModuleMap = {
  173. 'kvm-intel': 'Intel',
  174. 'kvm-amd': 'AMD',
  175. unsupport: this.$t('compute.text_587'),
  176. }
  177. if (!row.sys_info) return '-'
  178. return kvmModuleMap[row.sys_info.kvm_module] || '-'
  179. },
  180. },
  181. {
  182. field: 'cdrom_boot',
  183. title: this.$t('compute.text_588'),
  184. formatter: ({ cellData, row }) => {
  185. let ret = '-'
  186. if (row.ipmi_info && row.ipmi_info.cdrom_boot === 'true') {
  187. ret = this.$t('compute.text_589')
  188. } else {
  189. ret = this.$t('compute.text_587')
  190. }
  191. return ret
  192. },
  193. },
  194. {
  195. field: 'isolated_device_count',
  196. title: this.$t('compute.passthrough_device_count'),
  197. slots: {
  198. default: ({ row }, h) => {
  199. return [
  200. <a onClick={ () => this.$emit('tab-change', 'gpu-list') }>{row.isolated_device_count || 0}</a>,
  201. ]
  202. },
  203. },
  204. },
  205. ],
  206. extraInfo: [
  207. {
  208. title: this.$t('compute.text_590'),
  209. items: [
  210. {
  211. field: 'manufacture',
  212. title: this.$t('compute.text_228'),
  213. formatter: ({ cellValue, row }) => {
  214. return ((row.sys_info || {}).manufacture) || '-'
  215. },
  216. },
  217. {
  218. field: 'model',
  219. title: this.$t('compute.text_580'),
  220. formatter: ({ cellValue, row }) => {
  221. return ((row.sys_info || {}).model) || '-'
  222. },
  223. },
  224. getCopyWithContentTableColumn({
  225. field: 'sn',
  226. title: this.$t('compute.text_591'),
  227. }),
  228. ],
  229. },
  230. {
  231. title: 'CPU',
  232. items: [
  233. {
  234. field: 'cpu_count',
  235. title: this.$t('compute.text_592'),
  236. formatter: ({ cellValue }) => {
  237. return cellValue + this.$t('compute.text_167')
  238. },
  239. },
  240. {
  241. field: 'node_count',
  242. title: this.$t('compute.text_593'),
  243. formatter: ({ cellValue }) => {
  244. return cellValue + this.$t('compute.text_200')
  245. },
  246. },
  247. {
  248. field: 'cpu_cmtbound',
  249. title: this.$t('compute.text_594'),
  250. },
  251. {
  252. field: 'cpu_commit_rate',
  253. title: this.$t('compute.text_859'),
  254. },
  255. {
  256. field: 'cpu_desc',
  257. title: this.$t('compute.text_596'),
  258. },
  259. ],
  260. },
  261. {
  262. title: this.$t('compute.text_369'),
  263. items: [
  264. {
  265. field: 'mem_size',
  266. title: this.$t('compute.text_397'),
  267. formatter: ({ cellValue, row }) => {
  268. return sizestr(cellValue, 'M', 1024)
  269. },
  270. },
  271. {
  272. field: 'mem_reserved',
  273. title: this.$t('compute.text_598'),
  274. formatter: ({ cellValue, row }) => {
  275. return sizestr(cellValue, 'M', 1024)
  276. },
  277. },
  278. {
  279. field: 'mem_cmtbound',
  280. title: this.$t('compute.text_594'),
  281. },
  282. {
  283. field: 'mem_commit_rate',
  284. title: this.$t('compute.text_859'),
  285. },
  286. ],
  287. },
  288. {
  289. title: this.$t('compute.text_99'),
  290. items: [
  291. {
  292. field: 'storage_size',
  293. title: this.$t('compute.text_397'),
  294. // formatter: ({ cellValue, row }) => {
  295. // return sizestr(cellValue, 'M', 1024)
  296. // },
  297. slots: {
  298. default: ({ row }, h) => {
  299. return [
  300. <p>{ this.$t('compute.text_1321', { num: sizestr(row.storage_size, 'M', 1024) }) }</p>,
  301. ]
  302. },
  303. },
  304. },
  305. {
  306. field: 'storage_type',
  307. title: this.$t('compute.text_175'),
  308. formatter: ({ cellValue, row }) => {
  309. return storageType[cellValue]
  310. },
  311. },
  312. {
  313. field: 'storage_commit_rate',
  314. title: this.$t('compute.text_859'),
  315. },
  316. {
  317. field: 'storage_waste',
  318. title: this.$t('compute.text_599'),
  319. formatter: ({ cellValue, row }) => {
  320. return sizestr(cellValue || 0, 'M', 1024)
  321. },
  322. },
  323. {
  324. title: '',
  325. field: 'storage_info',
  326. slots: {
  327. default: ({ row }, h) => {
  328. return [
  329. <vxe-grid class="mb-2" data={ row.storage_info } columns={ this.storageColumns } />,
  330. ]
  331. },
  332. },
  333. },
  334. ],
  335. },
  336. {
  337. title: this.$t('compute.text_600'),
  338. field: 'nic_info',
  339. slots: {
  340. default: ({ row }, h) => {
  341. if (!row || !row.nic_info) {
  342. return []
  343. }
  344. const nics = row.nic_info.filter(
  345. (o) => {
  346. return o.nic_type !== 'ipmi'
  347. },
  348. )
  349. return [
  350. <vxe-grid class="mb-2" data={ nics } columns={ this.hostColumns } />,
  351. ]
  352. },
  353. },
  354. },
  355. {
  356. title: 'BMC' + this.$t('compute.text_600'),
  357. field: 'nic_info',
  358. slots: {
  359. default: ({ row }, h) => {
  360. if (!row || !row.nic_info) {
  361. return []
  362. }
  363. const nics = row.nic_info.filter(
  364. (o) => {
  365. return o.nic_type === 'ipmi'
  366. },
  367. )
  368. return [
  369. <vxe-grid class="mb-2" data={ nics } columns={ this.hostColumns } />,
  370. ]
  371. },
  372. },
  373. },
  374. ],
  375. }
  376. },
  377. created () {
  378. this.updateDetailData()
  379. },
  380. methods: {
  381. updateDetailData () {
  382. const hostManager = new this.$Manager('hosts')
  383. hostManager.get({ id: this.hostInfo.id })
  384. .then((res) => {
  385. this.itemData = res.data
  386. })
  387. },
  388. },
  389. }
  390. </script>