flocker

package module
v0.0.0-...-2b8b725 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2016 License: Apache-2.0 Imports: 10 Imported by: 96

README

flocker-go

circleci

flocker-go implements the package flocker that will let you easily interact with a Flocker Control Service.

What can it do?

You can check the package documentation here: https://godoc.org/github.com/ClusterHQ/flocker-go

TODO

  • Define a proper interface flockerClientable with all the needed methods for wrapping the Flocker API.

Documentation

Overview

flocker package allows you to easily interact with a Flocker Control Service.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*http.Client
	// contains filtered or unexported fields
}

Client is a default Flocker Client.

func NewClient

func NewClient(host string, port int, clientIP string, caCertPath, keyPath, certPath string) (*Client, error)

NewClient creates a wrapper over http.Client to communicate with the flocker control service.

func (*Client) CreateDataset

func (c *Client) CreateDataset(options *CreateDatasetOptions) (datasetState *DatasetState, err error)

CreateDataset creates a volume in Flocker, waits for it to be ready and returns the dataset id.

This process is a little bit complex but follows this flow:

1. Find the Flocker Control Service UUID 2. If it already exists an error is returned 3. If it didn't previously exist, wait for it to be ready

func (*Client) DeleteDataset

func (c *Client) DeleteDataset(datasetID string) error

DeleteDataset performs a delete request to the given datasetID

func (Client) GetDatasetID

func (c Client) GetDatasetID(metaName string) (datasetID string, err error)

GetDatasetID will return the DatasetID found for the given metadata name.

func (Client) GetDatasetState

func (c Client) GetDatasetState(datasetID string) (*DatasetState, error)

GetDatasetState performs a get request to get the state of the given datasetID, if something goes wrong or the datasetID was not found it returns an error.

func (Client) GetPrimaryUUID

func (c Client) GetPrimaryUUID() (uuid string, err error)

GetPrimaryUUID returns the UUID of the primary Flocker Control Service for the given host.

func (*Client) ListNodes

func (c *Client) ListNodes() (nodes []NodeState, err error)

ListNodes returns a list of dataset agent nodes from Flocker Control Service

func (Client) UpdatePrimaryForDataset

func (c Client) UpdatePrimaryForDataset(newPrimaryUUID, datasetID string) (*DatasetState, error)

UpdatePrimaryForDataset will update the Primary for the given dataset returning the current DatasetState.

type Clientable

type Clientable interface {
	CreateDataset(options *CreateDatasetOptions) (*DatasetState, error)
	DeleteDataset(datasetID string) error

	GetDatasetState(datasetID string) (*DatasetState, error)
	GetDatasetID(metaName string) (datasetID string, err error)
	GetPrimaryUUID() (primaryUUID string, err error)

	ListNodes() (nodes []NodeState, err error)

	UpdatePrimaryForDataset(primaryUUID, datasetID string) (*DatasetState, error)
}

Clientable exposes the needed methods to implement your own Flocker Client.

type CreateDatasetOptions

type CreateDatasetOptions struct {
	Primary     string            `json:"primary"`
	DatasetID   string            `json:"dataset_id,omitempty"`
	MaximumSize int64             `json:"maximum_size,omitempty"`
	Metadata    map[string]string `json:"metadata,omitempty"`
}

type DatasetState

type DatasetState struct {
	Path        string      `json:"path"`
	DatasetID   string      `json:"dataset_id"`
	Primary     string      `json:"primary,omitempty"`
	MaximumSize json.Number `json:"maximum_size,omitempty"`
}

type NodeState

type NodeState struct {
	UUID string `json:"uuid"`
	Host string `json:"host"`
}

Jump to

Keyboard shortcuts

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