gounity

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2019 License: Apache-2.0 Imports: 19 Imported by: 0

README

GoUnity

GitHub release Travis branch Coveralls github branch Go Report Card license

GoUnity is a Go project that provides a client for managing Dell EMC Unity storage.

Current State

Under developing. Please contribute and follow the guideline.

License

Apache License version 2

Support Operations

  • Query instances of:
    • Storage Pool
    • LUN
    • Host
    • Filesystem
    • Nas Server
    • NFS Share
  • Create/Delete LUNs
  • Create/Delete Filesystems
  • Create/Delete NFS Shares
  • Attach LUNs to Hosts

Installation

go get github.com/murray-liang/gounity

Tutorial

Create a connection to Unity Systems
unity, err := gounity.NewUnity(
    "UnityMgmtIP", "username", "password", true,
)
if err != nil {
    panic(err)
}
Query storage pools
// List all the pools
pools, err := unity.GetPools()

// Get the pool by ID
pool, err := unity.GetPoolById("Pool_1")
Create LUNs
// Create a 3GB LUN named `lunName` on `pool`
lun, err := pool.CreateLun("lunName", 3)
Query Hosts
host, err := unity.GetHostById("Host_1")
Attach LUNs to Hosts
hluNum, err := host.Attach(lun)
More examples

*_test.go files of this package contains lots of detailed examples.

Optional Parameters

Optional parameters are supported for forward compatibility.

fs, err := pool.CreateFilesystem(
    nas, "fs-name", 3,
    // `SupportedProtocol` is optional.
    gounity.SupportedProtocolsOpt(gounity.FSSupportedProtocolNFS),
)

Triage

HTTP requests and responses are traced with logs by enabling GOUNITY_TRACEHTTP.

  1. Set environment variable GOUNITY_TRACEHTTP.
    $ export GOUNITY_TRACEHTTP=true
    
  2. In your codes, enable Debug log level of logrus.
    logrus.SetLevel(logrus.DebugLevel)
    // Your codes continue here ......
    

Issues

If you have any questions or find any issues, please post Github Issues.

Contribute Guideline

You are one of the collaborators
  1. Create a branch from the latest develop branch: git checkout -b <branch_name>.
  2. Push code changes to your branch. Please make sure your changes be covered by unittest.
  3. Push your branch to the remote.
  4. Publish a pull request from your branch to develop branch.
  5. Merge the pull request after passing the review. Recommend using Squash and Merge and deleting your branch after merging.
You aren't
  1. Fork this repo as your own one.
  2. Push code changes to your repo. Please make sure your changes be covered by unittest.
  3. Publish a pull request from your repo to develop branch of this repo.
  4. Wait for merging the pull request.

Develop Tips

Code Generation

*_gen.go source files are generated by go generate. The templates and source files can be found under cmd/modelgen. You are not supposed to edit the *_gen.go files but the templates.

Once you modify the templates, run go generate, then all *_gen.go files update.

End to End Tests

Test cases in integration_test.go require a real Unity. go test won't run the cases there.

The below commands would help out.

# The integration tests would fail depending on the resources on Unity.
# Modify the cases accordingly before running.

# Command to test `CreateLun` on a real Unity.
$ go test -tags=integration -v -run TestE2ECreateLun \
    -args -mgmtIp='10.245.101.39' -username=admin -password=*****

# Command to run all integration tests on a real Unity.
$ go test -tags=integration -v \
    -args -mgmtIp='10.245.101.39' -username=admin -password=*****

Documentation

Overview

DO NOT EDIT. GENERATED by go:generate at 2019-01-01 09:01:44.294994663 +0000 UTC.

DO NOT EDIT. GENERATED by go:generate at 2019-01-01 09:01:44.29431512 +0000 UTC.

DO NOT EDIT. GENERATED by go:generate at 2019-01-01 09:01:44.294548637 +0000 UTC.

DO NOT EDIT. GENERATED by go:generate at 2019-01-01 09:01:44.295366513 +0000 UTC.

DO NOT EDIT. GENERATED by go:generate at 2019-01-01 09:01:44.295768847 +0000 UTC.

DO NOT EDIT. GENERATED by go:generate at 2019-01-01 09:01:44.296117331 +0000 UTC.

DO NOT EDIT. GENERATED by go:generate at 2019-01-01 09:01:44.296519432 +0000 UTC.

DO NOT EDIT. GENERATED by go:generate at 2019-01-01 09:01:44.296908927 +0000 UTC.

DO NOT EDIT. GENERATED by go:generate at 2019-01-01 09:01:44.297315917 +0000 UTC.

DO NOT EDIT. GENERATED by go:generate at 2019-01-01 09:01:44.308490403 +0000 UTC.

DO NOT EDIT. GENERATED by go:generate at 2019-01-01 09:01:44.30889602 +0000 UTC.

DO NOT EDIT. GENERATED by go:generate at 2019-01-01 09:01:44.309273397 +0000 UTC.

Index

Constants

