Files
cloudpods/pkg/hostman/container/device/interface.go
T
Zexi Liandwanyaoqi 6313ce87a3 Support pod container (#19706)
* 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>
2024-03-12 18:47:44 +08:00

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)
}