infra

package
v0.11.23 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2025 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Overview

Package mci is to manage multi-cloud infra

Package mci is to manage multi-cloud infra

Package mci is to manage multi-cloud infra

Package mci is to manage multi-cloud infra

Package mci is to manage multi-cloud infra

Package mci is to manage multi-cloud infra

Package mci is to manage multi-cloud infra

Package mci is to manage multi-cloud infra

Package mci is to manage multi-cloud infra

Package infra is to manage multi-cloud infra

Package mci is to manage multi-cloud infra

Package mci is to manage multi-cloud infra

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddCommandStatusInfo added in v0.11.10

func AddCommandStatusInfo(nsId, mciId, vmId, xRequestId, commandRequested, commandExecuted string) (int, error)

AddCommandStatusInfo adds a new command status record to VM's command history

func AddNLBVMs

func AddNLBVMs(nsId string, mciId string, resourceId string, u *model.NLBAddRemoveVMReq) (model.NLBInfo, error)

AddNLBVMs accepts VM addition request, adds VM to NLB, and returns an updated TB NLB object

func AnalyzeProvisioningRisk added in v0.11.3

func AnalyzeProvisioningRisk(specId string, cspImageName string) (riskLevel string, riskMessage string, err error)

AnalyzeProvisioningRisk analyzes the risk of provisioning failure based on historical data

func AnalyzeProvisioningRiskDetailed added in v0.11.3

func AnalyzeProvisioningRiskDetailed(specId string, cspImageName string) (*model.RiskAnalysis, error)

AnalyzeProvisioningRiskDetailed provides comprehensive risk analysis with separate spec and image risk assessment

func AttachDetachDataDisk

func AttachDetachDataDisk(nsId string, mciId string, vmId string, command string, dataDiskId string, force bool) (model.VmInfo, error)

AttachDetachDataDisk is func to attach/detach DataDisk to/from VM

func BenchmarkAction

func BenchmarkAction(nsId string, mciId string, action string, option string) (model.BenchmarkInfoArray, error)

BenchmarkAction is func to action Benchmark

func BuildAgnosticImage added in v0.11.14

func BuildAgnosticImage(nsId string, req model.BuildAgnosticImageReq) (model.BuildAgnosticImageResult, error)

BuildAgnosticImage creates an MCI, executes post commands, creates snapshots, and optionally cleans up This is a complete workflow for building agnostic (CSP-independent) custom images

func BuildLatencyOrderByClause added in v0.11.9

func BuildLatencyOrderByClause(param *[]model.ParameterKeyVal) (string, error)

BuildLatencyOrderByClause generates ORDER BY clause for latency-based sorting

func BuildLocationOrderByClause added in v0.11.9

func BuildLocationOrderByClause(param *[]model.ParameterKeyVal) (string, error)

BuildLocationOrderByClause generates ORDER BY clause for location-based sorting

func CallGetMonitoringAsync

func CallGetMonitoringAsync(wg *sync.WaitGroup, nsID string, mciID string, vmID string, vmIP string, method string, metric string, cmd string, returnResult *[]model.MonResultSimple)

CallGetMonitoringAsync makes asynchronous HTTP call to CB-Dragonfly for monitoring data and appends the result to the provided result array

func CallMilkyway

func CallMilkyway(wg *sync.WaitGroup, vmList []string, nsId string, mciId string, vmId string, vmIp string, action string, option string, results *model.BenchmarkInfoArray)

CallMilkyway is func to call milkyway agents

func CallMonitoringAsync

func CallMonitoringAsync(wg *sync.WaitGroup, nsID string, mciID string, mciServiceType string, vmID string, givenUserName string, method string, cmd string, returnResult *[]model.SshCmdResult)

CallMonitoringAsync is func to call CB-Dragonfly monitoring framework

func CheckAllowedTransition

func CheckAllowedTransition(nsId string, mciId string, vmId model.OptionalParameter, action string) error

CheckAllowedTransition is func to check status transition is acceptable

func CheckConnectivity

func CheckConnectivity(host string, port string) error

CheckConnectivity func checks if given port is open and ready

func CheckDragonflyEndpoint

func CheckDragonflyEndpoint() error

Module for checking CB-Dragonfly endpoint (call get config)

func CheckK8sClusterDynamicReq added in v0.10.0

CheckK8sClusterDynamicReq is func to check request info to create K8sCluster obeject and deploy requested Nodes in a dynamic way

func CheckMci

func CheckMci(nsId string, mciId string) (bool, error)

CheckMci func is to check given mciId is duplicated with existing

func CheckMciDynamicReq

CheckMciDynamicReq is func to check request info to create MCI obeject and deploy requested VMs in a dynamic way

func CheckMciPolicy

func CheckMciPolicy(nsId string, mciId string) (bool, error)

func CheckNLB

func CheckNLB(nsId string, mciId string, resourceId string) (bool, error)

CheckNLB returns the existence of the TB NLB object in bool form.

func CheckSubGroup

func CheckSubGroup(nsId string, mciId string, subGroupId string) (bool, error)

