machinemanager

package
v0.0.0-...-9ec3720 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2021 License: AGPL-3.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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, series string, 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)
	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)
}

type BackendState

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

type Charm

type Charm interface {
	URL() *charm.URL
	Meta() CharmMeta
	String() string
}

type CharmMeta

type CharmMeta interface {
	ComputedSeries() []string
}

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 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
	Destroy() error
	ForceDestroy(time.Duration) error
	Series() string
	Units() ([]Unit, error)
	SetKeepInstance(keepInstance bool) error
	CreateUpgradeSeriesLock([]string, string) 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)
}

type MachineManagerAPI

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

MachineManagerAPI provides access to the MachineManager API facade.

func NewFacade

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

NewFacade 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.

func (*MachineManagerAPI) DestroyMachine

func (mm *MachineManagerAPI) DestroyMachine(args params.Entities) (params.DestroyMachineResults, error)

DestroyMachine removes a set of machines from the model.

func (*MachineManagerAPI) DestroyMachineWithParams

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

DestroyMachineWithParams removes a set of machines from the model.

func (*MachineManagerAPI) ForceDestroyMachine

func (mm *MachineManagerAPI) ForceDestroyMachine(args params.Entities) (params.DestroyMachineResults, error)

ForceDestroyMachine forcibly removes a set of machines from the model. TODO (anastasiamac 2019-4-24) From Juju 3.0 this call will be removed in favour of DestroyMachinesWithParams. Also from ModelManger v6 this call is less useful as it does not support MaxWait customisation.

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) UpgradeSeriesComplete

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

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

func (*MachineManagerAPI) UpgradeSeriesPrepare

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

UpgradeSeriesPrepare prepares a machine for a OS series upgrade.

func (*MachineManagerAPI) UpgradeSeriesValidate

func (mm *MachineManagerAPI) UpgradeSeriesValidate(
	args params.UpdateSeriesArgs,
) (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 MachineManagerAPIV4

type MachineManagerAPIV4 struct {
	*MachineManagerAPIV5
}

MachineManagerAPIV4 defines the Version 4 of MachineManagerAPI

func NewFacadeV4

func NewFacadeV4(ctx facade.Context) (*MachineManagerAPIV4, error)

NewFacadeV4 creates a new server-side MachineManager API facade.

func (*MachineManagerAPIV4) UpdateMachineSeries

func (mm *MachineManagerAPIV4) UpdateMachineSeries(_ params.UpdateSeriesArgs) (params.ErrorResults, error)

UpdateMachineSeries returns an error. DEPRECATED

type MachineManagerAPIV5

type MachineManagerAPIV5 struct {
	*MachineManagerAPIV6
}

MachineManagerAPIV5 defines the Version 5 of Machine Manager API. Adds CreateUpgradeSeriesLock and removes UpdateMachineSeries.

func NewFacadeV5

func NewFacadeV5(ctx facade.Context) (*MachineManagerAPIV5, error)

NewFacadeV5 creates a new server-side MachineManager API facade.

func (*MachineManagerAPIV5) DestroyMachineWithParams

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

DestroyMachineWithParams removes a set of machines from the model. v5 and prior versions did not support MaxWait.

type MachineManagerAPIV6

type MachineManagerAPIV6 struct {
	*MachineManagerAPI
}

MachineManagerAPIV6 defines the Version 6 of Machine Manager API. Changes input parameters to DestroyMachineWithParams and ForceDestroyMachine.

func NewFacadeV6

func NewFacadeV6(ctx facade.Context) (*MachineManagerAPIV6, error)

NewFacadeV6 creates a new server-side MachineManager API facade.

type Model

type Model interface {
	Name() string
	UUID() string
	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)
}

type Unit

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

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 UpgradeSeriesValidator,
	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, series 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 UpgradeSeriesValidator

type UpgradeSeriesValidator interface {
	ApplicationValidator

	// ValidateSeries validates a given requested series against the current
	// machine series.
	// The machine tag is currently used for descriptive information and could
	// be deprecated in reality.
	ValidateSeries(requestedSeries, machineSeries, 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
}

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

type ValidationEntity

type ValidationEntity struct {
	Tag    string
	Series 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