client

package module
v0.4.19 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2021 License: Apache-2.0 Imports: 9 Imported by: 1

README

Golang REST API client for Shaken Fist

Go

This is a Golang library for the minimal cloud Shaken Fist

The library is a complete interface to the Shaken Fist HTTP API.

Examples of it's usage can be found in the examples subdirectory.

Documentation

Overview

Client is an API wrapper to access the Shaken Fist HTTP API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client holds all of the information required to connect to the server

func NewClient

func NewClient(server_url string, namespace, apiKey string) *Client

NewClient returns a Shaken Fist client.

The server_url string should be the base URL of the server including the port number: "http://<server>:<port>" eg. "http://sf-1:13000". (Standard port for the Shaken Fist API server is 13000.)

func (*Client) CacheImage

func (c *Client) CacheImage(imageURL string) error

CacheImage will cache an image.

func (*Client) CreateInstance

func (c *Client) CreateInstance(Name string, CPUs int, Memory int,
	Networks []NetworkSpec, Disks []DiskSpec, Video VideoSpec, SSHKey string,
	UserData string) (Instance, error)

CreateInstance creates a new instance.

func (*Client) CreateNamespace added in v0.2.0

func (c *Client) CreateNamespace(namespace string) error

CreateNameSpace creates a new Namespace.

func (*Client) CreateNamespaceKey added in v0.2.0

func (c *Client) CreateNamespaceKey(namespace, keyName, key string) error

CreateNameSpaceKey creates a key within a namespace.

func (*Client) CreateNetwork

func (c *Client) CreateNetwork(netblock string, provideDHCP bool, provideNAT bool,
	name string) (Network, error)

CreateNetwork creates a new network.

func (*Client) DefloatInterface

func (c *Client) DefloatInterface(interfaceUUID string) error

DefloatInterface removes a floating IP from an interface.

func (*Client) DeleteAllInstances added in v0.2.3

func (c *Client) DeleteAllInstances(namespace string) ([]string, error)

DeleteAllInstances deletes all instances within a namespace. Specifying namespace "system" will delete all instances in a cluster.

func (*Client) DeleteAllNetworks added in v0.2.3

func (c *Client) DeleteAllNetworks(namespace string) ([]string, error)

DeleteAllNetworks deletes all networks within a namespace. Specifying namespace of "system" will attempt to delete all networks in a cluster.

func (*Client) DeleteInstance

func (c *Client) DeleteInstance(uuid string) error

DeleteInstance deletes an instance.

func (*Client) DeleteInstanceMetadata added in v0.2.0

func (c *Client) DeleteInstanceMetadata(uuid, key string) error

Delete metadata from the instance

func (*Client) DeleteMetadata added in v0.2.0

func (c *Client) DeleteMetadata(res ResourceType, uuid, key string) error

DeleteMetadata retrieves the metadata attached to an instance.

func (*Client) DeleteNamespace added in v0.2.0

func (c *Client) DeleteNamespace(namespace string) error

DeleteNameSpace attempts to delete the namespace from Shaken Fist.

func (*Client) DeleteNamespaceKey added in v0.2.0

func (c *Client) DeleteNamespaceKey(namespace, keyName string) error

DeleteNameSpaceKey attempts to delete the key from the specified namespace.

func (*Client) DeleteNamespaceMetadata added in v0.2.0

func (c *Client) DeleteNamespaceMetadata(uuid, key string) error

Delete metadata from the namespace

func (*Client) DeleteNetwork

func (c *Client) DeleteNetwork(uuid string) error

DeleteNetwork removes a network with a specified UUID.

func (*Client) DeleteNetworkMetadata added in v0.2.0

func (c *Client) DeleteNetworkMetadata(uuid, key string) error

Delete metadata from the Network

func (*Client) DeployNetworkNode added in v0.2.0

func (c *Client) DeployNetworkNode(uuid string) error

DeployNetworkNode sends a DeployNetworkNode command to Shaken Fist.

func (*Client) FloatInterface

func (c *Client) FloatInterface(interfaceUUID string) error

FloatInterface adds a floating IP to an interface.

func (*Client) GetConsoleData added in v0.2.0

func (c *Client) GetConsoleData(uuid string, n int) (string, error)

GetConsoleData retrieves the last n bytes of console data from an instance.

func (*Client) GetImageMeta added in v0.3.2

func (c *Client) GetImageMeta() ([]ImageMeta, error)

GetImageMeta retrieves a list of Image metadata

func (*Client) GetInstance

func (c *Client) GetInstance(uuid string) (Instance, error)

GetInstance fetches a specific instance by UUID.

func (*Client) GetInstanceEvents

func (c *Client) GetInstanceEvents(uuid string) ([]Event, error)

GetInstanceEvents fetches events that have occurred on a specific instance.

func (*Client) GetInstanceInterfaces