CheckSubGroup func is to check given subGroupId is duplicated with existing

func CheckVm

func CheckVm(nsId string, mciId string, vmId string) (bool, error)

func CleanupCorruptedProvisioningLogs added in v0.11.3

func CleanupCorruptedProvisioningLogs() error

func ClearAllCommandStatusInfo added in v0.11.10

func ClearAllCommandStatusInfo(nsId, mciId, vmId string) (int, error)

ClearAllCommandStatusInfo deletes all command status records for a VM

func ControlMciAsync

func ControlMciAsync(nsId string, mciId string, action string, force bool) error

ControlMciAsync is func to control MCI async

func ControlVmAsync

func ControlVmAsync(wg *sync.WaitGroup, nsId string, mciId string, vmId string, action string, results chan<- model.ControlVmResult)

ControlVmAsync is func to control VM async

func ControlVmsInParallel added in v0.11.10

func ControlVmsInParallel(nsId, mciId string, vmList []string, action string, force bool) error

ControlVmsInParallel controls VMs with hierarchical rate limiting Level 1: CSPs are processed in parallel Level 2: Within each CSP, regions are processed with semaphore (maxConcurrentRegionsPerCSP) Level 3: Within each region, VMs are processed with semaphore (maxConcurrentVMsPerRegion)

func ConvertMciInfoToMciStatusInfo added in v0.11.10

func ConvertMciInfoToMciStatusInfo(mciInfo model.MciInfo) model.MciStatusInfo

ensureVmStatusInfoComplete ensures all VMs from VmInfo are represented in MciStatus.Vm This handles cases where VM status fetch might have failed or VM is newly created ConvertMciInfoToMciStatusInfo converts MciInfo to MciStatusInfo (partial conversion for basic fields)

func ConvertVmInfoFieldsToVmStatusInfo added in v0.11.10

func ConvertVmInfoFieldsToVmStatusInfo(vmStatus *model.VmStatusInfo, vmInfo model.VmInfo)

ConvertVmInfoFieldsToVmStatusInfo converts VmInfo fields into existing VmStatusInfo VmInfo is considered the trusted source, so all relevant fields are converted

func ConvertVmInfoFieldsToVmStatusInfoList added in v0.11.10

func ConvertVmInfoFieldsToVmStatusInfoList(vmStatusList []model.VmStatusInfo, vmInfoList []model.VmInfo)

ConvertVmInfoFieldsToVmStatusInfoList converts VmInfo fields into corresponding VmStatusInfo list

func ConvertVmInfoListToVmStatusInfoList added in v0.11.10

func ConvertVmInfoListToVmStatusInfoList(vmInfoList []model.VmInfo) []model.VmStatusInfo

ConvertVmInfoListToVmStatusInfoList converts a slice of VmInfo to VmStatusInfo for MCI status operations

func ConvertVmInfoToVmStatusInfo added in v0.11.10

func ConvertVmInfoToVmStatusInfo(vmInfo model.VmInfo) model.VmStatusInfo

ConvertVmInfoToVmStatusInfo converts VmInfo to VmStatusInfo for MCI status operations

func CoreGetBenchmark

func CoreGetBenchmark(nsId string, mciId string, action string, host string) (*model.BenchmarkInfoArray, error)

CoreGetBenchmark is func to get Benchmark

func CreateK8sClusterDynamic added in v0.10.0

func CreateK8sClusterDynamic(reqID string, nsId string, dReq *model.K8sClusterDynamicReq, deployOption string, skipVersionCheck bool) (*model.K8sClusterInfo, error)

CreateK8sClusterDynamic is func to create K8sCluster obeject and deploy requested K8sCluster and NodeGroup in a dynamic way

func CreateK8sMultiClusterDynamic added in v0.11.22

func CreateK8sMultiClusterDynamic(reqID string, nsId string, multiReq *model.K8sMultiClusterDynamicReq, deployOption string, skipVersionCheck bool) (*model.K8sMultiClusterInfo, error)

CreateK8sMultiClusterDynamic creates multiple K8sClusters in parallel

func CreateK8sNodeGroupDynamic added in v0.10.2

func CreateK8sNodeGroupDynamic(reqID string, nsId string, k8sClusterId string, dReq *model.K8sNodeGroupDynamicReq) (*model.K8sClusterInfo, error)

CreateK8sNodeGroupDynamic is func to create K8sNodeGroup obeject and deploy requested K8sNodeGroup in a dynamic way

func CreateMcSwNlb

func CreateMcSwNlb(nsId string, mciId string, req *model.NLBReq, option string) (model.McNlbInfo, error)

CreateMcSwNlb func create a special purpose MCI for NLB and depoly and setting SW NLB

func CreateMci

func CreateMci(nsId string, req *model.MciReq, option string, isReqFromDynamic bool) (*model.MciInfo, error)

CreateMci is func to create MCI object and deploy requested VMs (register CSP native VM with option=register)

func CreateMciDynamic

