api

package
v0.0.0-pre.3 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2025 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const (
	APIVersion string = "1.0"
	APIStatus  string = "devel"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Batch

type Batch struct {
	BatchPut

	// The status of this batch
	// Example: BATCHSTATUS_DEFINED
	Status BatchStatusType `json:"status" yaml:"status"`

	// A free-form string to provide additional information about the status
	// Example: "4 of 5 instances migrated"
	StatusMessage string `json:"status_message" yaml:"status_message"`
}

Batch defines a collection of Instances to be migrated, possibly during a specific window of time.

swagger:model

type BatchPut

type BatchPut struct {
	// A human-friendly name for this batch
	// Example: MyBatch
	Name string `json:"name" yaml:"name"`

	// The destination target name to be used by all instances in this batch
	// Example: Mytarget
	Target string `json:"target" yaml:"target"`

	// The target project to use
	// Example: default
	TargetProject string `json:"target_project" yaml:"target_project"`

	// The Incus storage pool that this batch should use for creating VMs and mounting ISO images
	// Example: local
	StoragePool string `json:"storage_pool" yaml:"storage_pool"`

	// A Expression used to select instances to add to this batch
	// Language reference: https://expr-lang.org/docs/language-definition
	// Example: GetInventoryPath() matches "^foobar/.*"
	IncludeExpression string `json:"include_expression" yaml:"include_expression"`

	// If specified, don't start the migration before this time
	MigrationWindowStart time.Time `json:"migration_window_start" yaml:"migration_window_start"`

	// If specified, don't start the migration after this time
	MigrationWindowEnd time.Time `json:"migration_window_end" yaml:"migration_window_end"`
}

BatchPut defines the configurable fields of Batch.

swagger:model

type BatchStatusType

type BatchStatusType string
const (
	BATCHSTATUS_DEFINED  BatchStatusType = "Defined"
	BATCHSTATUS_QUEUED   BatchStatusType = "Queued"
	BATCHSTATUS_RUNNING  BatchStatusType = "Running"
	BATCHSTATUS_STOPPED  BatchStatusType = "Stopped"
	BATCHSTATUS_FINISHED BatchStatusType = "Finished"
	BATCHSTATUS_ERROR    BatchStatusType = "Error"
)

func (BatchStatusType) Validate

func (b BatchStatusType) Validate() error

Validate ensures the BatchStatusType is valid.

type ExternalConnectivityStatus

type ExternalConnectivityStatus string
const (
	EXTERNALCONNECTIVITYSTATUS_UNKNOWN                 ExternalConnectivityStatus = "Unknown"
	EXTERNALCONNECTIVITYSTATUS_OK                      ExternalConnectivityStatus = "OK"
	EXTERNALCONNECTIVITYSTATUS_CANNOT_CONNECT          ExternalConnectivityStatus = "Cannot connect"
	EXTERNALCONNECTIVITYSTATUS_TLS_ERROR               ExternalConnectivityStatus = "TLS error"
	EXTERNALCONNECTIVITYSTATUS_TLS_CONFIRM_FINGERPRINT ExternalConnectivityStatus = "Confirm TLS fingerprint"
	EXTERNALCONNECTIVITYSTATUS_AUTH_ERROR              ExternalConnectivityStatus = "Authentication error"
	EXTERNALCONNECTIVITYSTATUS_WAITING_OIDC            ExternalConnectivityStatus = "Waiting for OIDC authentications"
)

func MapExternalConnectivityStatusToStatus

func MapExternalConnectivityStatusToStatus(err error) ExternalConnectivityStatus

type IncusProperties

type IncusProperties struct {
	// Hostname or IP address of the target endpoint
	// Example: https://incus.local:6443
	Endpoint string `json:"endpoint" yaml:"endpoint"`

	// Store the expected target's TLS certificate, in raw bytes. Useful in situations when TLS certificate validation fails, such as when using self-signed certificates.
	ServerCertificate []byte `json:"trusted_server_certificate,omitempty" yaml:"trusted_server_certificate,omitempty"`

	// If set and the fingerprint matches that of the ServerCertificate, enables use of that certificate when performing TLS handshake.
	// Example: b51b3046a03164a2ca279222744b12fe0878a8c12311c88fad427f4e03eca42d
	TrustedServerCertificateFingerprint string `json:"trusted_server_certificate_fingerprint,omitempty" yaml:"trusted_server_certificate_fingerprint,omitempty"`

	// base64-encoded TLS client key for authentication
	TLSClientKey string `json:"tls_client_key,omitempty" yaml:"tls_client_key,omitempty"`

	// base64-encoded TLS client certificate for authentication
	TLSClientCert string `json:"tls_client_cert,omitempty" yaml:"tls_client_cert,omitempty"`

	// OpenID Connect tokens
	OIDCTokens *oidc.Tokens[*oidc.IDTokenClaims] `json:"oidc_tokens,omitempty" yaml:"oidc_tokens,omitempty"`

	// Connectivity status of this target
	ConnectivityStatus ExternalConnectivityStatus `json:"connectivity_status" yaml:"connectivity_status"`
}

IncusProperties defines the set of Incus specific properties of a target that the migration manager can connect to.

swagger:model

type Instance

type Instance struct {
	// The migration status of this instance
	// Example: MIGRATIONSTATUS_RUNNING
	MigrationStatus MigrationStatusType `json:"migration_status" yaml:"migration_status"`

	// A free-form string to provide additional information about the migration status
	// Example: "Migration 25% complete"
	MigrationStatusMessage string `json:"migration_status_message" yaml:"migration_status_message"`

	// The last time this instance was updated from its source
	// Example: 2024-11-12 16:15:00 +0000 UTC
	LastUpdateFromSource time.Time `json:"last_update_from_source" yaml:"last_update_from_source"`

	// The last time this instance was updated from its worker
	// Example: 2024-11-12 16:15:00 +0000 UTC
	LastUpdateFromWorker time.Time `json:"last_update_from_worker" yaml:"last_update_from_worker"`

	// The originating source name for this instance
	// Example: MySource
	Source string `json:"source" yaml:"source"`

	// The batch ID for this instance
	// Example: 1
	Batch *string `json:"batch,omitempty" yaml:"batch,omitempty"`

	Properties InstanceProperties `json:"properties" yaml:"properties"`

	// Overrides, if any, for this instance
	// Example: {..., NumberCPUs: 16, ...}
	Overrides *InstanceOverride `json:"overrides" yaml:"overrides"`
}

Instance defines a VM instance to be migrated.

swagger:model

func (*Instance) GetName

func (i *Instance) GetName() string

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.

type InstanceOverride

type InstanceOverride struct {
	InstanceOverridePut

	// UUID corresponding to the overridden instance
	// Example: 26fa4eb7-8d4f-4bf8-9a6a-dd95d166dfad
	UUID uuid.UUID `json:"uuid" yaml:"uuid"`
}

InstanceOverride defines a limited set of instance values that can be overridden as part of the migration process.

swagger:model

type InstanceOverridePut

type InstanceOverridePut struct {
	// The last time this instance override was updated
	// Example: 2024-11-12 16:15:00 +0000 UTC
	LastUpdate time.Time `json:"last_update" yaml:"last_update"`

	// An optional comment about the override
	// Example: "Manually tweak number of CPUs"
	Comment string `json:"comment" yaml:"comment"`

	// If true, migration of this instance will be disabled.
	// Example: true
	DisableMigration bool `json:"disable_migration" yaml:"disable_migration"`

	Properties InstancePropertiesConfigurable `json:"properties" yaml:"properties"`
}

InstanceOverridePut defines the configurable fields of InstanceOverride.

swagger:model

type InstanceProperties

type InstanceProperties struct {
	InstancePropertiesConfigurable

	UUID             uuid.UUID `json:"uuid"              yaml:"uuid"`
	Name             string    `json:"name"              yaml:"name"`
	Location         string    `json:"location"          yaml:"location"`
	OS               string    `json:"os"                yaml:"os"`
	OSVersion        string    `json:"os_version"        yaml:"os_version"`
	SecureBoot       bool      `json:"secure_boot"       yaml:"secure_boot"`
	LegacyBoot       bool      `json:"legacy_boot"       yaml:"legacy_boot"`
	TPM              bool      `json:"tpm"               yaml:"tpm"`
	BackgroundImport bool      `json:"background_import" yaml:"background_import"`
	Architecture     string    `json:"architecture"      yaml:"architecture"`

	NICs      []InstancePropertiesNIC      `json:"nics"      yaml:"nics"`
	Disks     []InstancePropertiesDisk     `json:"disks"     yaml:"disks"`
	Snapshots []InstancePropertiesSnapshot `json:"snapshots" yaml:"snapshots"`
}

InstanceProperties are all properties supported by instances.

func (*InstanceProperties) Apply

Apply updates the properties with the given set of configurable properties. Only non-default values will be applied.

type InstancePropertiesConfigurable

type InstancePropertiesConfigurable struct {
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
	CPUs        int64  `json:"cpus"                  yaml:"cpus"`
	Memory      int64  `json:"memory"                yaml:"memory"`
}

InstancePropertiesConfigurable are the configurable properties of an instance.

type InstancePropertiesDisk

type InstancePropertiesDisk struct {
	Capacity int64  `json:"capacity" yaml:"capacity"`
	Name     string `json:"name"     yaml:"name"`
	Shared   bool   `json:"shared"   yaml:"shared"`
}

InstancePropertiesDisk are all properties supported by instance disks.

type InstancePropertiesNIC

type InstancePropertiesNIC struct {
	ID              string `json:"id"               yaml:"id"`
	HardwareAddress string `json:"hardware_address" yaml:"hardware_address"`
	Network         string `json:"network"          yaml:"network"`
}

InstancePropertiesNIC are all properties supported by instance NICs.

type InstancePropertiesSnapshot

type InstancePropertiesSnapshot struct {
	Name string `json:"name" yaml:"name"`
}

InstancePropertiesSnapshot are all properties supported by snapshots.

type MigrationStatusType

type MigrationStatusType string
const (
	MIGRATIONSTATUS_NOT_ASSIGNED_BATCH      MigrationStatusType = "Not yet assigned to a batch"
	MIGRATIONSTATUS_ASSIGNED_BATCH          MigrationStatusType = "Assigned to a batch"
	MIGRATIONSTATUS_CREATING                MigrationStatusType = "Creating new VM"
	MIGRATIONSTATUS_BACKGROUND_IMPORT       MigrationStatusType = "Performing background import tasks"
	MIGRATIONSTATUS_IDLE                    MigrationStatusType = "Idle"
	MIGRATIONSTATUS_FINAL_IMPORT            MigrationStatusType = "Performing final import tasks"
	MIGRATIONSTATUS_IMPORT_COMPLETE         MigrationStatusType = "Import tasks complete"
	MIGRATIONSTATUS_FINISHED                MigrationStatusType = "Finished"
	MIGRATIONSTATUS_ERROR                   MigrationStatusType = "Error"
	MIGRATIONSTATUS_USER_DISABLED_MIGRATION MigrationStatusType = "User disabled migration"
)

func (MigrationStatusType) Validate

func (m MigrationStatusType) Validate() error

Validate ensures the MigrationStatusType is valid.

type Network

type Network struct {
	// The name of the network
	// Example: network-23
	Name string `json:"name" yaml:"name"`

	// Any network-specific config options
	// Example: {"network": "vmware", "ipv6.address": "none"}
	Config map[string]string `json:"config" yaml:"config"`
}

Network defines the network config for use by the migration manager.

swagger:model

type OSType

type OSType string
const (
	OSTYPE_WINDOWS OSType = "Windows"
	OSTYPE_LINUX   OSType = "Linux"
)

type QueueEntry

type QueueEntry struct {
	// UUID for the instance; populated from the source and used across all migration manager operations
	// Example: 26fa4eb7-8d4f-4bf8-9a6a-dd95d166dfad
	InstanceUUID uuid.UUID `json:"instance_uuid" yaml:"instance_uuid"`

	// The name of the instance
	// Example: UbuntuServer
	InstanceName string `json:"instance_name" yaml:"instance_name"`

	// The migration status of the instance
	// Example: MIGRATIONSTATUS_RUNNING
	MigrationStatus MigrationStatusType `json:"migration_status" yaml:"migration_status"`

	// A free-form string to provide additional information about the migration status
	// Example: "Migration 25% complete"
	MigrationStatusMessage string `json:"migration_status_message" yaml:"migration_status_message"`

	// A human-friendly name for the batch
	// Example: MyBatch
	BatchName string `json:"batch_name" yaml:"batch_name"`
}

QueueEntry provides a high-level status for an instance that is in a migration stage.

swagger:model

type ServerPut

type ServerPut struct {
	// Server configuration map (refer to doc/server.md)
	// Example: {"core.https_address": ":6443"}
	Config map[string]string `json:"config" yaml:"config"`
}

ServerPut represents the modifiable fields of a server configuration

swagger:model

type ServerUntrusted

type ServerUntrusted struct {
	ServerPut `yaml:",inline"`

	// Support status of the current API (one of "devel", "stable" or "deprecated")
	// Read only: true
	// Example: stable
	APIStatus string `json:"api_status" yaml:"api_status"`

	// API version number
	// Read only: true
	// Example: 1.0
	APIVersion string `json:"api_version" yaml:"api_version"`

	// Whether the client is trusted (one of "trusted" or "untrusted")
	// Read only: true
	// Example: untrusted
	Auth string `json:"auth" yaml:"auth"`

	// List of supported authentication methods
	// Read only: true
	// Example: ["tls"]
	//
	// API extension: macaroon_authentication
	AuthMethods []string `json:"auth_methods" yaml:"auth_methods"`
}

ServerUntrusted represents a server configuration for an untrusted client

swagger:model

type Source

type Source struct {
	SourcePut
	// SourceType defines the type of the source
	SourceType SourceType `json:"source_type" yaml:"source_type"`
}

Source defines properties common to all sources.

swagger:model

type SourcePut

type SourcePut struct {
	// A human-friendly name for this source
	// Example: MySource
	Name string `json:"name" yaml:"name"`

	// Properties contains source type specific properties
	Properties json.RawMessage `json:"properties" yaml:"properties"`
}

SourcePut defines the configurable properties of Source.

swagger:model

type SourceType

type SourceType string
const (
	SOURCETYPE_COMMON SourceType = "common"
	SOURCETYPE_VMWARE SourceType = "vmware"
)

type Target

type Target struct {
	TargetPut

	// TargetType defines the type of the target
	TargetType TargetType `json:"target_type" yaml:"target_type"`
}

Target defines properties common to all targets.

swagger:model

type TargetPut

type TargetPut struct {
	// A human-friendly name for this target
	// Example: MyTarget
	Name string `json:"name" yaml:"name"`

	// Properties contains target type specific properties
	Properties json.RawMessage `json:"properties" yaml:"properties"`
}

TargetPut defines the configurable properties of Target.

swagger:model

type TargetType

type TargetType string
const (
	TARGETTYPE_INCUS TargetType = "incus"
)

type VMwareProperties

type VMwareProperties struct {
	// Hostname or IP address of the source endpoint
	// Example: vsphere.local
	Endpoint string `json:"endpoint" yaml:"endpoint"`

	// Store the expected source's TLS certificate, in raw bytes. Useful in situations when TLS certificate validation fails, such as when using self-signed certificates.
	ServerCertificate []byte `json:"trusted_server_certificate,omitempty" yaml:"trusted_server_certificate,omitempty"`

	// If set and the fingerprint matches that of the ServerCertificate, enables use of that certificate when performing TLS handshake.
	// Example: b51b3046a03164a2ca279222744b12fe0878a8c12311c88fad427f4e03eca42d
	TrustedServerCertificateFingerprint string `json:"trusted_server_certificate_fingerprint,omitempty" yaml:"trusted_server_certificate_fingerprint,omitempty"`

	// Username to authenticate against the endpoint
	// Example: admin
	Username string `json:"username" yaml:"username"`

	// Password to authenticate against the endpoint
	// Example: password
	Password string `json:"password" yaml:"password"`

	// Connectivity status of this source
	ConnectivityStatus ExternalConnectivityStatus `json:"connectivity_status" yaml:"connectivity_status"`
}

VMwareProperties defines the set of VMware specific properties of an endpoint that the migration manager can connect to.

swagger:model

type WorkerCommand

type WorkerCommand struct {
	// The command for the worker to execute
	// Example: WORKERCOMMAND_IMPORT_DISKS
	Command WorkerCommandType `json:"command" yaml:"command"`

	// Internal path to the instance
	// Example: /SHF/vm/Migration Tests/DebianTest
	Location string `json:"location" yaml:"location"`

	// SourceType declares the type of the worker and is used as a hint to
	// correctly process the details provided in Source.
	SourceType SourceType `json:"sourceType" yaml:"sourceType"`

	// Source for the worker to fetch VM metadata and/or disk from.
	Source json.RawMessage `json:"source" yaml:"source"`

	// The name of the operating system
	// Example: Ubuntu
	OS string `json:"os" yaml:"os"`

	// The version of the operating system
	// Example: 24.04
	OSVersion string `json:"os_version" yaml:"os_version"`
}

WorkerCommand defines a command sent from the migration manager to a worker.

swagger:model

type WorkerCommandType

type WorkerCommandType int
const (
	WORKERCOMMAND_UNKNOWN WorkerCommandType = iota
	WORKERCOMMAND_IDLE
	WORKERCOMMAND_IMPORT_DISKS
	WORKERCOMMAND_FINALIZE_IMPORT
)

type WorkerResponse

type WorkerResponse struct {
	// The status of the command the work is/was executing.
	// Example: WORKERRESPONSE_RUNNING
	Status WorkerResponseType `json:"status" yaml:"status"`

	// A free-form string to provide additional information about the command status
	// Example: "Migration 25% complete"
	StatusMessage string `json:"status_message" yaml:"status_message"`
}

WorkerResponse defines a response received from a worker.

swagger:model

type WorkerResponseType

type WorkerResponseType int
const (
	WORKERRESPONSE_UNKNOWN WorkerResponseType = iota
	WORKERRESPONSE_RUNNING
	WORKERRESPONSE_SUCCESS
	WORKERRESPONSE_FAILED
)

Jump to

Keyboard shortcuts

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