Documentation
¶
Overview ¶
Package sl wraps the SoftLayer API for managing IP notes and PTR records.
Index ¶
- Variables
- func FirstFree(subnets []SubnetInfo) (SubnetInfo, IPInfo, bool)
- func IsPrivateIP(ip string) bool
- func ResolveExcludeNotes(opts ListOpts, defaults []string) []string
- type Client
- func (c *Client) DeletePTR(ip string) (datatypes.Dns_Domain_ResourceRecord, error)
- func (c *Client) GetNote(ip string) (string, error)
- func (c *Client) GetPTR(ip string) (datatypes.Dns_Domain_ResourceRecord, error)
- func (c *Client) ListSubnets(opts ListOpts) ([]SubnetInfo, error)
- func (c *Client) SetNote(ip, note string) error
- func (c *Client) SetPTR(ip, ptr string, ttl int) (datatypes.Dns_Domain_ResourceRecord, error)
- func (c *Client) StaleIPs(opts ListOpts) ([]IPInfo, error)
- type IPInfo
- type ListOpts
- type SubnetInfo
Constants ¶
This section is empty.
Variables ¶
var DefaultListExcludeNotes = []string{
"ONLY FOR METAL",
"FULL",
"NETWORK FOR INFOSEC",
}
DefaultListExcludeNotes are subnet notes skipped by list and lease unless overridden on the command line.
var DefaultStaleExcludeNotes = []string{
"ONLY FOR METAL",
"NETWORK FOR INFOSEC",
}
DefaultStaleExcludeNotes are subnet notes skipped by stale. FULL subnets are kept: dead IPs there are exactly what we want to find.
var ErrPTRNotFound = errors.New("PTR record not found")
ErrPTRNotFound is returned when an IP has no matching PTR record.
Functions ¶
func FirstFree ¶
func FirstFree(subnets []SubnetInfo) (SubnetInfo, IPInfo, bool)
FirstFree returns the first free IP across the given subnets along with its subnet, or ok=false when everything is taken.
func IsPrivateIP ¶
IsPrivateIP reports whether the address belongs to a private range (RFC 1918: 10/8, 172.16/12, 192.168/16).
func ResolveExcludeNotes ¶
ResolveExcludeNotes returns the subnet-note exclusions to send to the API.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a thin wrapper around the SoftLayer API session.
func NewClientFromEnv ¶
NewClientFromEnv builds a Client using SL_USER / SL_APIKEY credentials.
func (*Client) DeletePTR ¶
func (c *Client) DeletePTR(ip string) (datatypes.Dns_Domain_ResourceRecord, error)
DeletePTR removes the PTR record of an IP. Deleting a missing record is reported via ErrPTRNotFound so callers can treat it as a no-op.
func (*Client) GetPTR ¶
func (c *Client) GetPTR(ip string) (datatypes.Dns_Domain_ResourceRecord, error)
GetPTR returns the PTR record for the given IP, or ErrPTRNotFound.
func (*Client) ListSubnets ¶
func (c *Client) ListSubnets(opts ListOpts) ([]SubnetInfo, error)
ListSubnets returns account subnets with their IPs, PTRs and notes.
type IPInfo ¶
type IPInfo struct {
IP string `json:"ip"`
PTR string `json:"ptr,omitempty"`
Note string `json:"note,omitempty"`
Free bool `json:"free"`
}
IPInfo describes a single usable IP address inside a subnet.