func CreateMciDynamic(reqID string, nsId string, req *model.MciDynamicReq, deployOption string) (*model.MciInfo, error)

CreateMciDynamic is func to create MCI obeject and deploy requested VMs in a dynamic way

func CreateMciGroupVm

func CreateMciGroupVm(nsId string, mciId string, vmRequest *model.CreateSubGroupReq, newSubGroup bool) (*model.MciInfo, error)

CreateMciGroupVm is func to create MCI groupVM

func CreateMciPolicy

func CreateMciPolicy(nsId string, mciId string, u *model.MciPolicyReq) (model.MciPolicyInfo, error)

CreateMciPolicy create model.MciPolicyInfo object in DB according to user's requirements.

func CreateMciSnapshot added in v0.11.14

func CreateMciSnapshot(nsId string, mciId string, snapshotReq model.SnapshotReq) (model.MciSnapshotResult, error)

CreateMciSnapshot creates snapshots for the first running VM in each subgroup of an MCI in parallel Snapshots are created with provider-specific semaphores to safely limit concurrent requests per CSP

func CreateMciSubGroupDynamic added in v0.11.9

func CreateMciSubGroupDynamic(nsId string, mciId string, req *model.CreateSubGroupDynamicReq) (*model.MciInfo, error)

CreateMciSubGroupDynamic is func to create requested VM in a dynamic way and add it to MCI

func CreateNLB

func CreateNLB(nsId string, mciId string, u *model.NLBReq, option string) (model.NLBInfo, error)

CreateNLB accepts nlb creation request, creates and returns an TB nlb object

func CreateSubGroupReqStructLevelValidation added in v0.11.9

func CreateSubGroupReqStructLevelValidation(sl validator.StructLevel)

CreateSubGroupReqStructLevelValidation is func to validate fields in model.CreateSubGroupReqStruct

func CreateSystemMciDynamic

func CreateSystemMciDynamic(option string) (*model.MciInfo, error)

CreateSystemMciDynamic is func to create MCI obeject and deploy requested VMs in a dynamic way

func CreateVm

func CreateVm(wg *sync.WaitGroup, nsId string, mciId string, vmInfoData *model.VmInfo, option string) error

CreateVm is func to create VM (option = "register" for register existing VM)

func CreateVmObject added in v0.9.19

func CreateVmObject(wg *sync.WaitGroup, nsId string, mciId string, vmInfoData *model.VmInfo) error

CreateVmObject is func to add VM to MCI

func CreateVmSnapshot

func CreateVmSnapshot(nsId string, mciId string, vmId string, snapshotReq model.SnapshotReq) (model.ImageInfo, error)

CreateVmSnapshot is func to create VM snapshot

func CreateVmsInParallel added in v0.11.10

func CreateVmsInParallel(nsId, mciId string, vmInfoList []*model.VmInfo, option string) error

CreateVmsInParallel creates VMs with hierarchical rate limiting Level 1: CSPs are processed in parallel Level 2: Within each CSP, regions are processed with semaphore (maxConcurrentRegionsPerCSP) Level 3: Within each region, VMs are processed with semaphore (maxConcurrentVMsPerRegion)

func DFMonAgentInstallReqStructLevelValidation

func DFMonAgentInstallReqStructLevelValidation(sl validator.StructLevel)

func DelAllMci

func DelAllMci(nsId string, option string) (string, error)

DelAllMci is func to delete all MCI objects in parallel

func DelAllMciPolicy

func DelAllMciPolicy(nsId string) (string, error)

DelAllMciPolicy deletes all model.MciPolicyInfo objects.

func DelAllNLB

func DelAllNLB(nsId string, mciId string, subString string, forceFlag string) (model.IdList, error)

DelAllNLB deletes all TB NLB object of given nsId

func DelMci

func DelMci(nsId string, mciId string, option string) (model.IdList, error)

DelMci is func to delete MCI object

func DelMciPolicy

func DelMciPolicy(nsId string, mciId string) error

DelMciPolicy deletes model.MciPolicyInfo object by mciId.

func DelMciVm

func DelMciVm(nsId string, mciId string, vmId string, option string) error

DelMciVm is func to delete VM object

func DelNLB

func DelNLB(nsId string, mciId string, resourceId string, forceFlag string) error

DelNLB deletes the TB NLB object

func DeleteCommandStatusInfo added in v0.11.10

func DeleteCommandStatusInfo(nsId, mciId, vmId string, index int) error

DeleteCommandStatusInfo deletes a specific command status record

func DeleteCommandStatusInfoByCriteria added in v0.11.10

func DeleteCommandStatusInfoByCriteria(nsId, mciId, vmId string, filter *model.CommandStatusFilter) (int, error)

DeleteCommandStatusInfoByCriteria deletes multiple command status records by criteria

func DeleteProvisioningLog added in v0.11.3

func DeleteProvisioningLog(specId string) error

DeleteProvisioningLog deletes provisioning log for a specific spec ID

func FetchVmStatus

func FetchVmStatus(nsId string, mciId string, vmId string) (model.VmStatusInfo, error)

