Skip to content

Commit

Permalink
Fix vmpool (#3181)
Browse files Browse the repository at this point in the history
* M #~: makes Vmpool configurable (extended/normal)

* M #~: fix dashboard vmpool request

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

* L #~: lint-fix
  • Loading branch information
jloboescalona2 authored Jul 31, 2024
1 parent d1d8d9d commit e45aedb
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 50 deletions.
2 changes: 1 addition & 1 deletion src/fireedge/etc/fireedge-server.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions src/fireedge/etc/sunstone/sunstone-server.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
105 changes: 57 additions & 48 deletions src/fireedge/src/client/components/Tables/Vms/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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(
() =>
Expand Down
1 change: 1 addition & 0 deletions src/fireedge/src/client/constants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function SunstoneDashboard() {
spacing={3}
>
<ResourceWidget
query={useGetVmsQuery}
query={() => useGetVmsQuery({ extended: false })}
bgColor="#fa7892"
text={T.VMs}
icon={VmsIcons}
Expand Down

0 comments on commit e45aedb

Please sign in to comment.