description

package
v0.0.0-...-4bd6544 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2016 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

The description package defines the structure and representation and serialisation of models to facilitate the import and export of models from different controllers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Serialize

func Serialize(model Model) ([]byte, error)

Serialize mirrors the Deserialize method, and makes sure that the same serialization method is used.

Types

type Action

type Action interface {
	Id() string
	Receiver() string
	Name() string
	Parameters() map[string]interface{}
	Enqueued() time.Time
	Started() time.Time
	Completed() time.Time
	Results() map[string]interface{}
	Status() string
	Message() string
}

Action represents an IP action.

type ActionArgs

type ActionArgs struct {
	Id         string
	Receiver   string
	Name       string
	Parameters map[string]interface{}
	Enqueued   time.Time
	Started    time.Time
	Completed  time.Time
	Status     string
	Message    string
	Results    map[string]interface{}
}

ActionArgs is an argument struct used to create a new internal action type that supports the Action interface.

type Address

type Address interface {
	Value() string
	Type() string
	Scope() string
	Origin() string
}

Address represents an IP Address of some form.

type AddressArgs

type AddressArgs struct {
	Value  string
	Type   string
	Scope  string
	Origin string
}

AddressArgs is an argument struct used to create a new internal address type that supports the Address interface.

type AgentTools

type AgentTools interface {
	Version() version.Binary
	URL() string
	SHA256() string
	Size() int64
}

AgentTools represent the version and related binary file that the machine and unit agents are using.

type AgentToolsArgs

type AgentToolsArgs struct {
	Version version.Binary
	URL     string
	SHA256  string
	Size    int64
}

AgentToolsArgs is an argument struct used to add information about the tools the agent is using to a Machine.

type Annotations_

type Annotations_ map[string]string

Instead of copy / pasting the Annotations, SetAnnotations, and the import three lines into every entity that has annotations, the Annotations_ helper type is provided for use in composition. This type is composed without a name so the methods get promoted so they satisfy the HasAnnotations interface.

NOTE(mjs) - The type is exported due to a limitation with go-yaml under 1.6. Once that's fixed it should be possible to make it private again.

NOTE(mjs) - The trailing underscore on the type name is to avoid collisions between the type name and the Annotations method. The underscore can go once the type becomes private again (revert to "annotations").

func (*Annotations_) Annotations

func (a *Annotations_) Annotations() map[string]string

Annotations implements HasAnnotations.

func (*Annotations_) SetAnnotations

func (a *Annotations_) SetAnnotations(annotations map[string]string)

SetAnnotations implements HasAnnotations.

type Application

type Application interface {
	HasAnnotations
	HasConstraints
	HasStatus
	HasStatusHistory

	Tag() names.ApplicationTag
	Name() string
	Series() string
	Subordinate() bool
	CharmURL() string
	Channel() string
	CharmModifiedVersion() int
	ForceCharm() bool
	Exposed() bool
	MinUnits() int

	Settings() map[string]interface{}

	Leader() string
	LeadershipSettings() map[string]interface{}

	MetricsCredentials() []byte
	StorageConstraints() map[string]StorageConstraint

	Units() []Unit
	AddUnit(UnitArgs) Unit

	Validate() error
}

Application represents a deployed charm in a model.

type ApplicationArgs

type ApplicationArgs struct {
	Tag                  names.ApplicationTag
	Series               string
	Subordinate          bool
	CharmURL             string
	Channel              string
	CharmModifiedVersion int
	ForceCharm           bool
	Exposed              bool
	MinUnits             int
	Settings             map[string]interface{}
	Leader               string
	LeadershipSettings   map[string]interface{}
	StorageConstraints   map[string]StorageConstraintArgs
	MetricsCredentials   []byte
}

ApplicationArgs is an argument struct used to add an application to the Model.

type BlockDevice

type BlockDevice interface {
	Name() string
	Links() []string
	Label() string
	UUID() string
	HardwareID() string
	BusAddress() string
	Size() uint64
	FilesystemType() string
	InUse() bool
	MountPoint() string
}

BlockDevice represents a block device on a machine.

type BlockDeviceArgs

