machinemanager

package
v0.0.0-...-a753888 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: AGPL-3.0 Imports: 38 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ClassifyDetachedStorage = storagecommon.ClassifyDetachedStorage

Functions

func InstanceConfig

func InstanceConfig(ctrlSt ControllerBackend, st InstanceConfigBackend, machineId, nonce, dataDir string) (*instancecfg.InstanceConfig, error)

InstanceConfig returns information from the model config that is needed for machine cloud-init (for non-controllers only). It is exposed for testing purposes. TODO(rog) fix environs/manual tests so they do not need to call this, or move this elsewhere.

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 {
	Name() string
	Charm() (Charm, bool, error)
	CharmOrigin() *state.CharmOrigin
}

type ApplicationValidator

type ApplicationValidator interface {
	// ValidateApplications attempts to validate a series of applications for
	// a given series. Using force to allow the overriding of the error to
	// ensure all applications validate.
	//
	// I do question if you actually need to validate anything if force is
	// employed here?
	ValidateApplications(applications []Application, base corebase.Base, force bool) error
}

ApplicationValidator defines an application validator. It aims to just validate a series of applications for a set series.

type Authorizer

type Authorizer interface {
	// CanRead checks to see if a read is possible. Returns an error if a read
	// is not possible.
	CanRead() error

	// CanWrite checks to see if a write is possible. Returns an error if a
	// write is not possible.
	CanWrite() error

	// AuthClient returns true if the entity is an external user.
	AuthClient() bool
}

Authorizer checks to see if an operation can be performed.

type Backend

type Backend interface {
	network.SpaceLookup

	// Application returns a application state by name.
	Application(string) (Application, error)
	Machine(string) (Machine, error)
	AllMachines() ([]Machine, error)
	Unit(string) (Unit, error)
	Model() (Model, error)
	GetBlockForType(t state.BlockType) (state.Block, bool, error)
	AddOneMachine(template state.MachineTemplate) (*state.Machine, error)
	AddMachineInsideNewMachine(template, parentTemplate state.MachineTemplate, containerType instance.ContainerType) (*state.Machine, error)
	AddMachineInsideMachine(template state.MachineTemplate, parentId string, containerType instance.ContainerType) (*state.Machine, error)
	ToolsStorage() (binarystorage.StorageCloser, error)
}

func StateBackend

func StateBackend(st *state.State) Backend

StateBackend wraps a state. TODO(juju3) - move to export_test It's here because we need to for the client facade for backwards compatibility.

type BackendState

type BackendState interface {
	Backend
	MachineFromTag(string) (Machine, error)
}

type Charm

type Charm interface {
	Meta() *charm.Meta
	Manifest() *charm.Manifest
}

type CharmhubClient

type CharmhubClient interface {
	Refresh(ctx context.Context, config charmhub.RefreshConfig) ([]transport.RefreshResponse, error)
}

CharmhubClient represents a way for querying the charmhub api for information about the application charm.

type ControllerBackend

type ControllerBackend interface {
	ControllerTag() names.ControllerTag
	ControllerConfig() (controller.Config, error)
	APIHostPortsForAgents() ([]network.SpaceHostPorts, error)
}

type InstanceConfigBackend

type InstanceConfigBackend interface {
	Model() (Model, error)
	Machine(string) (Machine, error)
	ToolsStorage() (binarystorage.StorageCloser, error)
}

type Leadership

type Leadership interface {
	// GetMachineApplicationNames returns the applications associated with a
	// machine.
	GetMachineApplicationNames(string) ([]string, error)

	// UnpinApplicationLeadersByName takes a slice of application names and
	// attempts to unpin them accordingly.
	UnpinApplicationLeadersByName(names.Tag, []string) (params.PinApplicationsResults, error)
}

Leadership represents a type for modifying the leadership settings of an application for series upgrades.

type Machine

