migration

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package migration is to provision target infra for migration

Package migration contains the K8s infra migration logic.

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 logic to provision target multi-cloud infra and managed middleware

Index

Constants

View Source
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"
)
View Source
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"
)
View Source
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 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 CreateK8sInfra added in v0.6.0

CreateK8sInfra provisions a K8s infra on the target CSP from a recommendation result: the prerequisite resources (VNet, SshKey, SecurityGroups) plus the cluster and its node groups. It follows the same pattern as CreateInfra for VM migration:

  1. Create VNet (with subnets)
  2. Create SSH Key
  3. Create Security Group (sets VNetId from step 1)
  4. Check CSP's nodeGroupsOnCreation flag 5a. nodeGroupsOnCreation=true (Azure/GCP/NHN/NCP/IBM): Include NodeGroups in K8sClusterReq and create in a single call, then poll for Active. 5b. nodeGroupsOnCreation=false (AWS/Alibaba/Tencent): Create cluster first, poll for Active, then add NodeGroups separately.

Both paths poll until the cluster is Active before returning, ensuring a consistent response. The cluster is labeled with the migration timestamp and, when given, the migration lineage.

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 CreateRDBMS added in v0.6.1

func CreateRDBMS(nsId string, req rdbmsmodel.RecommendedRDBMS, seed string) error

CreateRDBMS migrates managed RDBMS instances to the target cloud. It applies late-binding via the seed parameter, provisions each DB instance via CB-Tumblebug, and optionally creates inner logical databases if specified in the recommendation.

func CreateRDBMSDatabase added in v0.6.1

func CreateRDBMSDatabase(nsId, rdbmsId, adminUserName, adminPassword string, req rdbmsmodel.RDBMSDatabaseCreateReq) error

CreateRDBMSDatabase creates a logical database in a specific RDBMS instance.

func DeleteInfra added in v0.5.7

func DeleteInfra(nsId, infraId, option string) (common.SimpleMsg, error)

Delete the migrated infrastructure

func DeleteK8sCluster added in v0.5.10

func DeleteK8sCluster(nsId, clusterId string) error

DeleteK8sCluster deletes the K8s cluster after removing all node groups. AWS EKS requires node groups to be deleted before the cluster can be deleted.

func DeleteNlb added in v0.5.3

func DeleteNlb(nsId, infraId, nlbId string) error

DeleteNlb deletes a specific NLB. Treats 404 as already deleted (idempotent).

func DeleteObjectStorage added in v0.5.1

func DeleteObjectStorage(nsId, osId, option string) error

DeleteObjectStorage deletes or empties a specific object storage according to option. Options: "" (standard delete), "empty" (empty objects only, keep bucket), "force" (empty and force-delete).

func DeleteRDBMS added in v0.6.1

func DeleteRDBMS(nsId, rdbmsId, option string) error

DeleteRDBMS deletes a specific managed RDBMS instance. Treats 404 as already deleted (idempotent).

func DeleteRDBMSDatabase added in v0.6.1

func DeleteRDBMSDatabase(nsId, rdbmsId, dbName, adminUserName, adminPassword string) error

DeleteRDBMSDatabase deletes a logical database in a specific RDBMS instance.

func DeleteStorageObject added in v0.5.1

func DeleteStorageObject(nsId, osId, objectKey string) error

DeleteStorageObject deletes a specific object from an object storage bucket.

func ExistObjectStorage added in v0.5.1

func ExistObjectStorage(nsId, osId string) (bool, error)

ExistObjectStorage checks whether a specific object storage exists.

func GenerateConnectionName added in v0.5.1

func GenerateConnectionName(csp, region string) (string, error)

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 GetK8sCluster added in v0.5.10

func GetK8sCluster(nsId, clusterId string) (tbmodel.K8sClusterInfo, error)

GetK8sCluster returns the K8s cluster info for the given ID.

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 GetRDBMS added in v0.6.1

func GetRDBMS(nsId, rdbmsId string) (rdbmsmodel.RDBMSInfo, error)

GetRDBMS returns details of a specific migrated RDBMS instance.

func GetRDBMSSecureTransport added in v0.6.2

func GetRDBMSSecureTransport(nsId, rdbmsId, adminUserName, adminPassword string) (rdbmsmodel.RDBMSSecureTransportInfo, error)

GetRDBMSSecureTransport retrieves live TLS status and server CA certificate for an RDBMS instance.

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 ListK8sClusterIds added in v0.6.1

func ListK8sClusterIds(nsId string) (cloudmodel.IdList, error)

ListK8sClusterIds returns only the IDs of the K8s clusters in the namespace. Callers that merely need to know which clusters exist should prefer this over ListK8sClusters, whose cost grows with the cluster count because Tumblebug refreshes each one through Spider.

func ListK8sClusters added in v0.5.10

func ListK8sClusters(nsId string) ([]tbmodel.K8sClusterInfo, error)

ListK8sClusters returns all K8s clusters in the namespace.

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.

func ListRDBMS added in v0.6.1

func ListRDBMS(nsId string) (rdbmsmodel.RDBMSListResponse, error)

ListRDBMS returns all migrated RDBMS instances in the namespace.

func ListRDBMSDatabases added in v0.6.1

func ListRDBMSDatabases(nsId, rdbmsId, adminUserName, adminPassword string) (rdbmsmodel.RDBMSDatabaseListResponse, error)

ListRDBMSDatabases returns logical databases in a specific RDBMS instance.

func ListRDBMSIDs added in v0.6.1

func ListRDBMSIDs(nsId string) (rdbmsmodel.IdList, error)

ListRDBMSIDs returns all migrated RDBMS IDs in the namespace.

func MigrateInfra added in v0.6.2

func MigrateInfra(nsId string, targetInfraModel *cloudmodel.RecommendedInfra, lin ...lineage.MigrationLineage) (cloudmodel.VmInfraInfo, error)

MigrateInfra migrates an on-premise infrastructure to target cloud by creating fresh resources (useExisting=false)

func MigrateInfraWithExisting added in v0.6.2

func MigrateInfraWithExisting(nsId string, targetInfraModel *cloudmodel.RecommendedInfra, lin ...lineage.MigrationLineage) (cloudmodel.VmInfraInfo, error)

MigrateInfraWithExisting migrates an on-premise infrastructure by reusing/ensuring existing resources (useExisting=true)

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 MigratedObjectStorageResult added in v0.6.5

type MigratedObjectStorageResult struct {
	Status        string                           `json:"status"`             // "created", "partial", or "failed"
	Description   string                           `json:"description"`        // Human-readable migration summary
	Warnings      []string                         `json:"warnings,omitempty"` // Skipped or failed bucket or configuration details
	ObjectStorage []storagemodel.ObjectStorageInfo `json:"objectStorage"`      // Provisioned object storage buckets
}

MigratedObjectStorageResult represents the migration outcome for target object storages.

func CreateObjectStorage added in v0.5.1

CreateObjectStorage migrates object storages to the target cloud. Each target bucket is attempted independently; partial failures or skipped features are recorded in Warnings.

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 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.

Jump to

Keyboard shortcuts

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