target

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: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InternalIncusTarget

type InternalIncusTarget struct {
	InternalTarget      `yaml:",inline"`
	api.IncusProperties `yaml:",inline"`
	// contains filtered or unexported fields
}

func NewInternalIncusTargetFrom

func NewInternalIncusTargetFrom(apiTarget api.Target) (*InternalIncusTarget, error)

func (*InternalIncusTarget) Connect

func (t *InternalIncusTarget) Connect(ctx context.Context) error

func (*InternalIncusTarget) CreateNewVM

func (t *InternalIncusTarget) CreateNewVM(apiDef incusAPI.InstancesPost, storagePool string, bootISOImage string, driversISOImage string) error

func (*InternalIncusTarget) CreateStoragePoolVolumeFromISO

func (t *InternalIncusTarget) CreateStoragePoolVolumeFromISO(pool string, isoFilePath string) (incus.Operation, error)

func (*InternalIncusTarget) CreateVMDefinition

func (t *InternalIncusTarget) CreateVMDefinition(instanceDef migration.Instance, sourceName string, storagePool string) incusAPI.InstancesPost

func (*InternalIncusTarget) DeleteVM

func (t *InternalIncusTarget) DeleteVM(name string) error

func (*InternalIncusTarget) Disconnect

func (t *InternalIncusTarget) Disconnect(ctx context.Context) error

func (*InternalIncusTarget) ExecWithoutWaiting

func (t *InternalIncusTarget) ExecWithoutWaiting(instanceName string, cmd []string) error

func (*InternalIncusTarget) GetInstance

func (t *InternalIncusTarget) GetInstance(name string) (*incusAPI.Instance, string, error)

func (*InternalIncusTarget) GetProperties

func (t *InternalIncusTarget) GetProperties() json.RawMessage

func (*InternalIncusTarget) GetStoragePoolVolume

func (t *InternalIncusTarget) GetStoragePoolVolume(pool string, volType string, name string) (*incusAPI.StorageVolume, string, error)

func (*InternalIncusTarget) PushFile

func (t *InternalIncusTarget) PushFile(instanceName string, file string, destDir string) error

func (*InternalIncusTarget) SetClientTLSCredentials

func (t *InternalIncusTarget) SetClientTLSCredentials(key string, cert string) error

func (*InternalIncusTarget) SetInsecureTLS

func (t *InternalIncusTarget) SetInsecureTLS(insecure bool) error

func (*InternalIncusTarget) SetProject

func (t *InternalIncusTarget) SetProject(project string) error

func (*InternalIncusTarget) StartVM

func (t *InternalIncusTarget) StartVM(name string) error

func (*InternalIncusTarget) StopVM

func (t *InternalIncusTarget) StopVM(name string, force bool) error

func (*InternalIncusTarget) UpdateInstance

func (t *InternalIncusTarget) UpdateInstance(name string, instanceDef incusAPI.InstancePut, ETag string) (incus.Operation, error)

type InternalTarget

type InternalTarget struct {
	api.Target `yaml:",inline"`
	// contains filtered or unexported fields
}

func (*InternalTarget) Connect

func (t *InternalTarget) Connect(ctx context.Context) error

func (*InternalTarget) CreateNewVM

func (t *InternalTarget) CreateNewVM(apiDef incusAPI.InstancesPost, storagePool string, bootISOImage string, driversISOImage string) error

func (*InternalTarget) CreateStoragePoolVolumeFromISO

func (t *InternalTarget) CreateStoragePoolVolumeFromISO(pool string, isoFilePath string) (incus.Operation, error)

func (*InternalTarget) CreateVMDefinition

func (t *InternalTarget) CreateVMDefinition(instanceDef migration.Instance, sourceName string, storagePool string) incusAPI.InstancesPost

func (*InternalTarget) DeleteVM

func (t *InternalTarget) DeleteVM(name string) error

func (*InternalTarget) Disconnect

func (t *InternalTarget) Disconnect(ctx context.Context) error

func (*InternalTarget) ExecWithoutWaiting

func (t *InternalTarget) ExecWithoutWaiting(instanceName string, cmd []string) error

func (*InternalTarget) GetDatabaseID

func (t *InternalTarget) GetDatabaseID() (int, error)

func (*InternalTarget) GetInstance

func (t *InternalTarget) GetInstance(name string) (*api.Instance, string, error)

func (*InternalTarget) GetName

func (t *InternalTarget) GetName() string

func (*InternalTarget) GetProperties

func (t *InternalTarget) GetProperties() json.RawMessage

func (*InternalTarget) GetStoragePoolVolume

func (t *InternalTarget) GetStoragePoolVolume(pool string, volType string, name string) (*incusAPI.StorageVolume, string, error)

