migration

package
v0.0.0-pre.1 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("Not found")

	ErrConstraintViolation = errors.New("Constraint violation")

	ErrOperationNotPermitted = errors.New("Operation not permitted")
)

Functions

func NewBatchService

func NewBatchService(repo BatchRepo, instance InstanceService) batchService

func NewInstanceService

func NewInstanceService(repo InstanceRepo, source SourceService, opts ...InstanceServiceOption) instanceService

func NewNetworkService

func NewNetworkService(repo NetworkRepo) networkService

func NewQueueService

func NewQueueService(batch BatchService, instance InstanceService, source SourceService) queueService

func NewSourceService

func NewSourceService(repo SourceRepo) sourceService

func NewTargetService

func NewTargetService(repo TargetRepo) targetService

func NewValidationErrf

func NewValidationErrf(format string, a ...any) error

Types

type Batch

type Batch struct {
	ID                   int
	Name                 string
	TargetID             int
	TargetProject        string
	Status               api.BatchStatusType
	StatusString         string
	StoragePool          string
	IncludeExpression    string
	MigrationWindowStart time.Time
	MigrationWindowEnd   time.Time
}

func (Batch) CanBeModified

func (b Batch) CanBeModified() bool

func (Batch) CompileIncludeExpression

func (b Batch) CompileIncludeExpression(i InstanceWithDetails) (*vm.Program, error)

func (Batch) InstanceMatchesCriteria

func (b Batch) InstanceMatchesCriteria(instanceWithDetails InstanceWithDetails) (bool, error)

func (Batch) Validate

func (b Batch) Validate() error

type BatchRepo

type BatchRepo interface {
	Create(ctx context.Context, batch Batch) (Batch, error)
	GetAll(ctx context.Context) (Batches, error)
	GetAllByState(ctx context.Context, status api.BatchStatusType) (Batches, error)
	GetAllNames(ctx context.Context) ([]string, error)
	GetByID(ctx context.Context, id int) (Batch, error)
	GetByName(ctx context.Context, name string) (Batch, error)
	UpdateByID(ctx context.Context, batch Batch) (Batch, error)
	UpdateStatusByID(ctx context.Context, id int, status api.BatchStatusType, statusString string) (Batch, error)
	DeleteByName(ctx context.Context, name string) error
}

type BatchService

type BatchService interface {
	Create(ctx context.Context, batch Batch) (Batch, error)
	GetAll(ctx context.Context) (Batches, error)
	GetAllByState(ctx context.Context, status api.BatchStatusType) (Batches, error)
	GetAllNames(ctx context.Context) ([]string, error)
	GetByID(ctx context.Context, id int) (Batch, error)
	GetByName(ctx context.Context, name string) (Batch, error)
	UpdateByID(ctx context.Context, batch Batch) (Batch, error)
	UpdateInstancesAssignedToBatch(ctx context.Context, batch Batch) error
	UpdateStatusByID(ctx context.Context, id int, status api.BatchStatusType, statusString string) (Batch, error)
	DeleteByName(ctx context.Context, name string) error
	StartBatchByName(ctx context.Context, name string) error
	StopBatchByName(ctx context.Context, name string) error
}

type Batches

type Batches []Batch

type ErrValidation

type ErrValidation string

func (ErrValidation) Error

func (e ErrValidation) Error() string

type Instance

type Instance struct {
	UUID                  uuid.UUID
	InventoryPath         string
	Annotation            string
	MigrationStatus       api.MigrationStatusType
	MigrationStatusString string
	LastUpdateFromSource  time.Time
	SourceID              int
	BatchID               *int
	GuestToolsVersion     int
	Architecture          string
	HardwareVersion       string
	OS                    string
	OSVersion             string
	Devices               []api.InstanceDeviceInfo
	Disks                 []api.InstanceDiskInfo
	NICs                  []api.InstanceNICInfo
	Snapshots             []api.InstanceSnapshotInfo
	CPU                   api.InstanceCPUInfo
	Memory                api.InstanceMemoryInfo
	UseLegacyBios         bool
	SecureBootEnabled     bool
	TPMPresent            bool
	Overrides             *Overrides
	NeedsDiskImport       bool
	SecretToken           uuid.UUID
}

func (Instance) CanBeModified

func (i Instance) CanBeModified() bool

func (Instance) GetName

func (i Instance) GetName() string

Returns the name of the instance, which may not be unique among all instances for a given source. If a unique, human-readable identifier is needed, use the InventoryPath property.

func (*Instance) GetOSType

func (i *Instance) GetOSType() api.OSType

