appliance

package
v0.0.0-...-b79a0d8 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package appliance contains data on various models/revisions of appliance.

This includes sufficient data for identification of a particular variant, as well as data on its components where differences may matter.

For example, RAM doesn't matter (except when there is very little of it). RAID type matters, but the CPU type and number of cores doesn't.

Build tags

light: light builds are able to query platform_facts.json only; non-light is also able to use dmidecode (which accesses /dev/mem and thus requires root).

release: non-release builds include extra functionality for use in testing other packages.

Generated code

`go generate` runs go-bindata, encoding files and embedding them in the binary.

//go:generate ../../bin/go-bindata -tags !light -prefix=../../proprietary/data/appliance -pkg=$GOPACKAGE ../../proprietary/data/appliance

In this repo, there are no files in the referenced dir, so a lookup of embedded file `appliance.json` returns nothing. In this case we fall back to the contents of string `aj_default`, defined in identify.go.

To override aj_default, create a file appliance.json in the dir listed above ($GOPATH/src/github.com/purecloudlabs/gprovision/proprietary/data/appliance) with content like the following, a portion of aj_default. Note that appliance.json overrides aj_default, rather than adding to it.

{
  "Variants": [
    {
      "DevCodeName": "QEMU-mfg-test",
      "Familyname": "qemu",
      "DmiMbMfg": "GPROV_QEMU",
      "DmiProdName": "mfg_test",
      "DmiProdModelRegex": ".*",
      "SerNumField": "system-serial-number",
      "NumDataDisks": 1,
      "Disksize": 21474836480,
      "DiskIsSSD": true,
      "SwRaidlevel": -1,
      "Virttype": 2,
      "NICInfo": {
        "SharedDiagPorts": [],
        "WANIndex": 0,
        "DefaultNamesNoDiag": [
          "Port 1 (WAN)"
        ]
      },
      "RecoveryMedia": {
        "LocateRDMethod": "byLabel",
        "ValidateRDMethod": "usb",
        "FsType": "ext3",
        "SSD": true
      },
      "Lcd": "none",
      "Prototype": true
    },
  ]
}

DevCodeName is used in many places, including in manufData to identify which set of hardware specs to use and the additional config steps, if any, to apply.

Fields such as DmiMbMfg, DmiProdName, and DmiProdModelRegex are used to determine a match between the given Variant and the current device.

Other fields tell the application what to expect in terms of existing hardware, and in some cases influence what actions are taken - for example, SwRaidlevel impacts whether we try to create a raid array and what type of array is created.

Appliance json compared to manufData

ManufData, used by the mfg app, has some similarities. Both impose restrictions on what hardware must be present, but the intent is that appliance json be less restrictive. It must _never_ be more restrictive, else a device could be manufactured successfully but fail to factory restore.

During manufacture, the appliance json is first used to identify what the device _probably_ is, then manufData.json is used to ensure that the device exactly matches everything you deem important.

Index

Constants

View Source
const (
	/* standard mount options used on recovery media
	 *
	 * nofail option - system boots even if dev isn't present,
	 * mounts it when it appears. otherwise, there is a long
	 * delay before it goes to a failsafe, single-user mode
	 * (presumably without our services running)
	 *
	 * special codes: $u and $g are replaced by admin's uid and gid, respectively.
	 */
	StandardMountOpts = "auto,noexec,relatime,nofail,uid=$u,gid=$g"
)

general consts

Variables

This section is empty.

Functions

func DumpDescriptions

func DumpDescriptions()

func IdentifiedViaFallback

func IdentifiedViaFallback() bool

func LoadJson

func LoadJson(url string)

Types

type LcdType

type LcdType int

what type of lcd

const (
	Cfa635 LcdType = iota
	Cfa631
	NoLCD
)

func (LcdType) MarshalJSON

func (l LcdType) MarshalJSON() ([]byte, error)

func (*LcdType) UnmarshalJSON

func (l *LcdType) UnmarshalJSON(b []byte) error

type LocateRDEnum

type LocateRDEnum int //marshalling function in json.go
const (
	LocateByLabel LocateRDEnum = iota
	Locate9PVirt
)

func (LocateRDEnum) MarshalJSON

func (l LocateRDEnum) MarshalJSON() ([]byte, error)

func (*LocateRDEnum) UnmarshalJSON

