parent
72ee08414a
commit
05438d39f4
3 changed files with 53 additions and 1 deletions
@ -1,5 +1,11 @@ |
|||||||
import toAnvilMemoryCalcable from './toAnvilMemoryCalcable'; |
import toAnvilMemoryCalcable from './toAnvilMemoryCalcable'; |
||||||
import toAnvilOverviewHostList from './toAnvilOverviewHostList'; |
import toAnvilOverviewHostList from './toAnvilOverviewHostList'; |
||||||
import toAnvilOverviewList from './toAnvilOverviewList'; |
import toAnvilOverviewList from './toAnvilOverviewList'; |
||||||
|
import toAnvilSharedStorageOverview from './toAnvilSharedStorageOverview'; |
||||||
|
|
||||||
export { toAnvilMemoryCalcable, toAnvilOverviewHostList, toAnvilOverviewList }; |
export { |
||||||
|
toAnvilMemoryCalcable, |
||||||
|
toAnvilOverviewHostList, |
||||||
|
toAnvilOverviewList, |
||||||
|
toAnvilSharedStorageOverview, |
||||||
|
}; |
||||||
|
@ -0,0 +1,29 @@ |
|||||||
|
const toAnvilSharedStorageOverview = ( |
||||||
|
data: AnvilSharedStorage, |
||||||
|
): APIAnvilSharedStorageOverview => { |
||||||
|
const { storage_groups, total_free, total_size } = data; |
||||||
|
|
||||||
|
const totalFree = BigInt(total_free); |
||||||
|
const totalSize = BigInt(total_size); |
||||||
|
|
||||||
|
return storage_groups.reduce<APIAnvilSharedStorageOverview>( |
||||||
|
(previous, current) => { |
||||||
|
const { |
||||||
|
storage_group_free: rFree, |
||||||
|
storage_group_name: name, |
||||||
|
storage_group_total: rSize, |
||||||
|
storage_group_uuid: uuid, |
||||||
|
} = current; |
||||||
|
|
||||||
|
const free = BigInt(rFree); |
||||||
|
const size = BigInt(rSize); |
||||||
|
|
||||||
|
previous.storageGroups[uuid] = { free, name, size, uuid }; |
||||||
|
|
||||||
|
return previous; |
||||||
|
}, |
||||||
|
{ storageGroups: {}, totalFree, totalSize }, |
||||||
|
); |
||||||
|
}; |
||||||
|
|
||||||
|
export default toAnvilSharedStorageOverview; |
Loading…
Reference in new issue