v15.0.0
This commit is contained in:
45
pkg/cloudbroker/node/pci_device_driver_to_kernel.go
Normal file
45
pkg/cloudbroker/node/pci_device_driver_to_kernel.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package node
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/constants"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators"
|
||||
)
|
||||
|
||||
// PCIDeviceDriverToKernelRequest struct to bind PCI device driver to kernel
|
||||
type PCIDeviceDriverToKernelRequest struct {
|
||||
// Node ID
|
||||
// Required: true
|
||||
NodeID uint64 `url:"nid" json:"nid" validate:"required"`
|
||||
|
||||
// Hardware path of the PCI device, e.g. 0000:81:00.0
|
||||
// Required: true
|
||||
HWPath string `url:"hw_path" json:"hw_path" validate:"required,pciDeviceHWPath"`
|
||||
}
|
||||
|
||||
// PCIDeviceDriverToKernel binds PCI device driver to kernel
|
||||
func (n Node) PCIDeviceDriverToKernel(ctx context.Context, req PCIDeviceDriverToKernelRequest) (*RecordPCIDeviceDriver, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/node/pci_device_driver_to_kernel"
|
||||
|
||||
res, err := n.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result := RecordPCIDeviceDriver{}
|
||||
|
||||
err = json.Unmarshal(res, &result)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &result, nil
|
||||
}
|
||||
Reference in New Issue
Block a user