FetchVmStatus is func to fetch VM status (call to CSPs)

func FindTbVmByCspId

func FindTbVmByCspId(nsId string, mciId string, vmCspResourceId string) (model.VmInfo, error)

func GenNLBKey

func GenNLBKey(nsId string, mciId string, resourceId string) string

GenNLBKey is func to generate a key from NLB id

func GetAllMciPolicyObject

func GetAllMciPolicyObject(nsId string) ([]model.MciPolicyInfo, error)

GetAllMciPolicyObject returns all model.MciPolicyInfo objects.

func GetAvailableDataDisks

func GetAvailableDataDisks(nsId string, mciId string, vmId string, option string) (interface{}, error)

func GetBastionNodes

func GetBastionNodes(nsId string, mciId string, targetVmId string) ([]model.BastionNode, error)

GetBastionNodes func retrieves bastion nodes for a given VM

func GetCommandStatusInfo added in v0.11.10

func GetCommandStatusInfo(nsId, mciId, vmId string, index int) (*model.CommandStatusInfo, error)

GetCommandStatusInfo retrieves a specific command status record

func GetHandlingCommandCount added in v0.11.10

func GetHandlingCommandCount(nsId, mciId, vmId string) (int, error)

GetHandlingCommandCount returns the count of currently handling commands for a VM This function is optimized for frequent polling and avoids unnecessary processing

func GetLatency

func GetLatency(src string, dest string) (float64, error)

GetLatency func get latency between given two regions

func GetMcNlbAccess

func GetMcNlbAccess(nsId string, mciId string) (*model.MciAccessInfo, error)

GetMcNlbAccess returns the requested TB G-NLB access info (currenly MCI)

func GetMciAccessInfo

func GetMciAccessInfo(nsId string, mciId string, option string) (*model.MciAccessInfo, error)

GetMciAccessInfo is func to retrieve MCI Access information

func GetMciAssociatedResources added in v0.11.2

func GetMciAssociatedResources(nsId string, mciId string) (model.MciAssociatedResourceList, error)

GetMciAssociatedResources returns a list of associated resource IDs for given MCI info

func GetMciHandlingCommandCount added in v0.11.10

func GetMciHandlingCommandCount(nsId, mciId string) (map[string]int, int, error)

GetMciHandlingCommandCount returns the count of currently handling commands across all VMs in an MCI This function is optimized for MCI-level monitoring

func GetMciInfo

func GetMciInfo(nsId string, mciId string) (*model.MciInfo, error)

GetMciInfo is func to return MCI information with the current status update

func GetMciObject

func GetMciObject(nsId string, mciId string) (model.MciInfo, bool, error)

GetMciObject is func to retrieve MCI object from database (no current status update)

func GetMciPolicyObject

func GetMciPolicyObject(nsId string, mciId string) (model.MciPolicyInfo, error)

GetMciPolicyObject returns model.MciPolicyInfo object.

func GetMciStatus

func GetMciStatus(nsId string, mciId string) (*model.MciStatusInfo, error)

GetMciStatus is func to Get Mci Status

func GetMciVmAccessInfo added in v0.10.4

func GetMciVmAccessInfo(nsId string, mciId string, vmId string, option string) (*model.MciVmAccessInfo, error)

GetMciVmAccessInfo is func to retrieve MCI Access information

func GetMciVmCurrentStatus added in v0.11.10

func GetMciVmCurrentStatus(nsId string, mciId string, vmId string) (*model.VmStatusInfo, error)

GetMciVmCurrentStatus is func to Get MciVm Current Status from CSP API (real-time)

func GetMciVmStatus

func GetMciVmStatus(nsId string, mciId string, vmId string, fetchFromCSP bool) (*model.VmStatusInfo, error)

GetMciVmStatus is func to Get MciVm Status with option to control CSP API fetch

func GetMonitoringData

func GetMonitoringData(nsId string, mciId string, metric string) (model.MonResultSimpleResponse, error)

GetMonitoringData retrieves monitoring data from CB-Dragonfly for all VMs in an MCI Returns a consolidated response with metrics for each VM

func GetNLB

func GetNLB(nsId string, mciId string, resourceId string) (model.NLBInfo, error)

GetNLB returns the requested TB NLB object

func GetNLBHealth

func GetNLBHealth(nsId string, mciId string, nlbId string) (model.NLBHealthInfo, error)

GetNLBHealth queries the health status of NLB to CB-Spider, and returns it to user

func GetProvisioningLog added in v0.11.3

func GetProvisioningLog(specId string) (*model.ProvisioningLog, error)

GetProvisioningLog retrieves provisioning log for a specific spec ID

func GetSubGroup added in v0.9.10

func GetSubGroup(nsId string, mciId string, subGroupId string) (model.SubGroupInfo, error)

GetSubGroup is func to return list of SubGroups in a given MCI

func GetVmCurrentPublicIp

func GetVmCurrentPublicIp(nsId string, mciId string, vmId string) (model.VmStatusInfo, error)

GetVmCurrentPublicIp is func to get VM public IP

