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
- func DumpDescriptions()
- func IdentifiedViaFallback() bool
- func LoadJson(url string)
- type LcdType
- type LocateRDEnum
- type NICInfo
- type PlatFacts
- type ValidateRDEnum
- type Variant
- func Get(codename string) *Variant
- func Identify() *Variant
- func IdentifyWithFallback(fallback func() (string, error)) (*Variant, error)
- func ReIdentify() *Variant
- func Read() *Variant
- func TestSetup(i Variant_, mfg, prod, sku, serial string) (v *Variant)
- func TestSetupFrom(codename, mfg, prod, sku, serial string) *Variant
- func (v *Variant) BiosConfigTool() string
- func (v *Variant) CheckRecoveryDev(dev string) error
- func (v *Variant) DataDisks() int
- func (v *Variant) DefaultPortNames() []string
- func (v *Variant) DeviceCodeName() string
- func (v *Variant) DiagPorts() []int
- func (v *Variant) DiskSetTol() uint64
- func (v *Variant) DiskSize() uint64
- func (v *Variant) DiskTgtTol() uint64
- func (v *Variant) FakeRaidType() string
- func (v *Variant) FamilyName() string
- func (v *Variant) FindRecoveryDev() (fsIdent, fsType, fsOpts string)
- func (v *Variant) HasIPMI() bool
- func (v *Variant) HasRaid() bool
- func (v *Variant) IpmiConfigTool() string
- func (v *Variant) IsPrototype() bool
- func (v *Variant) Lcd() LcdType
- func (v *Variant) LowMemory() bool
- func (v *Variant) MACPrefixes() (prefixes [][]byte)
- func (v *Variant) Mfg() string
- func (v *Variant) PartOffset() string
- func (v *Variant) PrettyName() string
- func (v *Variant) Prod() string
- func (v *Variant) RaidLevel() int
- func (v *Variant) RecoveryCandidates(RecoverySize uint64) (devList []string)
- func (v *Variant) RecoveryDevVirt() bool
- func (v *Variant) SKU() string
- func (v *Variant) SSD() bool
- func (v *Variant) SerNum() string
- func (v *Variant) VirtType() Virtualization
- func (v *Variant) Virtual() bool
- func (v *Variant) WANIndex() int
- func (v *Variant) WriteOut(path string, ltype LcdType)
- type Variant_
- type Virtualization
Constants ¶
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
Types ¶
type LcdType ¶
type LcdType int
what type of lcd
func (LcdType) MarshalJSON ¶
func (*LcdType) UnmarshalJSON ¶
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 { // 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 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 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 ¶
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 ¶
To be used in testing. Allows assignment to normally-unassignable fields of Variant.
func TestSetupFrom ¶
Like TestSetup, but uses a codename and default data rather than Variant_
func (*Variant) BiosConfigTool ¶
func (*Variant) CheckRecoveryDev ¶
func (*Variant) DefaultPortNames ¶
func (*Variant) DeviceCodeName ¶
func (*Variant) DiskSetTol ¶
func (*Variant) DiskTgtTol ¶
func (*Variant) FakeRaidType ¶
func (*Variant) FamilyName ¶
func (*Variant) FindRecoveryDev ¶
func (*Variant) IpmiConfigTool ¶
func (*Variant) IsPrototype ¶
func (*Variant) MACPrefixes ¶
func (*Variant) PartOffset ¶
func (*Variant) PrettyName ¶
func (*Variant) RecoveryCandidates ¶
returns names of block devices which could be the recovery device excludes virtual devices and ones with incorrect size
func (*Variant) RecoveryDevVirt ¶
func (*Variant) VirtType ¶
func (v *Variant) VirtType() Virtualization
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.
type Virtualization ¶
type Virtualization int
virtualization type
const ( BareMetal Virtualization = iota HyperV KVM Qemu VirtualBox VMWare )
Source Files ¶
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. |