type BlockDeviceArgs struct {
	Name           string
	Links          []string
	Label          string
	UUID           string
	HardwareID     string
	BusAddress     string
	Size           uint64
	FilesystemType string
	InUse          bool
	MountPoint     string
}

BlockDeviceArgs is an argument struct used to add a block device to a Machine.

type ByName

type ByName []User

Implement length-based sort with ByLen type.

func (ByName) Len

func (a ByName) Len() int

func (ByName) Less

func (a ByName) Less(i, j int) bool

func (ByName) Swap

func (a ByName) Swap(i, j int)

type CloudImageMetadata

type CloudImageMetadata interface {
	Stream() string
	Region() string
	Version() string
	Series() string
	Arch() string
	VirtType() string
	RootStorageType() string
	RootStorageSize() (uint64, bool)
	DateCreated() int64
	Source() string
	Priority() int
	ImageId() string
}

CloudImageMetadata represents an IP cloudimagemetadata.

type CloudImageMetadataArgs

type CloudImageMetadataArgs struct {
	Stream          string
	Region          string
	Version         string
	Series          string
	Arch            string
	VirtType        string
	RootStorageType string
	RootStorageSize *uint64
	DateCreated     int64
	Source          string
	Priority        int
	ImageId         string
}

CloudImageMetadataArgs is an argument struct used to create a new internal cloudimagemetadata type that supports the CloudImageMetadata interface.

type CloudInstance

type CloudInstance interface {
	InstanceId() string
	Status() string
	Architecture() string
	Memory() uint64
	RootDisk() uint64
	CpuCores() uint64
	CpuPower() uint64
	Tags() []string
	AvailabilityZone() string
}

CloudInstance holds information particular to a machine instance in a cloud.

type CloudInstanceArgs

type CloudInstanceArgs struct {
	InstanceId       string
	Status           string
	Architecture     string
	Memory           uint64
	RootDisk         uint64
	CpuCores         uint64
	CpuPower         uint64
	Tags             []string
	AvailabilityZone string
}

CloudInstanceArgs is an argument struct used to add information about the cloud instance to a Machine.

type Constraints

type Constraints interface {
	Architecture() string
	Container() string
	CpuCores() uint64
	CpuPower() uint64
	InstanceType() string
	Memory() uint64
	RootDisk() uint64

	Spaces() []string
	Tags() []string

	VirtType() string
}

Constraints holds information about particular deployment constraints for entities.

type ConstraintsArgs

type ConstraintsArgs struct {
	Architecture string
	Container    string
	CpuCores     uint64
	CpuPower     uint64
	InstanceType string
	Memory       uint64
	RootDisk     uint64

	Spaces []string
	Tags   []string

	VirtType string
}

ConstraintsArgs is an argument struct to construct Constraints.

type Endpoint

type Endpoint interface {
	ApplicationName() string
	Name() string
	// Role, Interface, Optional, Limit, and Scope should all be available
	// through the Charm associated with the Application. There is no real need
	// for this information to be denormalised like this. However, for now,
	// since the import may well take place before the charms have been loaded
	// into the model, we'll send this information over.
	Role() string
	Interface() string
	Optional() bool
	Limit() int
	Scope() string

	// UnitCount returns the number of units the endpoint has settings for.
	UnitCount() int

	Settings(unitName string) map[string]interface{}
	SetUnitSettings(unitName string, settings map[string]interface{})
}

Endpoint represents one end of a relation. A named endpoint provided by the charm that is deployed for the application.

type EndpointArgs

type EndpointArgs struct {
	ApplicationName string
	Name            string
	Role            string
	Interface       string
	Optional        bool
	Limit           int
	Scope           string
}

EndpointArgs is an argument struct used to specify a relation.

type Filesystem

type Filesystem interface {
	HasStatus
	HasStatusHistory

	Tag() names.FilesystemTag
	Volume() names.VolumeTag
	Storage() names.StorageTag
	Binding() (names.Tag, error)

	Provisioned() bool

	Size() uint64
	Pool() string

	FilesystemID() string

	Attachments() []FilesystemAttachment
	AddAttachment(FilesystemAttachmentArgs) FilesystemAttachment
}

Filesystem represents a filesystem in the model.

type FilesystemArgs