The mapping of OS version strings to OS types is determined from https://dp-downloads.broadcom.com/api-content/apis/API_VWSA_001/8.0U3/html/ReferenceGuides/vim.vm.GuestOsDescriptor.GuestOsIdentifier.html

func (Instance) IsMigrating

func (i Instance) IsMigrating() bool

func (Instance) Validate

func (i Instance) Validate() error

type InstanceCPUInfo

type InstanceCPUInfo struct {
	NumberCPUs             int
	CPUAffinity            []int32
	NumberOfCoresPerSocket int
}

type InstanceDeviceInfo

type InstanceDeviceInfo struct {
	Type    string
	Label   string
	Summary string
}

type InstanceDiskInfo

type InstanceDiskInfo struct {
	Name                      string
	Type                      string
	ControllerModel           string
	DifferentialSyncSupported bool
	SizeInBytes               int64
	IsShared                  bool
}

type InstanceMemoryInfo

type InstanceMemoryInfo struct {
	MemoryInBytes            int64
	MemoryReservationInBytes int64
}

type InstanceNICInfo

type InstanceNICInfo struct {
	Network      string
	AdapterModel string
	Hwaddr       string
}

type InstanceRepo

type InstanceRepo interface {
	Create(ctx context.Context, instance Instance) (Instance, error)
	GetAll(ctx context.Context) (Instances, error)
	GetAllByState(ctx context.Context, status api.MigrationStatusType) (Instances, error)
	GetAllByBatchID(ctx context.Context, batchID int) (Instances, error)
	GetAllUUIDs(ctx context.Context) ([]uuid.UUID, error)
	GetAllUnassigned(ctx context.Context) (Instances, error)
	GetByID(ctx context.Context, id uuid.UUID) (Instance, error)
	UpdateByID(ctx context.Context, instance Instance) (Instance, error)
	UpdateStatusByUUID(ctx context.Context, id uuid.UUID, status api.MigrationStatusType, statusString string, needsDiskImport bool) (Instance, error)
	DeleteByID(ctx context.Context, id uuid.UUID) error

	// Overrides
	CreateOverrides(ctx context.Context, overrides Overrides) (Overrides, error)
	GetOverridesByID(ctx context.Context, id uuid.UUID) (Overrides, error)
	DeleteOverridesByID(ctx context.Context, id uuid.UUID) error
	UpdateOverridesByID(ctx context.Context, overrides Overrides) (Overrides, error)
}

type InstanceService

type InstanceService interface {
	Create(ctx context.Context, instance Instance) (Instance, error)
	GetAll(ctx context.Context) (Instances, error)
	GetAllByState(ctx context.Context, status api.MigrationStatusType) (Instances, error)
	GetAllByBatchID(ctx context.Context, batchID int) (Instances, error)
	GetAllUUIDs(ctx context.Context) ([]uuid.UUID, error)
	GetAllUnassigned(ctx context.Context) (Instances, error)
	GetByID(ctx context.Context, id uuid.UUID) (Instance, error)
	GetByIDWithDetails(ctx context.Context, id uuid.UUID) (InstanceWithDetails, error)
	UnassignFromBatch(ctx context.Context, id uuid.UUID) error
	UpdateByID(ctx context.Context, instance Instance) (Instance, error)
	UpdateStatusByUUID(ctx context.Context, id uuid.UUID, status api.MigrationStatusType, statusString string, needsDiskImport bool) (Instance, error)
	ProcessWorkerUpdate(ctx context.Context, id uuid.UUID, workerResponseTypeArg api.WorkerResponseType, statusString string) (Instance, error)
	DeleteByID(ctx context.Context, id uuid.UUID) error

	// Overrride
	CreateOverrides(ctx context.Context, overrides Overrides) (Overrides, error)
	GetOverridesByID(ctx context.Context, id uuid.UUID) (Overrides, error)
	DeleteOverridesByID(ctx context.Context, id uuid.UUID) error
	UpdateOverridesByID(ctx context.Context, overrides Overrides) (Overrides, error)
}

type InstanceServiceOption

type InstanceServiceOption func(s *instanceService)

type InstanceSnapshotInfo

type InstanceSnapshotInfo struct {
	Name         string
	Description  string
	CreationTime time.Time
	ID           int
}

type InstanceWithDetails

type InstanceWithDetails struct {
	Name              string
	InventoryPath     string
	Annotation        string
	GuestToolsVersion int
	Architecture      string
	HardwareVersion   string
	OS                string
	OSVersion         string
	Devices           []api.InstanceDeviceInfo
	Disks             []api.InstanceDiskInfo
	NICs              []api.InstanceNICInfo
	Snapshots         []api.InstanceSnapshotInfo
	CPU               api.InstanceCPUInfo
	Memory            api.InstanceMemoryInfo
	UseLegacyBios     bool
	SecureBootEnabled bool
	TPMPresent        bool

	Source    Source
	Overrides Overrides
}

