Documentation
¶
Index ¶
- type State
- func (st *State) AllMachineNames(ctx context.Context) ([]machine.Name, error)
- func (st *State) AppliedLXDProfileNames(ctx context.Context, mUUID string) ([]string, error)
- func (st *State) AvailabilityZone(ctx context.Context, machineUUID string) (string, error)
- func (st *State) ClearMachineReboot(ctx context.Context, uuid string) error
- func (st *State) CreateMachine(ctx context.Context, machineName machine.Name, nodeUUID, machineUUID string) error
- func (st *State) CreateMachineWithParent(ctx context.Context, machineName, parentName machine.Name, ...) error
- func (st *State) DeleteMachine(ctx context.Context, mName machine.Name) error
- func (st *State) DeleteMachineCloudInstance(ctx context.Context, mUUID string) error
- func (st *State) GetAllMachineRemovals(ctx context.Context) ([]string, error)
- func (st *State) GetInstanceStatus(ctx context.Context, mName machine.Name) (domainmachine.StatusInfo[domainmachine.InstanceStatusType], error)
- func (st *State) GetMachineLife(ctx context.Context, mName machine.Name) (*life.Life, error)
- func (st *State) GetMachineParentUUID(ctx context.Context, uuid string) (string, error)
- func (st *State) GetMachineStatus(ctx context.Context, mName machine.Name) (domainmachine.StatusInfo[domainmachine.MachineStatusType], error)
- func (st *State) GetMachineUUID(ctx context.Context, name machine.Name) (string, error)
- func (st *State) HardwareCharacteristics(ctx context.Context, machineUUID string) (*instance.HardwareCharacteristics, error)
- func (st *State) InitialWatchModelMachinesStatement() (string, string)
- func (st *State) InitialWatchStatement() (string, string)
- func (st *State) InstanceID(ctx context.Context, mUUID string) (string, error)
- func (st *State) InstanceIDAndName(ctx context.Context, mUUID string) (string, string, error)
- func (st *State) IsMachineController(ctx context.Context, mName machine.Name) (bool, error)
- func (st *State) IsMachineRebootRequired(ctx context.Context, uuid string) (bool, error)
- func (st *State) MarkMachineForRemoval(ctx context.Context, mName machine.Name) error
- func (st *State) RequireMachineReboot(ctx context.Context, uuid string) error
- func (st *State) SetAppliedLXDProfileNames(ctx context.Context, mUUID string, profileNames []string) error
- func (st *State) SetInstanceStatus(ctx context.Context, mName machine.Name, ...) error
- func (st *State) SetKeepInstance(ctx context.Context, mName machine.Name, keep bool) error
- func (st *State) SetMachineCloudInstance(ctx context.Context, machineUUID string, instanceID instance.Id, ...) error
- func (st *State) SetMachineLife(ctx context.Context, mName machine.Name, life life.Life) error
- func (st *State) SetMachineStatus(ctx context.Context, mName machine.Name, ...) error
- func (st *State) ShouldKeepInstance(ctx context.Context, mName machine.Name) (bool, error)
- func (st *State) ShouldRebootOrShutdown(ctx context.Context, uuid string) (coremachine.RebootAction, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type State ¶
State describes retrieval and persistence methods for storage.
func (*State) AllMachineNames ¶
AllMachineNames retrieves the names of all machines in the model.
func (*State) AppliedLXDProfileNames ¶
AppliedLXDProfileNames returns the names of the LXD profiles on the machine.
func (*State) AvailabilityZone ¶
AvailabilityZone returns the availability zone for the specified machine. If no hardware characteristics are set for the machine, it returns machineerrors.AvailabilityZoneNotFound.
func (*State) ClearMachineReboot ¶
ClearMachineReboot removes the reboot flag of the machine referenced by its UUID if a reboot has previously been required.
It basically removes the uuid from the "machine_requires_reboot" table if present. This function is idempotent.
func (*State) CreateMachine ¶
func (st *State) CreateMachine(ctx context.Context, machineName machine.Name, nodeUUID, machineUUID string) error
CreateMachine creates or updates the specified machine. Adds a row to machine table, as well as a row to the net_node table. It returns a MachineAlreadyExists error if a machine with the same name already exists.
func (*State) CreateMachineWithParent ¶
func (st *State) CreateMachineWithParent(ctx context.Context, machineName, parentName machine.Name, nodeUUID, machineUUID string) error
CreateMachineWithParent creates or updates the specified machine with a parent. Adds a row to machine table, as well as a row to the net_node table, and adds a row to the machine_parent table for associating with the specified parent. It returns a MachineNotFound error if the parent machine does not exist. It returns a MachineAlreadyExists error if a machine with the same name already exists.
func (*State) DeleteMachine ¶
DeleteMachine deletes the specified machine and any dependent child records. TODO - this just deals with child block devices for now.
func (*State) 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 (*State) GetAllMachineRemovals ¶
GetAllMachineRemovals returns the UUIDs of all of the machines that need to be removed but need provider-level cleanup.
func (*State) GetInstanceStatus ¶
func (st *State) GetInstanceStatus(ctx context.Context, mName machine.Name) (domainmachine.StatusInfo[domainmachine.InstanceStatusType], error)
GetInstanceStatus returns the cloud specific instance status for the given machine. It returns NotFound if the machine does not exist. It returns a StatusNotSet if the instance status is not set. Idempotent.
func (*State) GetMachineLife ¶
GetMachineLife returns the life status of the specified machine. It returns a MachineNotFound if the given machine doesn't exist.
func (*State) 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.
func (*State) GetMachineStatus ¶
func (st *State) GetMachineStatus(ctx context.Context, mName machine.Name) (domainmachine.StatusInfo[domainmachine.MachineStatusType], 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 (*State) GetMachineUUID ¶
GetMachineUUID returns the UUID of a machine identified by its name. It returns a MachineNotFound if the machine does not exist.
func (*State) HardwareCharacteristics ¶
func (st *State) HardwareCharacteristics( ctx context.Context, machineUUID string, ) (*instance.HardwareCharacteristics, error)
HardwareCharacteristics returns the hardware characteristics struct with data retrieved from the machine cloud instance table.
func (*State) InitialWatchModelMachinesStatement ¶
InitialWatchModelMachinesStatement returns the table and the initial watch statement for watching life changes of non-container machines.
func (*State) InitialWatchStatement ¶
InitialWatchStatement returns the table and the initial watch statement for the machines.
func (*State) InstanceID ¶
InstanceID returns the cloud specific instance id for this machine. If the machine is not provisioned, it returns a machineerrors.NotProvisionedError.
func (*State) InstanceIDAndName ¶
InstanceIDAndName returns the cloud specific instance ID and display name for this machine. If the machine is not provisioned, it returns a machineerrors.NotProvisionedError.
func (*State) IsMachineController ¶
IsMachineController returns whether the machine is a controller machine. It returns a NotFound if the given machine doesn't exist.
func (*State) IsMachineRebootRequired ¶
IsMachineRebootRequired checks if the specified machine requires a reboot.
It queries the "machine_requires_reboot" table for the machine UUID to determine if a reboot is required. Returns a boolean value indicating if a reboot is required, and an error if any occur during the process.
func (*State) MarkMachineForRemoval ¶
MarkMachineForRemoval marks the specified machine for removal. It returns NotFound if the machine does not exist. TODO(cderici): use machineerrors.MachineNotFound on rebase after #17759 lands. Idempotent.
func (*State) RequireMachineReboot ¶
RequireMachineReboot sets the machine referenced by its UUID as requiring a reboot.
Reboot requests are handled through the "machine_requires_reboot" table which contains only machine UUID for which a reboot has been requested. This function is idempotent.
func (*State) SetAppliedLXDProfileNames ¶
func (st *State) SetAppliedLXDProfileNames(ctx context.Context, mUUID string, profileNames []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. machineerrors.MachineNotFound will be returned if the machine does not exist.
func (*State) SetInstanceStatus ¶
func (st *State) SetInstanceStatus(ctx context.Context, mName machine.Name, newStatus domainmachine.StatusInfo[domainmachine.InstanceStatusType]) error
SetInstanceStatus sets the cloud specific instance status for this machine. It returns machineerrors.MachineNotFound if the machine does not exist.
func (*State) 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.
func (*State) SetMachineCloudInstance ¶
func (st *State) 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 (*State) SetMachineLife ¶
SetMachineLife sets the life status of the specified machine. It returns a MachineNotFound if the provided machine doesn't exist.
func (*State) SetMachineStatus ¶
func (st *State) SetMachineStatus(ctx context.Context, mName machine.Name, newStatus domainmachine.StatusInfo[domainmachine.MachineStatusType]) error
SetMachineStatus sets the status of the specified machine. It returns MachineNotFound if the machine does not exist.
func (*State) ShouldKeepInstance ¶
ShouldKeepInstance reports whether a machine, when removed from Juju, should cause the corresponding cloud instance to be stopped.
func (*State) ShouldRebootOrShutdown ¶
func (st *State) ShouldRebootOrShutdown(ctx context.Context, uuid string) (coremachine.RebootAction, error)
ShouldRebootOrShutdown determines if a machine should reboot or shutdown based on its state and parent's state.
The function first checks if a parent machine exists and requires a reboot. If so, it returns ShouldShutdown immediately.
If the parent machine does not require a reboot, the function checks if the current machine requires a reboot. If so, it returns ShouldReboot. If neither the parent machine nor the current machine require a reboot, it returns ShouldDoNothing.
The function also check if there is a grandparent machine, which is not supported. In this case, the function returns an errors.GrandParentNotSupported.
The function returns any error issued through interaction with the database, annotated with the UUID of the machine.