func GetVmIdNameInDetail

func GetVmIdNameInDetail(nsId string, mciId string, vmId string) (*model.IdNameInDetailInfo, error)

GetVmIdNameInDetail is func to get ID and Name details

func GetVmIp

func GetVmIp(nsId string, mciId string, vmId string) (string, string, string, error)

GetVmIp is func to get VM IP to return PublicIP, PrivateIP, SSHPort

func GetVmObject

func GetVmObject(nsId string, mciId string, vmId string) (model.VmInfo, error)

GetVmObject is func to get VM object

func GetVmSpecId

func GetVmSpecId(nsId string, mciId string, vmId string) string

GetVmSpecId is func to get VM SpecId

func GetVmSshKey

func GetVmSshKey(nsId string, mciId string, vmId string) (string, string, string, error)

GetVmSshKey is func to get VM SShKey. Returns username, verifiedUsername, privateKey

func GetVmTemplate

func GetVmTemplate(nsId string, mciId string, algo string) (model.VmInfo, error)

GetVmTemplate is func to get VM template

func HandleMciAction

func HandleMciAction(nsId string, mciId string, action string, force bool) (string, error)

HandleMciAction is func to handle actions to MCI

func HandleMciVmAction

func HandleMciVmAction(nsId string, mciId string, vmId string, action string, force bool) (string, error)

HandleMciVmAction is func to Get MciVm Action

func InspectResources

func InspectResources(connConfig string, resourceType string) (model.InspectResource, error)

InspectResources returns the state list of TB Resource objects of given connConfig and resourceType

func InspectResourcesOverview

func InspectResourcesOverview() (model.InspectResourceAllResult, error)

InspectResourcesOverview func is to check all resources in CB-TB and CSPs

func InstallBenchmarkAgentToMci

func InstallBenchmarkAgentToMci(nsId string, mciId string, req *model.MciCmdReq, option string) ([]model.SshCmdResult, error)

InstallBenchmarkAgentToMci is func to install milkyway agents in MCI

func InstallMonitorAgentToMci

func InstallMonitorAgentToMci(nsId string, mciId string, mciServiceType string, req *model.MciCmdReq) (model.AgentInstallContentWrapper, error)

func ListCommandStatusInfo added in v0.11.10

func ListCommandStatusInfo(nsId, mciId, vmId string, filter *model.CommandStatusFilter) (*model.CommandStatusListResponse, error)

ListCommandStatusInfo retrieves command status records with filtering

func ListMciId

func ListMciId(nsId string) ([]string, error)

ListMciId is func to list MCI ID

func ListMciInfo

func ListMciInfo(nsId string, option string) ([]model.MciInfo, error)

ListMciInfo is func to get all MCI objects

func ListMciPolicyId

func ListMciPolicyId(nsId string) []string

ListMciPolicyId returns a list of Ids for all model.MciPolicyInfo objects .

func ListMciStatus

func ListMciStatus(nsId string) ([]model.MciStatusInfo, error)

ListMciStatus is func to get MCI status all

func ListMciVmInfo added in v0.11.10

func ListMciVmInfo(nsId string, mciId string) ([]model.VmInfo, error)

ListMciVmInfo is func to Get all VM Info objects in MCI

func ListNLB

func ListNLB(nsId string, mciId string, filterKey string, filterVal string) (interface{}, error)

ListNLB returns the list of TB NLB objects of given nsId

func ListNLBId

func ListNLBId(nsId string, mciId string) ([]string, error)

ListNLBId returns the list of TB NLB object IDs of given nsId

func ListSubGroupId

func ListSubGroupId(nsId string, mciId string) ([]string, error)

ListSubGroupId is func to return list of SubGroups in a given MCI

func ListVmByFilter

func ListVmByFilter(nsId string, mciId string, filterKey string, filterVal string) ([]string, error)

ListVmByFilter is func to get list VMs in a MCI by a filter consist of Key and Value

func ListVmByLabel

func ListVmByLabel(nsId string, mciId string, labelKey string) ([]string, error)

ListVmByLabel is a function to list VM IDs by label

func ListVmBySubGroup

func ListVmBySubGroup(nsId string, mciId string, groupId string) ([]string, error)

ListVmBySubGroup is func to get VM list with a SubGroup label in a specified MCI

func ListVmId

func ListVmId(nsId string, mciId string) ([]string, error)

ListVmId is func to list VM IDs

func MciReqStructLevelValidation added in v0.11.9

func MciReqStructLevelValidation(sl validator.StructLevel)

MciReqStructLevelValidation is func to validate fields in MciReqStruct

func NLBReqStructLevelValidation added in v0.11.9

func NLBReqStructLevelValidation(sl validator.StructLevel)

NLBReqStructLevelValidation is a function to validate 'model.NLBReq' object.

func OrchestrationController

func OrchestrationController()

OrchestrationController is responsible for executing MCI automation policy. OrchestrationController will be periodically involked by a time.NewTicker in main.go.

func ProvisionDataDisk

