v1.13.0
This commit is contained in:
38
pkg/cloudbroker/node/get_logical_cores_count.go
Normal file
38
pkg/cloudbroker/node/get_logical_cores_count.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package node
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// GetLogicalCoresCountRequest struct to get logical cores count by node
|
||||
type GetLogicalCoresCountRequest struct {
|
||||
// Node ID
|
||||
// Required: true
|
||||
NodeId uint64 `url:"node_id" json:"node_id" validate:"required"`
|
||||
}
|
||||
|
||||
// GetLogicalCoresCount get logical cores count by node
|
||||
func (i Node) GetLogicalCoresCount(ctx context.Context, req GetLogicalCoresCountRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/node/get_logical_cores_count"
|
||||
|
||||
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -53,9 +53,6 @@ type RecordNode struct {
|
||||
// SriovEnabled
|
||||
SriovEnabled bool `json:"sriovEnabled"`
|
||||
|
||||
// StackID
|
||||
StackID uint64 `json:"stackId"`
|
||||
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
@@ -76,6 +73,15 @@ type RecordNode struct {
|
||||
|
||||
// Zone ID
|
||||
ZoneID uint64 `json:"zoneId"`
|
||||
|
||||
// OpenvSwitch Bridges
|
||||
OpenvSwitchBridges []string `json:"openvswitch_bridges"`
|
||||
|
||||
// Description
|
||||
Description string `json:"description"`
|
||||
|
||||
// SDN Hypervisor Name
|
||||
SDNHypervisorName string `json:"sdn_hypervisor_name"`
|
||||
}
|
||||
|
||||
// Resource consumption of the node
|
||||
@@ -102,7 +108,7 @@ type FreeResourcesInfo struct {
|
||||
RAM float64 `json:"RAM"`
|
||||
|
||||
// VCPU
|
||||
VCPU uint64 `json:"vCPU"`
|
||||
VCPU uint64 `json:"vCPUs"`
|
||||
}
|
||||
|
||||
// Resources Info
|
||||
@@ -136,6 +142,12 @@ type CpuInfo struct {
|
||||
|
||||
// PhysCount
|
||||
PhysCount uint64 `json:"physCount"`
|
||||
|
||||
// Flags
|
||||
Flags []string `json:"flags"`
|
||||
|
||||
// Mddel name
|
||||
ModelName string `json:"model_name"`
|
||||
}
|
||||
|
||||
// Main information about node
|
||||
@@ -245,9 +257,6 @@ type ItemNode struct {
|
||||
// SriovEnabled
|
||||
SriovEnabled bool `json:"sriovEnabled"`
|
||||
|
||||
// StackID
|
||||
StackID uint64 `json:"stackId"`
|
||||
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
@@ -265,6 +274,34 @@ type ItemNode struct {
|
||||
|
||||
// Zone ID
|
||||
ZoneID uint64 `json:"zoneId"`
|
||||
|
||||
// OpenvSwitch Bridges
|
||||
OpenvSwitchBridges []string `json:"openvswitch_bridges"`
|
||||
|
||||
// APIUrl
|
||||
APIUrl string `json:"apiUrl"`
|
||||
|
||||
// Drivers
|
||||
Drivers []string `json:"drivers"`
|
||||
|
||||
// Old Compat LVM ID
|
||||
OldCompatLVMID uint64 `json:"old_compat_lvm_id"`
|
||||
|
||||
// CPU Allocation ratio
|
||||
CPUAllocationRatio float64 `json:"cpu_allocation_ratio"`
|
||||
|
||||
// MemAllocationRatio
|
||||
|
||||
MemAllocationRatio float64 `json:"mem_allocation_ratio"`
|
||||
// Packages
|
||||
Packages map[string]PackageInfo `json:"packages"`
|
||||
}
|
||||
|
||||
type PackageInfo struct {
|
||||
// Installed size
|
||||
InstalledSize string `json:"installed_size"`
|
||||
// Version
|
||||
Ver string `json:"ver"`
|
||||
}
|
||||
|
||||
// Numa Topology Info
|
||||
|
||||
36
pkg/cloudbroker/node/set_cpu_allocation_ratio.go
Normal file
36
pkg/cloudbroker/node/set_cpu_allocation_ratio.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package node
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// SetCpuAllocationRatioRequest struct to set CPU allocation ratio
|
||||
type SetCpuAllocationRatioRequest struct {
|
||||
// Node ID
|
||||
// Required: true
|
||||
NodeID uint64 `url:"node_id" json:"node_id" validate:"required"`
|
||||
|
||||
// Allocation ratio (zero or positive value)
|
||||
// Required: true
|
||||
Ratio float64 `url:"ratio" json:"ratio" validate:"required"`
|
||||
}
|
||||
|
||||
// SetCpuAllocationRatio set CPU allocation ratio
|
||||
func (i Node) SetCpuAllocationRatio(ctx context.Context, req SetCpuAllocationRatioRequest) error {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/node/set_cpu_allocation_ratio"
|
||||
|
||||
_, err = i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
36
pkg/cloudbroker/node/set_mem_allocation_ratio.go
Normal file
36
pkg/cloudbroker/node/set_mem_allocation_ratio.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package node
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// SetMemAllocationRatioRequest struct to set memory allocation ratio
|
||||
type SetMemAllocationRatioRequest struct {
|
||||
// Node ID
|
||||
// Required: true
|
||||
NodeID uint64 `url:"node_id" json:"node_id" validate:"required"`
|
||||
|
||||
// Allocation ratio (zero or positive value)
|
||||
// Required: true
|
||||
Ratio float64 `url:"ratio" json:"ratio" validate:"required"`
|
||||
}
|
||||
|
||||
// SetMemAllocationRatio set memory allocation ratio
|
||||
func (i Node) SetMemAllocationRatio(ctx context.Context, req SetMemAllocationRatioRequest) error {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/node/set_mem_allocation_ratio"
|
||||
|
||||
_, err = i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user