func (c *Client) GetInstanceInterfaces(uuid string) ([]NetworkInterface, error)

GetInstanceInterfaces fetches a list of network interfaces for an instance.

func (*Client) GetInstanceMetadata added in v0.2.0

func (c *Client) GetInstanceMetadata(uuid string) (Metadata, error)

GetInstanceMetadata retrieves metadata for the instance

func (*Client) GetInstanceSnapshots

func (c *Client) GetInstanceSnapshots(uuid string) ([]Snapshot, error)

GetInstanceSnapshots fetches a list of instance snapshots.

func (*Client) GetInstances

func (c *Client) GetInstances() ([]Instance, error)

GetInstances fetches a list of instances.

func (*Client) GetInterface added in v0.2.0

func (c *Client) GetInterface(uuid string) (NetworkInterface, error)

GetInterface fetches a specific network interface.

func (*Client) GetLocks added in v0.3.2

func (c *Client) GetLocks() (Locks, error)

GetLocks retrieves a list of SF system locks

func (*Client) GetMetadata added in v0.2.0

func (c *Client) GetMetadata(res ResourceType, uuid string) (Metadata, error)

GetMetadata retrieves the metadata attached to an instance.

func (*Client) GetNamespaceKeys added in v0.2.0

func (c *Client) GetNamespaceKeys(namespace string) ([]string, error)

GetNameSpaceKeys retrieves a list of keys within the namespace

func (*Client) GetNamespaceMetadata added in v0.2.0

func (c *Client) GetNamespaceMetadata(uuid string) (Metadata, error)

GetNamespaceMetadata retrieves metadata for the namespace

func (*Client) GetNamespaces added in v0.2.0

func (c *Client) GetNamespaces() ([]string, error)

GetNamespaces fetches a list of all Namespaces.

func (*Client) GetNetwork

func (c *Client) GetNetwork(uuid string) (Network, error)

GetNetwork fetches a specific instance by UUID.

func (*Client) GetNetworkEvents

func (c *Client) GetNetworkEvents(uuid string) ([]Event, error)

GetNetworkEvents fetches events that have occurred on a specific network.

func (*Client) GetNetworkInterfaces added in v0.2.4

func (c *Client) GetNetworkInterfaces(uuid string) ([]NetworkInterface, error)

GetNetworkInterfaces fetches a list of interfaces on a network.

func (*Client) GetNetworkMetadata added in v0.2.0

func (c *Client) GetNetworkMetadata(uuid string) (Metadata, error)

GetNetworkMetadata retrieves metadata for the network

func (*Client) GetNetworks

func (c *Client) GetNetworks() ([]Network, error)

GetNetworks fetches a list of networks.

func (*Client) GetNodes

func (c *Client) GetNodes() ([]Node, error)

GetNodes fetches a list of nodes.

func (*Client) PauseInstance

func (c *Client) PauseInstance(uuid string) error

PauseInstance will pause an instance.

func (*Client) PowerOffInstance

func (c *Client) PowerOffInstance(uuid string) error

PowerOffInstance powers on an instance.

func (*Client) PowerOnInstance

func (c *Client) PowerOnInstance(uuid string) error

PowerOnInstance powers on an instance.

func (*Client) RebootInstance

func (c *Client) RebootInstance(uuid string) error

RebootInstance reboots an instance.

func (*Client) RemoveDHCP added in v0.2.0

func (c *Client) RemoveDHCP(uuid string) error

RemoveDHCP sends an RemoveDHCP command to Shaken Fist.

func (*Client) SetInstanceMetadata added in v0.2.0

func (c *Client) SetInstanceMetadata(uuid, key, value string) error

SetInstanceMetadata sets metadata for the instance

func (*Client) SetMetadata added in v0.2.0

func (c *Client) SetMetadata(res ResourceType, uuid, key, value string) error

SetMetadata sets key-value metadata on an instance.

func (*Client) SetNamespaceMetadata added in v0.2.0

func (c *Client) SetNamespaceMetadata(uuid, key, value string) error

SetNamespaceMetadata sets metadata for the namespace

func (*Client) SetNetworkMetadata added in v0.2.0

func (c *Client) SetNetworkMetadata(uuid, key, value string) error

SetNetworkMetadata sets metadata for the network

func (*Client) SetTimeout added in v0.3.0

func (c *Client) SetTimeout(timeout int)

SetTimeout sets the HTTP client timeout in seconds.

The default is zero. A timeout of zero equates to an infinite timeout.

func (*Client) SnapshotInstance

func (c *Client) SnapshotInstance(uuid string, all bool) error

SnapshotInstance takes a snapshot of an instance.

func (*Client) UnPauseInstance

func (c *Client) UnPauseInstance(uuid string) error

UnPauseInstance will unpause an instance.

func (*Client) UpdateDHCP added in v0.2.0

func (c *Client) UpdateDHCP(uuid string) error

