packet

package
v0.0.0-...-10b7995 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ZeroMAC = MACAddr{}
	OnesMAC = MACAddr{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
)

Functions

func IsNotExist

func IsNotExist(err error) bool

Types

type BondingMode

type BondingMode int

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(consumerToken, authToken string, baseURL *url.URL) (*Client, error)

func NewMockClient

func NewMockClient(baseURL *url.URL) *Client

func (*Client) DiscoverHardwareFromDHCP

func (c *Client) DiscoverHardwareFromDHCP(mac net.HardwareAddr, giaddr net.IP, circuitID string) (*Discovery, error)

func (*Client) DiscoverHardwareFromIP

func (c *Client) DiscoverHardwareFromIP(ip net.IP) (*Discovery, error)

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) error

func (*Client) Get

func (c *Client) Get(ref string, v interface{}) error

func (*Client) GetInstanceIDFromIP

func (c *Client) GetInstanceIDFromIP(dip net.IP) (string, error)

GetDeviceIDFromIP Looks up a device (instance) in cacher via ByIP

func (*Client) Patch

func (c *Client) Patch(ref, mime string, body io.Reader, v interface{}) error

func (*Client) Post

func (c *Client) Post(ref, mime string, body io.Reader, v interface{}) error

func (*Client) PostHardwareComponent

func (c *Client) PostHardwareComponent(hardwareID string, body io.Reader) (*ComponentsResponse, error)

PostHardwareComponent - POSTs a HardwareComponent to the API

func (*Client) PostHardwareEvent

func (c *Client) PostHardwareEvent(id string, body io.Reader) (string, error)

func (*Client) PostHardwareFail

func (c *Client) PostHardwareFail(id string, body io.Reader) error

func (*Client) PostHardwarePhoneHome

func (c *Client) PostHardwarePhoneHome(id string) error

func (*Client) PostHardwareProblem

func (c *Client) PostHardwareProblem(id string, body io.Reader) (string, error)

func (*Client) PostInstanceEvent

func (c *Client) PostInstanceEvent(id string, body io.Reader) (string, error)

func (*Client) PostInstanceFail

func (c *Client) PostInstanceFail(id string, body io.Reader) error

func (*Client) PostInstancePassword

func (c *Client) PostInstancePassword(id, pass string) error

func (*Client) PostInstancePhoneHome

func (c *Client) PostInstancePhoneHome(id string) error

func (*Client) UpdateInstance

func (c *Client) UpdateInstance(id string, body io.Reader) error

type Component

type Component struct {
	Type            string      `json:"type"`
	Name            string      `json:"name"`
	Vendor          string      `json:"vendor"`
	Model           string      `json:"model"`
	Serial          string      `json:"serial"`
	FirmwareVersion string      `json:"firmware_version"`
	Data            interface{} `json:"data"`
}

type ComponentsResponse

type ComponentsResponse struct {
	Components []Component `json:"components"`
}

type Device

type Device struct {
	ID string `json:"id"`
}

Device Full device result from /devices endpoint

type Discovery

type Discovery struct {
	*Hardware
}

func NewDiscovery

func NewDiscovery(j string) (*Discovery, error)

New instantiates a Discovery struct from the json argument

func (Discovery) DiscoveredIP

func (d Discovery) DiscoveredIP(mac string) *IP

DiscoveredIP returns the IP configuration that should be offered to a newly discovered BMC, if the MAC is a BMC MAC

func (Discovery) HardwareIP

func (d Discovery) HardwareIP(mac string) *IP

HardwareIP returns the IP configuration that should be offered to the hardware if there is no instance

func (Discovery) InstanceIP

func (d Discovery) InstanceIP(mac string) *IP

InstanceIP returns the IP configuration that should be Offered to the instance if there is one; if it's prov/deprov'ing, it's the hardware IP

func (Discovery) ManagementIP

func (d Discovery) ManagementIP(mac string) *IP

ManagementIP returns the IP configuration that should be Offered to the BMC, if the MAC is a BMC MAC

func (Discovery) ManagementMAC

func (d Discovery) ManagementMAC() MACAddr

ManagementMAC returns the mac address of the BMC interface

func (Discovery) Mode

func (d Discovery) Mode(mac net.HardwareAddr) string

Mode returns whether the mac belongs to the instance, hardware, bmc, discovered, or unknown

func (Discovery) NetConfig

func (d Discovery) NetConfig(mac net.HardwareAddr) IP

NetConfig returns the network configuration that corresponds to the interface whose MAC address is mac.

func (Discovery) PrimaryDataMAC

