registry

package
v0.0.0-...-eb548cc Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2015 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package registry provides some functions to interact with the BOSH Registry (http://bosh.io/docs/bosh-components.html#registry)

Example
var err error

clientOptions := registry.ClientOptions{
	Protocol: "http",
	Host:     "127.0.0.1",
	Port:     25777,
	Username: "username",
	Password: "password",
}
logger := boshlog.NewLogger(boshlog.LevelDebug)
registryClient := registry.NewHTTPClient(clientOptions, logger)

instanceID := "instance-id"

networksSettings := registry.NetworksSettings{}
envSettings := registry.EnvSettings{}
agentOptions := registry.AgentOptions{}
settings := registry.NewAgentSettings("agent-id", "vm-id", networksSettings, envSettings, agentOptions)

// Set the agent settings for a VM
fmt.Printf("Updating settings for instance '%s' with '%#v'", instanceID, settings)
err = registryClient.Update(instanceID, settings)
if err != nil {
	fmt.Printf("Update call returned an error: %s", err)
}

// Get the agent settings for a VM
settings, err = registryClient.Fetch(instanceID)
if err != nil {
	fmt.Printf("Fetch call returned an error: %s", err)
}
fmt.Printf("Settings for instance '%s' are '%#v'", instanceID, settings)

// Delete the agent settings for a VM
err = registryClient.Delete(instanceID)
if err != nil {
	fmt.Printf("Delete call returned an error: %s", err)
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentOptions

type AgentOptions struct {
	// Mbus URI
	Mbus string

	// List of NTP servers
	Ntp []string

	// Blobstore options
	Blobstore BlobstoreOptions
}

AgentOptions are the agent options passed to the the BOSH Agent (http://bosh.io/docs/bosh-components.html#agent).

func (AgentOptions) Validate

func (o AgentOptions) Validate() error

Validate validates the Agent options.

type AgentSettings

type AgentSettings struct {
	// Agent ID
	AgentID string `json:"agent_id"`

	// Blobstore settings
	Blobstore BlobstoreSettings `json:"blobstore"`

	// Disks settings
	Disks DisksSettings `json:"disks"`

	// Environment settings
	Env EnvSettings `json:"env"`

	// Mbus URI
	Mbus string `json:"mbus"`

	// Networks settings
	Networks NetworksSettings `json:"networks"`

	// List of NTP servers
	Ntp []string `json:"ntp"`

	// VM settings
	VM VMSettings `json:"vm"`
}

AgentSettings are the Agent settings for a particular VM.

func NewAgentSettings

func NewAgentSettings(agentID string, vmCID string, networksSettings NetworksSettings, env EnvSettings, agentOptions AgentOptions) AgentSettings

NewAgentSettings creates new agent settings for a VM.

func (AgentSettings) AttachPersistentDisk

func (as AgentSettings) AttachPersistentDisk(diskID string, volumeID string, path string) AgentSettings

AttachPersistentDisk updates the agent settings in order to add an attached persistent disk.

func (AgentSettings) ConfigureNetworks

func (as AgentSettings) ConfigureNetworks(networksSettings NetworksSettings) AgentSettings

ConfigureNetworks updates the agent settings with the networks settings.

func (AgentSettings) DetachPersistentDisk

func (as AgentSettings) DetachPersistentDisk(diskID string) AgentSettings

DetachPersistentDisk updates the agent settings in order to delete an attached persistent disk.

type BlobstoreOptions

type BlobstoreOptions struct {
	// Blobstore type
	Type string

	// Blobstore options
	Options map[string]interface{}
}

BlobstoreOptions are the blobstore options passed to the BOSH Agent (http://bosh.io/docs/bosh-components.html#agent).

func (BlobstoreOptions) Validate

func (o BlobstoreOptions) Validate() error

Validate validates the Blobstore options.

type BlobstoreSettings

type BlobstoreSettings struct {
	// Blobstore provider
	Provider string `json:"provider"`

	// Blobstore options
	Options map[string]interface{} `json:"options"`
}

BlobstoreSettings are the Blobstore settings for a particular VM.

type Client

type Client interface {
	Delete(instanceID string) error
	Fetch(instanceID string) (AgentSettings, error)
	Update(instanceID string, agentSettings AgentSettings) error
}

Client represents a BOSH Registry Client.

type ClientOptions

type ClientOptions struct {
	// BOSH Registry protocol
	Protocol string `json:"protocol,omitempty"`

	// BOSH Registry hostname
	Host string `json:"host,omitempty"`

	// BOSH Registry port
	Port int `json:"port,omitempty"`

	// BOSH Registry username
	Username string `json:"username,omitempty"`

	// BOSH Registry password
	Password string `json:"password,omitempty"`

	// BOSH Registry TLS options (only when using protocol https)
	TLS ClientTLSOptions `json:"tls,omitempty"`
}

ClientOptions are the options used to create a BOSH Registry client.

func (ClientOptions) Endpoint

func (o ClientOptions) Endpoint() string

Endpoint returns the BOSH Registry endpoint.

func (ClientOptions) EndpointWithCredentials

func (o ClientOptions) EndpointWithCredentials() string

EndpointWithCredentials returns the BOSH Registry endpoint including credentials.

func (ClientOptions) Validate

func (o ClientOptions) Validate() error

Validate validates the Client options.

type ClientTLSOptions

type ClientTLSOptions struct {
	// If the Client must skip the verification of the server certificates
	InsecureSkipVerify bool `json:"insecure_skip_verify,omitempty"`

	// Certificate file (PEM format)
	CertFile string `json:"certfile,omitempty"`

	// Private key file (PEM format)
	KeyFile string `json:"keyfile,omitempty"`

	// Roor CA certificate file (PEM format)
	CACertFile string `json:"cacertfile,omitempty"`
}

ClientTLSOptions are the TLS options used to create a BOSH Registry client.

func (ClientTLSOptions) Validate

func (o ClientTLSOptions) Validate() error

Validate validates the TLS options.

type DisksSettings

type DisksSettings struct {
	// System disk
	System string `json:"system"`

	// Ephemeral disk
	Ephemeral string `json:"ephemeral"`

	// Persistent disk
	Persistent map[string]PersistentSettings `json:"persistent"`
}

DisksSettings are the Disks settings for a particular VM.

type EnvSettings

type EnvSettings map[string]interface{}

EnvSettings are the Environment settings for a particular VM.

type HTTPClient

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

HTTPClient represents a BOSH Registry Client.

func NewHTTPClient

func NewHTTPClient(
	options ClientOptions,
	logger boshlog.Logger,
) HTTPClient

NewHTTPClient creates a new BOSH Registry Client.

func (HTTPClient) Delete

func (c HTTPClient) Delete(instanceID string) error

Delete deletes the instance settings for a given instance ID.

func (HTTPClient) Fetch

func (c HTTPClient) Fetch(instanceID string) (AgentSettings, error)

Fetch gets the agent settings for a given instance ID.

func (HTTPClient) Update

func (c HTTPClient) Update(instanceID string, agentSettings AgentSettings) error

Update updates the agent settings for a given instance ID. If there are not already agent settings for the instance, it will create ones.

type NetworkSettings

type NetworkSettings struct {
	// Network type
	Type string `json:"type"`

	// Network IP address
	IP string `json:"ip"`

	// Network gateway
	Gateway string `json:"gateway"`

	// Network MAC address
	Mac string `json:"mac"`

	// Network netmask
	Netmask string `json:"netmask"`

	// List of DNS servers
	DNS []string `json:"dns"`

	// List of defaults
	Default []string `json:"default"`

	// Network cloud properties
	CloudProperties map[string]interface{} `json:"cloud_properties"`
}

NetworkSettings are the Network settings for a particular VM.

type NetworksSettings

type NetworksSettings map[string]NetworkSettings

NetworksSettings are the Networks settings for a particular VM.

type PersistentSettings

type PersistentSettings struct {
	// Persistent disk ID
	ID string `json:"id"`

	// Persistent disk volume ID
	VolumeID string `json:"volume_id"`

	// Persistent disk path
	Path string `json:"path"`
}

PersistentSettings are the Persistent Disk settings for a particular VM.

type VMSettings

type VMSettings struct {
	// VM name
	Name string `json:"name"`
}

VMSettings are the VM settings for a particular VM.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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