Documentation ¶
Index ¶
- Constants
- Variables
- func SelectInternalAddress(addresses []Address, machineLocal bool) string
- func SelectInternalHostPort(hps []HostPort, machineLocal bool) string
- func SelectPublicAddress(addresses []Address) string
- func SelectPublicHostPort(hps []HostPort) string
- func SortPorts(ports []Port)
- type Address
- type AddressType
- type ContainerType
- type HardwareCharacteristics
- type HostPort
- type Id
- type Instance
- type NetworkScope
- type Placement
- type Port
Constants ¶
const ( NONE = ContainerType("none") LXC = ContainerType("lxc") KVM = ContainerType("kvm") )
const ( // MachineScope is a special scope name that is used // for machine placement directives (e.g. --to 0). MachineScope = "#" )
Variables ¶
var ContainerTypes []ContainerType = []ContainerType{ LXC, KVM, }
ContainerTypes is used to validate add-machine arguments.
var ErrPlacementScopeMissing = fmt.Errorf("placement scope missing")
Functions ¶
func SelectInternalAddress ¶
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 ¶
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 ¶
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 ¶
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 ¶
NewAddresses is a convenience function to create addresses from a string slice
func (Address) 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 ¶
func (hc *HardwareCharacteristics) Set(s string) error
Implement gnuflag.Value
func (HardwareCharacteristics) String ¶
func (hc HardwareCharacteristics) String() string
type HostPort ¶
HostPort associates an address with a port.
func AddressesWithPort ¶
AddressesWithPort returns the given addresses all associated with the given port.
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 ¶
MustParsePlacement attempts to parse the specified string and create a corresponding Placement structure, panicking if an error occurs.
func ParsePlacement ¶
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.