1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-04 05:17:40 +03:00

Fix vmpool (#3181)

* M #~: makes Vmpool configurable (extended/normal)

* M #~: fix dashboard vmpool request

* M #~: increase of the request time to 2min

* L #~: lint-fix
This commit is contained in:
Jorge Miguel Lobo Escalona 2024-07-31 13:33:05 +02:00 committed by GitHub
parent d1d8d9d0c8
commit e45aedb203
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 65 additions and 50 deletions

View File

@ -51,7 +51,7 @@ truncate_max_length: 150
# will wait for a response from the server before considering the request as timed out.
# If the server does not respond within this timeframe, the request will be aborted,
# and the connection will be closed.
api_timeout: 45_000
api_timeout: 120_000
# Guacamole daemon
guacd:

View File

@ -62,6 +62,11 @@ supported_fs:
- ext2
- xfs
# Use the extended VM pool
# By default this value is true
# https://docs.opennebula.io/6.8/integration_and_development/system_interfaces/api.html#one-vmpool-infoextended
#use_extended_vmpool: true
# Currency formatting
# Possible values are the ISO 4217 currency codes
# https://www.six-group.com/en/products-services/financial-information/data-standards.html

View File

@ -21,7 +21,12 @@ import { useGetVmsQuery } from 'client/features/OneApi/vm'
import EnhancedTable, { createColumns } from 'client/components/Tables/Enhanced'
import VmColumns from 'client/components/Tables/Vms/columns'
import VmRow from 'client/components/Tables/Vms/row'
import { RESOURCE_NAMES, STATES, VM_STATES } from 'client/constants'
import {
RESOURCE_NAMES,
STATES,
VM_EXTENDED_POOL,
VM_STATES,
} from 'client/constants'
const DEFAULT_DATA_CY = 'vms'
@ -51,57 +56,61 @@ const VmsTable = (props) => {
const { view, getResourceView } = useViews()
const { data, refetch, isFetching } = useGetVmsQuery(undefined, {
selectFromResult: (result) => ({
...result,
data:
result?.data
?.filter((vm) => {
// this filters data for host
if (host?.ID) {
if (
host?.ERROR_VMS?.ID ||
host?.UPDATED_VMS?.ID ||
host?.UPDATING_VMS?.ID
) {
return [
host?.ERROR_VMS.ID ?? [],
host?.UPDATED_VMS.ID ?? [],
host?.UPDATING_VMS.ID ?? [],
]
.flat()
.includes(vm.ID)
const { data, refetch, isFetching } = useGetVmsQuery(
{ extended: VM_EXTENDED_POOL },
{
selectFromResult: (result) => ({
...result,
data:
result?.data
?.filter((vm) => {
// this filters data for host
if (host?.ID) {
if (
host?.ERROR_VMS?.ID ||
host?.UPDATED_VMS?.ID ||
host?.UPDATING_VMS?.ID
) {
return [
host?.ERROR_VMS.ID ?? [],
host?.UPDATED_VMS.ID ?? [],
host?.UPDATING_VMS.ID ?? [],
]
.flat()
.includes(vm.ID)
}
return [host?.VMS?.ID ?? []].flat().includes(vm.ID)
}
return [host?.VMS?.ID ?? []].flat().includes(vm.ID)
}
// this filters data for backupjobs
if (backupjobs?.ID) {
if (backupjobsState) {
return [backupjobs?.[backupjobsState]?.ID ?? []]
.flat()
.includes(vm.ID)
} else {
return [
(backupjobs?.TEMPLATE?.BACKUP_VMS &&
backupjobs?.TEMPLATE?.BACKUP_VMS.split(',')) ??
[],
]
.flat()
.includes(vm.ID)
// this filters data for backupjobs
if (backupjobs?.ID) {
if (backupjobsState) {
return [backupjobs?.[backupjobsState]?.ID ?? []]
.flat()
.includes(vm.ID)
} else {
return [
(backupjobs?.TEMPLATE?.BACKUP_VMS &&
backupjobs?.TEMPLATE?.BACKUP_VMS.split(',')) ??
[],
]
.flat()
.includes(vm.ID)
}
}
}
// This is for return data without filters
return true
})
?.filter(({ ID }) =>
filterData?.length ? filterData?.includes(ID) : filterLoose
)
?.filter(({ STATE }) => VM_STATES[STATE]?.name !== STATES.DONE) ?? [],
}),
})
// This is for return data without filters
return true
})
?.filter(({ ID }) =>
filterData?.length ? filterData?.includes(ID) : filterLoose
)
?.filter(({ STATE }) => VM_STATES[STATE]?.name !== STATES.DONE) ??
[],
}),
}
)
const columns = useMemo(
() =>

View File

@ -86,6 +86,7 @@ export const DEFAULT_SCHEME = Setting.SCHEMES.SYSTEM
export const CURRENCY = SERVER_CONFIG?.currency ?? 'EUR'
export const DEFAULT_LANGUAGE = SERVER_CONFIG?.default_lang ?? 'en'
export const LANGUAGES_URL = `${STATIC_FILES_URL}/languages`
export const VM_EXTENDED_POOL = !!(SERVER_CONFIG?.use_extended_vmpool ?? true)
export const LANGUAGES = SERVER_CONFIG.langs ?? {
bg_BG: 'Bulgarian (Bulgaria)',
bg: 'Bulgarian',

View File

@ -65,7 +65,7 @@ function SunstoneDashboard() {
spacing={3}
>
<ResourceWidget
query={useGetVmsQuery}
query={() => useGetVmsQuery({ extended: false })}
bgColor="#fa7892"
text={T.VMs}
icon={VmsIcons}