api

package
v0.0.0-pre.4 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2025 License: Apache-2.0 Imports: 11 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 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 string `json:"min_instance_boot_time" yaml:"min_instance_boot_time"`
}

BatchConstraint is a constraint to be applied to a batch to determine which instances can be migrated.

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"`

	// PostMigrationRetries is the maximum number of times post-migration steps will be retried upon errors.
	// Example: 5
	PostMigrationRetries int `json:"post_migration_retries" yaml:"post_migration_retries"`

	// Set of migration window timings.
	MigrationWindows []MigrationWindow `json:"migration_windows" yaml:"migration_windows"`

	// Set of constraints to apply to the batch.
	Constraints []BatchConstraint `json:"constraints" yaml:"constraints"`

	// Time in UTC when the batch was started.
	StartDate time.Time `json:"start_date" yaml:"start_date"`
}

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"`

	// Maximum number of concurrent imports that can occur
	// Example: 10
	ImportLimit int `json:"import_limit,omitempty" yaml:"import_limit,omitempty"`

	// Maximum number of concurrent instance creations that can occur
	// Example: 10
	CreateLimit int `json:"create_limit,omitempty" yaml:"create_limit,omitempty"`
}

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 originating source name for this instance
	// Example: MySource
	Source string `json:"source" yaml:"source"`

	SourceType SourceType `json:"source_type" yaml:"source_type"`

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

	LastUpdateFromSource time.Time `json:"last_update_from_source" yaml:"last_update_from_source"`

	// 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 {
	// 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"`

	// If true, restrictions that put the VM in a blocked state, preventing migration, will be ignored.
	// Example: true
	IgnoreRestrictions bool `json:"ignore_restrictions" yaml:"ignore_restrictions"`

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

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

swagger:model

type InstanceProperties

type InstanceProperties struct {
	InstancePropertiesConfigurable

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

	NICs      []InstancePropertiesNIC      `json:"nics"      yaml:"nics"      expr:"nics"`
	Disks     []InstancePropertiesDisk     `json:"disks"     yaml:"disks"     expr:"disks"`
	Snapshots []InstancePropertiesSnapshot `json:"snapshots" yaml:"snapshots" expr:"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" expr:"description"`
	CPUs        int64             `json:"cpus"                  yaml:"cpus"                  expr:"cpus"`
	Memory      int64             `json:"memory"                yaml:"memory"                expr:"memory"`
	Config      map[string]string `json:"config"                yaml:"config"                expr:"config"`
}

InstancePropertiesConfigurable are the configurable properties of an instance.

type InstancePropertiesDisk

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

InstancePropertiesDisk are all properties supported by instance disks.

type InstancePropertiesNIC

type InstancePropertiesNIC struct {
	ID              string `json:"id"               yaml:"id"               expr:"id"`
	HardwareAddress string `json:"hardware_address" yaml:"hardware_address" expr:"hardware_address"`
	Network         string `json:"network"          yaml:"network"          expr:"network"`
	IPv4Address     string `json:"ipv4_address"     yaml:"ipv4_address"     expr:"ipv4_address"`
	IPv6Address     string `json:"ipv6_address"     yaml:"ipv6_address"     expr:"ipv6_address"`
}

InstancePropertiesNIC are all properties supported by instance NICs.

type InstancePropertiesSnapshot

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

InstancePropertiesSnapshot are all properties supported by snapshots.

type MigrationStatusType

type MigrationStatusType string
const (
	MIGRATIONSTATUS_WAITING           MigrationStatusType = "Waiting"
	MIGRATIONSTATUS_CREATING          MigrationStatusType = "Creating new VM"
	MIGRATIONSTATUS_BLOCKED           MigrationStatusType = "Blocked"
	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"
)

func (MigrationStatusType) Validate

func (m MigrationStatusType) Validate() error

Validate ensures the MigrationStatusType is valid.

type MigrationWindow

type MigrationWindow struct {
	// Start time for finalizing migrations after background import.
	Start time.Time `json:"start" yaml:"start"`

	// End time for finalizing migrations after background import.
	End time.Time `json:"end" yaml:"end"`

	// Lockout time after which the batch can no longer modify the target instance.
	Lockout time.Time `json:"lockout" yaml:"lockout"`
}

MigrationWindow defines the scheduling of a batch migration.

type Network

type Network struct {
	NetworkOverride

	// The identifier of the network
	// Example: network-23
	Identifier string `json:"identifier" yaml:"identifier"`

	// vCenter source for the network
	// Example: vcenter01
	Source string `json:"source" yaml:"source"`

	// Type of the network
	// Example: standard
	Type NetworkType `json:"type" yaml:"type"`

	// Full inventory location path of the network
	// Example: /vcenter01/network/net0
	Location string `json:"location" yaml:"location"`

	// Additional properties of the network.
	Properties json.RawMessage `json:"properties" yaml:"properties"`
}

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

swagger:model

func (Network) Name

func (n Network) Name() string

Name returns the overrided network name, or transforms the default name into an API compatible one.

type NetworkOverride

type NetworkOverride struct {
	// Name of the network on the target.
	// Example: "vmware"
	Name string `json:"name" yaml:"name"`

	// Name of the parent bridge to use with a VLAN.
	// Example: br0
	BridgeName string `json:"bridge_name" yaml:"bridge_name"`
}

NetworkOverride defines the configurable properties of Network.

swagger:model

type NetworkType

type NetworkType string
const (
	// NETWORKTYPE_VMWARE_STANDARD is a standard vCenter switch-backed port group.
	NETWORKTYPE_VMWARE_STANDARD NetworkType = "standard"

	// NETWORKTYPE_VMWARE_DISTRIBUTED is a distributed port group backed by a vCenter distributed switch.
	NETWORKTYPE_VMWARE_DISTRIBUTED NetworkType = "distributed"

	// NETWORKTYPE_VMWARE_DISTRIBUTED_NSX is a distributed port group backed by NSX.
	NETWORKTYPE_VMWARE_DISTRIBUTED_NSX NetworkType = "nsx-distributed"

	// NETWORKTYPE_VMWARE_NSX is an opaque network managed by NSX.
	NETWORKTYPE_VMWARE_NSX NetworkType = "nsx"
)

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"`

	// Time in UTC that the queue entry received a response from the migration worker
	LastWorkerResponse time.Time
}

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"
	SOURCETYPE_NSX    SourceType = "nsx"
)

func NetworkSourceTypes

func NetworkSourceTypes() []SourceType

NetworkSourceTypes are the list of source types that manage networks.

func VMSourceTypes

func VMSourceTypes() []SourceType

VMSourceTypes are the list of source types that manage VMs.

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"`

	// Maximum number of concurrent imports that can occur
	// Example: 10
	ImportLimit int `json:"import_limit,omitempty" yaml:"import_limit,omitempty"`
}

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