metadatas

package
v0.0.0-...-d214319 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// MetadataID is used as an identifier on the metadata search order configuration.
	MetadataID = "metadataService"

	// ConfigDriveID is used as an identifier on the metadata search order configuration.
	ConfigDriveID = "configDrive"
)

Variables

View Source
var ErrBadMetadata = errors.New("invalid OpenStack metadata, got empty uuid")

ErrBadMetadata is used to indicate a problem parsing data from metadata server

Functions

func CheckMetadataSearchOrder

func CheckMetadataSearchOrder(order string) error

func Clear

func Clear()

Clear clears the metadata cache

func GetDevicePath

func GetDevicePath(volumeID string) string

func Set

func Set(value *Metadata)

Set sets the value of metadata cache

Types

type DeviceMetadata

type DeviceMetadata struct {
	Type    string `json:"type"`
	Bus     string `json:"bus,omitempty"`
	Serial  string `json:"serial,omitempty"`
	Address string `json:"address,omitempty"`
}

DeviceMetadata is a single/simplified data structure for all kinds of device metadata types.

type IMetadata

type IMetadata interface {
	GetInstanceID() (string, error)
	GetAvailabilityZone() (string, error)
}

IMetadata implements GetInstanceID & GetAvailabilityZone

var MetadataService IMetadata

MetadataService instance of IMetadata

func GetMetadataProvider

func GetMetadataProvider(order string) IMetadata

GetMetadataProvider retrieves instance of IMetadata

type Metadata

type Metadata struct {
	UUID             string           `json:"uuid"`
	Name             string           `json:"name"`
	AvailabilityZone string           `json:"availability_zone"`
	Devices          []DeviceMetadata `json:"devices,omitempty"`
}

Metadata has the information fetched from OpenStack metadata service or config drives. Assumes the "latest" meta_data.json format.

func Get

func Get(order string) (*Metadata, error)

Get retrieves metadata from either config drive or metadata service. Search order depends on the order set in config file.

type MetadataOpts

type MetadataOpts struct {
	SearchOrder    string     `gcfg:"search-order"`
	RequestTimeout MyDuration `gcfg:"request-timeout"`
}

MetadataOpts is used for configuring how to talk to metadata service or config drive

type MyDuration

type MyDuration struct {
	time.Duration
}

MyDuration is the encoding.TextUnmarshaler interface for time.Duration

func (*MyDuration) UnmarshalText

func (d *MyDuration) UnmarshalText(text []byte) error

UnmarshalText is used to convert from text to Duration

Jump to

Keyboard shortcuts

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