Documentation
¶
Overview ¶
Client is an API wrapper to access the Shaken Fist HTTP API.
Index ¶
- type Client
- func (c *Client) CacheImage(imageURL string) error
- func (c *Client) CreateInstance(Name string, CPUs int, Memory int, Networks []NetworkSpec, Disks []DiskSpec, ...) (Instance, error)
- func (c *Client) CreateNamespace(namespace string) error
- func (c *Client) CreateNamespaceKey(namespace, keyName, key string) error
- func (c *Client) CreateNetwork(netblock string, provideDHCP bool, provideNAT bool, name string) (Network, error)
- func (c *Client) DefloatInterface(interfaceUUID string) error
- func (c *Client) DeleteAllInstances(namespace string) ([]string, error)
- func (c *Client) DeleteAllNetworks(namespace string) ([]string, error)
- func (c *Client) DeleteInstance(uuid string) error
- func (c *Client) DeleteInstanceMetadata(uuid, key string) error
- func (c *Client) DeleteMetadata(res ResourceType, uuid, key string) error
- func (c *Client) DeleteNamespace(namespace string) error
- func (c *Client) DeleteNamespaceKey(namespace, keyName string) error
- func (c *Client) DeleteNamespaceMetadata(uuid, key string) error
- func (c *Client) DeleteNetwork(uuid string) error
- func (c *Client) DeleteNetworkMetadata(uuid, key string) error
- func (c *Client) DeployNetworkNode(uuid string) error
- func (c *Client) FloatInterface(interfaceUUID string) error
- func (c *Client) GetConsoleData(uuid string, n int) (string, error)
- func (c *Client) GetImageMeta() ([]ImageMeta, error)
- func (c *Client) GetInstance(uuid string) (Instance, error)
- func (c *Client) GetInstanceEvents(uuid string) ([]Event, error)
- func (c *Client) GetInstanceInterfaces(uuid string) ([]NetworkInterface, error)
- func (c *Client) GetInstanceMetadata(uuid string) (Metadata, error)
- func (c *Client) GetInstanceSnapshots(uuid string) ([]Snapshot, error)
- func (c *Client) GetInstances() ([]Instance, error)
- func (c *Client) GetInterface(uuid string) (NetworkInterface, error)
- func (c *Client) GetLocks() (Locks, error)
- func (c *Client) GetMetadata(res ResourceType, uuid string) (Metadata, error)
- func (c *Client) GetNamespaceKeys(namespace string) ([]string, error)
- func (c *Client) GetNamespaceMetadata(uuid string) (Metadata, error)
- func (c *Client) GetNamespaces() ([]string, error)
- func (c *Client) GetNetwork(uuid string) (Network, error)
- func (c *Client) GetNetworkEvents(uuid string) ([]Event, error)
- func (c *Client) GetNetworkInterfaces(uuid string) ([]NetworkInterface, error)
- func (c *Client) GetNetworkMetadata(uuid string) (Metadata, error)
- func (c *Client) GetNetworks() ([]Network, error)
- func (c *Client) GetNodes() ([]Node, error)
- func (c *Client) PauseInstance(uuid string) error
- func (c *Client) PowerOffInstance(uuid string) error
- func (c *Client) PowerOnInstance(uuid string) error
- func (c *Client) RebootInstance(uuid string) error
- func (c *Client) RemoveDHCP(uuid string) error
- func (c *Client) SetInstanceMetadata(uuid, key, value string) error
- func (c *Client) SetMetadata(res ResourceType, uuid, key, value string) error
- func (c *Client) SetNamespaceMetadata(uuid, key, value string) error
- func (c *Client) SetNetworkMetadata(uuid, key, value string) error
- func (c *Client) SetTimeout(timeout int)
- func (c *Client) SnapshotInstance(uuid string, all bool) error
- func (c *Client) UnPauseInstance(uuid string) error
- func (c *Client) UpdateDHCP(uuid string) error
- func (c *Client) UpdateNamespaceKey(namespace, keyName, key string) error
- type DiskSpec
- type Event
- type ImageMeta
- type Instance
- type LockMetadata
- type Locks
- type Metadata
- type Network
- type NetworkInterface
- type NetworkSpec
- type Node
- type ResourceType
- type Snapshot
- type VideoSpec
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 ¶
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 ¶
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
CreateNameSpace creates a new Namespace.
func (*Client) CreateNamespaceKey ¶ added in v0.2.0
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 ¶
DefloatInterface removes a floating IP from an interface.
func (*Client) DeleteAllInstances ¶ added in v0.2.3
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
DeleteAllNetworks deletes all networks within a namespace. Specifying namespace of "system" will attempt to delete all networks in a cluster.
func (*Client) DeleteInstance ¶
DeleteInstance deletes an instance.
func (*Client) DeleteInstanceMetadata ¶ added in v0.2.0
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
DeleteNameSpace attempts to delete the namespace from Shaken Fist.
func (*Client) DeleteNamespaceKey ¶ added in v0.2.0
DeleteNameSpaceKey attempts to delete the key from the specified namespace.
func (*Client) DeleteNamespaceMetadata ¶ added in v0.2.0
Delete metadata from the namespace
func (*Client) DeleteNetwork ¶
DeleteNetwork removes a network with a specified UUID.
func (*Client) DeleteNetworkMetadata ¶ added in v0.2.0
Delete metadata from the Network
func (*Client) DeployNetworkNode ¶ added in v0.2.0
DeployNetworkNode sends a DeployNetworkNode command to Shaken Fist.
func (*Client) FloatInterface ¶
FloatInterface adds a floating IP to an interface.
func (*Client) GetConsoleData ¶ added in v0.2.0
GetConsoleData retrieves the last n bytes of console data from an instance.
func (*Client) GetImageMeta ¶ added in v0.3.2
GetImageMeta retrieves a list of Image metadata
func (*Client) GetInstance ¶
GetInstance fetches a specific instance by UUID.
func (*Client) GetInstanceEvents ¶
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
GetInstanceMetadata retrieves metadata for the instance
func (*Client) GetInstanceSnapshots ¶
GetInstanceSnapshots fetches a list of instance snapshots.
func (*Client) GetInstances ¶
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) 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
GetNameSpaceKeys retrieves a list of keys within the namespace
func (*Client) GetNamespaceMetadata ¶ added in v0.2.0
GetNamespaceMetadata retrieves metadata for the namespace
func (*Client) GetNamespaces ¶ added in v0.2.0
GetNamespaces fetches a list of all Namespaces.
func (*Client) GetNetwork ¶
GetNetwork fetches a specific instance by UUID.
func (*Client) GetNetworkEvents ¶
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
GetNetworkMetadata retrieves metadata for the network
func (*Client) GetNetworks ¶
GetNetworks fetches a list of networks.
func (*Client) PauseInstance ¶
PauseInstance will pause an instance.
func (*Client) PowerOffInstance ¶
PowerOffInstance powers on an instance.
func (*Client) PowerOnInstance ¶
PowerOnInstance powers on an instance.
func (*Client) RebootInstance ¶
RebootInstance reboots an instance.
func (*Client) RemoveDHCP ¶ added in v0.2.0
RemoveDHCP sends an RemoveDHCP command to Shaken Fist.
func (*Client) SetInstanceMetadata ¶ added in v0.2.0
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
SetNamespaceMetadata sets metadata for the namespace
func (*Client) SetNetworkMetadata ¶ added in v0.2.0
SetNetworkMetadata sets metadata for the network
func (*Client) SetTimeout ¶ added in v0.3.0
SetTimeout sets the HTTP client timeout in seconds.
The default is zero. A timeout of zero equates to an infinite timeout.
func (*Client) SnapshotInstance ¶
SnapshotInstance takes a snapshot of an instance.
func (*Client) UnPauseInstance ¶
UnPauseInstance will unpause an instance.
func (*Client) UpdateDHCP ¶ added in v0.2.0
UpdateDHCP sends an UpdateDHCP command to Shaken Fist.
func (*Client) UpdateNamespaceKey ¶ added in v0.2.0
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
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