@ -5,7 +5,7 @@
< / template >
< / template >
< / l i s t - h e a d e r >
< / l i s t - h e a d e r >
< preview -bar : handle -click = handleClick / >
< preview -bar : handle -click = handleClick :key ="componentKey" / >
< table -plus :api ="nodeApi.getNodeList()" :columns ="columns" :rowAction ="rowAction" :searchSchema ="searchSchema"
< table -plus :api ="nodeApi.getNodeList()" :columns ="columns" :rowAction ="rowAction" :searchSchema ="searchSchema"
: hasPagination = "false" style = "height: auto" hideTag ref = "table" staticPage >
: hasPagination = "false" style = "height: auto" hideTag ref = "table" staticPage >
@ -36,16 +36,19 @@
< script setup lang = "jsx" >
< script setup lang = "jsx" >
import nodeApi from '~/vgpu/api/node' ;
import nodeApi from '~/vgpu/api/node' ;
import searchSchema from '~/vgpu/views/node/admin/searchSchema' ;
import searchSchema from '~/vgpu/views/node/admin/searchSchema' ;
import { useRouter } from 'vue-router' ;
import PreviewBar from '~/vgpu/components/previewBar.vue' ;
import PreviewBar from '~/vgpu/components/previewBar.vue' ;
import { roundToDecimal } from '@/utils' ;
import { bytesToGB, roundToDecimal } from '@/utils' ;
import { ElMessage , ElMessageBox } from 'element-plus' ;
import { ElMessage , ElMessageBox } from 'element-plus' ;
import { ref } from 'vue' ;
import { ref } from 'vue' ;
import useParentAction from '~/vgpu/hooks/useParentAction' ;
const router = useRouter ( ) ;
const { sendRouteChange } = useParentAction ( ) ;
const table = ref ( ) ;
const table = ref ( ) ;
const componentKey = ref ( 0 ) ;
/ / 节 点 选 择 相 关
/ / 节 点 选 择 相 关
const dialogVisible = ref ( false )
const dialogVisible = ref ( false )
const nodeList = ref ( [ ] )
const nodeList = ref ( [ ] )
@ -61,7 +64,7 @@ const handleClick = async (params) => {
const node = list . find ( node => node . name === name ) ;
const node = list . find ( node => node . name === name ) ;
if ( node ) {
if ( node ) {
const uuid = node . uid ;
const uuid = node . uid ;
router. push ( ` /admin/vgpu/node/admin/ ${ uuid } ?nodeName= ${ name } ` ) ;
sendRouteChange ( ` /admin/vgpu/node/admin/ ${ uuid } ?nodeName= ${ name } ` ) ;
} else {
} else {
ElMessage . error ( '节点未找到' ) ;
ElMessage . error ( '节点未找到' ) ;
}
}
@ -83,7 +86,8 @@ const handleOk = async () => {
node _names
node _names
} )
} )
if ( res ? . code === 200 ) {
if ( res ? . code === 200 ) {
getList ( ) ;
table . value . fetchData ( ) ;
componentKey . value += 1 ;
dialogVisible . value = false ;
dialogVisible . value = false ;
}
}
} finally {
} finally {
@ -152,6 +156,26 @@ const columns = [
/ / r e t u r n r . m a p ( ( i t e m ) = > ( { t e x t : i t e m , v a l u e : i t e m } ) ) ;
/ / r e t u r n r . m a p ( ( i t e m ) = > ( { t e x t : i t e m , v a l u e : i t e m } ) ) ;
/ / } ,
/ / } ,
} ,
} ,
{
title : 'CPU' ,
dataIndex : 'coreTotal' ,
render : ( { coreTotal } ) => ` ${ coreTotal } 核 ` ,
} ,
{
title : '内存' ,
dataIndex : 'memoryTotal' ,
render : ( { memoryTotal } ) => ` ${ bytesToGB ( memoryTotal ) } GiB ` ,
} ,
{
title : '磁盘' ,
dataIndex : 'diskSize' ,
render : ( { diskSize } ) => ` ${ bytesToGB ( diskSize ) } GiB ` ,
} ,
{
title : '所属资源池' ,
dataIndex : 'resourcePools' ,
render : ( { resourcePools } ) => ` ${ resourcePools . join ( '、' ) } ` ,
} ,
{
{
title : '显卡数量' ,
title : '显卡数量' ,
dataIndex : 'cardCnt' ,
dataIndex : 'cardCnt' ,
@ -167,6 +191,7 @@ const columns = [
} ,
} ,
{
{
title : '算力(已分配/总量)' ,
title : '算力(已分配/总量)' ,
width : 120 ,
dataIndex : 'used' ,
dataIndex : 'used' ,
render : ( { coreTotal , coreUsed , isExternal } ) => (
render : ( { coreTotal , coreUsed , isExternal } ) => (
< span >
< span >
@ -177,6 +202,7 @@ const columns = [
{
{
title : '显存(已分配/总量)' ,
title : '显存(已分配/总量)' ,
dataIndex : 'w' ,
dataIndex : 'w' ,
width : 120 ,
render : ( { memoryTotal , memoryUsed , isExternal } ) => (
render : ( { memoryTotal , memoryUsed , isExternal } ) => (
< span >
< span >
{ isExternal ? '--' : roundToDecimal ( memoryUsed / 1024 , 1 ) } /
{ isExternal ? '--' : roundToDecimal ( memoryUsed / 1024 , 1 ) } /
@ -190,72 +216,72 @@ const rowAction = [
{
{
title : '查看详情' ,
title : '查看详情' ,
onClick : ( row ) => {
onClick : ( row ) => {
router . push ( ` /admin/vgpu/node/admin/ ${ row . uid } ?nodeName= ${ row . name } ` ) ;
sendRouteChange ( ` /admin/vgpu/node/admin/ ${ row . uid } ?nodeName= ${ row . name } ` ) ;
} ,
} ,
{
title : '禁用' ,
hidden : ( row ) => ! row . isSchedulable ,
onClick : async ( row ) => {
ElMessageBox . confirm ( ` 确认对该节点进行禁用操作? ` , '操作确认' , {
confirmButtonText : '确定' ,
cancelButtonText : '取消' ,
type : 'warning' ,
} )
. then ( async ( ) => {
try {
await nodeApi . stop (
{
nodeName : row . name ,
status : 'DISABLED'
}
) . then (
( ) => {
setTimeout ( ( ) => {
ElMessage . success ( '节点禁用成功' ) ;
table . value . fetchData ( ) ;
} , 500 ) ;
}
)
} catch ( error ) {
ElMessage . error ( error . message ) ;
}
} )
. catch ( ( ) => { } ) ;
} ,
} ,
{
title : '开启' ,
hidden : ( row ) => row . isSchedulable ,
disabled : ( row ) => row . isExternal ,
onClick : async ( row ) => {
ElMessageBox . confirm ( ` 确认对该节点进行开启调度操作? ` , '操作确认' , {
confirmButtonText : '确定' ,
cancelButtonText : '取消' ,
type : 'warning' ,
} )
. then ( async ( ) => {
try {
await nodeApi . stop (
{
nodeName : row . name ,
status : 'ENABLE'
}
) . then (
( ) => {
setTimeout ( ( ) => {
ElMessage . success ( '节点开启调度成功' ) ;
table . value . fetchData ( ) ;
} , 500 ) ;
}
)
} catch ( error ) {
ElMessage . error ( error . message ) ;
}
} )
. catch ( ( ) => { } ) ;
} ,
} ,
} ,
} ,
/ / {
/ / t i t l e : ' 禁 用 ' ,
/ / h i d d e n : ( r o w ) = > ! r o w . i s S c h e d u l a b l e ,
/ / o n C l i c k : a s y n c ( r o w ) = > {
/ / E l M e s s a g e B o x . c o n f i r m ( ` 确 认 对 该 节 点 进 行 禁 用 操 作 ? ` , ' 操 作 确 认 ' , {
/ / c o n f i r m B u t t o n T e x t : ' 确 定 ' ,
/ / c a n c e l B u t t o n T e x t : ' 取 消 ' ,
/ / t y p e : ' w a r n i n g ' ,
/ / } )
/ / . t h e n ( a s y n c ( ) = > {
/ / t r y {
/ / a w a i t n o d e A p i . s t o p (
/ / {
/ / n o d e N a m e : r o w . n a m e ,
/ / s w i t c h : ' o n '
/ / }
/ / ) . t h e n (
/ / ( ) = > {
/ / s e t T i m e o u t ( ( ) = > {
/ / E l M e s s a g e . s u c c e s s ( ' 节 点 禁 用 成 功 ' ) ;
/ / t a b l e . v a l u e . f e t c h D a t a ( ) ;
/ / } , 5 0 0 ) ;
/ / }
/ / )
/ / } c a t c h ( e r r o r ) {
/ / E l M e s s a g e . e r r o r ( e r r o r . m e s s a g e ) ;
/ / }
/ / } )
/ / . c a t c h ( ( ) = > { } ) ;
/ / } ,
/ / } ,
/ / {
/ / t i t l e : ' 开 启 ' ,
/ / h i d d e n : ( r o w ) = > r o w . i s S c h e d u l a b l e ,
/ / d i s a b l e d : ( r o w ) = > r o w . i s E x t e r n a l ,
/ / o n C l i c k : a s y n c ( r o w ) = > {
/ / E l M e s s a g e B o x . c o n f i r m ( ` 确 认 对 该 节 点 进 行 开 启 调 度 操 作 ? ` , ' 操 作 确 认 ' , {
/ / c o n f i r m B u t t o n T e x t : ' 确 定 ' ,
/ / c a n c e l B u t t o n T e x t : ' 取 消 ' ,
/ / t y p e : ' w a r n i n g ' ,
/ / } )
/ / . t h e n ( a s y n c ( ) = > {
/ / t r y {
/ / a w a i t n o d e A p i . s t o p (
/ / {
/ / n o d e N a m e : r o w . n a m e ,
/ / s w i t c h : ' o f f '
/ / }
/ / ) . t h e n (
/ / ( ) = > {
/ / s e t T i m e o u t ( ( ) = > {
/ / E l M e s s a g e . s u c c e s s ( ' 节 点 开 启 调 度 成 功 ' ) ;
/ / t a b l e . v a l u e . f e t c h D a t a ( ) ;
/ / } , 5 0 0 ) ;
/ / }
/ / )
/ / } c a t c h ( e r r o r ) {
/ / E l M e s s a g e . e r r o r ( e r r o r . m e s s a g e ) ;
/ / }
/ / } )
/ / . c a t c h ( ( ) = > { } ) ;
/ / } ,
/ / } ,
] ;
] ;
< / script >
< / script >