func (d Discovery) PrimaryDataMAC() MACAddr

PrimaryDataMAC returns the mac associated with eth0, or as a fallback the lowest numbered non-bmc MAC address

type Event

type Event struct {
	Type    string `json:"type"`
	Body    string `json:"body,omitempty"`
	Private bool   `json:"private"`
}

type Getter

type Getter interface {
	Get() (*http.Request, error)
}

type Hardware

type Hardware struct {
	ID    string        `json:"id"`
	Name  string        `json:"name"`
	State HardwareState `json:"state"`

	BondingMode     BondingMode     `json:"bonding_mode"`
	NetworkPorts    []Port          `json:"network_ports"`
	Manufacturer    Manufacturer    `json:"manufacturer"`
	PlanSlug        string          `json:"plan_slug"`
	PlanVersionSlug string          `json:"plan_version_slug"`
	Arch            string          `json:"arch"`
	FacilityCode    string          `json:"facility_code"`
	IPMI            IP              `json:"management"`
	IPs             []IP            `json:"ip_addresses"`
	PreinstallOS    OperatingSystem `json:"preinstalled_operating_system_version"`
	PrivateSubnets  []string        `json:"private_subnets,omitempty"`
	UEFI            bool            `json:"efi_boot"`
	AllowPXE        bool            `json:"allow_pxe"`
	ServicesVersion ServicesVersion `json:"services"`

	Instance *Instance `json:"instance"`
}

func (*Hardware) Interfaces

func (h *Hardware) Interfaces() []Port

func (*Hardware) Management

func (h *Hardware) Management() (address, netmask, gateway net.IP)

type HardwareState

type HardwareState string

type IP

type IP struct {
	Address    net.IP `json:"address"`
	Netmask    net.IP `json:"netmask"`
	Gateway    net.IP `json:"gateway"`
	Family     int    `json:"address_family"`
	Public     bool   `json:"public"`
	Management bool   `json:"management"`
}

type Instance

type Instance struct {
	ID       string        `json:"id"`
	State    InstanceState `json:"state"`
	Hostname string        `json:"hostname"`
	AllowPXE bool          `json:"allow_pxe"`
	Rescue   bool          `json:"rescue"`

	OS            OperatingSystem `json:"operating_system_version"`
	AlwaysPXE     bool            `json:"always_pxe,omitempty"`
	IPXEScriptURL string          `json:"ipxe_script_url,omitempty"`
	IPs           []IP            `json:"ip_addresses"`
	UserData      string          `json:"userdata,omitempty"`

	// Only returned in the first 24 hours
	CryptedRootPassword string `json:"crypted_root_password,omitempty"`
}

Instance models the instance data as returned by the API

func (*Instance) FindIP

func (i *Instance) FindIP(pred func(IP) bool) *IP

type InstanceState

type InstanceState string

type MACAddr

type MACAddr [6]byte

MACAddr is an IEEE 802 MAC-48 hardware address.

func (MACAddr) HardwareAddr

func (m MACAddr) HardwareAddr() net.HardwareAddr

func (MACAddr) IsOnes

func (m MACAddr) IsOnes() bool

func (MACAddr) IsZero

func (m MACAddr) IsZero() bool

func (MACAddr) String

func (m MACAddr) String() string

func (*MACAddr) UnmarshalText

func (m *MACAddr) UnmarshalText(text []byte) error

type Manufacturer

type Manufacturer struct {
	ID   string `json:"id"`
	Slug string `json:"slug"`
}

type NetworkPorts

type NetworkPorts struct {
	Main []Port `json:"main"`
	IPMI Port   `json:"ipmi"`
}

type OperatingSystem

type OperatingSystem struct {
	Slug     string `json:"slug"`
	Distro   string `json:"distro"`
	Version  string `json:"version"`
	ImageTag string `json:"image_tag"`
	OsSlug   string `json:"os_slug"`
}

type Port

type Port struct {
	ID   string   `json:"id"`
	Type PortType `json:"type"`
	Name string   `json:"name"`
	Data struct {
		MAC  *MACAddr `json:"mac"`
		Bond string   `json:"bond"`
	} `json:"data"`
}

func (*Port) MAC

func (p *Port) MAC() net.HardwareAddr

type PortType

type PortType string

type ServicesVersion

type ServicesVersion struct {
	Osie string `json:"osie"`
}

type UserEvent

type UserEvent struct {
	Code    string `json:"code"`
	State   string `json:"state"`
	Message string `json:"message"`
}

Jump to

Keyboard shortcuts

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