forked from k8snetworkplumbingwg/sriov-network-operator
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'k8snetworkplumbingwg:master' into network-operator-99.9.x
- Loading branch information
Showing
15 changed files
with
306 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package cpu | ||
|
||
import ( | ||
"fmt" | ||
|
||
ghwPkg "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host/internal/lib/ghw" | ||
"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host/types" | ||
) | ||
|
||
type cpuInfoProvider struct { | ||
ghwLib ghwPkg.GHWLib | ||
} | ||
|
||
func New(ghwLib ghwPkg.GHWLib) *cpuInfoProvider { | ||
return &cpuInfoProvider{ | ||
ghwLib: ghwLib, | ||
} | ||
} | ||
|
||
func (c *cpuInfoProvider) GetCPUVendor() (types.CPUVendor, error) { | ||
cpuInfo, err := c.ghwLib.CPU() | ||
if err != nil { | ||
return -1, fmt.Errorf("can't retrieve the CPU vendor: %w", err) | ||
} | ||
|
||
if len(cpuInfo.Processors) == 0 { | ||
return -1, fmt.Errorf("wrong CPU information retrieved: %v", cpuInfo) | ||
} | ||
|
||
switch cpuInfo.Processors[0].Vendor { | ||
case "GenuineIntel": | ||
return types.CPUVendorIntel, nil | ||
case "AuthenticAMD": | ||
return types.CPUVendorAMD, nil | ||
case "ARM": | ||
return types.CPUVendorARM, nil | ||
} | ||
|
||
return -1, fmt.Errorf("unknown CPU vendor: %s", cpuInfo.Processors[0].Vendor) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.