type FilesystemArgs struct {
	Tag          names.FilesystemTag
	Storage      names.StorageTag
	Volume       names.VolumeTag
	Binding      names.Tag
	Provisioned  bool
	Size         uint64
	Pool         string
	FilesystemID string
}

FilesystemArgs is an argument struct used to add a filesystem to the Model.

type FilesystemAttachment

type FilesystemAttachment interface {
	Machine() names.MachineTag
	Provisioned() bool
	MountPoint() string
	ReadOnly() bool
}

FilesystemAttachment represents a filesystem attached to a machine.

type FilesystemAttachmentArgs

type FilesystemAttachmentArgs struct {
	Machine     names.MachineTag
	Provisioned bool
	ReadOnly    bool
	MountPoint  string
}

FilesystemAttachmentArgs is an argument struct used to add information about the cloud instance to a Filesystem.

type HasAnnotations

type HasAnnotations interface {
	Annotations() map[string]string
	SetAnnotations(map[string]string)
}

HasAnnotations defines the common methods for setting and getting annotations for the various entities.

type HasConstraints

type HasConstraints interface {
	Constraints() Constraints
	SetConstraints(ConstraintsArgs)
}

HasConstraints defines the common methods for setting and getting constraints for the various entities.

type HasStatus

type HasStatus interface {
	Status() Status
	SetStatus(StatusArgs)
}

HasStatus defines the common methods for setting and getting status entries for the various entities.

type HasStatusHistory

type HasStatusHistory interface {
	StatusHistory() []Status
	SetStatusHistory([]StatusArgs)
}

HasStatusHistory defines the common methods for setting and getting historical status entries for the various entities.

type IPAddress

type IPAddress interface {
	ProviderID() string
	DeviceName() string
	MachineID() string
	SubnetCIDR() string
	ConfigMethod() string
	Value() string
	DNSServers() []string
	DNSSearchDomains() []string
	GatewayAddress() string
}

IPAddress represents an IP address.

type IPAddressArgs

type IPAddressArgs struct {
	ProviderID       string
	DeviceName       string
	MachineID        string
	SubnetCIDR       string
	ConfigMethod     string
	Value            string
	DNSServers       []string
	DNSSearchDomains []string
	GatewayAddress   string
}

IPAddressArgs is an argument struct used to create a new internal ipaddress type that supports the IPAddress interface.

type LinkLayerDevice

type LinkLayerDevice interface {
	Name() string
	MTU() uint
	ProviderID() string
	MachineID() string
	Type() string
	MACAddress() string
	IsAutoStart() bool
	IsUp() bool
	ParentName() string
}

LinkLayerDevice represents a link layer device.

type LinkLayerDeviceArgs

type LinkLayerDeviceArgs struct {
	Name        string
	MTU         uint
	ProviderID  string
	MachineID   string
	Type        string
	MACAddress  string
	IsAutoStart bool
	IsUp        bool
	ParentName  string
}

LinkLayerDeviceArgs is an argument struct used to create a new internal linklayerdevice type that supports the LinkLayerDevice interface.

type Machine

type Machine interface {
	HasAnnotations
	HasConstraints
	HasStatus
	HasStatusHistory

	Id() string
	Tag() names.MachineTag
	Nonce() string
	PasswordHash() string
	Placement() string
	Series() string
	ContainerType() string
	Jobs() []string
	SupportedContainers() ([]string, bool)

	Instance() CloudInstance
	SetInstance(CloudInstanceArgs)

	// Life() string -- only transmit alive things?
	ProviderAddresses() []Address
	MachineAddresses() []Address
	SetAddresses(machine []AddressArgs, provider []AddressArgs)

	PreferredPublicAddress() Address
	PreferredPrivateAddress() Address
	SetPreferredAddresses(public AddressArgs, private AddressArgs)

	Tools() AgentTools
	SetTools(AgentToolsArgs)

	Containers() []Machine
	AddContainer(MachineArgs) Machine

	BlockDevices() []BlockDevice
	AddBlockDevice(BlockDeviceArgs) BlockDevice

	OpenedPorts() []OpenedPorts
	AddOpenedPorts(OpenedPortsArgs) OpenedPorts

	// THINKING: Validate() error to make sure the machine has
	// enough stuff set, like tools, and addresses etc.
	Validate() error
}

