model

package
v0.0.0-...-b9bb202 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: AGPL-3.0 Imports: 11 Imported by: 37

Documentation

Index

Constants

View Source
const (
	// ContextKeyModelUUID is the key used to store the model UUID in the
	// context.
	ContextKeyModelUUID contextKey = "model-uuid"
)
View Source
const ControllerModelName = "controller"

ControllerModelName is the name given to the model that hosts the Juju controller. This is a static value that we use for every Juju deployment. It provides a common reference point that we can leverage in business logic to ask questions and calculate defaults in Juju.

Variables

View Source
var ControllerModelOwnerUsername = user.AdminUserName

ControllerModelOwnerUsername is the user name of the owner that is assigned to the controller model. This is a static value that we use for every Juju deployment.

Functions

func AnyJobNeedsState

func AnyJobNeedsState(jobs ...MachineJob) bool

AnyJobNeedsState returns true if any of the provided jobs require a state connection.

func WithContextModelUUID

func WithContextModelUUID(ctx context.Context, modelUUID UUID) context.Context

WitContextModelUUID returns a new context with the model UUID set.

Types

type MachineJob

type MachineJob string

MachineJob values define responsibilities that machines may be expected to fulfil.

const (
	JobHostUnits   MachineJob = "JobHostUnits"
	JobManageModel MachineJob = "JobManageModel"
)

func (MachineJob) NeedsState

func (job MachineJob) NeedsState() bool

NeedsState returns true if the job requires a state connection.

type Model

type Model struct {
	// Name returns the human friendly name of the model.
	Name string

	// Life is the current state of the model.
	// Options are alive, dying, dead. Every model starts as alive, only
	// during the destruction of the model it transitions to dying and then
	// dead.
	Life life.Value

	// UUID is the universally unique identifier of the model.
	UUID UUID

	// ModelType is the type of model.
	ModelType ModelType

	// AgentVersion is the target version for agents running under this model.
	AgentVersion version.Number

	// Cloud is the name of the cloud to associate with the model.
	// Must not be empty for a valid struct.
	Cloud string

	// CloudType is the type of the underlying cloud (e.g. lxd, azure, ...)
	CloudType string

	// CloudRegion is the region that the model will use in the cloud.
	CloudRegion string

	// Credential is the id attributes for the credential to be associated with
	// model. Credential must be for the same cloud as that of the model.
	// Credential can be the zero value of the struct to not have a credential
	// associated with the model.
	Credential credential.Key

	// Owner is the uuid of the user that owns this model in the Juju controller.
	Owner user.UUID

	// OwnerName is the name of the owner in the Juju controller.
	OwnerName user.Name
}

Model represents the state of a model.

type ModelMigrationStatus

type ModelMigrationStatus struct {
	Status string     `json:"status"`
	Start  *time.Time `json:"start"`
	End    *time.Time `json:"end,omitempty"`
}

ModelMigrationStatus holds information about the progress of a (possibly failed) migration.

type ModelSummary

type ModelSummary struct {
	// Name is the model name.
	Name string

	// UUID is the model unique identifier.
	UUID UUID

	// ModelType is the model type (e.g. IAAS or CAAS).
	ModelType ModelType

	// CloudName is the name of the model cloud.
	CloudName string

	// CloudType is the models cloud type.
	CloudType string

	// CloudRegion is the region of the model cloud.
	CloudRegion string

	// CloudCredentialName is the name of the cloud credential.
	CloudCredentialKey credential.Key

	// ControllerUUID is the unique identifier of the controller.
	ControllerUUID string

	// IsController indicates if the model is a controller.
	IsController bool

	// OwnerName is the tag of the user that owns the model.
	OwnerName user.Name

	// Life is the current lifecycle state of the model.
	Life life.Value

	// AgentVersion is the agent version for this model.
	AgentVersion version.Number

	// Status is the current status of the model.
	Status status.StatusInfo

	// MachineCount is the number of machines this model contains.
	MachineCount int64
	// CoreCount is the number of CPU cores used by this model.
	CoreCount int64
	// UnitCount is the number of application units in this model.
	UnitCount int64

	// Migration contains information about the latest failed or
	// currently-running migration. It'll be nil if there isn't one.
	Migration *ModelMigrationStatus
}

ModelSummary holds summary about a Juju model.

type ModelType

type ModelType string

ModelType indicates a model type.

const (
	// IAAS is the type for IAAS models.
	IAAS ModelType = "iaas"

	// CAAS is the type for CAAS models.
	CAAS ModelType = "caas"
)

func (ModelType) IsValid

func (m ModelType) IsValid() bool

IsValid returns true if the value of Type is a known valid type. Currently supported values are: - CAAS - IAAS

func (ModelType) String

func (m ModelType) String() string

String returns m as a string.

type ModelUserInfo

type ModelUserInfo struct {
	// Name is the username of the user.
	Name user.Name
	// DisplayName is a user-friendly name representation of the users name.
	DisplayName string
	// Access represents the level of model access this user has.
	Access permission.Access
	// LastLogin is the last time the user logged in.
	LastModelLogin time.Time
}

ModelUserInfo contains information about a user of a model.

type ReadOnlyModel

type ReadOnlyModel struct {
	// UUID represents the model UUID.
	UUID UUID

	// AgentVersion reports the current target agent version for the model.
	AgentVersion version.Number

	// ControllerUUID represents the controller UUID.
	ControllerUUID uuid.UUID

	// Name is the name of the model.
	Name string

	// Type is the type of the model.
	Type ModelType

	// Cloud is the name of the cloud to associate with the model.
	Cloud string

	// CloudType is the type of the underlying cloud (e.g. lxd, azure, ...)
	CloudType string

	// CloudRegion is the region that the model will use in the cloud.
	CloudRegion string

	// CredentialOwner is the owner of the model.
	CredentialOwner user.Name

	// Credential name is the name of the credential to use for the model.
	CredentialName string

	// IsControllerModel is a boolean value that indicates if the model is the
	// controller model.
	IsControllerModel bool
}

ReadOnlyModel represents the state of a read-only model found in the model database, not the controller database. All the fields are are denormalized from the model database.

type UUID

type UUID string

UUID represents a model unique identifier.

func ModelUUIDFromContext

func ModelUUIDFromContext(ctx context.Context) (UUID, bool)

ModelUUIDFromContext returns the model UUID from the context.

func NewUUID

func NewUUID() (UUID, error)

NewUUID is a convince function for generating a new model uuid.

func (UUID) String

func (u UUID) String() string

String implements the stringer interface for UUID.

func (UUID) Validate

func (u UUID) Validate() error

Validate ensures the consistency of the UUID. If the uuid is invalid an error satisfying errors.NotValid will be returned.

type UserModelSummary

type UserModelSummary struct {
	// UserAccess is model access level for the  current user.
	UserAccess permission.Access

	// UserLastConnection contains the time when current user logged in
	// into the model last.
	UserLastConnection *time.Time

	// ModelSummary embeds the remaining model summary fields.
	ModelSummary
}

UserModelSummary holds information about a model and a users access on it.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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