func ProvisionDataDisk(nsId string, mciId string, vmId string, u *model.DataDiskVmReq) (model.VmInfo, error)

ProvisionDataDisk is func to provision DataDisk to VM (create and attach to VM)

func RecommendK8sNode added in v0.10.0

func RecommendK8sNode(nsId string, plan model.RecommendSpecReq) ([]model.SpecInfo, error)

RecommendK8sNode is func to recommend a node for K8sCluster

func RecommendSpec added in v0.11.4

func RecommendSpec(nsId string, plan model.RecommendSpecReq) ([]model.SpecInfo, error)

RecommendSpec is func to recommend a VM

func RecommendSpecOptions added in v0.11.9

func RecommendSpecOptions(nsId string) (*model.RecommendSpecRequestOptions, error)

RecommendSpecOptions returns available options for RecommendSpec API

func RecommendVmCost

func RecommendVmCost(nsId string, specList *[]model.SpecInfo) ([]model.SpecInfo, error)

RecommendVmCost func prioritize specs based on given Cost

func RecommendVmLatency

func RecommendVmLatency(nsId string, specList *[]model.SpecInfo, param *[]model.ParameterKeyVal) ([]model.SpecInfo, error)

RecommendVmLatency func prioritize specs by latency based on given MCI (fair)

func RecommendVmLocation

func RecommendVmLocation(nsId string, specList *[]model.SpecInfo, param *[]model.ParameterKeyVal) ([]model.SpecInfo, error)

RecommendVmLocation func prioritize specs based on given location

func RecommendVmPerformance

func RecommendVmPerformance(nsId string, specList *[]model.SpecInfo) ([]model.SpecInfo, error)

RecommendVmPerformance func prioritize specs based on given Performance condition

func RecommendVmRandom

func RecommendVmRandom(nsId string, specList *[]model.SpecInfo) ([]model.SpecInfo, error)

RecommendVmRandom func prioritize specs randomly

func RecordProvisioningEvent added in v0.11.3

func RecordProvisioningEvent(event *model.ProvisioningEvent) error

RecordProvisioningEvent records a provisioning event (success or failure) to the log

func RecordProvisioningEventsFromMci added in v0.11.3

func RecordProvisioningEventsFromMci(nsId string, mciInfo *model.MciInfo) error

RecordProvisioningEventsFromMci analyzes MCI creation result and records provisioning events

func RegisterCspNativeResources

func RegisterCspNativeResources(nsId string, connConfig string, mciNamePrefix string, option string, mciFlag string) (model.RegisterResourceResult, error)

RegisterCspNativeResources func registers all CSP-native resources into CB-TB

func RegisterCspNativeResourcesAll

func RegisterCspNativeResourcesAll(nsId string, mciNamePrefix string, option string, mciFlag string) (model.RegisterResourceAllResult, error)

RegisterCspNativeResourcesAll func registers all CSP-native resources into CB-TB

func RemoteCommandToMci

func RemoteCommandToMci(nsId string, mciId string, subGroupId string, vmId string, labelSelector string, req *model.MciCmdReq, xRequestId string) ([]model.SshCmdResult, error)

RemoteCommandToMci is func to command to all VMs in MCI by SSH

func RemoveBastionNodes

func RemoveBastionNodes(nsId string, mciId string, bastionVmId string) (string, error)

RemoveBastionNodes func removes existing bastion nodes info

func RemoveNLBVMs

func RemoveNLBVMs(nsId string, mciId string, resourceId string, u *model.NLBAddRemoveVMReq) error

RemoveNLBVMs accepts VM removal request, removes VMs from NLB, and returns an error if occurs.

func ReviewMciDynamicReq added in v0.11.3

func ReviewMciDynamicReq(reqID string, nsId string, req *model.MciDynamicReq, deployOption string) (*model.ReviewMciDynamicReqInfo, error)

ReviewMciDynamicReq is func to review and validate MCI dynamic request comprehensively

func ReviewSingleSubGroupDynamicReq added in v0.11.9

func ReviewSingleSubGroupDynamicReq(reqID string, nsId string, req *model.CreateSubGroupDynamicReq) (*model.ReviewSubGroupDynamicReqInfo, error)

ReviewSingleSubGroupDynamicReq reviews and validates a single VM dynamic request and returns comprehensive review information

func RunAllBenchmarks

func RunAllBenchmarks(nsId string, mciId string, host string) (*model.BenchmarkInfoArray, error)

RunAllBenchmarks is func to get all Benchmarks

func RunLatencyBenchmark

func RunLatencyBenchmark(nsId string, mciId string, host string) (*model.BenchmarkInfoArray, error)

RunLatencyBenchmark is func to get MCI benchmark for network latency

func RunRemoteCommand

func RunRemoteCommand(nsId string, mciId string, vmId string, givenUserName string, cmds []string) (map[int]string, map[int]string, error)

RunRemoteCommand is func to execute a SSH command to a VM (sync call)

func RunRemoteCommandAsync

func RunRemoteCommandAsync(wg *sync.WaitGroup, nsId string, mciId string, vmId string, givenUserName string, cmd []string, returnResult *[]model.SshCmdResult)

