Documentation
¶
Index ¶
- Variables
- func NewBatchService(repo BatchRepo, instance InstanceService) batchService
- func NewInstanceService(repo InstanceRepo, opts ...InstanceServiceOption) instanceService
- func NewNetworkService(repo NetworkRepo) networkService
- func NewQueueService(repo QueueRepo, batch BatchService, instance InstanceService, ...) queueService
- func NewSourceService(repo SourceRepo) sourceService
- func NewTargetService(repo TargetRepo) targetService
- func NewValidationErrf(format string, a ...any) error
- type Batch
- type BatchConstraint
- type BatchRepo
- type BatchService
- type Batches
- type ErrValidation
- type Instance
- func (i Instance) DisabledReason() error
- func (i Instance) GetName() string
- func (i *Instance) GetOSType() api.OSType
- func (i Instance) MatchesCriteria(expression string) (bool, error)
- func (i Instance) ToAPI() api.Instance
- func (i Instance) ToFilterable() InstanceFilterable
- func (i Instance) Validate() error
- type InstanceFilterable
- type InstanceRepo
- type InstanceService
- type InstanceServiceOption
- type Instances
- type MigrationWindow
- type MigrationWindows
- type Network
- type NetworkRepo
- type NetworkService
- type Networks
- type QueueEntries
- type QueueEntry
- type QueueRepo
- type QueueService
- type Source
- func (s Source) GetExternalConnectivityStatus() api.ExternalConnectivityStatus
- func (s Source) GetServerCertificate() *x509.Certificate
- func (s Source) GetTrustedServerCertificateFingerprint() string
- func (s *Source) SetExternalConnectivityStatus(status api.ExternalConnectivityStatus)
- func (s *Source) SetServerCertificate(cert *x509.Certificate)
- func (s Source) ToAPI() api.Source
- func (s Source) Validate() error
- type SourceEndpoint
- type SourceRepo
- type SourceService
- type Sources
- type Target
- func (t Target) GetEndpoint() string
- func (t Target) GetExternalConnectivityStatus() api.ExternalConnectivityStatus
- func (t Target) GetServerCertificate() *x509.Certificate
- func (t Target) GetTrustedServerCertificateFingerprint() string
- func (t *Target) SetExternalConnectivityStatus(status api.ExternalConnectivityStatus)
- func (t *Target) SetOIDCTokens(tokens *oidc.Tokens[*oidc.IDTokenClaims])
- func (t *Target) SetServerCertificate(cert *x509.Certificate)
- func (t Target) ToAPI() api.Target
- func (t Target) Validate() error
- type TargetEndpoint
- type TargetRepo
- type TargetService
- type Targets
- type WorkerCommand
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func NewBatchService ¶
func NewBatchService(repo BatchRepo, instance InstanceService) batchService
func NewInstanceService ¶
func NewInstanceService(repo InstanceRepo, opts ...InstanceServiceOption) instanceService
func NewNetworkService ¶
func NewNetworkService(repo NetworkRepo) networkService
func NewQueueService ¶
func NewQueueService(repo QueueRepo, batch BatchService, instance InstanceService, source SourceService, target TargetService) queueService
func NewSourceService ¶
func NewSourceService(repo SourceRepo) sourceService
func NewTargetService ¶
func NewTargetService(repo TargetRepo) targetService
func NewValidationErrf ¶
Types ¶
type Batch ¶
type Batch struct { ID int64 Name string `db:"primary=yes"` Target string `db:"join=targets.name"` TargetProject string Status api.BatchStatusType StatusMessage string StoragePool string IncludeExpression string StartDate time.Time PostMigrationRetries int Constraints []BatchConstraint `db:"marshal=json"` }
func (Batch) CanBeModified ¶
func (Batch) CanStart ¶
func (b Batch) CanStart(windows []MigrationWindow) error
type BatchConstraint ¶
type BatchConstraint struct { // Name of the constraint. Name string `json:"name" yaml:"name"` // Description of the constraint. Description string `json:"description" yaml:"description"` // Expression used to select instances for the constraint. IncludeExpression string `json:"include_expression" yaml:"include_expression"` // Maximum amount of matched instances that can concurrently migrate, before moving to the next migration window. MaxConcurrentInstances int `json:"max_concurrent_instances" yaml:"max_concurrent_instances"` // Minimum amount of time required for an instance to boot after initial disk import. Migration window duration must be at least this much. MinInstanceBootTime time.Duration `json:"min_instance_boot_time" yaml:"min_instance_boot_time"` }
func (BatchConstraint) Validate ¶
func (b BatchConstraint) Validate() error
type BatchRepo ¶
type BatchRepo interface { Create(ctx context.Context, batch Batch) (int64, error) GetAll(ctx context.Context) (Batches, error) GetAllByState(ctx context.Context, status api.BatchStatusType) (Batches, error) GetAllNames(ctx context.Context) ([]string, error) GetAllNamesByState(ctx context.Context, status api.BatchStatusType) ([]string, error) GetByName(ctx context.Context, name string) (*Batch, error) Update(ctx context.Context, name string, batch Batch) error Rename(ctx context.Context, oldName string, newName string) error DeleteByName(ctx context.Context, name string) error AssignBatch(ctx context.Context, batchName string, instanceUUID uuid.UUID) error UnassignBatch(ctx context.Context, batchName string, instanceUUID uuid.UUID) error GetMigrationWindowsByBatch(ctx context.Context, batch string) (MigrationWindows, error) AssignMigrationWindows(ctx context.Context, batch string, windows MigrationWindows) error UnassignMigrationWindows(ctx context.Context, batch 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) GetAllNamesByState(ctx context.Context, status api.BatchStatusType) ([]string, error) GetByName(ctx context.Context, name string) (*Batch, error) Update(ctx context.Context, name string, batch *Batch) error UpdateStatusByName(ctx context.Context, name string, status api.BatchStatusType, statusMessage string) (*Batch, error) Rename(ctx context.Context, oldName string, newName string) error DeleteByName(ctx context.Context, name string) error StartBatchByName(ctx context.Context, name string) error StopBatchByName(ctx context.Context, name string) error AssignMigrationWindows(ctx context.Context, batch string, windows MigrationWindows) error ChangeMigrationWindows(ctx context.Context, batch string, windows MigrationWindows) error GetMigrationWindows(ctx context.Context, batch string) (MigrationWindows, error) GetEarliestWindow(ctx context.Context, batch string) (*MigrationWindow, error) }
type ErrValidation ¶
type ErrValidation string
func (ErrValidation) Error ¶
func (e ErrValidation) Error() string
type Instance ¶
type Instance struct { ID int64 UUID uuid.UUID `db:"primary=yes"` Source string `db:"join=sources.name"` SourceType api.SourceType `db:"join=sources.source_type&omit=create,update"` LastUpdateFromSource time.Time Overrides api.InstanceOverride `db:"marshal=json"` Properties api.InstanceProperties `db:"marshal=json"` }
func (Instance) DisabledReason ¶
DisabledReason returns the underlying reason for why the instance is disabled.
func (Instance) GetName ¶
GetName 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 Location property.
func (*Instance) GetOSType ¶
GetOSType returns the OS type, as determined from https://dp-downloads.broadcom.com/api-content/apis/API_VWSA_001/8.0U3/html/ReferenceGuides/vim.vm.GuestOsDescriptor.GuestOsIdentifier.html
func (Instance) MatchesCriteria ¶
func (Instance) ToFilterable ¶
func (i Instance) ToFilterable() InstanceFilterable
type InstanceFilterable ¶
type InstanceFilterable struct { api.InstanceProperties Source string `expr:"source"` SourceType api.SourceType `expr:"source_type"` LastUpdateFromSource time.Time `expr:"last_update_from_source"` }
func (InstanceFilterable) CompileIncludeExpression ¶
func (i InstanceFilterable) CompileIncludeExpression(expression string) (*vm.Program, error)
type InstanceRepo ¶
type InstanceRepo interface { Create(ctx context.Context, instance Instance) (int64, error) GetAll(ctx context.Context) (Instances, error) GetAllByBatch(ctx context.Context, batch string) (Instances, error) GetAllBySource(ctx context.Context, source string) (Instances, error) GetAllByUUIDs(ctx context.Context, id ...uuid.UUID) (Instances, error) GetAllUUIDs(ctx context.Context) ([]uuid.UUID, error) GetAllUUIDsBySource(ctx context.Context, source string) ([]uuid.UUID, error) GetAllAssigned(ctx context.Context) (Instances, error) GetAllUnassigned(ctx context.Context) (Instances, error) GetBatchesByUUID(ctx context.Context, instanceUUID uuid.UUID) (Batches, error) GetByUUID(ctx context.Context, id uuid.UUID) (*Instance, error) Update(ctx context.Context, instance Instance) error DeleteByUUID(ctx context.Context, id uuid.UUID) error RemoveFromQueue(ctx context.Context, id uuid.UUID) error }
type InstanceService ¶
type InstanceService interface { Create(ctx context.Context, instance Instance) (Instance, error) GetAll(ctx context.Context) (Instances, error) GetAllByBatch(ctx context.Context, batch string) (Instances, error) GetAllBySource(ctx context.Context, source string) (Instances, error) GetAllUUIDs(ctx context.Context) ([]uuid.UUID, error) GetAllUUIDsBySource(ctx context.Context, source string) ([]uuid.UUID, error) GetAllAssigned(ctx context.Context) (Instances, error) GetAllUnassigned(ctx context.Context) (Instances, error) GetByUUID(ctx context.Context, id uuid.UUID) (*Instance, error) GetAllQueued(ctx context.Context, queue QueueEntries) (Instances, error) GetBatchesByUUID(ctx context.Context, id uuid.UUID) (Batches, error) Update(ctx context.Context, instance *Instance) error DeleteByUUID(ctx context.Context, id uuid.UUID) error RemoveFromQueue(ctx context.Context, id uuid.UUID) error GetPostMigrationRetries(id uuid.UUID) int RecordPostMigrationRetry(id uuid.UUID) }
type InstanceServiceOption ¶
type InstanceServiceOption func(s *instanceService)
type MigrationWindow ¶
type MigrationWindow struct { ID int64 Start time.Time `db:"primary=yes"` End time.Time `db:"primary=yes"` Lockout time.Time `db:"primary=yes"` }
func (MigrationWindow) Begun ¶
func (w MigrationWindow) Begun() bool
Begun returns whether the migration window has begun (whether its start time and lockout time are both in the past).
func (MigrationWindow) FitsDuration ¶
func (w MigrationWindow) FitsDuration(duration time.Duration) bool
func (MigrationWindow) Key ¶
func (w MigrationWindow) Key() string
Key returns an identifying key for the MigrationWindow, based on its timings.
func (MigrationWindow) Validate ¶
func (w MigrationWindow) Validate() error
type MigrationWindows ¶
type MigrationWindows []MigrationWindow
func (MigrationWindows) GetEarliest ¶
func (ws MigrationWindows) GetEarliest() (*MigrationWindow, error)
GetEarliest returns the earliest valid migration window, or an error if none are found.
type Network ¶
type Network struct { ID int64 Type api.NetworkType Identifier string `db:"primary=yes"` Location string Source string `db:"primary=yes&join=sources.name"` Properties json.RawMessage `db:"marshal=json"` Overrides api.NetworkOverride `db:"marshal=json"` }
type NetworkRepo ¶
type NetworkRepo interface { Create(ctx context.Context, network Network) (int64, error) GetAll(ctx context.Context) (Networks, error) GetAllBySource(ctx context.Context, src string) (Networks, error) GetByNameAndSource(ctx context.Context, name string, src string) (*Network, error) Update(ctx context.Context, network Network) error DeleteByNameAndSource(ctx context.Context, name string, src string) error }
type NetworkService ¶
type NetworkService interface { Create(ctx context.Context, network Network) (Network, error) GetAll(ctx context.Context) (Networks, error) GetAllBySource(ctx context.Context, src string) (Networks, error) GetByNameAndSource(ctx context.Context, name string, src string) (*Network, error) Update(ctx context.Context, network *Network) error DeleteByNameAndSource(ctx context.Context, name string, src string) error }
type Networks ¶
type Networks []Network
func FilterUsedNetworks ¶
FilterUsedNetworks returns the subset of supplied networks that are in use by the supplied instances.
type QueueEntries ¶
type QueueEntries []QueueEntry
type QueueEntry ¶
type QueueEntry struct { ID int64 InstanceUUID uuid.UUID `db:"primary=yes&join=instances.uuid"` BatchName string `db:"join=batches.name"` NeedsDiskImport bool SecretToken uuid.UUID MigrationStatus api.MigrationStatusType MigrationStatusMessage string LastWorkerStatus api.WorkerResponseType }
func (QueueEntry) IsMigrating ¶
func (q QueueEntry) IsMigrating() bool
func (QueueEntry) ToAPI ¶
func (q QueueEntry) ToAPI(instanceName string, lastWorkerUpdate time.Time) api.QueueEntry
func (QueueEntry) Validate ¶
func (q QueueEntry) Validate() error
type QueueRepo ¶
type QueueRepo interface { Create(ctx context.Context, queue QueueEntry) (int64, error) GetAll(ctx context.Context) (QueueEntries, error) GetAllByState(ctx context.Context, status ...api.MigrationStatusType) (QueueEntries, error) GetAllByBatch(ctx context.Context, batch string) (QueueEntries, error) GetAllByBatchAndState(ctx context.Context, batch string, statuses ...api.MigrationStatusType) (QueueEntries, error) GetAllNeedingImport(ctx context.Context, batch string, needsDiskImport bool) (QueueEntries, error) GetByInstanceUUID(ctx context.Context, id uuid.UUID) (*QueueEntry, error) Update(ctx context.Context, entry QueueEntry) error DeleteByUUID(ctx context.Context, id uuid.UUID) error DeleteAllByBatch(ctx context.Context, batch string) error }
type QueueService ¶
type QueueService interface { CreateEntry(ctx context.Context, queue QueueEntry) (QueueEntry, error) GetAll(ctx context.Context) (QueueEntries, error) GetAllByState(ctx context.Context, status ...api.MigrationStatusType) (QueueEntries, error) GetAllByBatch(ctx context.Context, batch string) (QueueEntries, error) GetAllByBatchAndState(ctx context.Context, batch string, status ...api.MigrationStatusType) (QueueEntries, error) GetAllNeedingImport(ctx context.Context, batch string, needsDiskImport bool) (QueueEntries, error) GetByInstanceUUID(ctx context.Context, id uuid.UUID) (*QueueEntry, error) Update(ctx context.Context, entry *QueueEntry) error DeleteByUUID(ctx context.Context, id uuid.UUID) error DeleteAllByBatch(ctx context.Context, batch string) error UpdateStatusByUUID(ctx context.Context, id uuid.UUID, status api.MigrationStatusType, statusMessage string, needsDiskImport bool) (*QueueEntry, error) NewWorkerCommandByInstanceUUID(ctx context.Context, id uuid.UUID) (WorkerCommand, error) ProcessWorkerUpdate(ctx context.Context, id uuid.UUID, workerResponseTypeArg api.WorkerResponseType, statusMessage string) (QueueEntry, error) }
type Source ¶
type Source struct { ID int64 Name string `db:"primary=yes"` SourceType api.SourceType Properties json.RawMessage EndpointFunc func(api.Source) (SourceEndpoint, error) `json:"-" db:"ignore"` }
func (Source) GetExternalConnectivityStatus ¶
func (s Source) GetExternalConnectivityStatus() api.ExternalConnectivityStatus
func (Source) GetServerCertificate ¶
func (s Source) GetServerCertificate() *x509.Certificate
func (Source) GetTrustedServerCertificateFingerprint ¶
func (*Source) SetExternalConnectivityStatus ¶
func (s *Source) SetExternalConnectivityStatus(status api.ExternalConnectivityStatus)
func (*Source) SetServerCertificate ¶
func (s *Source) SetServerCertificate(cert *x509.Certificate)
type SourceEndpoint ¶
type SourceEndpoint interface { Connect(ctx context.Context) error DoBasicConnectivityCheck() (api.ExternalConnectivityStatus, *x509.Certificate) }
type SourceRepo ¶
type SourceRepo interface { Create(ctx context.Context, source Source) (int64, error) GetAll(ctx context.Context, sourceTypes ...api.SourceType) (Sources, error) GetAllNames(ctx context.Context, sourceTypes ...api.SourceType) ([]string, error) GetByName(ctx context.Context, name string) (*Source, error) Update(ctx context.Context, name string, source Source) error Rename(ctx context.Context, oldName string, newName string) 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, sourceTypes ...api.SourceType) (Sources, error) GetAllNames(ctx context.Context, sourceTypes ...api.SourceType) ([]string, error) GetByName(ctx context.Context, name string) (*Source, error) Update(ctx context.Context, name string, source *Source, instanceService InstanceService) error DeleteByName(ctx context.Context, name string, instanceService InstanceService) error InitImportCache(initial map[string]int) error GetCachedImports(sourceName string) int RecordActiveImport(sourceName string) RemoveActiveImport(sourceName string) }
type Target ¶
type Target struct { ID int64 Name string `db:"primary=yes"` TargetType api.TargetType Properties json.RawMessage EndpointFunc func(api.Target) (TargetEndpoint, error) `json:"-" db:"ignore"` }
func (Target) GetEndpoint ¶
func (Target) GetExternalConnectivityStatus ¶
func (t Target) GetExternalConnectivityStatus() api.ExternalConnectivityStatus
func (Target) GetServerCertificate ¶
func (t Target) GetServerCertificate() *x509.Certificate
func (Target) GetTrustedServerCertificateFingerprint ¶
func (*Target) SetExternalConnectivityStatus ¶
func (t *Target) SetExternalConnectivityStatus(status api.ExternalConnectivityStatus)
func (*Target) SetOIDCTokens ¶
func (t *Target) SetOIDCTokens(tokens *oidc.Tokens[*oidc.IDTokenClaims])
func (*Target) SetServerCertificate ¶
func (t *Target) SetServerCertificate(cert *x509.Certificate)
type TargetEndpoint ¶
type TargetEndpoint interface { Connect(ctx context.Context) error DoBasicConnectivityCheck() (api.ExternalConnectivityStatus, *x509.Certificate) IsWaitingForOIDCTokens() bool }
type TargetRepo ¶
type TargetRepo interface { Create(ctx context.Context, target Target) (int64, error) GetAll(ctx context.Context) (Targets, error) GetAllNames(ctx context.Context) ([]string, error) GetByName(ctx context.Context, name string) (*Target, error) Update(ctx context.Context, name string, target Target) error Rename(ctx context.Context, oldName string, newName string) 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) GetByName(ctx context.Context, name string) (*Target, error) Update(ctx context.Context, name string, target *Target) error DeleteByName(ctx context.Context, name string) error InitImportCache(initial map[string]int) error GetCachedImports(targetName string) int RecordActiveImport(targetName string) RemoveActiveImport(targetName string) InitCreateCache(initial map[string]int) error GetCachedCreations(targetName string) int RecordCreation(targetName string) RemoveCreation(targetName string) }
type WorkerCommand ¶
type WorkerCommand struct { Command api.WorkerCommandType Location string SourceType api.SourceType Source Source OS string OSVersion string }