From 338904e6edc1fa512e1d303bea56964f5b2b01c4 Mon Sep 17 00:00:00 2001 From: "Maciej \"Iwan\" Iwanowski" Date: Thu, 12 Mar 2020 09:17:21 +0100 Subject: [PATCH] Using a struct to store all NVM-related information Signed-off-by: Maciej "Iwan" Iwanowski --- info/v1/machine.go | 8 ++++++-- machine/info.go | 34 +++++++++++++++++----------------- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/info/v1/machine.go b/info/v1/machine.go index 364afb01..0b7c3f16 100644 --- a/info/v1/machine.go +++ b/info/v1/machine.go @@ -176,8 +176,7 @@ type MachineInfo struct { // Memory capacity and number of DIMMs by memory type MemoryByType map[string]*MemoryInfo `json:"memory_by_type"` - // Average power budget for NVM devices configured in BIOS. - NVMAvgPowerBudget uint `json:"nvm_avg_power_budget"` + NVMInfo NVMInfo `json:"nvm_info"` // HugePages on this machine. HugePages []HugePagesInfo `json:"hugepages"` @@ -222,6 +221,11 @@ type MemoryInfo struct { DimmCount uint `json:"dimm_count"` } +type NVMInfo struct { + // Average power budget for NVM devices configured in BIOS. + AvgPowerBudget uint `json:"avg_power_budget"` +} + type VersionInfo struct { // Kernel version. KernelVersion string `json:"kernel_version"` diff --git a/machine/info.go b/machine/info.go index fa87283a..c7c229aa 100644 --- a/machine/info.go +++ b/machine/info.go @@ -119,23 +119,23 @@ func Info(sysFs sysfs.SysFs, fsInfo fs.FsInfo, inHostNamespace bool) (*info.Mach instanceID := realCloudInfo.GetInstanceID() machineInfo := &info.MachineInfo{ - NumCores: numCores, - NumPhysicalCores: GetPhysicalCores(cpuinfo), - NumSockets: GetSockets(cpuinfo), - CpuFrequency: clockSpeed, - MemoryCapacity: memoryCapacity, - MemoryByType: memoryByType, - NVMAvgPowerBudget: nvmPowerBudget, - HugePages: hugePagesInfo, - DiskMap: diskMap, - NetworkDevices: netDevices, - Topology: topology, - MachineID: getInfoFromFiles(filepath.Join(rootFs, *machineIdFilePath)), - SystemUUID: systemUUID, - BootID: getInfoFromFiles(filepath.Join(rootFs, *bootIdFilePath)), - CloudProvider: cloudProvider, - InstanceType: instanceType, - InstanceID: instanceID, + NumCores: numCores, + NumPhysicalCores: GetPhysicalCores(cpuinfo), + NumSockets: GetSockets(cpuinfo), + CpuFrequency: clockSpeed, + MemoryCapacity: memoryCapacity, + MemoryByType: memoryByType, + NVMInfo: info.NVMInfo{AvgPowerBudget: nvmPowerBudget}, + HugePages: hugePagesInfo, + DiskMap: diskMap, + NetworkDevices: netDevices, + Topology: topology, + MachineID: getInfoFromFiles(filepath.Join(rootFs, *machineIdFilePath)), + SystemUUID: systemUUID, + BootID: getInfoFromFiles(filepath.Join(rootFs, *bootIdFilePath)), + CloudProvider: cloudProvider, + InstanceType: instanceType, + InstanceID: instanceID, } for i := range filesystems {