Documentation
¶
Overview ¶
Package migration is to provision target infra for migration
Package migration is to provision target multi-cloud infra for migration ¶
Package migration is to provision target multi-cloud infra for migration ¶
Package migration provides SSH readiness check rate limiting
Index ¶
- Constants
- func CreateInfra(nsId string, targetInfraModel *cloudmodel.RecommendedInfra) (cloudmodel.VmInfraInfo, error)
- func CreateInfraWithDefaults(nsId string, infraModel *cloudmodel.InfraDynamicReq) (cloudmodel.VmInfraInfo, error)
- func CreateInfraWithExisting(nsId string, targetInfraModel *cloudmodel.RecommendedInfra) (cloudmodel.VmInfraInfo, error)
- func CreateNlbs(nsId, infraId string, req cloudmodel.RecommendedNlb, useExisting bool) (cloudmodel.MigratedNlbResult, error)
- func CreateObjectStorage(nsId string, req storagemodel.RecommendedObjectStorage, seed string) error
- func DeleteInfra(nsId, infraId, option string) (common.SimpleMsg, error)
- func DeleteNlb(nsId, infraId, nlbId string) error
- func DeleteObjectStorage(nsId, osId, option string) error
- func DeleteStorageObject(nsId, osId, objectKey string) error
- func ExistObjectStorage(nsId, osId string) (bool, error)
- func GenerateConnectionName(csp, region string) (string, error)
- func GetInfra(nsId, infraId string) (cloudmodel.InfraInfo, error)
- func GetNlb(nsId, infraId, nlbId string) (cloudmodel.NLBInfo, error)
- func GetNlbHealth(nsId, infraId, nlbId string) (cloudmodel.NLBInfo, error)
- func GetObjectStorage(nsId, osId string) (storagemodel.ObjectStorageInfo, error)
- func ListAllInfraInfo(nsId string) (cloudmodel.InfraInfoList, error)
- func ListInfraIDs(nsId string, option string) (cloudmodel.IdList, error)
- func ListNlbs(nsId, infraId string) ([]cloudmodel.NLBInfo, error)
- func ListObjectStorageIDs(nsId string) (storagemodel.IdList, error)
- func ListObjectStorages(nsId string) (storagemodel.ObjectStorageListResponse, error)
- type MigratedObjectStorageInfo
- type MigratedObjectStorageListResponse
- type NodeSSHStatusDetail
- type SSHCheckRateLimiter
- type SSHCheckRecord
- type StorageObjectInfo
- type StorageObjectListResponse
- type StorageObjectMetadata
Constants ¶
const ( // ActionCreate is const for Create ActionCreate string = "Create" // ActionTerminate is const for Terminate ActionTerminate string = "Terminate" // ActionSuspend is const for Suspend ActionSuspend string = "Suspend" // ActionResume is const for Resume ActionResume string = "Resume" // ActionReboot is const for Reboot ActionReboot string = "Reboot" // ActionRefine is const for Refine ActionRefine string = "Refine" // ActionComplete is const for Complete ActionComplete string = "None" )
const ( // StatusRunning is const for Running StatusRunning string = "Running" // StatusSuspended is const for Suspended StatusSuspended string = "Suspended" // StatusFailed is const for Failed StatusFailed string = "Failed" // StatusTerminated is const for Terminated StatusTerminated string = "Terminated" // StatusCreating is const for Creating StatusCreating string = "Creating" // StatusSuspending is const for Suspending StatusSuspending string = "Suspending" // StatusResuming is const for Resuming StatusResuming string = "Resuming" // StatusRebooting is const for Rebooting StatusRebooting string = "Rebooting" // StatusTerminating is const for Terminating StatusTerminating string = "Terminating" // StatusUndefined is const for Undefined StatusUndefined string = "Undefined" // StatusComplete is const for Complete StatusComplete string = "None" )
const DefaultSystemLabel string = "Managed by CM-Beetle"
DefaultSystemLabel is const for string to specify the Default System Label
Variables ¶
This section is empty.
Functions ¶
func CreateInfra ¶ added in v0.5.3
func CreateInfra(nsId string, targetInfraModel *cloudmodel.RecommendedInfra) (cloudmodel.VmInfraInfo, error)
CreateInfra creates an infrastructure for the computing infra migration by creating fresh resources (useExisting=false)
func CreateInfraWithDefaults ¶ added in v0.5.7
func CreateInfraWithDefaults(nsId string, infraModel *cloudmodel.InfraDynamicReq) (cloudmodel.VmInfraInfo, error)
CreateInfraWithDefaults Create an infrastructure with defaults for the computing infra migration
func CreateInfraWithExisting ¶ added in v0.5.3
func CreateInfraWithExisting(nsId string, targetInfraModel *cloudmodel.RecommendedInfra) (cloudmodel.VmInfraInfo, error)
CreateInfraWithExisting creates an infrastructure by reusing/ensuring existing resources (useExisting=true)
func CreateNlbs ¶ added in v0.5.3
func CreateNlbs(nsId, infraId string, req cloudmodel.RecommendedNlb, useExisting bool) (cloudmodel.MigratedNlbResult, error)
CreateNlbs migrates NLBs to the target cloud infra. Each TargetNlb in req.NLBs is sent to Tumblebug as a separate NLBReq. All NLBs are attempted; individual failures are recorded in the result. If useExisting is true (default) and an NLB with the same nodeGroupId already exists, it is reused. (Tumblebug sets NLB Id = nodeGroupId, so GetNlb(nodeGroupId) is used for the existence check.)
func CreateObjectStorage ¶ added in v0.5.1
func CreateObjectStorage(nsId string, req storagemodel.RecommendedObjectStorage, seed string) error
CreateObjectStorage migrates object storages to the target cloud. It applies late-binding via the seed parameter, creates each bucket, then configures versioning and CORS according to CSP support information.
func DeleteInfra ¶ added in v0.5.7
Delete the migrated infrastructure
func DeleteNlb ¶ added in v0.5.3
DeleteNlb deletes a specific NLB. Treats 404 as already deleted (idempotent).
func DeleteObjectStorage ¶ added in v0.5.1
DeleteObjectStorage deletes a specific object storage. Treats 404 as already deleted (idempotent). option controls deletion behavior: "" (standard), "empty" (empty first), "force" (force with contents), "reconcile" (metadata only).
func DeleteStorageObject ¶ added in v0.5.1
DeleteStorageObject deletes a specific object from an object storage bucket.
func ExistObjectStorage ¶ added in v0.5.1
ExistObjectStorage checks whether a specific object storage exists.
func GenerateConnectionName ¶ added in v0.5.1
GenerateConnectionName builds and validates a connection name from csp and region.
func GetInfra ¶ added in v0.5.7
func GetInfra(nsId, infraId string) (cloudmodel.InfraInfo, error)
Get the migrated infrastructure
func GetNlb ¶ added in v0.5.3
func GetNlb(nsId, infraId, nlbId string) (cloudmodel.NLBInfo, error)
GetNlb returns details of a specific NLB.
func GetNlbHealth ¶ added in v0.5.4
func GetNlbHealth(nsId, infraId, nlbId string) (cloudmodel.NLBInfo, error)
GetNlbHealth performs a live health check on NLB targets via CSP. Unlike GetNlb (which returns cached state), this call reaches out to the CSP to get current health status.
func GetObjectStorage ¶ added in v0.5.1
func GetObjectStorage(nsId, osId string) (storagemodel.ObjectStorageInfo, error)
GetObjectStorage returns details of a specific migrated object storage.
func ListAllInfraInfo ¶ added in v0.5.7
func ListAllInfraInfo(nsId string) (cloudmodel.InfraInfoList, error)
List all migrated infrastructures
func ListInfraIDs ¶ added in v0.5.7
func ListInfraIDs(nsId string, option string) (cloudmodel.IdList, error)
Get all migrated infrastructures
func ListNlbs ¶ added in v0.5.3
func ListNlbs(nsId, infraId string) ([]cloudmodel.NLBInfo, error)
ListNlbs returns all NLBs in the specified infra.
func ListObjectStorageIDs ¶ added in v0.5.7
func ListObjectStorageIDs(nsId string) (storagemodel.IdList, error)
ListObjectStorageIDs returns all migrated object storage IDs in the namespace.
func ListObjectStorages ¶ added in v0.5.1
func ListObjectStorages(nsId string) (storagemodel.ObjectStorageListResponse, error)
ListObjectStorages returns all migrated object storages in the namespace.
Types ¶
type MigratedObjectStorageInfo ¶ added in v0.5.1
type MigratedObjectStorageInfo = storagemodel.ObjectStorageInfo
MigratedObjectStorageInfo represents an object storage bucket created in the target cloud via CM-Beetle.
type MigratedObjectStorageListResponse ¶ added in v0.5.1
type MigratedObjectStorageListResponse = storagemodel.ObjectStorageListResponse
MigratedObjectStorageListResponse is the list response for migrated object storages.
type NodeSSHStatusDetail ¶ added in v0.5.7
type NodeSSHStatusDetail struct {
ID string
Name string
PublicIP string
PrivateIP string
Username string
Status string
SSHReady bool
SSHPort int
Error string
}
NodeSSHStatusDetail represents the SSH readiness status of a node (internal use)
func CheckSSHReadinessWithDetails ¶ added in v0.5.7
func CheckSSHReadinessWithDetails(nsId string, infraId string, maxWaitTime time.Duration, checkInterval time.Duration) ([]NodeSSHStatusDetail, error)
CheckSSHReadinessWithDetails checks if all Nodes in the infrastructure are SSH-accessible and returns detailed status for each node. It works for any CSP; "Running" status doesn't mean cloud-init (SSH user setup) is done (IBM Cloud VPC: up to ~3 min in testing), so this polls until ready or maxWaitTime elapses.
Parameters:
- nsId: Namespace ID
- infraId: Infrastructure ID
- maxWaitTime: Maximum time to wait (e.g., 3*time.Minute)
- checkInterval: Interval between checks (e.g., 10*time.Second)
Returns:
- []NodeSSHStatusDetail: Detailed status for each node
- error: nil if all Nodes are SSH-ready, or error describing the issue
type SSHCheckRateLimiter ¶ added in v0.5.7
type SSHCheckRateLimiter struct {
// contains filtered or unexported fields
}
SSHCheckRateLimiter provides rate limiting for SSH readiness checks to prevent abuse and excessive SSH connection attempts
func GetSSHCheckRateLimiter ¶ added in v0.5.7
func GetSSHCheckRateLimiter() *SSHCheckRateLimiter
GetSSHCheckRateLimiter returns the singleton instance of SSH check rate limiter
func (*SSHCheckRateLimiter) CheckAllowed ¶ added in v0.5.7
func (l *SSHCheckRateLimiter) CheckAllowed(nsId string, infraId string) (bool, time.Duration, error)
CheckAllowed checks if an SSH readiness check is allowed for the given infrastructure Returns true if allowed, false if rate limited, along with time until next allowed check
func (*SSHCheckRateLimiter) GetStats ¶ added in v0.5.7
func (l *SSHCheckRateLimiter) GetStats() map[string]interface{}
GetStats returns current statistics about the rate limiter
func (*SSHCheckRateLimiter) Stop ¶ added in v0.5.7
func (l *SSHCheckRateLimiter) Stop()
Stop stops the background cleanup goroutine
type SSHCheckRecord ¶ added in v0.5.7
type SSHCheckRecord struct {
InfraKey string // Format: "nsId:infraId"
LastCheckTime time.Time // Time of last check
CheckCount int // Number of checks performed
}
SSHCheckRecord tracks SSH readiness check for a specific infrastructure
type StorageObjectInfo ¶ added in v0.5.1
type StorageObjectInfo struct {
Key string `json:"key"` // Object key (relative path within the bucket)
Size int64 `json:"size"` // Size in bytes
LastModified string `json:"lastModified,omitempty"` // Last modified timestamp (RFC 3339)
ETag string `json:"eTag,omitempty"` // Entity tag (content hash)
StorageClass string `json:"storageClass,omitempty"` // Storage class (e.g., STANDARD)
}
StorageObjectInfo represents a single object in an object storage bucket.
type StorageObjectListResponse ¶ added in v0.5.1
type StorageObjectListResponse struct {
OsId string `json:"osId"` // Object storage ID
Count int `json:"count"` // Total number of objects
Objects []StorageObjectInfo `json:"objects"` // List of objects
}
StorageObjectListResponse is the list response for objects in an object storage bucket.
func ListObjectStorageObjects ¶ added in v0.5.1
func ListObjectStorageObjects(nsId, osId string) (StorageObjectListResponse, error)
ListObjectStorageObjects returns the list of objects stored in a specific object storage bucket.
type StorageObjectMetadata ¶ added in v0.5.1
type StorageObjectMetadata struct {
Key string `json:"key"` // Object key
Size int64 `json:"size"` // Size in bytes
LastModified string `json:"lastModified,omitempty"` // Last modified timestamp
ETag string `json:"eTag,omitempty"` // Entity tag (content hash)
StorageClass string `json:"storageClass,omitempty"` // Storage class
}
StorageObjectMetadata represents the metadata of a single object returned by a HEAD request.
func GetStorageObject ¶ added in v0.5.1
func GetStorageObject(nsId, osId, objectKey string) (StorageObjectMetadata, error)
GetStorageObject retrieves metadata of a specific object from an object storage bucket.