func (l *LocateRDEnum) UnmarshalJSON(b []byte) error

type NICInfo

type NICInfo struct {
	// SharedDiagPorts contains a list of _shared_ diag port indexes. This will
	// be empty on platforms where diag ports are isolated from the OS. These
	// ports will be hidden by nic_config, so this should generally be
	// ignored.
	SharedDiagPorts []int

	// WANIndex is the index of the wan port, starting at 0, once diag ports are excluded.
	WANIndex int

	// DefaultNamesNoDiag: port names/aliases. Note that this list only makes sense once
	// diag ports are hidden by nic_config.
	DefaultNamesNoDiag []string

	// MACPrefix overrides the default prefix from strs.MacOUI() with one or more different prefixes.
	// Note that if two prefixes may/will be present, one of which is the default, both must be listed.
	// Format as colon-separated string since json does not support hex.
	MACPrefix []string `json:",omitempty"`
}

contents of this struct assume the interfaces have been sorted by MAC and indexes start at 0

type PlatFacts

type PlatFacts struct {
	Variant_
	Mfg, Prod, SKU, Serial string
}

type ValidateRDEnum

type ValidateRDEnum int //marshalling function in json.go
const (
	NoValidation ValidateRDEnum = iota
	ValidateUSB
	ValidateSATA
	Validate9P
)

func (ValidateRDEnum) MarshalJSON

func (v ValidateRDEnum) MarshalJSON() ([]byte, error)

func (*ValidateRDEnum) UnmarshalJSON

func (v *ValidateRDEnum) UnmarshalJSON(b []byte) error

type Variant

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

Variant describes a particular model of appliance.

func Get

func Get(codename string) *Variant

func Identify

func Identify() *Variant

TODO move to per-variant match function? TODO add bool to Variant to indicate whether to use baseboard-* or system-*

func IdentifyWithFallback

func IdentifyWithFallback(fallback func() (string, error)) (*Variant, error)

Call Identify(); if that fails, use fallback() to get the stored code name. Use appliance.json section matching that codename. The fallback() func probably gets the codename from the file /platform on the recovery volume (and ultimately from the windows disktag).

func ReIdentify

func ReIdentify() *Variant

func Read

func Read() *Variant

Returns platform info. If appliance.Identify() has been called, uses its data. Otherwise loads info from platform_facts.json (see Pjson), written by factory restore.

func TestSetup

func TestSetup(i Variant_, mfg, prod, sku, serial string) (v *Variant)

To be used in testing. Allows assignment to normally-unassignable fields of Variant.

func TestSetupFrom

func TestSetupFrom(codename, mfg, prod, sku, serial string) *Variant

Like TestSetup, but uses a codename and default data rather than Variant_

func (*Variant) BiosConfigTool

func (v *Variant) BiosConfigTool() string

func (*Variant) CheckRecoveryDev

func (v *Variant) CheckRecoveryDev(dev string) error

func (*Variant) DataDisks

func (v *Variant) DataDisks() int

func (*Variant) DefaultPortNames

func (v *Variant) DefaultPortNames() []string

func (*Variant) DeviceCodeName

func (v *Variant) DeviceCodeName() string

func (*Variant) DiagPorts

func (v *Variant) DiagPorts() []int

func (*Variant) DiskSetTol

func (v *Variant) DiskSetTol() uint64

func (*Variant) DiskSize

func (v *Variant) DiskSize() uint64

func (*Variant) DiskTgtTol

func (v *Variant) DiskTgtTol() uint64

func (*Variant) FakeRaidType

func (v *Variant) FakeRaidType() string

func (*Variant) FamilyName

func (v *Variant) FamilyName() string

func (*Variant) FindRecoveryDev

func (v *Variant) FindRecoveryDev() (fsIdent, fsType, fsOpts string)

func (*Variant) HasIPMI

func (v *Variant) HasIPMI() bool

func (*Variant) HasRaid

func (v *Variant) HasRaid() bool

func (*Variant) IpmiConfigTool

func (v *Variant) IpmiConfigTool() string

func (*Variant) IsPrototype

func (v *Variant) IsPrototype() bool

func (*Variant) Lcd

func (v *Variant) Lcd() LcdType

func (*Variant) LowMemory

func (v *Variant) LowMemory() bool