type Machine interface {
	Id() string
	Tag() names.Tag
	SetPassword(string) error
	HardwareCharacteristics() (*instance.HardwareCharacteristics, error)
	Destroy() error
	ForceDestroy(time.Duration) error
	Base() state.Base
	Containers() ([]string, error)
	Units() ([]Unit, error)
	SetKeepInstance(keepInstance bool) error
	CreateUpgradeSeriesLock([]string, state.Base) error
	RemoveUpgradeSeriesLock() error
	CompleteUpgradeSeries() error
	Principals() []string
	WatchUpgradeSeriesNotifications() (state.NotifyWatcher, error)
	GetUpgradeSeriesMessages() ([]string, bool, error)
	IsManager() bool
	IsLockedForSeriesUpgrade() (bool, error)
	UpgradeSeriesStatus() (model.UpgradeSeriesStatus, error)
	SetUpgradeSeriesStatus(model.UpgradeSeriesStatus, string) error
	ApplicationNames() ([]string, error)
	InstanceStatus() (status.StatusInfo, error)
	SetInstanceStatus(sInfo status.StatusInfo) error
}

type MachineManagerAPI

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

MachineManagerAPI provides access to the MachineManager API facade.

func NewFacadeV10

func NewFacadeV10(ctx facade.Context) (*MachineManagerAPI, error)

NewFacadeV10 create a new server-side MachineManager API facade. This is used for facade registration.

func NewMachineManagerAPI

func NewMachineManagerAPI(
	backend Backend,
	storageAccess StorageInterface,
	pool Pool,
	auth Authorizer,
	callCtx environscontext.ProviderCallContext,
	resources facade.Resources,
	leadership Leadership,
	charmhubClient CharmhubClient,
) (*MachineManagerAPI, error)

NewMachineManagerAPI creates a new server-side MachineManager API facade.

func (*MachineManagerAPI) AddMachines

AddMachines adds new machines with the supplied parameters. The args will contain Base info.

func (*MachineManagerAPI) DestroyMachineWithParams

func (mm *MachineManagerAPI) DestroyMachineWithParams(args params.DestroyMachinesParams) (params.DestroyMachineResults, error)

DestroyMachineWithParams removes a set of machines from the model.

func (*MachineManagerAPI) GetUpgradeSeriesMessages

GetUpgradeSeriesMessages returns all new messages associated with upgrade series events. Messages that have already been retrieved once are not returned by this method.

func (*MachineManagerAPI) InstanceTypes

InstanceTypes returns instance type information for the cloud and region in which the current model is deployed.

func (*MachineManagerAPI) ProvisioningScript

ProvisioningScript returns a shell script that, when run, provisions a machine agent on the machine executing the script.

func (*MachineManagerAPI) RetryProvisioning

RetryProvisioning marks a provisioning error as transient on the machines.

func (*MachineManagerAPI) UpgradeSeriesComplete

func (mm *MachineManagerAPI) UpgradeSeriesComplete(arg params.UpdateChannelArg) (params.ErrorResult, error)

UpgradeSeriesComplete marks a machine as having completed a managed series upgrade.

func (*MachineManagerAPI) UpgradeSeriesPrepare

func (mm *MachineManagerAPI) UpgradeSeriesPrepare(arg params.UpdateChannelArg) (params.ErrorResult, error)

UpgradeSeriesPrepare prepares a machine for a OS series upgrade.

func (*MachineManagerAPI) UpgradeSeriesValidate

func (mm *MachineManagerAPI) UpgradeSeriesValidate(
	args params.UpdateChannelArgs,
) (params.UpgradeSeriesUnitsResults, error)

UpgradeSeriesValidate validates that the incoming arguments correspond to a valid series upgrade for the target machine. If they do, a list of the machine's current units is returned for use in soliciting user confirmation of the command.

func (*MachineManagerAPI) WatchUpgradeSeriesNotifications

func (mm *MachineManagerAPI) WatchUpgradeSeriesNotifications(args params.Entities) (params.NotifyWatchResults, error)

WatchUpgradeSeriesNotifications returns a watcher that fires on upgrade series events.

type MachineManagerV9

type MachineManagerV9 struct {
	*MachineManagerAPI
}

func NewFacadeV9

func NewFacadeV9(ctx facade.Context) (*MachineManagerV9, error)

NewFacadeV9 create a new server-side MachineManager API facade. This is used for facade registration.

func (*MachineManagerV9) DestroyMachineWithParams

func (mm *MachineManagerV9) DestroyMachineWithParams(args params.DestroyMachinesParamsV9) (params.DestroyMachineResults, error)

DestroyMachineWithParams removes a set of machines from the model.

type Model

type Model interface {
	Name() string
	UUID() string
	ModelTag() names.ModelTag
	ControllerUUID() string
	Type() state.ModelType
	Cloud() (cloud.Cloud, error)
	CloudCredential() (state.Credential, bool, error)
	CloudRegion() string
	Config() (*config.Config, error)
}

