instance

package
v0.0.0-...-732aecd Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2014 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NONE = ContainerType("none")
	LXC  = ContainerType("lxc")
	KVM  = ContainerType("kvm")
)
View Source
const (
	// MachineScope is a special scope name that is used
	// for machine placement directives (e.g. --to 0).
	MachineScope = "#"
)

Variables

View Source
var ContainerTypes []ContainerType = []ContainerType{
	LXC,
	KVM,
}

ContainerTypes is used to validate add-machine arguments.

View Source
var ErrPlacementScopeMissing = fmt.Errorf("placement scope missing")

Functions

func SelectInternalAddress

func SelectInternalAddress(addresses []Address, machineLocal bool) string

SelectInternalAddress picks one address from a slice that can be used as an endpoint for juju internal communication. If there are no suitable addresses, the empty string is returned.

func SelectInternalHostPort

func SelectInternalHostPort(hps []HostPort, machineLocal bool) string

SelectInternalHostPort picks one HostPort from a slice that can be used as an endpoint for juju internal communication and returns it in its NetAddr form. If there are no suitable addresses, the empty string is returned.

func SelectPublicAddress

func SelectPublicAddress(addresses []Address) string

SelectPublicAddress picks one address from a slice that would be appropriate to display as a publicly accessible endpoint. If there are no suitable addresses, the empty string is returned.

func SelectPublicHostPort

func SelectPublicHostPort(hps []HostPort) string

func SortPorts

func SortPorts(ports []Port)

SortPorts sorts the given ports, first by protocol, then by number.

Types

type Address

type Address struct {
	Value       string
	Type        AddressType
	NetworkName string
	NetworkScope
}

Address represents the location of a machine, including metadata about what kind of location the address describes.

func NewAddress

func NewAddress(value string, scope NetworkScope) Address

NewAddress creates a new Address, deriving its type from the value.

If the specified scope is NetworkUnknown, then NewAddress will attempt derive the scope based on reserved IP address ranges.

func NewAddresses

func NewAddresses(inAddresses ...string) (outAddresses []Address)

NewAddresses is a convenience function to create addresses from a string slice

func (Address) String

func (a Address) String() string

String returns a string representation of the address, in the form: scope:address(network name); for example:

public:c2-54-226-162-124.compute-1.amazonaws.com(ec2network)

If the scope is NetworkUnknown, the initial scope: prefix will be omitted. If the NetworkName is blank, the (network name) suffix will be omitted.

type AddressType

type AddressType string

AddressType represents the possible ways of specifying a machine location by either a hostname resolvable by dns lookup, or ipv4 or ipv6 address.

const (
	HostName    AddressType = "hostname"
	Ipv4Address AddressType = "ipv4"
	Ipv6Address AddressType = "ipv6"
)

func DeriveAddressType

func DeriveAddressType(value string) AddressType

type ContainerType

type ContainerType string

func ParseContainerType

func ParseContainerType(ctype string) (ContainerType, error)

ParseContainerType converts the specified string into a supported ContainerType instance or returns an error if the container type is invalid.

func ParseContainerTypeOrNone

func ParseContainerTypeOrNone(ctype string) (ContainerType, error)

ParseContainerTypeOrNone converts the specified string into a supported ContainerType instance or returns an error if the container type is invalid. For this version of the function, 'none' is a valid value.

type HardwareCharacteristics

type HardwareCharacteristics struct {
	Arch     *string   `json:",omitempty" yaml:"arch,omitempty"`
	Mem      *uint64   `json:",omitempty" yaml:"mem,omitempty"`
	RootDisk *uint64   `json:",omitempty" yaml:"rootdisk,omitempty"`
	CpuCores *uint64   `json:",omitempty" yaml:"cpucores,omitempty"`
	CpuPower *uint64   `json:",omitempty" yaml:"cpupower,omitempty"`
	Tags     *[]string `json:",omitempty" yaml:"tags,omitempty"`
}

HardwareCharacteristics represents the characteristics of the instance (if known). Attributes that are nil are unknown or not supported.

func MustParseHardware

func MustParseHardware(args ...string) HardwareCharacteristics

MustParseHardware constructs a HardwareCharacteristics from the supplied arguments, as Parse, but panics on failure.

func ParseHardware

func ParseHardware(args ...string) (HardwareCharacteristics, error)

ParseHardware constructs a HardwareCharacteristics from the supplied arguments, each of which must contain only spaces and name=value pairs. If any name is specified more than once, an error is returned.

func (*HardwareCharacteristics) Set

Implement gnuflag.Value

func (HardwareCharacteristics) String

func (hc HardwareCharacteristics) String() string

type HostPort

type HostPort struct {
	Address
	Port int
}

HostPort associates an address with a port.

func AddressesWithPort

func AddressesWithPort(addrs []Address, port int) []HostPort

AddressesWithPort returns the given addresses all associated with the given port.

func (HostPort) NetAddr

func (hp HostPort) NetAddr() string

NetAddr returns the host-port as an address suitable for calling net.Dial.

type Id

type Id string

An instance Id is a provider-specific identifier associated with an instance (physical or virtual machine allocated in the provider).

type Instance

type Instance interface {
	// Id returns a provider-generated identifier for the Instance.
	Id() Id

	// Status returns the provider-specific status for the instance.
	Status() string

	// Refresh refreshes local knowledge of the instance from the provider.
	Refresh() error

	// Addresses returns a list of hostnames or ip addresses
	// associated with the instance.
	Addresses() ([]Address, error)

	// OpenPorts opens the given ports on the instance, which
	// should have been started with the given machine id.
	OpenPorts(machineId string, ports []Port) error

	// ClosePorts closes the given ports on the instance, which
	// should have been started with the given machine id.
	ClosePorts(machineId string, ports []Port) error

	// Ports returns the set of ports open on the instance, which
	// should have been started with the given machine id.
	// The ports are returned as sorted by SortPorts.
	Ports(machineId string) ([]Port, error)
}

Instance represents the the realization of a machine in state.

type NetworkScope

type NetworkScope string

NetworkScope denotes the context a location may apply to. If a name or address can be reached from the wider internet, it is considered public. A private network address is either specific to the cloud or cloud subnet a machine belongs to, or to the machine itself for containers.

const (
	NetworkUnknown      NetworkScope = ""
	NetworkPublic       NetworkScope = "public"
	NetworkCloudLocal   NetworkScope = "local-cloud"
	NetworkMachineLocal NetworkScope = "local-machine"
)

type Placement

type Placement struct {
	// Scope is the scope of the placement directive. Scope may
	// be a container type (lxc, kvm), instance.MachineScope, or
	// an environment name.
	//
	// If Scope is empty, then it must be inferred from the context.
	Scope string

	// Directive is a scope-specific placement directive.
	//
	// For MachineScope or a container scope, this may be empty or
	// the ID of an existing machine.
	Directive string
}

Placement defines a placement directive, which has a scope and a value that is scope-specific.

func MustParsePlacement

func MustParsePlacement(directive string) *Placement

MustParsePlacement attempts to parse the specified string and create a corresponding Placement structure, panicking if an error occurs.

func ParsePlacement

func ParsePlacement(directive string) (*Placement, error)

ParsePlacement attempts to parse the specified string and create a corresponding Placement structure.

If the placement directive is non-empty and missing a scope, ErrPlacementScopeMissing will be returned as well as a Placement with an empty Scope field.

func (*Placement) String

func (p *Placement) String() string

type Port

type Port struct {
	Protocol string
	Number   int
}

Port identifies a network port number for a particular protocol.

func (Port) String

func (p Port) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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