This commit is contained in:
2026-06-05 17:30:36 +03:00
parent 3e2edf53a5
commit f1112e5a11
1246 changed files with 6117 additions and 1589 deletions

View File

@@ -0,0 +1,50 @@
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"
)
// PCIDeviceDriverToVFIORequest struct to bind PCI device driver to VFIO
type PCIDeviceDriverToVFIORequest 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"`
// Driver binding mode
// Required: true
// Possible values: safe, unsafe
Mode string `url:"mode" json:"mode" validate:"required,oneof=safe unsafe"`
}
// PCIDeviceDriverToVFIO binds PCI device driver to VFIO
func (n Node) PCIDeviceDriverToVFIO(ctx context.Context, req PCIDeviceDriverToVFIORequest) (*RecordPCIDeviceDriver, error) {
err := validators.ValidateRequest(req)
if err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/node/pci_device_driver_to_vfio"
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
}