hostinfo

package
v0.0.0-...-e560ebb Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2021 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package hostinfo provides support for Autotest's serialized hostinfo data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

func Marshal(hi *HostInfo) ([]byte, error)

Marshal serializes the HostInfo struct into a slice of bytes.

func MarshalIndent

func MarshalIndent(hi *HostInfo) ([]byte, error)

MarshalIndent serializes the HostInfo struct into a slice of bytes. The prefix and indent options of json.MarshalIndent are not exposed to the user because You Don't Need Them.

func RevertDut

func RevertDut(d *inventory.DeviceUnderTest, hi *HostInfo)

RevertDut reverts the Autotest hostinfo back to an inventory DUT struct.

Types

type AdminClient

type AdminClient interface {
	GetStableVersion(ctx context.Context, in *fleet.GetStableVersionRequest, opts ...grpc.CallOption) (*fleet.GetStableVersionResponse, error)
}

AdminClient is a client that knows how to respond to the GetStableVersion RPC call. Its prototypical implementation is fleet.InventoryClient.

type Getter

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

Getter is a container for the clients needed to construct the host_info_store contents for a given hostname.

func NewGetter

func NewGetter(
	ic InventoryClient,
	ac AdminClient,
) *Getter

NewGetter constructs a getter in the default configuration.

func (*Getter) GetContentsForHostname

func (g *Getter) GetContentsForHostname(ctx context.Context, hostname string) (string, error)

GetContentsForHostname gets the entire hostinfostore file contents for a given hostname as a string.

func (*Getter) GetStableVersionForHostname

func (g *Getter) GetStableVersionForHostname(ctx context.Context, hostname string) (map[string]string, error)

GetStableVersionForHostname gets the stable version info for a given hostname.

func (*Getter) GetStableVersionForModel

func (g *Getter) GetStableVersionForModel(ctx context.Context, board, model string) (map[string]string, error)

GetStableVersionForModel gets the stable version info for a given board/model.

type HostInfo

type HostInfo struct {
	Labels         []string          `json:"labels"`
	Attributes     map[string]string `json:"attributes"`
	StableVersions map[string]string `json:"stable_versions"`
}

HostInfo stores the host information. Hostinfo files are used to pass host information to Autotest and receive host information changes from Autotest.

func ConvertDut

func ConvertDut(d *inventory.DeviceUnderTest) *HostInfo

ConvertDut converts the inventory DUT struct to Autotest hostinfo.

func Unmarshal

func Unmarshal(blob []byte) (*HostInfo, error)

Unmarshal deserializes a HostInfo struct from a slice of bytes. Unmarshal accepts a serialized HostInfo or serialized versionedHostInfo it always ignores all version information

type InventoryClient

type InventoryClient interface {
	GetDutInfo(ctx context.Context, id string, byHostname bool) (*inventory.DeviceUnderTest, error)
}

InventoryClient is a client that knows how to resolve a DUT hostname to information about the DUT. Its prototypical implementation is inventoryclient.InventoryClientV2.

Jump to

Keyboard shortcuts

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