View Source
const (

	// UnityLunNameExistErrorCode is error code of UnityLunNameExist.
	UnityLunNameExistErrorCode = 108007744

	// UnityResourceNotFoundErrorCode is error code of UnityResourceNotFound.
	UnityResourceNotFoundErrorCode = 131149829
)
View Source
const (
	// HeaderKeyContentType is key name of `Content-Type`.
	HeaderKeyContentType = "Content-Type"
	// HeaderValueContentTypeJSON is `json` value of `Content-Type`.
	HeaderValueContentTypeJSON = "application/json"
	// HeaderValueContentTypeBinaryOctetStream is `binary` value of `Content-Type`.
	HeaderValueContentTypeBinaryOctetStream = "binary/octet-stream"
)

Variables

View Source
var ErrUnableParseRespToError = errors.New("unable parse response body to unity error")

Functions

func GetUnityErrorStatusCode added in v0.2.0

func GetUnityErrorStatusCode(err error) int

GetUnityErrorStatusCode returns the unity error code.

func IsUnityError added in v0.2.0

func IsUnityError(err error) bool

IsUnityError returns true if err is an unity error.

func IsUnityLunNameExistError added in v0.2.0

func IsUnityLunNameExistError(err error) bool

IsUnityLunNameExistError returns true or false on whether its error code is UnityLunNameExistErrorCode.

func IsUnityResourceNotFoundError added in v0.2.0

func IsUnityResourceNotFoundError(err error) bool

IsUnityResourceNotFoundError returns true or false on whether its error code is UnityResourceNotFoundErrorCode.

func NewFilter added in v0.2.0

func NewFilter(f string) *filter

NewFilter returns a filter used for filtering collection.

func NewFilterOn added in v0.2.0

func NewFilterOn(typeName string) filterOn

func NewFilterf added in v0.2.0

func NewFilterf(format string, args ...interface{}) *filter

NewFilterf returns a filter used for filtering collection.

func NewRestClient

func NewRestClient(
	ctx context.Context, host, username, password string, opts *restClientOptions,
) (*restClient, error)

NewRestClient returns a new REST client to Unity.

func NewRestClientOptions added in v0.2.0

func NewRestClientOptions(insecure, traceHttp bool) *restClientOptions

NewRestClientOptions returns a rest client option for creating rest client.

func ParseUnityError added in v0.2.0

func ParseUnityError(reader io.Reader) (error, error)

Types

type BlockHostAccess

type BlockHostAccess struct {
	Resource

	Host       *Host             `json:"host"`
	AccessMask HostLUNAccessEnum `json:"accessMask"`
}

BlockHostAccess defines `blockHostAccess` type.

type BlockHostAccessEnum added in v0.2.0

type BlockHostAccessEnum int
const (

	// BlockHostAccessOff means: Access is disabled.
	BlockHostAccessOff BlockHostAccessEnum = 0

	// BlockHostAccessOn means: Access is enabled.
	BlockHostAccessOn BlockHostAccessEnum = 1

	// BlockHostAccessMixed means: (Applies to Consistency Groups only.) Indicates that LUNs in a consistency group have different host access.
	BlockHostAccessMixed BlockHostAccessEnum = 2
)

type FSSupportedProtocolEnum added in v0.2.0

type FSSupportedProtocolEnum int
const (

	// FSSupportedProtocolNFS means: Only NFS share protocol supported by file system.
	FSSupportedProtocolNFS FSSupportedProtocolEnum = 0

	// FSSupportedProtocolCIFS means: Only SMB (also known as CIFS) share protocol is supported by file system.
	FSSupportedProtocolCIFS FSSupportedProtocolEnum = 1

	// FSSupportedProtocolMultiprotocol means: Both share protocols NFS and SMB (also known as CIFS) are supported by file system.
	FSSupportedProtocolMultiprotocol FSSupportedProtocolEnum = 2
)

type Filesystem added in v0.2.0

type Filesystem struct {
	Resource

	Id              string           `json:"id"`
	Name            string           `json:"name"`
	Health          *Health          `json:"health"`
	Description     string           `json:"description"`
	StorageResource *StorageResource `json:"storageResource"`
}

Filesystem defines `filesystem` type.

func (*Filesystem) Delete added in v0.2.0

func (r *Filesystem) Delete() error

Delete deletes a filesystem object.

func (*Filesystem) ExportNfsShare added in v0.2.0

func (fs *Filesystem) ExportNfsShare(
	name string, opts ...Option,
) (*NfsShare, error)

ExportNfsShare exports the nfs share from this filesystem.

func (*Filesystem) Refresh added in v0.2.0

func (r *Filesystem) Refresh() error

Refresh updates the info from Unity.

func (*Filesystem) Repr added in v0.2.0

func (r *Filesystem) Repr() *idRepresent

Repr represents a `filesystem` object using its id.

type FilesystemOperatorGen added in v0.2.0

type FilesystemOperatorGen interface {
	NewFilesystemById(id string) *Filesystem

	NewFilesystemByName(name string) *Filesystem

	GetFilesystemById(id string) (*Filesystem, error)

	GetFilesystemByName(name string) (*Filesystem, error)

	GetFilesystems() ([]*Filesystem, error)

	FillFilesystems(respEntries []*instanceResp) ([]*Filesystem, error)

	FilterFilesystems(filter *filter) ([]*Filesystem, error)
}

type Health

type Health struct {
	Resource

	Value          int      `json:"value"`
	DescriptionIds []string `json:"descriptionIds"`
	Descriptions   []string `json:"descriptions"`
}

Health defines `health` type.

type Host

type Host struct {
	Resource

	Id          string  `json:"id"`
	Name        string  `json:"name"`
	Health      *Health `json:"health"`
	Description string  `json:"description"`
	OsType      string  `json:"osType"`
}

Host defines `host` type.

func (*Host) Attach

func (h *Host) Attach(lun *Lun) (uint16, error)

Attach attaches the Lun to the host.

func (*Host) Detach added in v0.2.0

func (h *Host) Detach(lun *Lun) error

Detach detaches the Lun from the host.

func (*Host) Refresh added in v0.2.0

func (r *Host) Refresh() error

Refresh updates the info from Unity.

func (*Host) Repr added in v0.2.0

func (r *Host) Repr() *idRepresent

Repr represents a `host` object using its id.

type HostLUN

type HostLUN struct {
	Resource

	Id            string          `json:"id"`
	Host          *Host           `json:"host"`
	Type          HostLunTypeEnum `json:"type"`
	Hlu           uint16          `json:"hlu"`
	Lun           *Lun            `json:"lun"`
	IsReadOnly    bool            `json:"isReadOnly"`
	IsDefaultSnap bool            `json:"isDefaultSnap"`
}

HostLUN defines `hostLUN` type.

func (*HostLUN) Refresh added in v0.2.0

func (r *HostLUN) Refresh() error

Refresh updates the info from Unity.

func (*HostLUN) Repr added in v0.2.0

func (r *HostLUN) Repr() *idRepresent

Repr represents a `hostLUN` object using its id.

type HostLUNAccessEnum

type HostLUNAccessEnum int
const (

	// HostLUNAccessNoAccess means: No access.
	HostLUNAccessNoAccess HostLUNAccessEnum = 0

	// HostLUNAccessProduction means: Access to production LUNs only.
	HostLUNAccessProduction HostLUNAccessEnum = 1

	// HostLUNAccessSnapshot means: Access to LUN snapshots only.
	HostLUNAccessSnapshot HostLUNAccessEnum = 2

	// HostLUNAccessBoth means: Access to both production LUNs and their snapshots.
	HostLUNAccessBoth HostLUNAccessEnum = 3

	// HostLUNAccessProductionOn means: Request to grant production access to LUNs for host. Should be used only by GUI.
	HostLUNAccessProductionOn HostLUNAccessEnum = 4

	// HostLUNAccessProductionOff means: Request to deny production access to LUNs for host. Should be used only by GUI.
	HostLUNAccessProductionOff HostLUNAccessEnum = 5

	// HostLUNAccessMixed means: (Applies to consistency groups only.) Indicates that LUNs in a consistency group have different host access. Do not use this value in Create or Modify requests.
	HostLUNAccessMixed HostLUNAccessEnum = 65535
)

type HostLUNOperator added in v0.2.0

type HostLUNOperator interface {
	HostLUNOperatorGen

	FilterHostLunByHostAndLun(hostId, lunId string) (*HostLUN, error)
}

type HostLUNOperatorGen added in v0.2.0

type HostLUNOperatorGen interface {
	NewHostLUNById(id string) *HostLUN

	GetHostLUNById(id string) (*HostLUN, error)

	GetHostLUNs() ([]*HostLUN, error)

	FillHostLUNs(respEntries []*instanceResp) ([]*HostLUN, error)

	FilterHostLUNs(filter *filter) ([]*HostLUN, error)
}

type HostLunTypeEnum added in v0.2.0

type HostLunTypeEnum int
const (

	// HostLunTypeUnknown means: Unknown LUN type.
	HostLunTypeUnknown HostLunTypeEnum = 0

	// HostLunTypeLUN means: Production LUN.
	HostLunTypeLUN HostLunTypeEnum = 1

	// HostLunTypeLUN_Snap means: Snapshot LUN.
	HostLunTypeLUN_Snap HostLunTypeEnum = 2
)

type HostOperatorGen added in v0.2.0

type HostOperatorGen interface {
	NewHostById(id string) *Host

	NewHostByName(name string) *Host

	GetHostById(id string) (*Host, error)

	GetHostByName(name string) (*Host, error)

	GetHosts() ([]*Host, error)

	FillHosts(respEntries []*instanceResp) ([]*Host, error)

	FilterHosts(filter *filter) ([]*Host, error)
}

type Lun added in v0.2.0

type Lun struct {
	Resource

	Description           string             `json:"description"`
	Health                *Health            `json:"health"`
	HostAccess            []*BlockHostAccess `json:"hostAccess"`
	Id                    string             `json:"id"`
	IsThinEnabled         bool               `json:"isThinEnabled"`
	MetadataSize          uint64             `json:"metadataSize"`
	MetadataSizeAllocated uint64             `json:"metadataSizeAllocated"`
	Name                  string             `json:"name"`
	Pool                  *Pool              `json:"pool"`
	SizeAllocated         uint64             `json:"sizeAllocated"`
	SizeTotal             uint64             `json:"sizeTotal"`
	SizeUsed              uint64             `json:"sizeUsed"`
	SnapCount             uint32             `json:"snapCount"`
	SnapWwn               string             `json:"snapWwn"`
	SnapsSize             uint64             `json:"snapsSize"`
	SnapsSizeAllocated    uint64             `json:"snapsSizeAllocated"`
	StorageResource       *StorageResource   `json:"storageResource"`
	Wwn                   string             `json:"wwn"`
}

Lun defines `lun` type.

func (*Lun) Delete added in v0.2.0

func (r *Lun) Delete() error

Delete deletes a lun object.

func (*Lun) Refresh added in v0.2.0

func (r *Lun) Refresh() error

Refresh updates the info from Unity.

func (*Lun) Repr added in v0.2.0

func (r *Lun) Repr() *idRepresent

Repr represents a `lun` object using its id.

type LunOperatorGen added in v0.2.0

type LunOperatorGen interface {
	NewLunById(id string) *Lun

	NewLunByName(name string) *Lun

	GetLunById(id string) (*Lun, error)

	GetLunByName(name string) (*Lun, error)

	GetLuns() ([]*Lun, error)

	FillLuns(respEntries []*instanceResp) ([]*Lun, error)

	FilterLuns(filter *filter) ([]*Lun, error)
}

type NFSShareDefaultAccessEnum added in v0.2.0

type NFSShareDefaultAccessEnum int
const (

	// NFSShareDefaultAccessNoAccess means: Deny access to the share for the hosts.
	NFSShareDefaultAccessNoAccess NFSShareDefaultAccessEnum = 0

	// NFSShareDefaultAccessReadOnly means: Allow read only access to the share for the hosts.
	NFSShareDefaultAccessReadOnly NFSShareDefaultAccessEnum = 1

	// NFSShareDefaultAccessReadWrite means: Allow read write access to the share for the hosts.
	NFSShareDefaultAccessReadWrite NFSShareDefaultAccessEnum = 2

	// NFSShareDefaultAccessRoot means: Allow read write root access to the share for the hosts.
	NFSShareDefaultAccessRoot NFSShareDefaultAccessEnum = 3

	// NFSShareDefaultAccessRoRoot means: Allow read only root access to the share for the hosts.
	NFSShareDefaultAccessRoRoot NFSShareDefaultAccessEnum = 4
)

type NasServer added in v0.2.0

type NasServer struct {
	Resource

	Id     string  `json:"id"`
	Name   string  `json:"name"`
	Health *Health `json:"health"`
}

NasServer defines `nasServer` type.

func (*NasServer) Refresh added in v0.2.0

func (r *NasServer) Refresh() error

Refresh updates the info from Unity.

func (*NasServer) Repr added in v0.2.0

func (r *NasServer) Repr() *idRepresent

Repr represents a `nasServer` object using its id.

type NasServerOperatorGen added in v0.2.0

type NasServerOperatorGen interface {
	NewNasServerById(id string) *NasServer

	NewNasServerByName(name string) *NasServer

	GetNasServerById(id string) (*NasServer, error)

	GetNasServerByName(name string) (*NasServer, error)

	GetNasServers() ([]*NasServer, error)

	FillNasServers(respEntries []*instanceResp) ([]*NasServer, error)

	FilterNasServers(filter *filter) ([]*NasServer, error)
}

type NfsShare added in v0.2.0

type NfsShare struct {
	Resource

	Id          string      `json:"id"`
	Name        string      `json:"name"`
	Description string      `json:"description"`
	ExportPaths []string    `json:"exportPaths"`
	Filesystem  *Filesystem `json:"filesystem"`
}

NfsShare defines `nfsShare` type.

func (*NfsShare) Delete added in v0.2.0

func (r *NfsShare) Delete() error

func (*NfsShare) Refresh added in v0.2.0

func (r *NfsShare) Refresh() error

Refresh updates the info from Unity.

func (*NfsShare) Repr added in v0.2.0

func (r *NfsShare) Repr() *idRepresent

Repr represents a `nfsShare` object using its id.

type NfsShareOperatorGen added in v0.2.0

type NfsShareOperatorGen interface {
	NewNfsShareById(id string) *NfsShare

	NewNfsShareByName(name string) *NfsShare

	GetNfsShareById(id string) (*NfsShare, error)

	GetNfsShareByName(name string) (*NfsShare, error)

	GetNfsShares() ([]*NfsShare, error)

	FillNfsShares(respEntries []*instanceResp) ([]*NfsShare, error)

	FilterNfsShares(filter *filter) ([]*NfsShare, error)
}

type Option added in v0.2.0

type Option func(*Options)

Option defines an optional parameter.

func DefaultAccessOpt added in v0.2.0

func DefaultAccessOpt(da NFSShareDefaultAccessEnum) Option

DefaultAccessOpt constructs optional parameter `defaultAccess`.

func HostAccessOpt added in v0.2.0

func HostAccessOpt(host *Host, accessMask HostLUNAccessEnum) Option

HostAccessOpt constructs optional parameter `hostAccess`.

func NameOpt added in v0.2.0

func NameOpt(name string) Option

NameOpt constructs optional parameter `name`.

func SizeGBOpt added in v0.2.0

func SizeGBOpt(sizeGB uint64) Option

SizeGBOpt constructs optional parameter `size` in GB.

func SupportedProtocolsOpt added in v0.2.0

func SupportedProtocolsOpt(protocol FSSupportedProtocolEnum) Option

SupportedProtocolsOpt constructs optional parameter `supportedProtocols`.

type Options added in v0.2.0

type Options map[string]interface{}

Options defines the mapping of optional parameters.

func NewOptions added in v0.2.0

func NewOptions(opts ...Option) *Options

NewOptions constructs the optional parameters.

func (*Options) PopDefaultAccess added in v0.2.0

func (o *Options) PopDefaultAccess() interface{}

PopDefaultAccess retrieves optional parameter `defaultAccess` and removes it from options.

func (*Options) PopHostAccess added in v0.2.0

func (o *Options) PopHostAccess() interface{}

PopHostAccess retrieves optional parameter `hostAccess` and removes it from options.

func (*Options) PopName added in v0.2.0

func (o *Options) PopName() interface{}

PopName retrieves optional parameter `name` and removes it from options.

func (*Options) PopSize added in v0.2.0

func (o *Options) PopSize() interface{}

PopSize retrieves optional parameter `size` and removes it from options.

func (*Options) PopSupportedProtocols added in v0.2.0

func (o *Options) PopSupportedProtocols() interface{}

PopSupportedProtocols retrieves optional parameter `supportedProtocols` and removes it from options.

func (*Options) PushDefaultAccess added in v0.2.0

func (o *Options) PushDefaultAccess(da NFSShareDefaultAccessEnum)

PushDefaultAccess adds optional parameter `defaultAccess`.

func (*Options) PushHostAccess added in v0.2.0

func (o *Options) PushHostAccess(host *Host, accessMask HostLUNAccessEnum)

PushHostAccess adds optional parameter `hostAccess`.

func (*Options) PushName added in v0.2.0

func (o *Options) PushName(name string)

PushName adds optional parameter `name`.

func (*Options) PushSize added in v0.2.0

func (o *Options) PushSize(sizeBytes uint64)

PushSize adds optional parameter `size`.

func (*Options) PushSupportedProtocols added in v0.2.0

func (o *Options) PushSupportedProtocols(protocol FSSupportedProtocolEnum)

PushSupportedProtocols adds optional parameter `supportedProtocols`.

func (*Options) WarnNotUsedOptions added in v0.2.0

func (o *Options) WarnNotUsedOptions()

WarnNotUsedOptions logs warning messages for not-used optional parameters.

type Pool

type Pool struct {
	Resource

	Id          string  `json:"id"`
	Name        string  `json:"name"`
	Description string  `json:"description"`
	Health      *Health `json:"health"`
	SizeFree    uint64  `json:"sizeFree"`
	SizeTotal   uint64  `json:"sizeTotal"`
	SizeUsed    uint64  `json:"sizeUsed"`
}

Pool defines `pool` type.

func (*Pool) CreateFilesystem added in v0.2.0

func (p *Pool) CreateFilesystem(
	nasServer *NasServer, name string, sizeGB uint64, opts ...Option,
) (*Filesystem, error)

CreateFilesystem creates a new filesystem on the pool. Parameters - nasServer, name and sizeGB are required. SupportedProtocolsOpt is optional.

func (*Pool) CreateLun added in v0.2.0

func (p *Pool) CreateLun(
	name string, sizeGB uint64, opts ...Option,
) (*Lun, error)

CreateLun creates a new Lun on the pool. Parameter - name and sizeGB are required. HostAccessOpt is optional.

func (*Pool) CreateNfsShare added in v0.2.0

func (p *Pool) CreateNfsShare(
	nasServer *NasServer, name string, sizeGB uint64, opts ...Option,
) (*NfsShare, error)

CreateNfsShare creates a new filesystem on the pool then exports a nfs share from it. Parameters - nasServer, name and sizeGB are required. DefaultAccessOpt is optional.

func (*Pool) Refresh added in v0.2.0

func (r *Pool) Refresh() error

Refresh updates the info from Unity.

func (*Pool) Repr added in v0.2.0

func (r *Pool) Repr() *idRepresent

Repr represents a `pool` object using its id.

type PoolOperatorGen added in v0.2.0

type PoolOperatorGen interface {
	NewPoolById(id string) *Pool

	NewPoolByName(name string) *Pool

	GetPoolById(id string) (*Pool, error)

	GetPoolByName(name string) (*Pool, error)

	GetPools() ([]*Pool, error)

	FillPools(respEntries []*instanceResp) ([]*Pool, error)

	FilterPools(filter *filter) ([]*Pool, error)
}

type Resource added in v0.2.0

type Resource struct {
	Unity UnityConnector
	// contains filtered or unexported fields
}

type RestClient

type RestClient interface {
	Do(
		ctx context.Context,
		method, path string, body, resp interface{},
	) error

	Get(
		ctx context.Context,
		path string, headers map[string]string, resp interface{},
	) error

	Post(
		ctx context.Context,
		path string, headers map[string]string, body, resp interface{},
	) error

	Delete(
		ctx context.Context,
		path string, headers map[string]string, body, resp interface{},
	) error
}

RestClient acts as a REST client.

type StorageResource

type StorageResource struct {
	Resource

	Id          string      `json:"id"`
	Name        string      `json:"name"`
	Health      *Health     `json:"health"`
	Description string      `json:"description"`
	Filesystem  *Filesystem `json:"filesystem"`
}

StorageResource defines `storageResource` type.

func (*StorageResource) Refresh added in v0.2.0

func (r *StorageResource) Refresh() error

Refresh updates the info from Unity.

func (*StorageResource) Repr added in v0.2.0

func (r *StorageResource) Repr() *idRepresent

Repr represents a `storageResource` object using its id.

type StorageResourceOperatorGen added in v0.2.0

type StorageResourceOperatorGen interface {
	NewStorageResourceById(id string) *StorageResource

	NewStorageResourceByName(name string) *StorageResource

	GetStorageResourceById(id string) (*StorageResource, error)

	GetStorageResourceByName(name string) (*StorageResource, error)

	GetStorageResources() ([]*StorageResource, error)

	FillStorageResources(respEntries []*instanceResp) ([]*StorageResource, error)

	FilterStorageResources(filter *filter) ([]*StorageResource, error)
}

type Unity

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

Unity defines the connection to Unity system.

func NewUnity

func NewUnity(
	mgmtIp, username, password string, insecure bool,
) (*Unity, error)

NewUnity creates a connection to a Unity system.

func (*Unity) DeleteInstance added in v0.2.0

func (u *Unity) DeleteInstance(resType, id string) error

DeleteInstance deletes the instance.

func (*Unity) FillFilesystems added in v0.2.0

func (u *Unity) FillFilesystems(
	respEntries []*instanceResp,
) ([]*Filesystem, error)

FillFilesystems generates the `filesystem` objects from collection query response.

func (*Unity) FillHostLUNs added in v0.2.0

func (u *Unity) FillHostLUNs(
	respEntries []*instanceResp,
) ([]*HostLUN, error)

FillHostLUNs generates the `hostLUN` objects from collection query response.

func (*Unity) FillHosts added in v0.2.0

func (u *Unity) FillHosts(
	respEntries []*instanceResp,
) ([]*Host, error)

FillHosts generates the `host` objects from collection query response.

func (*Unity) FillLuns added in v0.2.0

func (u *Unity) FillLuns(
	respEntries []*instanceResp,
) ([]*Lun, error)

FillLuns generates the `lun` objects from collection query response.

func (*Unity) FillNasServers added in v0.2.0

func (u *Unity) FillNasServers(
	respEntries []*instanceResp,
) ([]*NasServer, error)

FillNasServers generates the `nasServer` objects from collection query response.

func (*Unity) FillNfsShares added in v0.2.0

func (u *Unity) FillNfsShares(
	respEntries []*instanceResp,
) ([]*NfsShare, error)

FillNfsShares generates the `nfsShare` objects from collection query response.

func (*Unity) FillPools added in v0.2.0

func (u *Unity) FillPools(
	respEntries []*instanceResp,
) ([]*Pool, error)

FillPools generates the `pool` objects from collection query response.

func (*Unity) FillStorageResources added in v0.2.0

func (u *Unity) FillStorageResources(
	respEntries []*instanceResp,
) ([]*StorageResource, error)

FillStorageResources generates the `storageResource` objects from collection query response.

func (*Unity) FilterFilesystems added in v0.2.0

func (u *Unity) FilterFilesystems(
	filter *filter,
) ([]*Filesystem, error)

FilterFilesystems filters the `filesystem` objects by given filters.

func (*Unity) FilterHostLUNs added in v0.2.0

func (u *Unity) FilterHostLUNs(
	filter *filter,
) ([]*HostLUN, error)

FilterHostLUNs filters the `hostLUN` objects by given filters.

func (*Unity) FilterHostLunByHostAndLun added in v0.2.0

func (u *Unity) FilterHostLunByHostAndLun(hostId, lunId string) (*HostLUN, error)

FilterHostLunByHostAndLun filters the `HostLun` by given its host Id and Lun Id.

func (*Unity) FilterHosts added in v0.2.0

func (u *Unity) FilterHosts(
	filter *filter,
) ([]*Host, error)

FilterHosts filters the `host` objects by given filters.

func (*Unity) FilterLuns added in v0.2.0

func (u *Unity) FilterLuns(
	filter *filter,
) ([]*Lun, error)

FilterLuns filters the `lun` objects by given filters.

func (*Unity) FilterNasServers added in v0.2.0

func (u *Unity) FilterNasServers(
	filter *filter,
) ([]*NasServer, error)

FilterNasServers filters the `nasServer` objects by given filters.

func (*Unity) FilterNfsShares added in v0.2.0

func (u *Unity) FilterNfsShares(
	filter *filter,
) ([]*NfsShare, error)

FilterNfsShares filters the `nfsShare` objects by given filters.

func (*Unity) FilterPools added in v0.2.0

func (u *Unity) FilterPools(
	filter *filter,
) ([]*Pool, error)

FilterPools filters the `pool` objects by given filters.

func (*Unity) FilterStorageResources added in v0.2.0

func (u *Unity) FilterStorageResources(
	filter *filter,
) ([]*StorageResource, error)

FilterStorageResources filters the `storageResource` objects by given filters.

func (*Unity) GetCollection added in v0.2.0

func (u *Unity) GetCollection(
	resType, fields string, filter *filter,
) ([]*instanceResp, error)

GetCollection queries instance collection.

func (*Unity) GetFilesystemById added in v0.2.0

func (u *Unity) GetFilesystemById(
	id string,
) (*Filesystem, error)

GetFilesystemById retrives the `filesystem` by given its id.

func (*Unity) GetFilesystemByName added in v0.2.0

func (u *Unity) GetFilesystemByName(
	name string,
) (*Filesystem, error)

GetFilesystemByName retrives the `filesystem` by given its name.

func (*Unity) GetFilesystems added in v0.2.0

func (u *Unity) GetFilesystems() ([]*Filesystem, error)

GetFilesystems retrives all `filesystem` objects.

func (*Unity) GetHostById added in v0.2.0

func (u *Unity) GetHostById(
	id string,
) (*Host, error)

GetHostById retrives the `host` by given its id.

func (*Unity) GetHostByName added in v0.2.0

func (u *Unity) GetHostByName(
	name string,
) (*Host, error)

GetHostByName retrives the `host` by given its name.

func (*Unity) GetHostLUNById added in v0.2.0

func (u *Unity) GetHostLUNById(
	id string,
) (*HostLUN, error)

GetHostLUNById retrives the `hostLUN` by given its id.

func (*Unity) GetHostLUNs added in v0.2.0

func (u *Unity) GetHostLUNs() ([]*HostLUN, error)

GetHostLUNs retrives all `hostLUN` objects.

func (*Unity) GetHosts

func (u *Unity) GetHosts() ([]*Host, error)

GetHosts retrives all `host` objects.

func (*Unity) GetInstanceById added in v0.2.0

func (u *Unity) GetInstanceById(
	resType, id, fields string, instance interface{},
) error

GetInstanceById queries instance via id.

func (*Unity) GetInstanceByName added in v0.2.0

func (u *Unity) GetInstanceByName(
	resType, name, fields string, instance interface{},
) error

GetInstanceByName queries instance via name.

func (*Unity) GetLunById added in v0.2.0

func (u *Unity) GetLunById(
	id string,
) (*Lun, error)

GetLunById retrives the `lun` by given its id.

func (*Unity) GetLunByName added in v0.2.0

func (u *Unity) GetLunByName(
	name string,
) (*Lun, error)

GetLunByName retrives the `lun` by given its name.

func (*Unity) GetLuns added in v0.2.0

func (u *Unity) GetLuns() ([]*Lun, error)

GetLuns retrives all `lun` objects.

func (*Unity) GetNasServerById added in v0.2.0

func (u *Unity) GetNasServerById(
	id string,
) (*NasServer, error)

GetNasServerById retrives the `nasServer` by given its id.

func (*Unity) GetNasServerByName added in v0.2.0

func (u *Unity) GetNasServerByName(
	name string,
) (*NasServer, error)

GetNasServerByName retrives the `nasServer` by given its name.

func (*Unity) GetNasServers added in v0.2.0

func (u *Unity) GetNasServers() ([]*NasServer, error)

GetNasServers retrives all `nasServer` objects.

func (*Unity) GetNfsShareById added in v0.2.0

func (u *Unity) GetNfsShareById(
	id string,
) (*NfsShare, error)

GetNfsShareById retrives the `nfsShare` by given its id.

func (*Unity) GetNfsShareByName added in v0.2.0

func (u *Unity) GetNfsShareByName(
	name string,
) (*NfsShare, error)

GetNfsShareByName retrives the `nfsShare` by given its name.

func (*Unity) GetNfsShares added in v0.2.0

func (u *Unity) GetNfsShares() ([]*NfsShare, error)

GetNfsShares retrives all `nfsShare` objects.

func (*Unity) GetPoolById added in v0.2.0

func (u *Unity) GetPoolById(
	id string,
) (*Pool, error)

GetPoolById retrives the `pool` by given its id.

func (*Unity) GetPoolByName added in v0.2.0

func (u *Unity) GetPoolByName(
	name string,
) (*Pool, error)

GetPoolByName retrives the `pool` by given its name.

func (*Unity) GetPools

func (u *Unity) GetPools() ([]*Pool, error)

GetPools retrives all `pool` objects.

func (*Unity) GetStorageResourceById added in v0.2.0

func (u *Unity) GetStorageResourceById(
	id string,
) (*StorageResource, error)

GetStorageResourceById retrives the `storageResource` by given its id.

func (*Unity) GetStorageResourceByName added in v0.2.0

func (u *Unity) GetStorageResourceByName(
	name string,
) (*StorageResource, error)

GetStorageResourceByName retrives the `storageResource` by given its name.

func (*Unity) GetStorageResources added in v0.2.0

func (u *Unity) GetStorageResources() ([]*StorageResource, error)

GetStorageResources retrives all `storageResource` objects.

func (*Unity) NewFilesystemById added in v0.2.0

func (u *Unity) NewFilesystemById(
	id string,
) *Filesystem

NewFilesystemById constructs a `Filesystem` object with id.

func (*Unity) NewFilesystemByName added in v0.2.0

func (u *Unity) NewFilesystemByName(
	name string,
) *Filesystem

NewFilesystemByName constructs a `filesystem` object with name.

func (*Unity) NewHostById added in v0.2.0

func (u *Unity) NewHostById(
	id string,
) *Host

NewHostById constructs a `Host` object with id.

func (*Unity) NewHostByName added in v0.2.0

func (u *Unity) NewHostByName(
	name string,
) *Host

NewHostByName constructs a `host` object with name.

func (*Unity) NewHostLUNById added in v0.2.0

func (u *Unity) NewHostLUNById(
	id string,
) *HostLUN

NewHostLUNById constructs a `HostLUN` object with id.

func (*Unity) NewLunById added in v0.2.0

func (u *Unity) NewLunById(
	id string,
) *Lun

NewLunById constructs a `Lun` object with id.

func (*Unity) NewLunByName added in v0.2.0

func (u *Unity) NewLunByName(
	name string,
) *Lun

NewLunByName constructs a `lun` object with name.

func (*Unity) NewNasServerById added in v0.2.0

func (u *Unity) NewNasServerById(
	id string,
) *NasServer

NewNasServerById constructs a `NasServer` object with id.

func (*Unity) NewNasServerByName added in v0.2.0

func (u *Unity) NewNasServerByName(
	name string,
) *NasServer

NewNasServerByName constructs a `nasServer` object with name.

func (*Unity) NewNfsShareById added in v0.2.0

func (u *Unity) NewNfsShareById(
	id string,
) *NfsShare

NewNfsShareById constructs a `NfsShare` object with id.

func (*Unity) NewNfsShareByName added in v0.2.0

func (u *Unity) NewNfsShareByName(
	name string,
) *NfsShare

NewNfsShareByName constructs a `nfsShare` object with name.

func (*Unity) NewPoolById added in v0.2.0

func (u *Unity) NewPoolById(
	id string,
) *Pool

NewPoolById constructs a `Pool` object with id.

func (*Unity) NewPoolByName added in v0.2.0

func (u *Unity) NewPoolByName(
	name string,
) *Pool

NewPoolByName constructs a `pool` object with name.

func (*Unity) NewStorageResourceById added in v0.2.0

func (u *Unity) NewStorageResourceById(
	id string,
) *StorageResource

NewStorageResourceById constructs a `StorageResource` object with id.

func (*Unity) NewStorageResourceByName added in v0.2.0

func (u *Unity) NewStorageResourceByName(
	name string,
) *StorageResource

NewStorageResourceByName constructs a `storageResource` object with name.

func (*Unity) PostOnInstance added in v0.2.0

func (u *Unity) PostOnInstance(
	typeName, resId, action string, body map[string]interface{},
) error

PostOnInstance sends POST request on resource instance.

func (*Unity) PostOnType added in v0.2.0

func (u *Unity) PostOnType(
	typeName, action string, body map[string]interface{},
) (string, error)

PostOnType sends POST request on resource type.

type UnityConnector added in v0.2.0

type UnityConnector interface {
	GetInstanceById(
		resType, id, fields string, instance interface{},
	) error

	GetInstanceByName(
		resType, name, fields string, instance interface{},
	) error

	GetCollection(
		resType, fields string, filter *filter,
	) ([]*instanceResp, error)

	PostOnType(
		typeName, action string, body map[string]interface{},
	) (string, error)

	PostOnInstance(
		typeName, resId, action string, body map[string]interface{},
	) error

	DeleteInstance(resType, id string) error

	StorageResourceOperatorGen

	PoolOperatorGen

	LunOperatorGen

	HostOperatorGen

	HostLUNOperator

	NasServerOperatorGen

	FilesystemOperatorGen

	NfsShareOperatorGen
}

UnityConnector defines the interface to storage system.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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