func (*InternalTarget) IsConnected

func (t *InternalTarget) IsConnected() bool

func (*InternalTarget) PushFile

func (t *InternalTarget) PushFile(instanceName string, file string, destDir string) error

func (*InternalTarget) SetClientTLSCredentials

func (t *InternalTarget) SetClientTLSCredentials(key string, cert string) error

func (*InternalTarget) SetInsecureTLS

func (t *InternalTarget) SetInsecureTLS(insecure bool) error

func (*InternalTarget) SetProject

func (t *InternalTarget) SetProject(project string) error

func (*InternalTarget) StartVM

func (t *InternalTarget) StartVM(name string) error

func (*InternalTarget) StopVM

func (t *InternalTarget) StopVM(name string, force bool) error

func (*InternalTarget) UpdateInstance

func (t *InternalTarget) UpdateInstance(name string, instanceDef incusAPI.InstancePut, ETag string) (incus.Operation, error)

func (*InternalTarget) WithAdditionalRootCertificate

func (t *InternalTarget) WithAdditionalRootCertificate(rootCert *tls.Certificate)

type Target

type Target interface {
	// Connects to the target.
	//
	// Prior to calling Connect(), set any other configuration required, such as the client's TLS
	// credentials if not using OIDC authentication.
	//
	// Returns an error if unable to connect (unable to reach remote host, bad credentials, etc).
	Connect(ctx context.Context) error

	// Disconnects from the target.
	//
	// Returns an error if there was a problem disconnecting from the target.
	Disconnect(ctx context.Context) error

	// Toggles whether TLS verification should be skipped or not.
	//
	// As this can enable MITM-style attacks, in general this SHOULD NOT be used.
	//
	// Returns an error if called while connected to a target.
	SetInsecureTLS(insecure bool) error

	// WithAdditionalRootCertificate accepts an additional certificate, which
	// is added to the default CertPool used to validate server certificates
	// while connecting to the Target using TLS.
	WithAdditionalRootCertificate(rootCert *tls.Certificate)

	// Sets the client TLS key and certificate to be used to authenticate with the target. Leave unset to
	// default to OIDC authentication.
	//
	// The key/cert pair can be generated with a command like
	// `openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:secp384r1 -sha384 -keyout "client.key" -nodes -out "client.crt" -days 365 -subj "/"`.
	// The resulting certificate can then be imported on the target instance with
	// `incus config trust add-certificate <client.crt>`.
	//
	// Returns an error if called while connected to a target.
	SetClientTLSCredentials(key string, cert string) error

	// Returns whether currently connected to the target or not.
	IsConnected() bool

	// Returns the human-readable name for this target.
	GetName() string

	// Returns a unique ID for this target that can be used when interacting with the database.
	//
	// Attempting to get an ID for a freshly-created target that hasn't yet been added to the database
	// via AddTarget() or retrieved via GetTarget()/GetAllTargets() will return an error.
	GetDatabaseID() (int, error)

	// Returns the json-encoded type specific properties for this target.
	GetProperties() json.RawMessage

	// Selects the Incus project to use when performing actions on the target.
	//
	// Returns an error if called while disconnected from a target.
	SetProject(project string) error

	// Creates a VM definition for use with the Incus REST API.
	CreateVMDefinition(instanceDef migration.Instance, sourceName string, storagePool string) api.InstancesPost

	// Creates a new VM from the pre-populated API definition.
	CreateNewVM(apiDef api.InstancesPost, storagePool string, bootISOImage string, driversISOImage string) error

	// Deletes a VM.
	DeleteVM(name string) error

	// Starts a VM.
	StartVM(name string) error

	// Stops a VM.
	StopVM(name string, force bool) error

	// Push a file into a running instance.
	PushFile(instanceName string, file string, destDir string) error

	// Run a command within an instance and return immediately without waiting for it to complete.
	ExecWithoutWaiting(instanceName string, cmd []string) error

	// Wrapper around Incus' GetInstance method.
	GetInstance(name string) (*api.Instance, string, error)

	// Wrapper around Incus' UpdateInstance method.
	UpdateInstance(name string, instanceDef api.InstancePut, ETag string) (incus.Operation, error)

	// Wrapper around Incus' GetStoragePoolVolume method.
	GetStoragePoolVolume(pool string, volType string, name string) (*api.StorageVolume, string, error)

	// Wrapper around Incus' CreateStoragePoolVolumeFromISO.
	CreateStoragePoolVolumeFromISO(pool string, isoFilePath string) (incus.Operation, error)
}

Interface definition for all migration manager targets.

Jump to

Keyboard shortcuts

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