Files
decort-golang-sdk/pkg/cloudbroker/node/set_vfs_number.go

52 lines
1.2 KiB
Go
Raw Normal View History

2024-04-16 14:26:06 +03:00
package node
import (
"context"
"net/http"
2025-04-09 11:21:07 +03:00
"strconv"
2024-04-16 14:26:06 +03:00
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// SetVFsNumberRequest struct to set number of VFs for individual NIC on node
type SetVFsNumberRequest struct {
// Node ID
// Required: true
NID uint64 `url:"nid" json:"nid" validate:"required"`
// PCI address or NIC name
// Required: true
2025-04-09 11:21:07 +03:00
NICID string `url:"nicId" json:"nicId" validate:"required"`
2024-04-16 14:26:06 +03:00
// Number of VF to assign
// Required: true
VFNum uint64 `url:"vfNum" json:"vfNum" validate:"required"`
2025-04-09 11:21:07 +03:00
// Number of VF to assign
2024-12-27 11:35:22 +03:00
// Required: true
2025-04-09 11:21:07 +03:00
VFParams []VFParam `url:"vfParams" json:"vfParams" validate:"required"`
2024-04-16 14:26:06 +03:00
}
// SetVFsNumber sets number of VFs for individual NIC on node
2025-04-09 11:21:07 +03:00
func (n Node) SetVFsNumber(ctx context.Context, req SetVFsNumberRequest) (bool, error) {
2024-04-16 14:26:06 +03:00
err := validators.ValidateRequest(req)
if err != nil {
2025-04-09 11:21:07 +03:00
return false, validators.ValidationErrors(validators.GetErrors(err))
2024-04-16 14:26:06 +03:00
}
url := "/cloudbroker/node/setVFsNumber"
res, err := n.client.DecortApiCall(ctx, http.MethodPost, url, req)
2025-04-09 11:21:07 +03:00
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
2024-04-16 14:26:06 +03:00
if err != nil {
2025-04-09 11:21:07 +03:00
return false, err
2024-04-16 14:26:06 +03:00
}
2025-04-09 11:21:07 +03:00
return result, nil
2024-04-16 14:26:06 +03:00
}