dothill

package module
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

README

dothill-api-go

Build status Go Report Card PkgGoDev License

A Go implementation of the Dothill API.

Run tests using our mock server

In order to run tests, you will need to start a mock server by running go run cmd/mock/mock.go. It will expose the mocked api on localhost:8080.

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

You can also run tests with docker-compose, using this command, which is the one used in the CI:

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

Both the mocked api and the tests use as username and passwords variables from the environment, or from the .env file if missing. Since the .env file is pre-filled, you should not have to add any environment variable in order to make the tests work.

Test using a live system

This option runs the golang test cases against a live storage system. Two steps are required:

  • Update .env with the correct system IP address and credentials
  • Run go test -v

Another option is to define environment variables, which take precedence over .env values

export TEST_STORAGEIP=http://<ipaddress>
export TEST_USERNAME=<username>
export TEST_PASSWORD=<password>
go test -v
unset TEST_STORAGEIP TEST_PASSWORD TEST_USERNAME

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

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

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

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

DeleteHost : deletes a host by its ID or nickname

func (*Client) DeleteSnapshot

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

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

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

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

ShowSnapshots : list snapshots

func (*Client) ShowVolumes

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

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

func (*Collector) Collect

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

func (*Collector) Describe

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

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

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

Directories

Path Synopsis
cmd
internal

Jump to

Keyboard shortcuts

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