machinemanager

package
v0.0.0-...-0a271de 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: 40 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ClassifyDetachedStorage = storagecommon.ClassifyDetachedStorage

Functions

func InstanceConfig

func InstanceConfig(
	ctx context.Context,
	modelID coremodel.UUID,
	providerGetter func(context.Context) (environs.BootstrapEnviron, error),
	ctrlSt ControllerBackend,
	st InstanceConfigBackend,
	services InstanceConfigServices,
	machineId, nonce, dataDir string,
) (*instancecfg.InstanceConfig, error)

InstanceConfig returns information from the model config that is needed for configuring manual machines. It is exposed for testing purposes.

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
}

type Authorizer

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

	// CanWrite checks to see if a write is possible. Returns an error if a
	// write is not possible.
	CanWrite(context.Context) 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 {
	// Application returns a application state by name.
	Application(string) (Application, error)
	Machine(string) (Machine, error)
	AllMachines() ([]Machine, error)
	Unit(string) (Unit, error)
	AddOneMachine(template state.MachineTemplate) (Machine, error)
	AddMachineInsideNewMachine(template, parentTemplate state.MachineTemplate, containerType instance.ContainerType) (Machine, error)
	AddMachineInsideMachine(template state.MachineTemplate, parentId string, containerType instance.ContainerType) (Machine, error)
	ToolsStorage(objectstore.ObjectStore) (binarystorage.StorageCloser, error)
}

type BackendState

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

type BlockCommandService

type BlockCommandService interface {
	// GetBlockSwitchedOn returns the optional block message if it is switched
	// on for the given type.
	GetBlockSwitchedOn(ctx context.Context, t blockcommand.BlockType) (string, error)

	// GetBlocks returns all the blocks that are currently in place.
	GetBlocks(ctx context.Context) ([]blockcommand.Block, error)
}

BlockCommandService defines methods for interacting with block commands.

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 CloudService

type CloudService interface {
	// Cloud returns the named cloud.
	Cloud(ctx context.Context, name string) (*cloud.Cloud, error)
}

CloudService provides access to clouds.

type ControllerBackend

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

type ControllerConfigService

type ControllerConfigService interface {
	ControllerConfig(context.Context) (controller.Config, error)
}

ControllerConfigService defines a method for getting the controller config.

type InstanceConfigBackend

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

type InstanceConfigServices

type InstanceConfigServices struct {
	ControllerConfigService ControllerConfigService
	CloudService            common.CloudService
	KeyUpdaterService       KeyUpdaterService
	ModelConfigService      ModelConfigService
	MachineService          MachineService
	ObjectStore             objectstore.ObjectStore
}

InstanceConfigServices holds the services needed to configure instances.

type KeyUpdaterService

type KeyUpdaterService interface {
	// GetAuthorisedKeysForMachine returns the authorized keys that should be
	// allowed to access the given machine.
	GetAuthorisedKeysForMachine(context.Context, coremachine.Name) ([]string, error)
}

KeyUpdaterService is responsible for returning information about the ssh keys for a machine within a model.

type Leadership

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

	// UnpinApplicationLeadersByName takes a slice of application names and
	// attempts to unpin them accordingly.
	UnpinApplicationLeadersByName(context.Context, 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
	Destroy(objectstore.ObjectStore) error
	ForceDestroy(time.Duration) error
	Base() state.Base
	Containers() ([]string, error)
	Units() ([]Unit, error)
	Principals() []string
	IsManager() bool
	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 NewMachineManagerAPI

func NewMachineManagerAPI(
	model coremodel.ModelInfo,
	controllerConfigService ControllerConfigService,
	backend Backend,
	cloudService CloudService,
	machineService MachineService,
	store, controllerStore objectstore.ObjectStore,
	storageAccess StorageInterface,
	pool Pool,
	auth Authorizer,
	credentialInvalidatorGetter environscontext.ModelCredentialInvalidatorGetter,
	resources facade.Resources,
	leadership Leadership,
	logger corelogger.Logger,
	networkService NetworkService,
	keyUpdaterService KeyUpdaterService,
	modelConfigService ModelConfigService,
	blockCommandService BlockCommandService,
) *MachineManagerAPI

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

DestroyMachineWithParams removes a set of machines from the model.

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.

type MachineService

type MachineService interface {
	// CreateMachine creates a machine with the given name.
	CreateMachine(context.Context, coremachine.Name) (string, error)
	// DeleteMachine deletes a machine with the given name.
	DeleteMachine(context.Context, coremachine.Name) error
	// GetBootstrapEnviron returns the bootstrap environ.
	GetBootstrapEnviron(context.Context) (environs.BootstrapEnviron, error)
	// GetInstanceTypesFetcher returns the instance types fetcher.
	GetInstanceTypesFetcher(context.Context) (environs.InstanceTypesFetcher, error)
	// ShouldKeepInstance reports whether a machine, when removed from Juju, should cause
	// the corresponding cloud instance to be stopped.
	// It returns a NotFound if the given machine doesn't exist.
	ShouldKeepInstance(ctx context.Context, machineName coremachine.Name) (bool, error)
	// SetKeepInstance sets whether the machine cloud instance will be retained
	// when the machine is removed from Juju. This is only relevant if an instance
	// exists.
	// It returns a NotFound if the given machine doesn't exist.
	SetKeepInstance(ctx context.Context, machineName coremachine.Name, keep bool) error
	// GetMachineUUID returns the UUID of a machine identified by its name.
	GetMachineUUID(ctx context.Context, name coremachine.Name) (string, error)
	// HardwareCharacteristics returns the hardware characteristics of the
	// specified machine.
	HardwareCharacteristics(ctx context.Context, machineUUID string) (*instance.HardwareCharacteristics, error)
}

MachineService is the interface that is used to interact with the machines.

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(ctx context.Context) 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(ctx context.Context) error

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

type ModelConfigService

type ModelConfigService interface {
	// ModelConfig provides the currently set model config for the model.
	ModelConfig(context.Context) (*config.Config, error)
}

ModelConfigService is responsible for providing an accessor to the models config.

type NetworkService

type NetworkService interface {
	// GetAllSpaces returns all spaces for the model.
	GetAllSpaces(ctx context.Context) (network.SpaceInfos, error)
}

NetworkService is the interface that is used to interact with the network spaces/subnets.

type Pool

type Pool interface {
	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)
}

Jump to

Keyboard shortcuts

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