dothill

package module
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2021 License: MIT Imports: 12 Imported by: 0

README

dothill-api-go

Build status Go Report Card PkgGoDev

A Go implementation of the Dothill API.

Run tests

In order to run tests, you will need to install node.js and npm to run the mock server. When it's done, go to the mock directory, install dependencies and start the mock server.

cd ./mock
npm install
npm run start

You're now ready to go, just run go test to run the tests suite.

You can also skip previous steps and just run tests with docker-compose:

docker-compose up --build --abort-on-container-exit --exit-code-from tests

Documentation

Index

Constants

View Source
const (
	APICallMetric = "dothill_api_appliance_api_call"
	APICallHelp   = "How many API calls have been executed"

	APICallDurationMetric = "dothill_api_appliance_api_call_duration"
	APICallDurationHelp   = "The total duration of API calls"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Username   string
	Password   string
	Addr       string
	HTTPClient http.Client
	Collector  *Collector
	// contains filtered or unexported fields
}

Client : Can be used to request the dothill API

func NewClient

func NewClient() *Client

NewClient : Creates a dothill client by setting up its HTTP client

func (*Client) CopyVolume added in v1.7.0

func (client *Client) CopyVolume(sourceName string, destinationName string, pool string) (*Response, *ResponseStatus, error)

CopyVolume : create an new volume by copying another one or a snapshot

func (*Client) CreateHost

func (client *Client) CreateHost(name, iqn string) (*Response, *ResponseStatus, error)

CreateHost : creates a host

func (*Client) CreateSnapshot added in v1.7.0

func (client *Client) CreateSnapshot(name string, snapshotName string) (*Response, *ResponseStatus, error)

CreateSnapshot : create a snapshot in a snap pool and the snap pool if it doesn't exsits

func (*Client) CreateVolume

func (client *Client) CreateVolume(name, size, pool string) (*Response, *ResponseStatus, error)

CreateVolume : creates a volume with the given name, capacity in the given pool

func (*Client) DeleteHost added in v1.3.0

func (client *Client) DeleteHost(name string) (*Response, *ResponseStatus, error)

DeleteHost : deletes a host by its ID or nickname

func (*Client) DeleteSnapshot added in v1.7.0

func (client *Client) DeleteSnapshot(names ...string) (*Response, *ResponseStatus, error)

DeleteSnapshot : delete a snapshot

func (*Client) DeleteVolume

func (client *Client) DeleteVolume(name string) (*Response, *ResponseStatus, error)

DeleteVolume : deletes a volume

func (*Client) ExpandVolume added in v1.4.0

func (client *Client) ExpandVolume(name, size string) (*Response, *ResponseStatus, error)

ExpandVolume : extend a volume if there is enough space on the vdisk

func (*Client) FormattedRequest added in v1.6.0

func (client *Client) FormattedRequest(endpointFormat string, opts ...interface{}) (*Response, *ResponseStatus, error)

FormattedRequest : Format and execute the given request with client's configuration

func (*Client) Login

func (client *Client) Login() error

Login : Called automatically, may be called manually if credentials changed

func (*Client) MapVolume

func (client *Client) MapVolume(name, host, access string, lun int) (*Response, *ResponseStatus, error)

MapVolume : map a volume to host + LUN

func (*Client) Request

func (client *Client) Request(endpoint string) (*Response, *ResponseStatus, error)

Request : Execute the given request with client's configuration Deprecated: Use FormattedRequest instead

func (*Client) ShowHostMaps

func (client *Client) ShowHostMaps(host string) ([]Volume, *ResponseStatus, error)

ShowHostMaps : list the volume mappings for given host If host is an empty string, mapping for all hosts is shown

func (*Client) ShowSnapshots added in v1.7.0

func (client *Client) ShowSnapshots(names ...string) (*Response, *ResponseStatus, error)

ShowSnapshots : list snapshots

func (*Client) ShowVolumes added in v1.5.0

func (client *Client) ShowVolumes(volumes ...string) (*Response, *ResponseStatus, error)

ShowVolumes : get informations about volumes

func (*Client) UnmapVolume

func (client *Client) UnmapVolume(name, host string) (*Response, *ResponseStatus, error)

UnmapVolume : unmap a volume from host

type Collector added in v1.6.0

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

func (*Collector) Collect added in v1.6.0

func (collector *Collector) Collect(ch chan<- prometheus.Metric)

func (*Collector) Describe added in v1.6.0

func (collector *Collector) Describe(ch chan<- *prometheus.Desc)

type Object

type Object struct {
	Typ           string     `xml:"basetype,attr"`
	Name          string     `xml:"name,attr"`
	OID           int32      `xml:"oid,attr"`
	Format        string     `xml:"format,attr,omitempty"`
	Objects       []Object   `xml:"OBJECT"`
	Properties    []Property `xml:"PROPERTY"`
	ObjectsMap    map[string]*Object
	PropertiesMap map[string]*Property
}

Object : Typed representation of any XML API object

func (*Object) GetProperties added in v1.7.0

func (object *Object) GetProperties(names ...string) ([]*Property, error)

type Property

type Property struct {
	Name        string `xml:"name,attr"`
	Typ         string `xml:"type,attr"`
	Size        int32  `xml:"size,attr"`
	Draw        bool   `xml:"draw,attr"`
	Sort        string `xml:"sort,attr"`
	DisplayName string `xml:"display-name,attr"`
	Data        string `xml:",chardata"`
}

Property : Typed representation of any XML API property

type Request

type Request struct {
	Endpoint string
	Data     interface{}
}

Request : Used internally, and can be used to send custom requests (see Client.Request())

type Response

type Response struct {
	Version    string   `xml:"VERSION,attr"`
	Objects    []Object `xml:"OBJECT"`
	ObjectsMap map[string]*Object
}

Response : Typed representation of any XML API response

func NewResponse

func NewResponse(data []byte) (*Response, error)

NewResponse : Unmarshals the raw data into a typed response object and generate a hash map from fields for optimization

func (*Response) GetStatus

func (res *Response) GetStatus() *ResponseStatus

GetStatus : Creates and returns the final ResponseStatus struct from the raw status object in response

type ResponseStatus

type ResponseStatus struct {
	ResponseType        string
	ResponseTypeNumeric int
	Response            string
	ReturnCode          int
	Time                time.Time
}

ResponseStatus : Final representation of the "status" object in every API response

func NewErrorStatus added in v1.5.1

func NewErrorStatus(err string) *ResponseStatus

NewErrorStatus : Creates an error status when response is not available

type Volume

type Volume struct {
	LUN int
}

Volume : volume-view representation

Jump to

Keyboard shortcuts

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