UpdateDHCP sends an UpdateDHCP command to Shaken Fist.

func (*Client) UpdateNamespaceKey added in v0.2.0

func (c *Client) UpdateNamespaceKey(namespace, keyName, key string) error

UpdateNameSpaceKey will modify an existing Key within a Namespace.

type DiskSpec

type DiskSpec struct {
	Base string `json:"base"`
	Size int    `json:"size"`
	Bus  string `json:"bus"`
	Type string `json:"type"`
}

DiskSpec is a definition of an instance disk.

type Event

type Event struct {
	Timestamp float32 `json:"timestamp"`
	FQDN      string  `json:"fqdn"`
	Operation string  `json:"operation"`
	Phase     string  `json:"phase"`
	Duration  float32 `json:"duration"`
	Message   string  `json:"message"`
}

Event defines an event that occurred on an instance.

type ImageMeta added in v0.3.2

type ImageMeta struct {
	Checksum    string `json:"checksum"`
	Fetched     string `json:"fetched"`
	FileVersion int    `json:"file_version"`
	Modified    string `json:"modified"`
	Node        string `json:"node"`
	Ref         string `json:"ref"`
	Size        string `json:"size"`
	URL         string `json:"url"`
}

ImageMeta contains the metadata for a cached Image

type Instance

type Instance struct {
	UUID         string                 `json:"uuid"`
	Name         string                 `json:"name"`
	CPUs         int                    `json:"cpus"`
	Memory       int                    `json:"memory"`
	DiskSpecs    []DiskSpec             `json:"disk_spec"`
	Video        VideoSpec              `json:"video"`
	SSHKey       string                 `json:"ssh_key"`
	Node         string                 `json:"node"`
	ConsolePort  int                    `json:"console_port"`
	VDIPort      int                    `json:"vdi_port"`
	UserData     string                 `json:"user_data"`
	BlockDevices map[string]interface{} `json:"block_devices"`
	State        string                 `json:"state"`
	StateUpdated float64                `json:"state_updated"`
	PowerState   string                 `json:"power_state"`
}

Instance is a definition of an instance.

type LockMetadata added in v0.3.2

type LockMetadata struct {
	Node      string `json:"node"`
	Operation string `json:"operation"`
	PID       int    `json:"pid"`
}

Lock contains the metadata for a SF system lock

type Locks added in v0.3.2

type Locks map[string]LockMetadata

Locks is a map of lock references to lock metadata

type Metadata added in v0.2.0

type Metadata map[string]string

Metadata is a map of key value pairs storing metadata on an instance.

type Network

type Network struct {
	UUID            string  `json:"uuid"`
	Name            string  `json:"name"`
	VXId            int     `json:"vxid"`
	NetBlock        string  `json:"netblock"`
	ProvideDHCP     bool    `json:"provide_dhcp"`
	ProvideNAT      bool    `json:"provide_nat"`
	Owner           string  `json:"owner"`
	FloatingGateway string  `json:"floating_gateway"`
	State           string  `json:"state"`
	StateUpdated    float64 `json:"state_updated"`
}

Network is a definition of a network.

type NetworkInterface

type NetworkInterface struct {
	UUID         string  `json:"uuid"`
	NetworkUUID  string  `json:"network_uuid"`
	InstanceUUID string  `json:"instance_uuid"`
	MACAddress   string  `json:"macaddr"`
	IPv4         string  `json:"ipv4"`
	Order        int     `json:"order"`
	Floating     string  `json:"floating"`
	State        string  `json:"state"`
	StateUpdated float64 `json:"state_updated"`
	Model        string  `json:"model"`
}

NetworkInterface is a definition of an network interface for an instance.

type NetworkSpec

type NetworkSpec struct {
	NetworkUUID string `json:"network_uuid"`
	Address     string `json:"address"`
	MACAddress  string `json:"macaddress"`
	Model       string `json:"model"`
}

NetworkSpec is a definition of an instance network connect.

type Node

type Node struct {
	Name     string  `json:"name"`
	IP       string  `json:"ip"`
	LastSeen float64 `json:"lastseen"`
}

Node defines a ShakenFist node.

type ResourceType added in v0.2.0

type ResourceType int

ResourceType is a type of Shaken Fist resource

const (
	TypeNamespace ResourceType = iota
	TypeInstance
	TypeNetwork
)

func (ResourceType) String added in v0.2.0

func (r ResourceType) String() string

type Snapshot

type Snapshot struct {
	UUID    string `json:"uuid"`
	Device  string `json:"device"`
	Created int64  `json:"created"`
}

Snapshot defines a snapshot of an instance.

type VideoSpec added in v0.2.3

type VideoSpec struct {
	Model  string `json:"model"`
	Memory int    `json:"memory"` // Memory size in KB
}

VideoSpec defines the type of video card in an instance.

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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