type Instances

type Instances []Instance

type Network

type Network struct {
	ID   int
	Name string

	Config map[string]string
}

func (Network) Validate

func (n Network) Validate() error

type NetworkRepo

type NetworkRepo interface {
	Create(ctx context.Context, network Network) (Network, error)
	GetAll(ctx context.Context) (Networks, error)
	GetAllNames(ctx context.Context) ([]string, error)
	GetByID(ctx context.Context, id int) (Network, error)
	GetByName(ctx context.Context, name string) (Network, error)
	UpdateByID(ctx context.Context, network Network) (Network, error)
	DeleteByName(ctx context.Context, name string) error
}

type NetworkService

type NetworkService interface {
	Create(ctx context.Context, network Network) (Network, error)
	GetAll(ctx context.Context) (Networks, error)
	GetAllNames(ctx context.Context) ([]string, error)
	GetByID(ctx context.Context, id int) (Network, error)
	GetByName(ctx context.Context, name string) (Network, error)
	UpdateByID(ctx context.Context, network Network) (Network, error)
	DeleteByName(ctx context.Context, name string) error
}

type Networks

type Networks []Network

type Overrides

type Overrides struct {
	UUID             uuid.UUID
	LastUpdate       time.Time
	Comment          string
	NumberCPUs       int
	MemoryInBytes    int64
	DisableMigration bool
}

func (Overrides) Validate

func (o Overrides) Validate() error

type QueueEntries

type QueueEntries []QueueEntry

type QueueEntry

type QueueEntry struct {
	InstanceUUID          uuid.UUID
	InstanceName          string
	MigrationStatus       api.MigrationStatusType
	MigrationStatusString string
	BatchID               int
	BatchName             string
}

type QueueService

type QueueService interface {
	GetAll(ctx context.Context) (QueueEntries, error)
	GetByInstanceID(ctx context.Context, id uuid.UUID) (QueueEntry, error)
	GetWorkerCommandByInstanceID(ctx context.Context, id uuid.UUID) (WorkerCommand, error)
}

type Source

type Source struct {
	ID         int
	Name       string
	SourceType api.SourceType

	Properties json.RawMessage
}

func (Source) Validate

func (s Source) Validate() error

type SourceRepo

type SourceRepo interface {
	Create(ctx context.Context, source Source) (Source, error)
	GetAll(ctx context.Context) (Sources, error)
	GetAllNames(ctx context.Context) ([]string, error)
	GetByID(ctx context.Context, id int) (Source, error)
	GetByName(ctx context.Context, name string) (Source, error)
	UpdateByID(ctx context.Context, source Source) (Source, error)
	DeleteByName(ctx context.Context, name string) error
}

type SourceService

type SourceService interface {
	Create(ctx context.Context, source Source) (Source, error)
	GetAll(ctx context.Context) (Sources, error)
	GetAllNames(ctx context.Context) ([]string, error)
	GetByID(ctx context.Context, id int) (Source, error)
	GetByName(ctx context.Context, name string) (Source, error)
	UpdateByID(ctx context.Context, source Source) (Source, error)
	DeleteByName(ctx context.Context, name string) error
}

type Sources

type Sources []Source

type Target

type Target struct {
	ID         int
	Name       string
	TargetType api.TargetType

	Properties json.RawMessage
}

func (Target) Validate

func (t Target) Validate() error

type TargetRepo

type TargetRepo interface {
	Create(ctx context.Context, target Target) (Target, error)
	GetAll(ctx context.Context) (Targets, error)
	GetAllNames(ctx context.Context) ([]string, error)
	GetByID(ctx context.Context, id int) (Target, error)
	GetByName(ctx context.Context, name string) (Target, error)
	UpdateByID(ctx context.Context, target Target) (Target, error)
	DeleteByName(ctx context.Context, name string) error
}

type TargetService

type TargetService interface {
	Create(ctx context.Context, target Target) (Target, error)
	GetAll(ctx context.Context) (Targets, error)
	GetAllNames(ctx context.Context) ([]string, error)
	GetByID(ctx context.Context, id int) (Target, error)
	GetByName(ctx context.Context, name string) (Target, error)
	UpdateByID(ctx context.Context, target Target) (Target, error)
	DeleteByName(ctx context.Context, name string) error
}

type Targets

type Targets []Target

type WorkerCommand

type WorkerCommand struct {
	Command       api.WorkerCommandType
	InventoryPath string
	SourceType    api.SourceType
	Source        Source
	OS            string
	OSVersion     string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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