Machine represents an existing live machine or container running in the model.

type MachineArgs

type MachineArgs struct {
	Id            names.MachineTag
	Nonce         string
	PasswordHash  string
	Placement     string
	Series        string
	ContainerType string
	Jobs          []string
	// A null value means that we don't yet know which containers
	// are supported. An empty slice means 'no containers are supported'.
	SupportedContainers *[]string
}

MachineArgs is an argument struct used to add a machine to the Model.

type Model

type Model interface {
	HasAnnotations
	HasConstraints

	Cloud() string
	CloudRegion() string
	CloudCredential() string
	Tag() names.ModelTag
	Owner() names.UserTag
	Config() map[string]interface{}
	LatestToolsVersion() version.Number

	// UpdateConfig overwrites existing config values with those specified.
	UpdateConfig(map[string]interface{})

	// Blocks returns a map of block type to the message associated with that
	// block.
	Blocks() map[string]string

	Users() []User
	AddUser(UserArgs)

	Machines() []Machine
	AddMachine(MachineArgs) Machine

	Applications() []Application
	AddApplication(ApplicationArgs) Application

	Relations() []Relation
	AddRelation(RelationArgs) Relation

	Spaces() []Space
	AddSpace(SpaceArgs) Space

	LinkLayerDevices() []LinkLayerDevice
	AddLinkLayerDevice(LinkLayerDeviceArgs) LinkLayerDevice

	Subnets() []Subnet
	AddSubnet(SubnetArgs) Subnet

	IPAddresses() []IPAddress
	AddIPAddress(IPAddressArgs) IPAddress

	SSHHostKeys() []SSHHostKey
	AddSSHHostKey(SSHHostKeyArgs) SSHHostKey

	CloudImageMetadata() []CloudImageMetadata
	AddCloudImageMetadata(CloudImageMetadataArgs) CloudImageMetadata

	Actions() []Action
	AddAction(ActionArgs) Action

	Sequences() map[string]int
	SetSequence(name string, value int)

	Volumes() []Volume
	AddVolume(VolumeArgs) Volume

	Filesystems() []Filesystem
	AddFilesystem(FilesystemArgs) Filesystem

	Storages() []Storage
	AddStorage(StorageArgs) Storage

	StoragePools() []StoragePool
	AddStoragePool(StoragePoolArgs) StoragePool

	Validate() error
}

Model is a database agnostic representation of an existing model.

func Deserialize

func Deserialize(bytes []byte) (Model, error)

Deserialize constructs a Model from a serialized YAML byte stream. The normal use for this is to construct the Model representation after getting the byte stream from an API connection or read from a file.

func NewModel

func NewModel(args ModelArgs) Model

NewModel returns a Model based on the args specified.

type ModelArgs

type ModelArgs struct {
	Owner              names.UserTag
	Config             map[string]interface{}
	LatestToolsVersion version.Number
	Blocks             map[string]string
	Cloud              string
	CloudRegion        string
	CloudCredential    string
}

ModelArgs represent the bare minimum information that is needed to represent a model.

type OpenedPorts

type OpenedPorts interface {
	SubnetID() string
	OpenPorts() []PortRange
}

OpenedPorts represents a collection of port ranges that are open on a particular subnet. OpenedPorts are always associated with a Machine.

type OpenedPortsArgs

type OpenedPortsArgs struct {
	SubnetID    string
	OpenedPorts []PortRangeArgs
}

OpenedPortsArgs is an argument struct used to add a set of opened port ranges to a machine.

type Payload

type Payload interface {
	Name() string
	Type() string
	RawID() string
	State() string
	Labels() []string
}

Payload represents a charm payload for a unit.

type PayloadArgs

type PayloadArgs struct {
	Name   string
	Type   string
	RawID  string
	State  string
	Labels []string
}

PayloadArgs is an argument struct used to create a new internal payload type that supports the Payload interface.

type PortRange

type PortRange interface {
	UnitName() string
	FromPort() int
	ToPort() int
	Protocol() string
}

PortRange represents one or more contiguous ports opened by a particular Unit.

type PortRangeArgs

type PortRangeArgs struct {
	UnitName string
	FromPort int
	ToPort   int
	Protocol string
}