type ModelAuthorizer

type ModelAuthorizer struct {
	ModelTag   names.ModelTag
	Authorizer facade.Authorizer
}

ModelAuthorizer defines if a given operation can be performed based on a model tag.

func (ModelAuthorizer) AuthClient

func (a ModelAuthorizer) AuthClient() bool

AuthClient returns true if the entity is an external user.

func (ModelAuthorizer) CanRead

func (a ModelAuthorizer) CanRead() error

CanRead checks to see if a read is possible. Returns an error if a read is not possible.

func (ModelAuthorizer) CanWrite

func (a ModelAuthorizer) CanWrite() error

CanWrite checks to see if a write is possible. Returns an error if a write is not possible.

type Pool

type Pool interface {
	GetModel(string) (Model, func(), error)
	SystemState() (ControllerBackend, error)
}

type StorageInterface

type StorageInterface interface {
	storagecommon.StorageAccess
	VolumeAccess() storagecommon.VolumeAccess
	FilesystemAccess() storagecommon.FilesystemAccess
}

type Unit

type Unit interface {
	UnitTag() names.UnitTag
	Name() string
	AgentStatus() (status.StatusInfo, error)
	Status() (status.StatusInfo, error)
}

type UpgradeBaseValidator

type UpgradeBaseValidator interface {
	ApplicationValidator

	// ValidateBase validates a given requested base against the current
	// machine base.
	// The machine tag is currently used for descriptive information and could
	// be deprecated in reality.
	ValidateBase(requestedBase, machineBase corebase.Base, machineTag string) error

	// ValidateMachine validates a given machine for ensuring it meets a given
	// state (quiescence essentially) and has no current ongoing machine lock.
	ValidateMachine(Machine) error

	// ValidateUnits validates a given set of units.
	ValidateUnits([]Unit) error
}

UpgradeBaseValidator defines a set of validators for the upgrade series scenarios.

type UpgradeSeries

type UpgradeSeries interface {

	// Validate validates that the incoming arguments correspond to a
	// valid series upgrade for the target machine.
	// If they do, a list of the machine's current units is returned for use in
	// soliciting user confirmation of the command.
	Validate([]ValidationEntity) ([]ValidationResult, error)

	// Prepare attempts to prepare a machine for a OS series upgrade.
	// It is expected that a validate call has been performed before the prepare
	// step.
	Prepare(string, string, bool) error

	// Complete will complete the upgrade series.
	Complete(string) error
}

UpgradeSeries defines an interface for interacting with upgrading a series.

type UpgradeSeriesAPI

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

UpgradeSeriesAPI provides the upgrade series API facade for any given version. It is expected that any API parameter changes should be performed before entering the API.

func NewUpgradeSeriesAPI

func NewUpgradeSeriesAPI(
	state UpgradeSeriesState,
	validator UpgradeBaseValidator,
	authorizer Authorizer,
) *UpgradeSeriesAPI

NewUpgradeSeriesAPI creates a new UpgradeSeriesAPI

func (*UpgradeSeriesAPI) Complete

func (a *UpgradeSeriesAPI) Complete(tag string) error

func (*UpgradeSeriesAPI) Prepare

func (a *UpgradeSeriesAPI) Prepare(tag, channel string, force bool) (retErr error)

func (*UpgradeSeriesAPI) Validate

func (a *UpgradeSeriesAPI) Validate(entities []ValidationEntity) ([]ValidationResult, error)

Validate validates that the incoming arguments correspond to a valid series upgrade for the target machine. If they do, a list of the machine's current units is returned for use in soliciting user confirmation of the command.

type UpgradeSeriesState

type UpgradeSeriesState interface {
	// MachineFromTag returns a machine from a given tag.
	// Returns an error if the machine is not found.
	MachineFromTag(string) (Machine, error)

	// ApplicationsFromMachine returns a list of all the applications for a
	// given machine. This includes all the subordinates.
	ApplicationsFromMachine(Machine) ([]Application, error)
}

UpgradeSeriesState defines a common set of functions for retrieving state objects.

type ValidationEntity

type ValidationEntity struct {
	Tag     string
	Channel string
	Force   bool
}

ValidationEntity defines a type that requires validation.

type ValidationResult

type ValidationResult struct {
	Error     error
	UnitNames []string
}

ValidationResult defines the result of the validation.

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