Documentation
¶
Index ¶
- type Provider
- type ProviderService
- type Service
- func (s *Service) AllMachineNames(ctx context.Context) ([]machine.Name, error)
- func (s *Service) AppliedLXDProfileNames(ctx context.Context, mUUID string) ([]string, error)
- func (s *Service) AvailabilityZone(ctx context.Context, machineUUID string) (string, error)
- func (s *Service) ClearMachineReboot(ctx context.Context, uuid string) error
- func (s *Service) CreateMachine(ctx context.Context, machineName machine.Name) (string, error)
- func (s *Service) CreateMachineWithParent(ctx context.Context, machineName, parentName machine.Name) (string, error)
- func (s *Service) DeleteMachine(ctx context.Context, machineName machine.Name) error
- func (s *Service) DeleteMachineCloudInstance(ctx context.Context, machineUUID string) error
- func (s *Service) EnsureDeadMachine(ctx context.Context, machineName machine.Name) error
- func (s *Service) GetAllMachineRemovals(ctx context.Context) ([]string, error)
- func (s *Service) GetInstanceStatus(ctx context.Context, machineName machine.Name) (status.StatusInfo, error)
- func (s *Service) GetMachineLife(ctx context.Context, machineName machine.Name) (*life.Life, error)
- func (s *Service) GetMachineParentUUID(ctx context.Context, machineUUID string) (string, error)
- func (s *Service) GetMachineStatus(ctx context.Context, machineName machine.Name) (status.StatusInfo, error)
- func (s *Service) GetMachineUUID(ctx context.Context, name machine.Name) (string, error)
- func (s *Service) HardwareCharacteristics(ctx context.Context, machineUUID string) (*instance.HardwareCharacteristics, error)
- func (s *Service) InstanceID(ctx context.Context, machineUUID string) (instance.Id, error)
- func (s *Service) InstanceIDAndName(ctx context.Context, machineUUID string) (instance.Id, string, error)
- func (s *Service) IsMachineController(ctx context.Context, machineName machine.Name) (bool, error)
- func (s *Service) IsMachineRebootRequired(ctx context.Context, uuid string) (bool, error)
- func (s *Service) MarkMachineForRemoval(ctx context.Context, machineName machine.Name) error
- func (s *Service) RequireMachineReboot(ctx context.Context, uuid string) error
- func (s *Service) SetAppliedLXDProfileNames(ctx context.Context, mUUID string, profileNames []string) error
- func (s *Service) SetInstanceStatus(ctx context.Context, machineName machine.Name, status status.StatusInfo) error
- func (s *Service) SetKeepInstance(ctx context.Context, machineName machine.Name, keep bool) error
- func (s *Service) SetMachineCloudInstance(ctx context.Context, machineUUID string, instanceID instance.Id, ...) error
- func (s *Service) SetMachineLife(ctx context.Context, machineName machine.Name, life life.Life) error
- func (s *Service) SetMachineStatus(ctx context.Context, machineName machine.Name, status status.StatusInfo) error
- func (s *Service) ShouldKeepInstance(ctx context.Context, machineName machine.Name) (bool, error)
- func (s *Service) ShouldRebootOrShutdown(ctx context.Context, uuid string) (machine.RebootAction, error)
- type State
- type WatchableService
- func (s *WatchableService) WatchLXDProfiles(ctx context.Context, machineUUID string) (watcher.NotifyWatcher, error)
- func (s *WatchableService) WatchMachineCloudInstances(ctx context.Context, machineUUID string) (watcher.NotifyWatcher, error)
- func (s *WatchableService) WatchMachineReboot(ctx context.Context, uuid string) (watcher.NotifyWatcher, error)
- func (s *WatchableService) WatchModelMachines() (watcher.StringsWatcher, error)
- type WatcherFactory
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Provider ¶
type Provider interface { environs.BootstrapEnviron environs.InstanceTypesFetcher }
Provider represents an underlying cloud provider.
type ProviderService ¶
type ProviderService struct { Service // contains filtered or unexported fields }
ProviderService provides the API for working with machines using the underlying provider.
func (*ProviderService) GetBootstrapEnviron ¶
func (s *ProviderService) GetBootstrapEnviron(ctx context.Context) (environs.BootstrapEnviron, error)
GetBootstrapEnviron returns the bootstrap environ.
func (*ProviderService) GetInstanceTypesFetcher ¶
func (s *ProviderService) GetInstanceTypesFetcher(ctx context.Context) (environs.InstanceTypesFetcher, error)
GetInstanceTypesFetcher returns the instance types fetcher.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides the API for working with machines.
func NewService ¶
NewService returns a new service reference wrapping the input state.
func (*Service) AllMachineNames ¶
AllMachineNames returns the names of all machines in the model.
func (*Service) AppliedLXDProfileNames ¶
LXDProfiles returns the names of the LXD profiles on the machine.
func (*Service) AvailabilityZone ¶
AvailabilityZone returns the availability zone for the specified machine.
func (*Service) ClearMachineReboot ¶
ClearMachineReboot removes the reboot flag of the machine referenced by its UUID if a reboot has previously been required.
func (*Service) CreateMachine ¶
CreateMachine creates the specified machine. It returns a MachineAlreadyExists error if a machine with the same name already exists.
func (*Service) CreateMachineWithParent ¶
func (s *Service) CreateMachineWithParent(ctx context.Context, machineName, parentName machine.Name) (string, error)
CreateMachineWirhParent creates the specified machine with the specified parent. It returns a MachineAlreadyExists error if a machine with the same name already exists. It returns a MachineNotFound error if the parent machine does not exist.
func (*Service) DeleteMachine ¶
DeleteMachine deletes the specified machine.
func (*Service) DeleteMachineCloudInstance ¶
DeleteMachineCloudInstance removes an entry in the machine cloud instance table along with the instance tags and the link to a lxd profile if any, as well as any associated status data.
func (*Service) EnsureDeadMachine ¶
EnsureDeadMachine sets the provided machine's life status to Dead. No error is returned if the provided machine doesn't exist, just nothing gets updated.
func (*Service) GetAllMachineRemovals ¶
GetAllMachineRemovals returns the UUIDs of all of the machines that need to be removed but need provider-level cleanup.
func (*Service) GetInstanceStatus ¶
func (s *Service) GetInstanceStatus(ctx context.Context, machineName machine.Name) (status.StatusInfo, error)
GetInstanceStatus returns the cloud specific instance status for this machine. It returns MachineNotFound if the machine does not exist. It returns a StatusNotSet if the instance status is not set. Idempotent.
func (*Service) GetMachineLife ¶
GetMachineLife returns the GetMachineLife status of the specified machine. It returns a NotFound if the given machine doesn't exist.
func (*Service) GetMachineParentUUID ¶
GetMachineParentUUID returns the parent UUID of the specified machine. It returns a MachineNotFound if the machine does not exist. It returns a MachineHasNoParent if the machine has no parent. It returns a GrandParentNotAllowed if the machine's parent has a parent.
func (*Service) GetMachineStatus ¶
func (s *Service) GetMachineStatus(ctx context.Context, machineName machine.Name) (status.StatusInfo, error)
GetMachineStatus returns the status of the specified machine. It returns MachineNotFound if the machine does not exist. It returns a StatusNotSet if the status is not set. Idempotent.
func (*Service) GetMachineUUID ¶
GetMachineUUID returns the UUID of a machine identified by its name. It returns a MachineNotFound if the machine does not exist.
func (*Service) HardwareCharacteristics ¶
func (s *Service) HardwareCharacteristics(ctx context.Context, machineUUID string) (*instance.HardwareCharacteristics, error)
HardwareCharacteristics returns the hardware characteristics of the of the specified machine.
func (*Service) InstanceID ¶
InstanceID returns the cloud specific instance id for this machine. If the machine is not provisioned, it returns a github.com/juju/juju/domain/machine/errors.NotProvisioned
func (*Service) InstanceIDAndName ¶
func (s *Service) InstanceIDAndName(ctx context.Context, machineUUID string) (instance.Id, string, error)
InstanceIDAndName returns the cloud specific instance ID and display name for this machine. If the machine is not provisioned, it returns a github.com/juju/juju/domain/machine/errors.NotProvisioned
func (*Service) IsMachineController ¶
IsMachineController returns whether the machine is a controller machine. It returns a NotFound if the given machine doesn't exist.
func (*Service) IsMachineRebootRequired ¶
IsMachineRebootRequired checks if the machine referenced by its UUID requires a reboot.
func (*Service) MarkMachineForRemoval ¶
MarkMachineForRemoval marks the given machine for removal. It returns a MachineNotFound error if the machine does not exist.
func (*Service) RequireMachineReboot ¶
RequireMachineReboot sets the machine referenced by its UUID as requiring a reboot.
func (*Service) SetAppliedLXDProfileNames ¶
func (s *Service) SetAppliedLXDProfileNames(ctx context.Context, mUUID string, profileNames []string) error
SetLXDProfiles 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. machineerrors.MachineNotFound will be returned if the machine does not exist.
func (*Service) SetInstanceStatus ¶
func (s *Service) SetInstanceStatus(ctx context.Context, machineName machine.Name, status status.StatusInfo) error
SetInstanceStatus sets the cloud specific instance status for this machine. It returns MachineNotFound if the machine does not exist. It returns InvalidStatus if the given status is not a known status value.
func (*Service) SetKeepInstance ¶
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.
func (*Service) SetMachineCloudInstance ¶
func (s *Service) SetMachineCloudInstance( ctx context.Context, machineUUID string, instanceID instance.Id, displayName string, hardwareCharacteristics *instance.HardwareCharacteristics, ) error
SetMachineCloudInstance sets an entry in the machine cloud instance table along with the instance tags and the link to a lxd profile if any.
func (*Service) SetMachineLife ¶
func (s *Service) SetMachineLife(ctx context.Context, machineName machine.Name, life life.Life) error
SetMachineLife sets the life status of the specified machine. It returns a MachineNotFound if the provided machine doesn't exist.
func (*Service) SetMachineStatus ¶
func (s *Service) SetMachineStatus(ctx context.Context, machineName machine.Name, status status.StatusInfo) error
SetMachineStatus sets the status of the specified machine. It returns MachineNotFound if the machine does not exist. It returns InvalidStatus if the given status is not a known status value.
func (*Service) ShouldKeepInstance ¶
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.
func (*Service) ShouldRebootOrShutdown ¶
func (s *Service) ShouldRebootOrShutdown(ctx context.Context, uuid string) (machine.RebootAction, error)
ShouldRebootOrShutdown determines whether a machine should reboot or shutdown
type State ¶
type State interface { // CreateMachine persists the input machine entity. // It returns a MachineAlreadyExists error if a machine with the same name // already exists. CreateMachine(context.Context, machine.Name, string, string) error CreateMachineWithParent(context.Context, machine.Name, machine.Name, string, string) error // DeleteMachine deletes the input machine entity. DeleteMachine(context.Context, machine.Name) error // InitialWatchStatement returns the table and the initial watch statement // for the machines. InitialWatchStatement() (string, string) // InitialWatchModelMachinesStatement returns the table and the initial watch // statement for watching life changes of non-container machines. InitialWatchModelMachinesStatement() (string, string) // GetMachineLife returns the life status of the specified machine. // It returns a MachineNotFound if the given machine doesn't exist. GetMachineLife(context.Context, machine.Name) (*life.Life, error) // SetMachineLife sets the life status of the specified machine. // It returns a MachineNotFound if the provided machine doesn't exist. SetMachineLife(context.Context, machine.Name, life.Life) error // AllMachineNames retrieves the names of all machines in the model. // If there's no machine, it returns an empty slice. AllMachineNames(context.Context) ([]machine.Name, error) // InstanceID returns the cloud specific instance id for this machine. InstanceID(context.Context, string) (string, error) // InstanceIDAndName returns the cloud specific instance ID and display name for // this machine. InstanceIDAndName(ctx context.Context, mUUID string) (string, string, error) // GetInstanceStatus returns the cloud specific instance status for this // machine. // It returns MachineNotFound if the machine does not exist. // It returns a StatusNotSet if the instance status is not set. GetInstanceStatus(context.Context, machine.Name) (domainmachine.StatusInfo[domainmachine.InstanceStatusType], error) // SetInstanceStatus sets the cloud specific instance status for this // machine. // It returns MachineNotFound if the machine does not exist. SetInstanceStatus(context.Context, machine.Name, domainmachine.StatusInfo[domainmachine.InstanceStatusType]) error // GetMachineStatus returns the status of the specified machine. // It returns MachineNotFound if the machine does not exist. // It returns a StatusNotSet if the status is not set. GetMachineStatus(context.Context, machine.Name) (domainmachine.StatusInfo[domainmachine.MachineStatusType], error) // SetMachineStatus sets the status of the specified machine. // It returns MachineNotFound if the machine does not exist. SetMachineStatus(context.Context, machine.Name, domainmachine.StatusInfo[domainmachine.MachineStatusType]) error // HardwareCharacteristics returns the hardware characteristics struct with // data retrieved from the machine cloud instance table. HardwareCharacteristics(context.Context, string) (*instance.HardwareCharacteristics, error) // AvailabilityZone returns the availability zone for the specified machine. AvailabilityZone(context.Context, string) (string, error) // SetMachineCloudInstance sets an entry in the machine cloud instance table // along with the instance tags and the link to a lxd profile if any. SetMachineCloudInstance(context.Context, string, instance.Id, string, *instance.HardwareCharacteristics) error // DeleteMachineCloudInstance removes an entry in the machine cloud instance // table along with the instance tags and the link to a lxd profile if any. DeleteMachineCloudInstance(context.Context, string) error // IsMachineController returns whether the machine is a controller machine. // It returns a NotFound if the given machine doesn't exist. IsMachineController(context.Context, machine.Name) (bool, error) // ShouldKeepInstance reports whether a machine, when removed from Juju, should cause // the corresponding cloud instance to be stopped. ShouldKeepInstance(ctx context.Context, mName machine.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. SetKeepInstance(ctx context.Context, mName machine.Name, keep bool) error // RequireMachineReboot sets the machine referenced by its UUID as requiring a reboot. RequireMachineReboot(ctx context.Context, uuid string) error // ClearMachineReboot removes the reboot flag of the machine referenced by its UUID if a reboot has previously been required. ClearMachineReboot(ctx context.Context, uuid string) error // IsMachineRebootRequired checks if the machine referenced by its UUID requires a reboot. IsMachineRebootRequired(ctx context.Context, uuid string) (bool, error) // GetMachineParentUUID returns the parent UUID of the specified machine. // It returns a MachineNotFound if the machine does not exist. // It returns a MachineHasNoParent if the machine has no parent. GetMachineParentUUID(ctx context.Context, machineUUID string) (string, error) // ShouldRebootOrShutdown determines whether a machine should reboot or shutdown ShouldRebootOrShutdown(ctx context.Context, uuid string) (machine.RebootAction, error) // MarkMachineForRemoval marks the given machine for removal. // It returns a MachineNotFound error if the machine does not exist. MarkMachineForRemoval(context.Context, machine.Name) error // GetAllMachineRemovals returns the UUIDs of all of the machines that need // to be removed but need provider-level cleanup. GetAllMachineRemovals(context.Context) ([]string, error) // GetMachineUUID returns the UUID of a machine identified by its name. GetMachineUUID(context.Context, machine.Name) (string, error) // AppliedLXDProfileNames returns the names of the LXD profiles on the machine. AppliedLXDProfileNames(ctx context.Context, mUUID 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, mUUID string, profileNames []string) error }
State describes retrieval and persistence methods for machines.
type WatchableService ¶
type WatchableService struct { ProviderService // contains filtered or unexported fields }
func NewWatchableService ¶
func NewWatchableService( st State, watcherFactory WatcherFactory, providerGetter providertracker.ProviderGetter[Provider], ) *WatchableService
NewWatchableService returns a new service reference wrapping the input state.
func (*WatchableService) WatchLXDProfiles ¶
func (s *WatchableService) WatchLXDProfiles(ctx context.Context, machineUUID string) (watcher.NotifyWatcher, 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. Note: Sometime in the future, this watcher could react to logical changes fired from `SetAppliedLXDProfileNames()` instead of the `machine_lxd_profile` table, which could become noisy.
func (*WatchableService) WatchMachineCloudInstances ¶
func (s *WatchableService) WatchMachineCloudInstances(ctx context.Context, machineUUID string) (watcher.NotifyWatcher, error)
WatchMachineCloudInstances returns a NotifyWatcher that is subscribed to the changes in the machine_cloud_instance table in the model, for the given machine UUID.
func (*WatchableService) WatchMachineReboot ¶
func (s *WatchableService) WatchMachineReboot(ctx context.Context, uuid string) (watcher.NotifyWatcher, error)
WatchMachineReboot returns a NotifyWatcher that is subscribed to the changes in the machine_requires_reboot table in the model. It raises an event whenever the machine uuid or its parent is added to the reboot table.
func (*WatchableService) WatchModelMachines ¶
func (s *WatchableService) WatchModelMachines() (watcher.StringsWatcher, error)
WatchModelMachines watches for additions or updates to non-container machines. It is used by workers that need to factor life value changes, and so does not factor machine removals, which are considered to be after their transition to the dead state. It emits machine names rather than UUIDs.
type WatcherFactory ¶
type WatcherFactory interface { // NewNamespaceWatcher returns a new namespace watcher // for events based on the input change mask. NewNamespaceWatcher( namespace string, changeMask changestream.ChangeType, initialStateQuery eventsource.NamespaceQuery, ) (watcher.StringsWatcher, error) NewNamespaceMapperWatcher( namespace string, changeMask changestream.ChangeType, initialStateQuery eventsource.NamespaceQuery, mapper eventsource.Mapper, ) (watcher.StringsWatcher, error) // NewNamespaceNotifyMapperWatcher returns a new namespace notify watcher // for events based on the input change mask and mapper. NewNamespaceNotifyMapperWatcher( namespace string, changeMask changestream.ChangeType, mapper eventsource.Mapper, ) (watcher.NotifyWatcher, error) }
WatcherFactory describes methods for creating watchers.