func (*Variant) MACPrefixes

func (v *Variant) MACPrefixes() (prefixes [][]byte)

func (*Variant) Mfg

func (v *Variant) Mfg() string

func (*Variant) PartOffset

func (v *Variant) PartOffset() string

func (*Variant) PrettyName

func (v *Variant) PrettyName() string

func (*Variant) Prod

func (v *Variant) Prod() string

func (*Variant) RaidLevel

func (v *Variant) RaidLevel() int

func (*Variant) RecoveryCandidates

func (v *Variant) RecoveryCandidates(RecoverySize uint64) (devList []string)

returns names of block devices which could be the recovery device excludes virtual devices and ones with incorrect size

func (*Variant) RecoveryDevVirt

func (v *Variant) RecoveryDevVirt() bool

func (*Variant) SKU

func (v *Variant) SKU() string

func (*Variant) SSD

func (v *Variant) SSD() bool

func (*Variant) SerNum

func (v *Variant) SerNum() string

func (*Variant) VirtType

func (v *Variant) VirtType() Virtualization

func (*Variant) Virtual

func (v *Variant) Virtual() bool

func (*Variant) WANIndex

func (v *Variant) WANIndex() int

func (*Variant) WriteOut

func (v *Variant) WriteOut(path string, ltype LcdType)

Use in factory restore to write the file. Path is the image root. Lcd type is untouched if ltype == NoLCD

type Variant_

type Variant_ struct {
	Familyname            string         //like code name, but more generic. lower case. ex: oxcart
	DmiMbMfg, DmiProdName string         //mfg & product name from DMI
	DmiProdModelRegex     string         //regex to match the DMI Product Model field (the SKU shown by `dmidecode -t 1`)
	DmiPMOverrideTyp      int            `json:",omitempty"` //override source of product model data; this is a handle type passed with -t to dmidecode
	DmiPMOverrideFld      string         `json:",omitempty"` //override source of product model data; this is the field name in the human-readable output
	CPU                   string         `json:",omitempty"` //fill out if two models are otherwise indistinguishable, otherwise leave blank.
	SerNumField           string         //'dmidecode -s' field name
	NICInfo               NICInfo        //nic configuration information
	IPMI                  bool           `json:",omitempty"`
	IPMIChannel           int            `json:",omitempty"` //the networked ipmi channel to be queried for IP information (needed by services in the OS)
	NumDataDisks          int            //generally 2 if raid, otherwise 1
	Disksize              uint64         //size in bytes, BLKGETSIZE64
	DiskIsSSD             bool           `json:",omitempty"`
	SwRaidlevel           int            // -1 for no raid, or for HW raid we don't configure
	FakeraidType          string         `json:",omitempty"` //DDF, iMSM (field describes format used by windows; used in data erase process)
	BiosConfigTool        string         `json:",omitempty"`
	IpmiConfigTool        string         `json:",omitempty"`
	Virttype              Virtualization `json:",omitempty"`
	RecoveryMedia         recoveryMediaS //in separate struct
	Lcd                   LcdType        //renamed; now stored as string in json rather than enum value
	DevCodeName           string         //specific code name - ex: Oxcart-12
	Partoffset            string         `json:",omitempty"` //unused?
	Lowmemory             bool           `json:",omitempty"` //true for low-memory devices such as the micro
	Prototype             bool           `json:",omitempty"` //true for prototypes - relax some restrictions
	DiskSTol              uint64         `json:",omitempty"` //allowable tolerance between disks in a group
	DiskTTol              uint64         `json:",omitempty"` //allowable tolerance between any one disk in group and target size
}

A hidden field of Variant. Hidden/protected because I've been bitten too many times by accidental overwrites.

func (*Variant_) DiagSummary

func (v *Variant_) DiagSummary() string

one-line summary

type Virtualization

type Virtualization int

virtualization type

const (
	BareMetal Virtualization = iota
	HyperV
	KVM
	Qemu
	VirtualBox
	VMWare
)

Directories

Path Synopsis
Package altIdent allows reading, writing a file containing the platform's identity, for use as a fallback if the dmi data doesn't clearly identify the platform.
Package altIdent allows reading, writing a file containing the platform's identity, for use as a fallback if the dmi data doesn't clearly identify the platform.

Jump to

Keyboard shortcuts

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