instancemutater

package
v0.0.0-...-f88c608 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2025 License: AGPL-3.0 Imports: 23 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(registry facade.FacadeRegistry)

Register is called to expose a package of facades onto a given registry.

Types

type Application

type Application interface {
	CharmURL() *string
}

Application represents point of use methods from the state Application object.

type ApplicationService

type ApplicationService interface {
	// GetCharmLXDProfile returns the LXD profile along with the revision of the
	// charm using the charm name, source and revision.
	//
	// If the charm does not exist, a [applicationerrors.CharmNotFound] error is
	// returned.
	GetCharmLXDProfile(ctx context.Context, locator applicationcharm.CharmLocator) (charm.LXDProfile, applicationcharm.Revision, error)
	// WatchCharms returns a watcher that observes changes to charms.
	WatchCharms() (watcher.StringsWatcher, error)
}

ApplicationService is an interface for the application domain service.

type InstanceMutaterAPI

type InstanceMutaterAPI struct {
	*common.LifeGetter
	// contains filtered or unexported fields
}

func NewInstanceMutaterAPI

func NewInstanceMutaterAPI(
	st InstanceMutaterState,
	machineService MachineService,
	applicationService ApplicationService,
	watcher InstanceMutatorWatcher,
	resources facade.Resources,
	authorizer facade.Authorizer,
	logger logger.Logger,
) (*InstanceMutaterAPI, error)

NewInstanceMutaterAPI creates a new API server endpoint for managing charm profiles on juju lxd machines and containers.

func (*InstanceMutaterAPI) CharmProfilingInfo

func (api *InstanceMutaterAPI) CharmProfilingInfo(ctx context.Context, arg params.Entity) (params.CharmProfilingInfoResult, error)

CharmProfilingInfo returns info to update lxd profiles on the machine. If the machine is not provisioned, no profile change info will be returned, nor will an error.

func (*InstanceMutaterAPI) ContainerType

ContainerType returns the container type of a machine.

func (*InstanceMutaterAPI) SetCharmProfiles

func (api *InstanceMutaterAPI) SetCharmProfiles(ctx context.Context, args params.SetProfileArgs) (params.ErrorResults, error)

SetCharmProfiles records the given slice of charm profile names.

func (*InstanceMutaterAPI) SetModificationStatus

func (api *InstanceMutaterAPI) SetModificationStatus(ctx context.Context, args params.SetStatus) (params.ErrorResults, error)

SetModificationStatus updates the instance whilst changes are occurring. This is different from SetStatus and SetInstanceStatus, by the fact this holds information about the ongoing changes that are happening to instances. Consider LXD Profile updates that can modify a instance, but may not cause the instance to be placed into a error state. This modification status serves the purpose of highlighting that to the operator. Only machine tags are accepted.

func (*InstanceMutaterAPI) WatchContainers

func (api *InstanceMutaterAPI) WatchContainers(ctx context.Context, arg params.Entity) (params.StringsWatchResult, error)

WatchContainers starts a watcher to track Containers on a given machine.

func (*InstanceMutaterAPI) WatchLXDProfileVerificationNeeded

func (api *InstanceMutaterAPI) WatchLXDProfileVerificationNeeded(ctx context.Context, args params.Entities) (params.NotifyWatchResults, error)

WatchLXDProfileVerificationNeeded starts a watcher to track Applications with LXD Profiles.

func (*InstanceMutaterAPI) WatchMachines

func (api *InstanceMutaterAPI) WatchMachines(ctx context.Context) (params.StringsWatchResult, error)

WatchMachines starts a watcher to track machines. WatchMachines does not consume the initial event of the watch response, as that returns the initial set of machines that are currently available.

func (*InstanceMutaterAPI) WatchModelMachines

func (api *InstanceMutaterAPI) WatchModelMachines(ctx context.Context) (params.StringsWatchResult, error)

WatchModelMachines starts a watcher to track machines, but not containers. WatchModelMachines does not consume the initial event of the watch response, as that returns the initial set of machines that are currently available.

type InstanceMutaterState

type InstanceMutaterState interface {
	state.EntityFinder

	ModelName() (string, error)
	Application(appName string) (Application, error)
	Machine(id string) (Machine, error)
	Unit(unitName string) (Unit, error)
	ControllerTimestamp() (*time.Time, error)

	WatchMachines() state.StringsWatcher
	WatchModelMachines() state.StringsWatcher
	WatchApplicationCharms() state.StringsWatcher
	WatchUnits() state.StringsWatcher
}

InstanceMutaterState represents point of use methods from the state object.

type InstanceMutaterV2

type InstanceMutaterV2 interface {
	Life(ctx context.Context, args params.Entities) (params.LifeResults, error)

	CharmProfilingInfo(ctx context.Context, arg params.Entity) (params.CharmProfilingInfoResult, error)
	ContainerType(ctx context.Context, arg params.Entity) (params.ContainerTypeResult, error)
	SetCharmProfiles(ctx context.Context, args params.SetProfileArgs) (params.ErrorResults, error)
	SetModificationStatus(ctx context.Context, args params.SetStatus) (params.ErrorResults, error)
	WatchMachines(ctx context.Context) (params.StringsWatchResult, error)
	WatchLXDProfileVerificationNeeded(ctx context.Context, args params.Entities) (params.NotifyWatchResults, error)
}

InstanceMutaterV2 defines the methods on the instance mutater API facade, version 2.

type InstanceMutatorWatcher

type InstanceMutatorWatcher interface {
	WatchLXDProfileVerificationForMachine(context.Context, Machine, logger.Logger) (state.NotifyWatcher, error)
}

InstanceMutatorWatcher instances return a lxd profile watcher for a machine.

type Machine

type Machine interface {
	Id() string
	ContainerType() instance.ContainerType
	IsManual() (bool, error)
	SetModificationStatus(status.StatusInfo) error
	Units() ([]Unit, error)
	WatchContainers(instance.ContainerType) state.StringsWatcher
}

Machine represents point of use methods from the state Machine object.

type MachineLXDProfileWatcherConfig

type MachineLXDProfileWatcherConfig struct {
	// contains filtered or unexported fields
}

type MachineService

type MachineService interface {
	// GetMachineUUID returns the UUID of a machine identified by its name.
	GetMachineUUID(ctx context.Context, name coremachine.Name) (string, error)

	// InstanceID returns the cloud specific instance id for this machine.
	InstanceID(ctx context.Context, machineUUID string) (instance.Id, error)

	// AppliedLXDProfileNames returns the names of the LXD profiles on the machine.
	AppliedLXDProfileNames(ctx context.Context, machineUUID string) ([]string, error)

	// SetAppliedLXDProfileNames sets the list of LXD profile names to the
	// lxd_profile table for the given machine. This method will overwrite the list
	// of profiles for the given machine without any checks.
	SetAppliedLXDProfileNames(ctx context.Context, machineUUID string, profileNames []string) error

	// WatchLXDProfiles returns a NotifyWatcher that is subscribed to the changes in
	// the machine_cloud_instance table in the model, for the given machine UUID.
	WatchLXDProfiles(ctx context.Context, machineUUID string) (watcher.NotifyWatcher, error)
}

MachineService defines the methods that the facade assumes from the Machine service.

type Unit

type Unit interface {
	Name() string
	Life() state.Life
	ApplicationName() string
	Application() (Application, error)
	PrincipalName() (string, bool)
	AssignedMachineId() (string, error)
	CharmURL() *string
}

Unit represents a point of use methods from the state Unit object.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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