46 lines
1.2 KiB
Go
46 lines
1.2 KiB
Go
|
|
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
|
||
|
|
}
|