PortRangeArgs is an argument struct used to create a PortRange. This is only done as part of creating OpenedPorts for a Machine.

type Relation

type Relation interface {
	Id() int
	Key() string

	Endpoints() []Endpoint
	AddEndpoint(EndpointArgs) Endpoint
}

Relation represents a relationship between two applications, or a peer relation between different instances of an application.

type RelationArgs

type RelationArgs struct {
	Id  int
	Key string
}

RelationArgs is an argument struct used to specify a relation.

type SSHHostKey

type SSHHostKey interface {
	MachineID() string
	Keys() []string
}

SSHHostKey represents an ssh host key.

type SSHHostKeyArgs

type SSHHostKeyArgs struct {
	MachineID string
	Keys      []string
}

SSHHostKeyArgs is an argument struct used to create a new internal sshHostKey type that supports the SSHHostKey interface.

type Space

type Space interface {
	Name() string
	Public() bool
	ProviderID() string
}

Space represents a network space, which is a named collection of subnets.

type SpaceArgs

type SpaceArgs struct {
	Name       string
	Public     bool
	ProviderID string
}

SpaceArgs is an argument struct used to create a new internal space type that supports the Space interface.

type Status

type Status interface {
	Value() string
	Message() string
	Data() map[string]interface{}
	Updated() time.Time
}

Status represents an agent, application, or workload status.

type StatusArgs

type StatusArgs struct {
	Value   string
	Message string
	Data    map[string]interface{}
	Updated time.Time
}

StatusArgs is an argument struct used to set the agent, application, or workload status.

type StatusHistory_

type StatusHistory_ struct {
	Version int             `yaml:"version"`
	History []*StatusPoint_ `yaml:"history"`
}

func (*StatusHistory_) SetStatusHistory

func (s *StatusHistory_) SetStatusHistory(args []StatusArgs)

SetStatusHistory implements HasStatusHistory.

func (*StatusHistory_) StatusHistory

func (s *StatusHistory_) StatusHistory() []Status

StatusHistory implements HasStatusHistory.

type StatusPoint_

type StatusPoint_ struct {
	Value_   string                 `yaml:"value"`
	Message_ string                 `yaml:"message,omitempty"`
	Data_    map[string]interface{} `yaml:"data,omitempty"`
	Updated_ time.Time              `yaml:"updated"`
}

StatusPoint_ implements Status, and represents the status of an entity at a point in time. Used in the serialization of both status and StatusHistory_.

func (*StatusPoint_) Data

func (a *StatusPoint_) Data() map[string]interface{}

Data implements Status.

func (*StatusPoint_) Message

func (a *StatusPoint_) Message() string

Message implements Status.

func (*StatusPoint_) Updated

func (a *StatusPoint_) Updated() time.Time

Updated implements Status.

func (*StatusPoint_) Value

func (a *StatusPoint_) Value() string

Value implements Status.

type Storage

type Storage interface {
	Tag() names.StorageTag
	Kind() string
	// Owner returns the tag of the application or unit that owns this storage
	// instance.
	Owner() (names.Tag, error)
	Name() string

	Attachments() []names.UnitTag

	Validate() error
}

Storage represents the state of a unit or application-wide storage instance in the model.

type StorageArgs

type StorageArgs struct {
	Tag         names.StorageTag
	Kind        string
	Owner       names.Tag
	Name        string
	Attachments []names.UnitTag
}

StorageArgs is an argument struct used to add a storage to the Model.

type StorageConstraint

type StorageConstraint interface {
	// Pool is the name of the storage pool from which to provision the
	// storage instances.
	Pool() string
	// Size is the required size of the storage instances, in MiB.
	Size() uint64
	// Count is the required number of storage instances.
	Count() uint64
}

StorageConstraint repressents the user-specified constraints for provisioning storage instances for an application unit.

type StorageConstraintArgs

type StorageConstraintArgs struct {
	Pool  string
	Size  uint64
	Count uint64
}

StorageConstraintArgs is an argument struct used to create a new internal storageconstraint type that supports the StorageConstraint interface.

type StoragePool

type StoragePool interface {
	Name() string
	Provider() string
	Attributes() map[string]interface{}
}

StoragePool represents a named storage pool and its settings.

type StoragePoolArgs

