diff --git a/src/fireedge/src/client/components/Cards/VirtualMachineCard.js b/src/fireedge/src/client/components/Cards/VirtualMachineCard.js index e979e86ea9..60e32f4a05 100644 --- a/src/fireedge/src/client/components/Cards/VirtualMachineCard.js +++ b/src/fireedge/src/client/components/Cards/VirtualMachineCard.js @@ -24,6 +24,7 @@ import { Lock, Network, User, + Internet as HostnameIcon, WarningCircledOutline as WarningIcon, } from 'iconoir-react' @@ -80,7 +81,7 @@ const VirtualMachineCard = memo( USER_TEMPLATE: { LABELS } = {}, GNAME, UNAME, - TEMPLATE: { VCPU = '-', MEMORY } = {}, + TEMPLATE: { VCPU = '-', MEMORY, CONTEXT = {} } = {}, } = vm const { HOSTNAME = '--', VM_MAD: hypervisor } = useMemo( @@ -88,6 +89,8 @@ const VirtualMachineCard = memo( [vm.HISTORY_RECORDS] ) + const { SET_HOSTNAME: VM_HOSTNAME = '' } = CONTEXT + const [time, timeFormat] = useMemo(() => { const fromMill = timeFromMilliseconds(+ETIME || +STIME) @@ -190,10 +193,16 @@ const VirtualMachineCard = memo( {memValue} - + {HOSTNAME} + {!!VM_HOSTNAME && ( + + + {` ${VM_HOSTNAME}`} + + )} {!!UNAME && ( diff --git a/src/fireedge/src/client/components/Tables/Vms/columns.js b/src/fireedge/src/client/components/Tables/Vms/columns.js index 79952e2cfb..3ce13aa301 100644 --- a/src/fireedge/src/client/components/Tables/Vms/columns.js +++ b/src/fireedge/src/client/components/Tables/Vms/columns.js @@ -21,6 +21,7 @@ import { getLastHistory, getState, getType, + getVmHostname, } from 'client/models/VirtualMachine' /** @type {Column[]} VM columns */ @@ -55,6 +56,11 @@ const COLUMNS = [ }, { Header: T.Hostname, + id: 'vmhostname', + accessor: (row) => getVmHostname(row)?.pop() ?? '', + }, + { + Header: T.Host, id: 'hostname', accessor: (row) => getLastHistory(row)?.HOSTNAME, }, diff --git a/src/fireedge/src/client/components/Tables/Vms/index.js b/src/fireedge/src/client/components/Tables/Vms/index.js index 7996574e23..ce9a14e837 100644 --- a/src/fireedge/src/client/components/Tables/Vms/index.js +++ b/src/fireedge/src/client/components/Tables/Vms/index.js @@ -35,7 +35,13 @@ import { useGeneral } from 'client/features/General' import { useGetVmsQuery } from 'client/features/OneApi/vm' import { getColorFromString, getUniqueLabels } from 'client/models/Helper' -import { getIps, getLastHistory, getState } from 'client/models/VirtualMachine' +import { + getIps, + getLastHistory, + getState, + getVmHostname, +} from 'client/models/VirtualMachine' + const DEFAULT_DATA_CY = 'vms' const { VNC, RDP, SSH, VMRC } = VM_ACTIONS @@ -163,6 +169,11 @@ const VmsTable = (props) => { }, { header: T.Hostname, + id: 'vmhostname', + accessor: (vm) => getVmHostname(vm), + }, + { + header: T.Host, id: 'hostname', accessor: (vm) => getLastHistory(vm)?.HOSTNAME, }, diff --git a/src/fireedge/src/client/models/VirtualMachine.js b/src/fireedge/src/client/models/VirtualMachine.js index 4c9cec2a4d..febd9bc38e 100644 --- a/src/fireedge/src/client/models/VirtualMachine.js +++ b/src/fireedge/src/client/models/VirtualMachine.js @@ -60,6 +60,19 @@ export const getHistoryAction = (action) => HISTORY_ACTIONS[+action] export const getHistoryRecords = (vm) => [vm?.HISTORY_RECORDS?.HISTORY ?? []].flat() +/** + * @param {VM} vm - Virtual machine + * @returns {object} Context vars from resource + */ +export const getContext = (vm) => [vm?.TEMPLATE?.CONTEXT ?? []].flat() + +/** + * @param {VM} vm - Virtual machine + * @returns {string} VM hostname from resource + */ +export const getVmHostname = (vm) => + [getContext(vm)?.pop()?.SET_HOSTNAME ?? []].flat() + /** * @param {VM} vm - Virtual machine * @returns {HistoryRecord} Last history record from resource