RunRemoteCommandAsync is func to execute a SSH command to a VM (async call)

func RunRemoteCommandAsyncWithStatus added in v0.11.10

func RunRemoteCommandAsyncWithStatus(wg *sync.WaitGroup, nsId string, mciId string, vmId string, givenUserName string, cmd []string, cmdIndex int, returnResult *[]model.SshCmdResult)

RunRemoteCommandAsyncWithStatus is func to execute a SSH command to a VM (async call) with command status tracking

func SaveProvisioningLog added in v0.11.3

func SaveProvisioningLog(provisioningLog *model.ProvisioningLog) error

SaveProvisioningLog saves or updates provisioning log for a specific spec ID

func ScaleOutMciSubGroup

func ScaleOutMciSubGroup(nsId string, mciId string, subGroupId string, numVMsToAdd string) (*model.MciInfo, error)

ScaleOutMciSubGroup is func to create MCI groupVM

func SetBastionNodes

func SetBastionNodes(nsId string, mciId string, targetVmId string, bastionVmId string) (string, error)

SetBastionNodes func sets bastion nodes

func SetMonitoringAgentStatusInstalled

func SetMonitoringAgentStatusInstalled(nsId string, mciId string, vmId string) error

SetMonitoringAgentStatusInstalled is func to Set Monitoring Agent Status Installed

func TbMciCmdReqStructLevelValidation

func TbMciCmdReqStructLevelValidation(sl validator.StructLevel)

TbMciCmdReqStructLevelValidation is func to validate fields in model.MciCmdReq

func TransferFileToMci added in v0.9.12

func TransferFileToMci(nsId string, mciId string, subGroupId string, vmId string, fileData []byte, fileName string, targetPath string) ([]model.SshCmdResult, error)

TransferFileToMci is a function to transfer a file to all VMs in MCI by SSH through bastion hosts

func TrimIP

func TrimIP(sshAccessPoint string) (string, error)

func UpdateCommandStatusInfo added in v0.11.10

func UpdateCommandStatusInfo(nsId, mciId, vmId string, index int, status model.CommandExecutionStatus, resultSummary, errorMessage, stdout, stderr string) error

UpdateCommandStatusInfo updates an existing command status record

func UpdateMciInfo

func UpdateMciInfo(nsId string, mciInfoData model.MciInfo)

UpdateMciInfo is func to update MCI Info (without VM info in MCI)

func UpdateMciPolicyInfo

func UpdateMciPolicyInfo(nsId string, mciPolicyInfoData model.MciPolicyInfo)

UpdateMciPolicyInfo updates model.MciPolicyInfo object in DB.

func UpdateMonitoringAgentStatusManually

func UpdateMonitoringAgentStatusManually(nsId string, mciId string, vmId string, targetStatus string) error

UpdateMonitoringAgentStatusManually is func to Update Monitoring Agent Installation Status Manually

func UpdateVmInfo

func UpdateVmInfo(nsId string, mciId string, vmInfoData model.VmInfo)

UpdateVmInfo is func to update VM Info

func UpdateVmPublicIp

func UpdateVmPublicIp(nsId string, mciId string, vmInfoData model.VmInfo) error

UpdateVmPublicIp is func to update VM public IP

func UpdateVmSshKey

func UpdateVmSshKey(nsId string, mciId string, vmId string, verifiedUserName string) error

UpdateVmSshKey is func to update VM SShKey

func ValidateMciDynamicReq added in v0.11.3

func ValidateMciDynamicReq(reqID string, nsId string, req *model.MciDynamicReq, deployOption string) (*model.ReviewMciDynamicReqInfo, error)

ValidateMciDynamicReq is func to validate MCI dynamic request before actual provisioning

func ValidateProvisioningLogIntegrity added in v0.11.3

func ValidateProvisioningLogIntegrity(specId string) error

ValidateProvisioningLogIntegrity checks and repairs provisioning log data integrity

func VerifySshUserName

func VerifySshUserName(nsId string, mciId string, vmId string, vmIp string, sshPort string, givenUserName string) (string, string, error)

VerifySshUserName is func to verify SSH username

Types

type CreatedResource added in v0.11.2

type CreatedResource struct {
	Type string `json:"type"` // "vnet", "sshkey", "securitygroup"
	Id   string `json:"id"`   // Resource ID
}

CreatedResource represents a resource created during dynamic MCI provisioning

type JobStatus added in v0.11.16

type JobStatus string

JobStatus represents the current status of a scheduled job

const (
	// JobStatusRunning indicates the job is actively running
	JobStatusRunning JobStatus = "Running"
	// JobStatusStopped indicates the job has been stopped
	JobStatusStopped JobStatus = "Stopped"
	// JobStatusExecuting indicates the job is currently executing a task
	JobStatusExecuting JobStatus = "Executing"
	// JobStatusScheduled indicates the job is scheduled and waiting for the next execution time
	JobStatusScheduled JobStatus = "Scheduled"
)