type StoragePoolArgs struct {
	Name       string
	Provider   string
	Attributes map[string]interface{}
}

StoragePoolArgs is an argument struct used to add a storage pool to the Model.

type Subnet

type Subnet interface {
	ProviderId() string
	CIDR() string
	VLANTag() int
	AvailabilityZone() string
	SpaceName() string
	AllocatableIPHigh() string
	AllocatableIPLow() string
}

Subnet represents a network subnet.

type SubnetArgs

type SubnetArgs struct {
	ProviderId       string
	CIDR             string
	VLANTag          int
	AvailabilityZone string
	SpaceName        string

	// These will be deprecated once the address allocation strategy for
	// EC2 is changed. They are unused already on MAAS.
	AllocatableIPHigh string
	AllocatableIPLow  string
}

SubnetArgs is an argument struct used to create a new internal subnet type that supports the Subnet interface.

type Unit

type Unit interface {
	HasAnnotations
	HasConstraints

	Tag() names.UnitTag
	Name() string
	Machine() names.MachineTag

	PasswordHash() string

	Principal() names.UnitTag
	Subordinates() []names.UnitTag

	MeterStatusCode() string
	MeterStatusInfo() string

	Tools() AgentTools
	SetTools(AgentToolsArgs)

	WorkloadStatus() Status
	SetWorkloadStatus(StatusArgs)

	WorkloadStatusHistory() []Status
	SetWorkloadStatusHistory([]StatusArgs)

	WorkloadVersion() string

	WorkloadVersionHistory() []Status
	SetWorkloadVersionHistory([]StatusArgs)

	AgentStatus() Status
	SetAgentStatus(StatusArgs)

	AgentStatusHistory() []Status
	SetAgentStatusHistory([]StatusArgs)

	AddPayload(PayloadArgs) Payload
	Payloads() []Payload

	Validate() error
}

Unit represents an instance of an application in a model.

type UnitArgs

type UnitArgs struct {
	Tag          names.UnitTag
	Machine      names.MachineTag
	PasswordHash string
	Principal    names.UnitTag
	Subordinates []names.UnitTag

	WorkloadVersion string
	MeterStatusCode string
	MeterStatusInfo string
}

UnitArgs is an argument struct used to add a Unit to a Application in the Model.

type User

type User interface {
	Name() names.UserTag
	DisplayName() string
	CreatedBy() names.UserTag
	DateCreated() time.Time
	LastConnection() time.Time
	Access() string
}

User represents a user of the model. Users are able to connect to, and depending on the read only flag, modify the model.

type UserArgs

type UserArgs struct {
	Name           names.UserTag
	DisplayName    string
	CreatedBy      names.UserTag
	DateCreated    time.Time
	LastConnection time.Time
	Access         string
}

type Volume

type Volume interface {
	HasStatus
	HasStatusHistory

	Tag() names.VolumeTag
	Storage() names.StorageTag

	Binding() (names.Tag, error)

	Provisioned() bool

	Size() uint64
	Pool() string

	HardwareID() string
	VolumeID() string
	Persistent() bool

	Attachments() []VolumeAttachment
	AddAttachment(VolumeAttachmentArgs) VolumeAttachment
}

Volume represents a volume (disk, logical volume, etc.) in the model.

type VolumeArgs

type VolumeArgs struct {
	Tag         names.VolumeTag
	Storage     names.StorageTag
	Binding     names.Tag
	Provisioned bool
	Size        uint64
	Pool        string
	HardwareID  string
	VolumeID    string
	Persistent  bool
}

VolumeArgs is an argument struct used to add a volume to the Model.

type VolumeAttachment

type VolumeAttachment interface {
	Machine() names.MachineTag
	Provisioned() bool
	ReadOnly() bool
	DeviceName() string
	DeviceLink() string
	BusAddress() string
}

VolumeAttachment represents a volume attached to a machine.

type VolumeAttachmentArgs

type VolumeAttachmentArgs struct {
	Machine     names.MachineTag
	Provisioned bool
	ReadOnly    bool
	DeviceName  string
	DeviceLink  string
	BusAddress  string
}

VolumeAttachmentArgs is an argument struct used to add information about the cloud instance to a Volume.

Jump to

Keyboard shortcuts

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