Documentation

Index

Constants

View Source
const (
	Onboard    = "eno"
	Peripheral = "enp"
)

Variables

This section is empty.

Functions

func DimmHeader

func DimmHeader(tw *tabwriter.Writer)

func DiskHeader

func DiskHeader(tw *tabwriter.Writer)

func Gb

func Gb(value uint64) uint64

func Gbps

func Gbps(value uint64) uint64

func Kb

func Kb(value uint64) uint64

func Kbps

func Kbps(value uint64) uint64

func MHz

func MHz(value uint64) uint64

func Mb

func Mb(value uint64) uint64

func Mbps

func Mbps(value uint64) uint64

func NicHeader

func NicHeader(tw *tabwriter.Writer)

func ProcHeader

func ProcHeader(tw *tabwriter.Writer)

func Tb

func Tb(value uint64) uint64

func Tbps

func Tbps(value uint64) uint64

Types

type ACPowerRating

type ACPowerRating struct {
	PowerRating
	FreqMin float32 `json:"freq_min,omitempty"`
	FreqMax float32 `json:"freq_max,omitempty"`
}

type Base

type Base struct {
	Manufacturer string   `json:"manufacturer,omitempty"`
	Model        string   `json:"model_name,omitempty"`
	SKU          string   `json:"model_name,omitempty"`
	Tags         []string `json:"tags,omitempty"`
	Integrated   bool     `json:"integrated,omitempty"`
	Cost         float64  `json:"cost,omitempty"`
}

func (*Base) Tag

func (b *Base) Tag(tags ...string)

type Cable

