// Copyright 2016 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package state
// ipAddressDoc describes the persistent state of an IP address assigned to a
// link-layer network device (a.k.a network interface card - NIC).
type ipAddressDoc struct {
// DocID is the IP address ID, prefixed by ModelUUID.
DocID string `bson:"_id"`
// ID is the ID of the IP address, which is generated from a sequence like
// for machines and units.
ID string `bson:"id"`
// ModelUUID is the UUID of the model this IP address belongs to.
ModelUUID string `bson:"model-uuid"`
// ProviderID is a provider-specific ID of the IP address, prefixed by
// ModelUUID. Empty when not supported by the provider.
ProviderID string `bson:"providerid,omitempty"`
// DeviceName is the name of the link-layer device this IP address is
// assigned to.
DeviceName string `bson:"device-name"`
// MachineID is the ID of the machine this IP address's device belongs to.
MachineID string `bson:"machine-id"`
// SubnetID is the ID of the subnet this IP address belongs to. Must be
// empty for ConfigType LoopbackIPAddress.
SubnetID string `bson:"subnet-id"`
// ConfigMethod is the method used to configure this IP address.
ConfigMethod IPAddressConfigMethod `bson:"config-method"`
// Address is the value of the configured IP address.
Address string `bson:"address"`
// DNSServers contains a list of DNS nameservers that apply to this IP
// address's device. Can be empty.
DNSServers []string `bson:"dns-servers,omitempty"`
// DNSSearchDomains contains a list of DNS domain names used to qualify
// hostnames, and can be empty.
DNSSearchDomains []string `bson:"dns-search-domains,omitempty"`
// GatewayAddress is the IP address of the gateway this IP address's device
// uses. Can be empty.
GatewayAddress string `bson:"gateway-address,omitempty"`
}
// IPAddressConfigMethod is the method used to configure an IP address.
type IPAddressConfigMethod string
const (
// UnknownIPAddress is used for IP addresses with unknown configuration type.
UnknownIPAddress IPAddressConfigMethod = "unknown"
// LoopbackIPAddress is used for IP addresses of LoopbackDevice types.
LoopbackIPAddress IPAddressConfigMethod = "loopback"
// StaticIPAddress is used for statically configured addresses.
StaticIPAddress IPAddressConfigMethod = "static"
// DynamicIPAddress is used for addresses dynamically configured via DHCP.
DynamicIPAddress IPAddressConfigMethod = "dynamic"
// ManualIPAddress is used for manually configured addresses.
ManualIPAddress IPAddressConfigMethod = "manual"
)
// IPAddress represents the state of an IP address assigned to a link-layer
// network device on a machine.
type IPAddress struct {
st *State
doc ipAddressDoc
}