devicestate

package
v2.42.5-go-mod+incompa... Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2020 License: GPL-3.0 Imports: 48 Imported by: 0

Documentation

Overview

Package devicestate implements the manager and state aspects responsible for the device identity and policies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanManageRefreshes

func CanManageRefreshes(st *state.State) bool

CanManageRefreshes returns true if the device can be switched to the "core.refresh.schedule=managed" mode.

TODO:

  • Move the CanManageRefreshes code into the ifstate
  • Look at the connections and find the connection for snapd-control with the managed attribute
  • Take the snap from this connection and look at the snapstate to see if that snap has a snap declaration (to ensure it comes from the store)

func DeviceCtx

func DeviceCtx(st *state.State, task *state.Task, providedDeviceCtx snapstate.DeviceContext) (snapstate.DeviceContext, error)

DeviceCtx picks a device context from state, optional task or an optionally pre-provided one. Returns ErrNoState if a model assertion is not yet known. In particular if task belongs to a remodeling change this will find the appropriate remodel context.

func Remodel

func Remodel(st *state.State, new *asserts.Model) (*state.Change, error)

Remodel takes a new model assertion and generates a change that takes the device from the old to the new model or an error if the transition is not possible.

TODO:

  • Check estimated disk size delta
  • Reapply gadget connections as needed
  • Check all relevant snaps exist in new store (need to check that even unchanged snaps are accessible)

func Remodeling

func Remodeling(st *state.State) bool

Remodeling returns true whether there's a remodeling in progress

Types

type DeviceManager

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

DeviceManager is responsible for managing the device identity and device policies.

func Manager

func Manager(s *state.State, hookManager *hookstate.HookManager, runner *state.TaskRunner, newStore func(storecontext.DeviceBackend) snapstate.StoreService) (*DeviceManager, error)

Manager returns a new device manager.

func (*DeviceManager) CanStandby

func (m *DeviceManager) CanStandby() bool

func (*DeviceManager) Ensure

func (m *DeviceManager) Ensure() error

Ensure implements StateManager.Ensure.

func (*DeviceManager) Model

func (m *DeviceManager) Model() (*asserts.Model, error)

Model returns the device model assertion.

func (*DeviceManager) Registered

func (m *DeviceManager) Registered() <-chan struct{}

Registered returns a channel that is closed when the device is known to have been registered.

func (*DeviceManager) Serial

func (m *DeviceManager) Serial() (*asserts.Serial, error)

Serial returns the device serial assertion.

func (*DeviceManager) StoreContextBackend

func (m *DeviceManager) StoreContextBackend() storecontext.Backend

type RemodelKind

type RemodelKind int

RemodelKind designates a kind of remodeling.

const (
	// same brand/model, brand store
	UpdateRemodel RemodelKind = iota
	// same brand/model, different brand store
	StoreSwitchRemodel
	// different brand/model, maybe different brand store
	ReregRemodel
)

func ClassifyRemodel

func ClassifyRemodel(oldModel, newModel *asserts.Model) RemodelKind

ClassifyRemodel returns what kind of remodeling is going from oldModel to newModel.

func (RemodelKind) String

func (k RemodelKind) String() string

Directories

Path Synopsis
Package internal (of devicestate) provides functions to access and set the device state for use only by devicestate, for convenience they are also exposed via devicestatetest for use in tests.
Package internal (of devicestate) provides functions to access and set the device state for use only by devicestate, for convenience they are also exposed via devicestatetest for use in tests.

Jump to

Keyboard shortcuts

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