type Cable struct {
	Base
	Kind       CableKind
	Connectors [2]End
	Length     uint64 //meters
	Props      xir.Props
}

    A Cable is a physical link between two hosts.

    func GenericCable

    func GenericCable(capacity uint64) *Cable

      GenericCable creates a generic cable.

      func (Cable) BaseInfo

      func (c Cable) BaseInfo() Base

      func (*Cable) Breakout

      func (c *Cable) Breakout(a *Port, b []*Port)

        Breakout connects a single port to multiple. This function assumes the first end is the trunk end of the cable.

        func (*Cable) Connect

        func (c *Cable) Connect(a, b *Port)

          Connect a simple straight cable. Breakouts require more detailed attention.

          func (c *Cable) Link() *xir.Link

            Link creates an XIR parameterized link from a cable.

            func (Cable) Show

            func (c Cable) Show() string

            type CableKind

            type CableKind uint16

              CableKind defines the type of cable

              const (
              	// UnspecCable indicates the cable kind is not defined
              	UnspecCable CableKind = iota
              
              	// Cat5 indicates a category 5 copper cable
              	Cat5
              
              	// Cat5e indicates a category 5 enhanced copper cable
              	Cat5e
              
              	// Cat6 indicates a category 6 copper cable
              	Cat6
              
              	// DAC indicates a direct attach copper cable
              	DAC
              
              	DACBreakout
              
              	// FiberLC indicates a fiber cable with LC type connectors
              	FiberLC
              
              	// FiberMPOTrunk indicates a fiber trunk cable with MPO connectors
              	FiberMPOTrunk
              
              	// FiberMPOBreakout indicates a fiber breakout cable with an MPO connector on
              	// the trunk side.
              	FiberMPOBreakout
              
              	AOC
              )

              func (CableKind) String

              func (c CableKind) String() string

              type Connector

              type Connector struct {
              	Base
              	Kind      ConnectorKind `json:"kind,omitempty"`
              	Protocols []Layer1      `json:"layer1,omitempty"`
              	Capacity  uint64        `json:"capacity,omitempty"`
              
              	Port *Port `json:"-" yaml:"-" mapstructure:"-"`
              }

                A Connector couples a cable to a host.

                func (*Connector) Connect

                func (c *Connector) Connect(p *Port)

                  Connect a connector to a port.

                  type ConnectorKind

                  type ConnectorKind uint16

                    ConnectorKind defines the type of connector.

                    const (
                    	// UnspecConnector indicates the connector kind is not defined
                    	UnspecConnector ConnectorKind = iota
                    
                    	// RJ45 type twisted pair connector.
                    	RJ45
                    
                    	// SFP type modular connector.
                    	SFP
                    
                    	// QSFP type modular connector.
                    	QSFP
                    
                    	// SFPP indicates SFP+ type modular connector
                    	SFPP
                    
                    	// QSFPP indicates QSFP+ type modular connector
                    	QSFPP
                    
                    	// SFP28 type modular connector
                    	SFP28
                    
                    	// QSFP28 type modular connector
                    	QSFP28
                    
                    	// CXP type modular connector
                    	CXP
                    
                    	// LC type fiber connector
                    	LC
                    
                    	// MPO type fiber connector
                    	MPO
                    
                    	// SFP56 type modular connector
                    	SFP56
                    
                    	// QSFP56 type modular connector
                    	QSFP56
                    
                    	// QSFP double density connector
                    	QSFPDD
                    )

                    func (ConnectorKind) String

                    func (c ConnectorKind) String() string

                    type Device

                    type Device struct {
                    	Base
                    	Procs  []Proc `json:"procs,omitempty"`
                    	Memory []Dimm `json:"memory,omitempty"`
                    	Nics   []Nic  `json:"nics,omitempty"`
                    	Usbs   []Usb  `json:"usbs,omitempty"`
                    	Ttys   []Tty  `json:"ttys,omitempty"`
                    	Disks  []Disk `json:"disks,omitempty"`
                    	GPUs   []GPU  `json:"gpus,omitempty"`
                    	PSUs   []PSU  `json:"psus,omitempty"`
                    }

                    func GenericServer

                    func GenericServer(ports int, portSpeed uint64) *Device

                      GenericServer creates a generic server with the provided number of ports and port speed.

                      func GenericSwitch

                      func GenericSwitch(radix int, portSpeed uint64) *Device

                        GenericSwitch creates a generic switch with the provided radix and port speed.

                        func (*Device) BaseInfo

                        func (d *Device) BaseInfo() Base

                        func (*Device) ComponentPower

                        func (d *Device) ComponentPower() float32

                        func (*Device) Node

                        func (d *Device) Node(id string) *xir.Node

                        func (*Device) Show

                        func (d *Device) Show() string

                        type DeviceSpec

                        type DeviceSpec struct {
                        	Base
                        	Procs  map[string]*Procs
                        	Memory map[string]*Dimms
                        	Nics   map[string]*Nics
                        	Disks  map[string]*Disks
                        }

                          DeviceSpec contains a keyed set of components. The semantics behind this data structure are that they key uniquely identifies the object, and that when a new object is added with the same key the count is simply incremented. This is uesful for building device specifications that contain many of the same parts. For example consider a computer with 8 identical ram sticks, or 10 identical drives. This data structure contains the spec for just one and increments a counter.

                          func NewSpec

                          func NewSpec(d *Device) *DeviceSpec

                          func (*DeviceSpec) AddDisk

                          func (s *DeviceSpec) AddDisk(x Disk)

                          func (*DeviceSpec) AddMemory

                          func (s *DeviceSpec) AddMemory(x Dimm)

                          func (*DeviceSpec) AddNic

                          func (s *DeviceSpec) AddNic(x Nic)

                          func (*DeviceSpec) AddProc

                          func (s *DeviceSpec) AddProc(x Proc)

                          func (DeviceSpec) Bandwidth

                          func (s DeviceSpec) Bandwidth() uint64

                          func (DeviceSpec) CoreCount

                          func (s DeviceSpec) CoreCount() int

                          func (DeviceSpec) DiskCapacity

                          func (s DeviceSpec) DiskCapacity() uint64

                          func (DeviceSpec) MemoryCapacity

                          func (s DeviceSpec) MemoryCapacity() uint64

                          type Dimm

                          type Dimm struct {
                          	Base
                          	Type      MemoryType `json:"type,omitempty"`
                          	Capacity  uint64     `json:"capacity,omitempty"`
                          	Frequency uint64     `json:"frequency,omitempty"`
                          }

                          func (Dimm) BaseInfo

                          func (d Dimm) BaseInfo() Base

                          func (Dimm) Show

                          func (d Dimm) Show() string

                          func (Dimm) Table

                          func (d Dimm) Table(count int, tw *tabwriter.Writer)

                          type Dimms

                          type Dimms struct {
                          	Count int
                          	Spec  Dimm
                          }

                          type Disk

                          type Disk struct {
                          	Base
                          	Capacity   uint64         `json:"capacity"`
                          	FormFactor DiskFormFactor `json:"formfactor"`
                          	Interface  DiskInterface  `json:"interface"`
                          }

                          func (Disk) BaseInfo

                          func (d Disk) BaseInfo() Base

                          func (Disk) Show

                          func (d Disk) Show() string

                          func (Disk) Table

                          func (d Disk) Table(count int, tw *tabwriter.Writer)

                          type DiskFormFactor

                          type DiskFormFactor int
                          const (
                          	DiskFormFactorUnknown DiskFormFactor = iota
                          
                          	HDD35
                          	HDD25
                          
                          	SSD35
                          	SSD25
                          
                          	MSATA
                          	M2_2216
                          	M2_2226
                          	M2_2230
                          	M2_2238
                          	M2_2242
                          	M2_2260
                          	M2_2280
                          	M2_22110
                          
                          	U2
                          
                          	EMMC
                          	EUSB
                          )

                          func (DiskFormFactor) String

                          func (dff DiskFormFactor) String() string

                          type DiskInterface

                          type DiskInterface int
                          const (
                          	DiskInterfaceUnknown DiskInterface = iota
                          
                          	SATA1
                          	SATA2
                          	SATA3
                          
                          	NVMEx2
                          	NVMEx4
                          
                          	MMC
                          	SD
                          
                          	USB
                          
                          	SAS
                          )

                          func (DiskInterface) String

                          func (di DiskInterface) String() string

                          type Disks

                          type Disks struct {
                          	Count int
                          	Spec  Disk
                          }

                          type Element

                          type Element interface {
                          	BaseInfo() Base
                          	Show() string
                          }

                          type End

                          type End []*Connector

                            An End represents an end of a cable that may have 1 or many connectors (breakout cable).

                            func (End) Connect

                            func (e End) Connect(ps ...*Port) error

                              Connect a cable end to a set of ports

                              type GPU

                              type GPU struct {
                              	Base
                              }

                              type ISA

                              type ISA uint

                                ISA enum indicates instruction set achitecture.

                                const (
                                	Unknown ISA = iota
                                	// X86_64 indicates Intel x86 ISA with 64 bit addresses
                                	X86_64
                                )

                                func (ISA) String

                                func (i ISA) String() string

                                type Layer1

                                type Layer1 uint

                                  Layer 1 (physical) protocol

                                  const (
                                  	UnspecProtocol Layer1 = iota
                                  
                                  	// 100 mbps
                                  	Base100T
                                  
                                  	// 1 gbps
                                  	Base1000T
                                  	Base1000X
                                  	Base1000CX
                                  	Base1000SX
                                  	Base1000LX
                                  	Base1000LX10
                                  	Base1000EX
                                  	Base1000BX10
                                  	Base1000ZX
                                  
                                  	// 10 gbps
                                  	GBase10T
                                  	GBase10CR
                                  	GBase10SR
                                  	GBase10LR
                                  	GBase10LRM
                                  	GBase10ER
                                  	GBase10ZR
                                  	GBase10LX4
                                  	GBase10PR
                                  
                                  	// 25 gbps
                                  	GBase25CR
                                  	GBase25SR
                                  	GBase25LR
                                  	GBase25ER
                                  
                                  	// 40 gbps
                                  	GBase40CR4
                                  	GBase40SR4
                                  	GBase40LR4
                                  	GBase40ER4
                                  
                                  	// 100 gbps
                                  	GBase100CR4
                                  	GBase100SR4
                                  	GBase100SR10
                                  	GBase100LR4
                                  	GBase100ER4
                                  
                                  	// Console
                                  	RS232
                                  	Uart
                                  
                                  	// 50 gbps
                                  	GBase50SR4
                                  	GBase50LR4
                                  	GBase50ER4
                                  	GBase50CR
                                  	GBase50KR
                                  	GBase50SR
                                  	GBase50LR
                                  	GBase50FR
                                  	GBase50ER
                                  	LAUI_2
                                  	GAUI50_1
                                  	GAUI50_2
                                  
                                  	// 200 gbps
                                  	GBase200CR4
                                  	GBase200KR4
                                  	GBase200SR4
                                  	GBase200DR4
                                  	GBase200FR4
                                  	GBase200LR4
                                  	GBase200ER4
                                  	GAUI200_4
                                  	GAUI200_8
                                  
                                  	// 400 gbps
                                  	GBase400SR16
                                  	GBase400SR8
                                  	GBase400SR4_2
                                  	GBase400DR4
                                  	GBase400FR8
                                  	GBase400ER8
                                  	GBase400ZR
                                  	GAUI400_16
                                  	GAUI400_8
                                  
                                  	XBee
                                  	ZWave
                                  	Zigbee
                                  
                                  	CXP100
                                  	CXP120
                                  )

                                  func (Layer1) String

                                  func (l Layer1) String() string

                                  type MemoryType

                                  type MemoryType int
                                  const (
                                  	MemoryTypeUnknown MemoryType = iota
                                  	DDR3
                                  	DDR4
                                  )

                                  func (MemoryType) String

                                  func (t MemoryType) String() string

                                  type Nic

                                  type Nic struct {
                                  	Base
                                  	StartingIndex int     `json:"starting_index"`
                                  	Ports         []*Port `json:"ports"`
                                  	Kind          string  `json:"kind"`
                                  }

                                  func (Nic) BaseInfo

                                  func (n Nic) BaseInfo() Base

                                  func (*Nic) GetKind

                                  func (n *Nic) GetKind() string

                                  func (*Nic) Onboard

                                  func (n *Nic) Onboard()

                                  func (Nic) Show

                                  func (n Nic) Show() string

                                  func (Nic) Table

                                  func (n Nic) Table(count int, tw *tabwriter.Writer)

                                  type Nics

                                  type Nics struct {
                                  	Count int
                                  	Spec  Nic
                                  }

                                  type PSU

                                  type PSU struct {
                                  	Base
                                  	PowerRatingWatts int                     `json:"power_rating_w,omitempty"`
                                  	IO               []PowerConversionRating `json:"io,omitempty"`
                                  	EfficiencyRating int                     `json:"efficiency,omitempty"`
                                  }

                                  type Port

                                  type Port struct {
                                  	Protocols  []Layer1      `json:"protocol,omitempty"`
                                  	Capacity   uint64        `json:"capacity,omitempty"` //bits per second
                                  	Mac        string        `json:"mac,omitempty"`
                                  	FormFactor ConnectorKind `json:"form_factor,omitempty"`
                                  	Connector  *Connector    `json:"-" yaml:"-" mapstructure:"-"`
                                  	Breakout   string
                                  
                                  	Endpoint *xir.Endpoint `json:"-" yaml:"-" mapstructure:"-"`
                                  }

                                  func Ports

                                  func Ports(count int, p *Port) []*Port

                                  type PowerConversionRating

                                  type PowerConversionRating struct {
                                  	ACinput  ACPowerRating `json:"ac_input,omitempty"`
                                  	DCoutput PowerRating   `json:"dc_output,omitempty"`
                                  }

                                  type PowerRating

                                  type PowerRating struct {
                                  	VoltageMin float32 `json:"voltage_min,omitempty"`
                                  	VoltageMax float32 `json:"voltage_min,omitempty"`
                                  	CurrentMax float32 `json:"current_max,omitempty"`
                                  }

                                  type Proc

                                  type Proc struct {
                                  	Base
                                  	ISA           ISA    `json:"isa,omitempty"`
                                  	Family        string `json:"family,omitempty"`
                                  	BaseFrequency uint64 `json:"basefrequency,omitempty"`
                                  	L2            uint64 `json:"l2,omitempty"`
                                  	Cores         uint   `json:"cores,omitempty"`
                                  	Threads       uint   `json:"threads,omitempty"`
                                  	Tdp           uint   `json:"tdp,omitempty"`
                                  }

                                    Proc represents a processor

                                    func (Proc) BaseInfo

                                    func (p Proc) BaseInfo() Base

                                    func (Proc) Show

                                    func (p Proc) Show() string

                                    func (Proc) Table

                                    func (p Proc) Table(count int, tw *tabwriter.Writer)

                                    type Procs

                                    type Procs struct {
                                    	Count int
                                    	Spec  Proc
                                    }

                                    type Tty

                                    type Tty struct {
                                    	Port *Port `json:"port"`
                                    }

                                    type Usb

                                    type Usb struct {
                                    	Version UsbVersion `json:"version"`
                                    }

                                    type UsbVersion

                                    type UsbVersion float32
                                    const (
                                    	USB1  UsbVersion = 1.0
                                    	USB11 UsbVersion = 1.1
                                    	USB20 UsbVersion = 2.0
                                    	USB21 UsbVersion = 2.1
                                    	USB30 UsbVersion = 3.0
                                    	USB31 UsbVersion = 3.1
                                    )

                                    Directories

                                    Path Synopsis