storage

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Copyright 2016 ePoxy Authors

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ////////////////////////////////////////////////////////////////////////////

Package storage includes the Host record definition. Host records represent a managed machine and store the next stage configuration. Host records are saved to persistent storage.

Index

Constants

View Source
const (
	Stage1IPXE = "stage1.ipxe"
	Stage1JSON = "stage1.json"
	Stage2     = "stage2"
	Stage3     = "stage3"
)

Constant names for standard boot & update sequence maps.

Variables

View Source
var (
	// Extensions is a static map of operation names to extension URLS for testing.
	// TODO: save/retrieve extension configuration in/from datastore.
	Extensions = map[string]string{
		"allocate_k8s_token": "http://token-server-platform-cluster.%s.measurementlab.net:8800/v1/allocate_k8s_token",
		"bmc_store_password": "http://bmc-store-password-platform-cluster.%s.measurementlab.net:8801/v1/bmc_store_password",
		"test_op":            "http://soltesz-epoxy-testing-instance-1.c.%s.internal:8001/operation",
	}
)

Functions

This section is empty.

Types

type DatastoreConfig

type DatastoreConfig struct {
	Client iface.DatastoreClient
	// Kind is the datastore entity kind, e.g. "Host".
	Kind string
	// Namespace is the datastore namespace for all storage operations.
	Namespace string
}

DatastoreConfig contains configuration for accessing Google Cloud Datastore.

func NewDatastoreConfig

func NewDatastoreConfig(client iface.DatastoreClient) *DatastoreConfig

NewDatastoreConfig creates a new DatastoreConfig instance from a *datastore.Client.

func (*DatastoreConfig) List

func (c *DatastoreConfig) List() ([]*Host, error)

List retrieves all Host records currently in the Datastore. TODO(soltesz): support some simple query filtering or subsets.

func (*DatastoreConfig) Load

func (c *DatastoreConfig) Load(name string) (*Host, error)

Load retrieves a Host record from the datastore.

func (*DatastoreConfig) Save

func (c *DatastoreConfig) Save(host *Host) error

Save stores a Host record to Datastore. Host names are globally unique. If a Host record already exists, then it is overwritten.

type ExtentionOperation

type ExtentionOperation struct {
	// Name is the operation name. This will appear in URLs to the ePoxy server.
	// Name should only use characters [a-zA-Z0-9].
	Name string

	// URL references a service that implements the extension operation. During
	// machine boot, when a machine requests the ePoxy extension URL, the ePoxy
	// server will, in turn, issue a request to this URL, sending an
	// extension.Request message. The extension service response is
	// returned to the client verbatim.
	URL string
}

ExtentionOperation maps an operation name (used in URLs) to an extension service URL.

type Host

type Host struct {
	// Name is the FQDN of the host.
	Name string
	// IPv4Addr is the IPv4 address the booting machine will use to connect to the API.
	IPv4Addr string

	// Boot is the typical boot sequence for this Host.
	Boot datastorex.Map
	// Update is an alternate boot sequence, typically used to update the system, e.g. reinstall, reflash.
	Update datastorex.Map
	// ImagesVersion is the version of epoxy-images to use when booting the
	// machines in all stages (1-3).
	ImagesVersion string

	// UpdateEnabled controls whether ePoxy returns the Update sequence (true)
	// or Boot sequence (false) Chain URLs.
	UpdateEnabled bool

	// Extensions is an array of extension operation names enabled for this host.
	Extensions []string

	// CurrentSessionIDs are the most recently generated session ids for a booting machine.
	CurrentSessionIDs SessionIDs
	// LastSessionCreation is the time when CurrentSessionIDs was generated.
	LastSessionCreation time.Time
	// LastReport is the time of the most recent report for this host.
	LastReport time.Time
	// LastSuccess is the time of the most recent successful report from this host.
	LastSuccess time.Time
	// CollectedInformation reported by the host. CollectedInformation must be non-nil.
	CollectedInformation datastorex.Map
}

A Host represents the configuration of a server managed by ePoxy.

func (*Host) AddInformation

func (h *Host) AddInformation(values url.Values)

AddInformation adds values to the Host's CollectedInformation. Only key names in CollectedInformationWhitelist will be added.

func (*Host) CurrentSequence

func (h *Host) CurrentSequence() datastorex.Map

CurrentSequence returns the currently enabled boot sequence.

func (*Host) GenerateSessionIDs

func (h *Host) GenerateSessionIDs()

GenerateSessionIDs creates new random session IDs for the host's CurrentSessionIDs. On success, the host LastSessionCreation is updated to the current time.

func (*Host) String

func (h *Host) String() string

String serializes a Host record. All string type Host fields should be UTF8.

type SessionIDs

type SessionIDs struct {
	Stage2ID string // Needed for requesting the stage2.json target.
	Stage3ID string // Needed for requesting the stage3.json target.
	ReportID string // Needed for requesting the report target.
	// TODO: support multiple extensions.
	ExtensionID string // Needed for requesting the extension target.
}

SessionIDs contains the three session IDs generated when requesting a stage1 target.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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