model

package
v0.0.0-...-56cb166 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2025 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package model contains the controller model service. The controller stores information about all the models it manages. This service exposes methods to perform management operations such as creating, destroying and gathering information about models the controller manages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToCoreConstraints

func ToCoreConstraints(cons Constraints) constraints.Value

ToCoreConstraints is responsible for converting a Constraints value to a constraints.Value.

Types

type Constraints

type Constraints struct {
	// Arch, if not nil or empty, indicates that a machine must run the named
	// architecture.
	Arch *string

	// Container, if not nil, indicates that a machine must be the specified container type.
	Container *instance.ContainerType

	// CpuCores, if not nil, indicates that a machine must have at least that
	// number of effective cores available.
	CpuCores *uint64

	// CpuPower, if not nil, indicates that a machine must have at least that
	// amount of CPU power available, where 100 CpuPower is considered to be
	// equivalent to 1 Amazon ECU (or, roughly, a single 2007-era Xeon).
	CpuPower *uint64

	// Mem, if not nil, indicates that a machine must have at least that many
	// megabytes of RAM.
	Mem *uint64

	// RootDisk, if not nil, indicates that a machine must have at least
	// that many megabytes of disk space available in the root disk. In
	// providers where the root disk is configurable at instance startup
	// time, an instance with the specified amount of disk space in the OS
	// disk might be requested.
	RootDisk *uint64

	// RootDiskSource, if specified, determines what storage the root
	// disk should be allocated from. This will be provider specific -
	// in the case of vSphere it identifies the datastore the root
	// disk file should be created in.
	RootDiskSource *string

	// Tags, if not nil, indicates tags that the machine must have applied to it.
	// An empty list is treated the same as a nil (unspecified) list, except an
	// empty list will override any default tags, where a nil list will not.
	Tags *[]string

	// InstanceRole, if not nil, indicates that the specified role/profile for
	// the given cloud should be used. Only valid for clouds which support
	// instance roles. Currently only for AWS with instance-profiles
	InstanceRole *string

	// InstanceType, if not nil, indicates that the specified cloud instance type
	// be used. Only valid for clouds which support instance types.
	InstanceType *string

	// Spaces, if not nil, holds a list of juju network spaces that
	// should be available (or not) on the machine.
	Spaces *[]SpaceConstraint

	// VirtType, if not nil or empty, indicates that a machine must run the named
	// virtual type. Only valid for clouds with multi-hypervisor support.
	VirtType *string

	// Zones, if not nil, holds a list of availability zones limiting where
	// the machine can be located.
	Zones *[]string

	// AllocatePublicIP, if nil or true, signals that machines should be
	// created with a public IP address instead of a cloud local one.
	// The default behaviour if the value is not specified is to allocate
	// a public IP so that public cloud behaviour works out of the box.
	AllocatePublicIP *bool

	// ImageID, if not nil, indicates that a machine must use the specified
	// image. This is provider specific, and for the moment is only
	// implemented on MAAS clouds.
	ImageID *string
}

func FromCoreConstraints

func FromCoreConstraints(coreCons constraints.Value) Constraints

FromCoreConstraints is responsible for converting a constraints.Value to a Constraints object.

type DeleteModelOption

type DeleteModelOption func(*DeleteModelOptions)

DeleteModelOption is a functional option that can be used to modify the behavior of the DeleteModel function.

func WithDeleteDB

func WithDeleteDB() DeleteModelOption

WithDeleteDB is a functional option that can be used to modify the behavior of the DeleteModel function to delete the model from the database.

type DeleteModelOptions

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

DeleteModelOptions is a struct that is used to modify the behavior of the DeleteModel function.

func DefaultDeleteModelOptions

func DefaultDeleteModelOptions() *DeleteModelOptions

DefaultDeleteModelOptions returns a pointer to a DeleteModelOptions struct with the default values set.

func (DeleteModelOptions) DeleteDB

func (o DeleteModelOptions) DeleteDB() bool

DeleteDB returns a boolean value that indicates if the model should be deleted from the database.

type GlobalModelCreationArgs

type GlobalModelCreationArgs struct {
	// 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

	// 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

	// Name is the name of the model.
	// Must not be empty for a valid struct.
	Name string

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

	// SecretBackend dictates the secret backend to be used for the newly
	// created model. SecretBackend can be left empty and a default will be
	// chosen at creation time.
	SecretBackend string
}

GlobalModelCreationArgs supplies the information required for recording details of a new model in the controller database.

func (GlobalModelCreationArgs) Validate

func (m GlobalModelCreationArgs) Validate() error

Validate is responsible for checking all of the fields of GlobalModelCreationArgs are in a set state that is valid for use. If a validation failure happens an error satisfying errors.NotValid is returned.

type ModelDetailArgs

type ModelDetailArgs struct {
	// UUID represents the unique id for the model when being created. This
	// value is optional and if omitted will be generated for the caller. Use
	// this value when you are trying to import a model during model migration.
	UUID coremodel.UUID

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

	// ControllerUUID represents the unique id for the controller that the model
	// is associated with.
	ControllerUUID uuid.UUID

	// Name is the name of the model.
	// Must not be empty for a valid struct.
	Name string

	// Type is the type of the model.
	// Type must satisfy IsValid() for a valid struct.
	Type coremodel.ModelType

	// 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.
	// Optional and can be empty.
	CloudRegion string

	// CredentialOwner is the name of the credential owner for this model in
	// the Juju controller.
	// Optional and can be empty.
	CredentialOwner user.Name

	// CredentialName is the name of the credential to be associated with the
	// model.
	// Optional and can be empty.
	CredentialName string

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

ModelDetailArgs is a struct that is used to create a model within the model database. This struct is used to create a model with all of its associated metadata.

type ModelImportArgs

type ModelImportArgs struct {
	// ID represents the unique id of the model to import.
	ID coremodel.UUID

	// GlobalModelCreationArgs supplies the information needed for importing the new
	// model into Juju.
	GlobalModelCreationArgs
}

ModelImportArgs supplies the information needed for importing a model into a Juju controller.

func (ModelImportArgs) Validate

func (m ModelImportArgs) Validate() error

Validate is responsible for checking all of the fields of ModelImportArgs are in a set state valid for use. If a validation failure happens an error satisfying errors.NotValid is returned.

type ModelState

type ModelState struct {
	// Destroying is a boolean value that indicates if the model is being destroyed.
	Destroying bool
	// Migrating is a boolean value that indicates if the model is being migrated.
	Migrating bool
	// HasInvalidCloudCredential is a boolean value that indicates if the model's cloud credential is invalid.
	HasInvalidCloudCredential bool
	// InvalidCloudCredentialReason is a string that describes the reason for the model's cloud credential being invalid.
	InvalidCloudCredentialReason string
}

ModelState describes the state of a model.

type SpaceConstraint

type SpaceConstraint struct {
	// Excluded indicates that this space should not be available to the
	// machine.
	Exclude bool

	// SpaceName is the name of the space.
	SpaceName string
}

SpaceConstraint represents a single space constraint for a model.

type StatusInfo

type StatusInfo struct {
	// Status is the current status of the model.
	Status corestatus.Status
	// Message is a human-readable message that describes the current status of the model.
	Message string
	// Reason is a human-readable message that describes the reason for the current status of the model.
	Reason string
	// Since is the time when the model entered the current status.
	Since time.Time
}

StatusInfo represents the current status of a model.

Directories

Path Synopsis
Package service contains the services required for interacting with the underlying models within a Juju controller.
Package service contains the services required for interacting with the underlying models within a Juju controller.

Jump to

Keyboard shortcuts

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