type JobType added in v0.11.16

type JobType string

JobType represents the type of scheduled job

const (
	// JobTypeRegisterCspResources represents CSP resource registration job
	JobTypeRegisterCspResources JobType = "registerCspResources"
	// JobTypeRegisterCspResourcesAll represents all CSP resources registration job
	JobTypeRegisterCspResourcesAll JobType = "registerCspResourcesAll"
)

type ScheduledJob added in v0.11.16

type ScheduledJob struct {
	// Job identification
	JobId     string    `json:"jobId"`
	JobType   JobType   `json:"jobType"`
	NsId      string    `json:"nsId"`
	CreatedAt time.Time `json:"createdAt"`

	// Job configuration
	IntervalSeconds  int  `json:"intervalSeconds"`  // Interval between executions in seconds
	ExecutionTimeout int  `json:"executionTimeout"` // Max execution time in seconds (0 = use default)
	Enabled          bool `json:"enabled"`

	// Job-specific parameters
	ConnectionName string `json:"connectionName,omitempty"` // For registerCspResources
	MciNamePrefix  string `json:"mciNamePrefix,omitempty"`  // For registerCspResources
	Option         string `json:"option,omitempty"`         // For registerCspResources
	MciFlag        string `json:"mciFlag,omitempty"`        // For registerCspResources

	// Job status
	Status              JobStatus `json:"status"`
	LastExecutedAt      time.Time `json:"lastExecutedAt,omitempty"`
	NextExecutionAt     time.Time `json:"nextExecutionAt,omitempty"`
	ExecutionCount      int       `json:"executionCount"`
	SuccessCount        int       `json:"successCount"`        // Total successful executions
	FailureCount        int       `json:"failureCount"`        // Total failed executions
	ConsecutiveFailures int       `json:"consecutiveFailures"` // Current consecutive failures
	LastError           string    `json:"lastError,omitempty"`
	LastResult          string    `json:"lastResult,omitempty"`
	AutoDisabled        bool      `json:"autoDisabled"` // Whether job was auto-disabled due to failures
	// contains filtered or unexported fields
}

ScheduledJob represents a scheduled recurring job

func (*ScheduledJob) GetStatus added in v0.11.16

func (job *ScheduledJob) GetStatus() model.ScheduleJobStatus

GetStatus returns the current status of the job (thread-safe)

type SchedulerManager added in v0.11.16

type SchedulerManager struct {
	// contains filtered or unexported fields
}

SchedulerManager manages all scheduled jobs

func GetSchedulerManager added in v0.11.16

func GetSchedulerManager() *SchedulerManager

GetSchedulerManager returns the singleton scheduler manager instance

func (*SchedulerManager) CreateScheduledJob added in v0.11.16

func (sm *SchedulerManager) CreateScheduledJob(req model.ScheduleJobRequest) (*ScheduledJob, error)

CreateScheduledJob creates a new scheduled job

func (*SchedulerManager) GetScheduledJob added in v0.11.16

func (sm *SchedulerManager) GetScheduledJob(jobId string) (*ScheduledJob, error)

GetScheduledJob retrieves a scheduled job by ID

func (*SchedulerManager) ListScheduledJobs added in v0.11.16

func (sm *SchedulerManager) ListScheduledJobs() []*ScheduledJob

ListScheduledJobs returns all scheduled jobs Jobs are not scoped to namespaces, so all jobs are returned

func (*SchedulerManager) StopAllScheduledJobs added in v0.11.16

func (sm *SchedulerManager) StopAllScheduledJobs() (int, error)

StopAllScheduledJobs stops all scheduled jobs in the system Jobs are not scoped to namespaces, so all jobs in the system are deleted

func (*SchedulerManager) StopScheduledJob added in v0.11.16

func (sm *SchedulerManager) StopScheduledJob(jobId string) error

StopScheduledJob stops a scheduled job

func (*SchedulerManager) UpdateScheduledJob added in v0.11.16

func (sm *SchedulerManager) UpdateScheduledJob(jobId string, req model.UpdateScheduleJobRequest) (*ScheduledJob, error)

UpdateScheduledJob updates job configuration

type VmControlInfo added in v0.11.10

type VmControlInfo struct {
	VmId         string
	ProviderName string
	RegionName   string
}

VmControlInfo represents VM control information with grouping details

type VmCreateInfo added in v0.11.10

type VmCreateInfo struct {
	VmInfo       *model.VmInfo
	ProviderName string
	RegionName   string
}

VmCreateInfo represents VM creation information with grouping details

type VmGroupInfo added in v0.11.10

type VmGroupInfo struct {
	VmId         string
	ProviderName string
	RegionName   string
}

VmGroupInfo represents VM grouping information for rate limiting

type VmReqWithCreatedResources added in v0.11.2

type VmReqWithCreatedResources struct {
	VmReq            *model.CreateSubGroupReq `json:"vmReq"`
	CreatedResources []CreatedResource        `json:"createdResources"`
}

VmReqWithCreatedResources contains VM request and list of created resources for rollback

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL