mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-11-02 04:02:18 +08:00
* feat(region,scheduler,host): support pod and container * feat(region,host): container nvidia gpu support * fix(region,host): function parameters --------- Co-authored-by: wanyaoqi <d3lx.yq@gmail.com>
32 lines
664 B
Go
32 lines
664 B
Go
package device
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1"
|
|
|
|
"yunion.io/x/onecloud/pkg/apis"
|
|
hostapi "yunion.io/x/onecloud/pkg/apis/host"
|
|
)
|
|
|
|
var (
|
|
drivers = make(map[apis.ContainerDeviceType]IDeviceDriver)
|
|
)
|
|
|
|
func RegisterDriver(drv IDeviceDriver) {
|
|
drivers[drv.GetType()] = drv
|
|
}
|
|
|
|
func GetDriver(typ apis.ContainerDeviceType) IDeviceDriver {
|
|
drv, ok := drivers[typ]
|
|
if !ok {
|
|
panic(fmt.Sprintf("not found driver by type %s", typ))
|
|
}
|
|
return drv
|
|
}
|
|
|
|
type IDeviceDriver interface {
|
|
GetType() apis.ContainerDeviceType
|
|
GetRuntimeDevices(input *hostapi.ContainerCreateInput, dev *hostapi.ContainerDevice) ([]*runtimeapi.Device, error)
|
|
}
|