api

package
v19.10.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

This package provides a high-level interface to the E-series Web Services Proxy REST API.

Index

Constants

View Source
const NullRef = "0000000000000000000000000000000000000000"

Variables

View Source
var HostTypes = map[string]string{
	"linux_atto":        "LnxTPGSALUA",
	"linux_dm_mp":       "LnxALUA",
	"linux_mpp_rdac":    "LNX",
	"linux_pathmanager": "LnxTPGSALUA_PM",
	"linux_sf":          "LnxTPGSALUA_SF",
	"ontap":             "ONTAP_ALUA",
	"ontap_rdac":        "ONTAP_RDAC",
	"vmware":            "VmwTPGSALUA",
	"windows":           "W2KNETNCL",
	"windows_atto":      "WinTPGSALUA",
	"windows_clustered": "W2KNETCL",
}

Functions

This section is empty.

Types

type ByFreeSpace

type ByFreeSpace []VolumeGroupEx

Functions to allow sorting storage pools by free space

func (ByFreeSpace) Len

func (s ByFreeSpace) Len() int

func (ByFreeSpace) Less

func (s ByFreeSpace) Less(i, j int) bool

func (ByFreeSpace) Swap

func (s ByFreeSpace) Swap(i, j int)

type CallResponseError

type CallResponseError struct {
	ErrorMsg     string `json:"errorMessage"`
	LocalizedMsg string `json:"localizedMessage"`
	ReturnCode   string `json:"retcode"`
	CodeType     string `json:"codeType"` //'symbol', 'webservice', 'systemerror', 'devicemgrerror'
}

Used for errors on RESTful calls to return what went wrong

type Client

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

Client is the object to use for interacting with the E-series API.

func NewAPIClient

func NewAPIClient(config ClientConfig) *Client

NewAPIClient is a factory method for creating a new instance.

func (Client) Connect

func (d Client) Connect() (string, error)

Connect connects to the Web Services Proxy and registers the array with it.

func (Client) CreateHost

func (d Client) CreateHost(name string, iqn string, hostType string, hostGroup HostGroup) (HostEx, error)

CreateHost creates a Host on the array. If a HostGroup is specified, the Host is placed in that group.

func (Client) CreateHostGroup

func (d Client) CreateHostGroup(name string) (HostGroup, error)

CreateHostGroup creates an E-series HostGroup object with the specified name and returns the resulting HostGroup structure.

func (Client) CreateVolume

func (d Client) CreateVolume(
	name string, volumeGroupRef string, size uint64, mediaType, fstype string,
) (VolumeEx, error)

CreateVolume creates a volume (i.e. a LUN) on the array, and it returns the resulting VolumeEx structure.

func (Client) DeleteVolume

func (d Client) DeleteVolume(volume VolumeEx) error

DeleteVolume deletes a volume from the array.

func (Client) EnsureHostForIQN

func (d Client) EnsureHostForIQN(iqn string) (HostEx, error)

EnsureHostForIQN handles automatic E-series Host and Host Group creation. Given the IQN of a host, this method verifies whether a Host is already configured on the array. If so, the Host info is returned and no further action is taken. If not, this method chooses a unique name for the Host and creates it on the array. Once the Host is created, it is placed in the Host Group used for nDVP volumes.

func (Client) EnsureHostGroup

func (d Client) EnsureHostGroup() (HostGroup, error)

EnsureHostGroup ensures that an E-series HostGroup exists to contain all Host objects created by the nDVP E-series driver. The group name is taken from the config structure. If the group exists, the group structure is returned and no further action is taken. If not, this method creates the group and returns the resulting group structure.

func (Client) GetChassisSerialNumber

func (d Client) GetChassisSerialNumber() (string, error)

GetChassisSerialNumber returns the chassis serial number for this storage system.

func (Client) GetHostForIQN

func (d Client) GetHostForIQN(iqn string) (HostEx, error)

GetHostForIQN queries the Host objects on the array an returns one matching the supplied IQN. An empty struct is returned if a matching host is not found, so the caller should check for empty values in the result.

func (Client) GetHostGroup

func (d Client) GetHostGroup(name string) (HostGroup, error)

GetHostGroup returns an E-series HostGroup structure with the specified name. If no matching group is found, an empty structure is returned, so the caller should check for empty values in the result.

func (Client) GetStorageSystem

func (d Client) GetStorageSystem() (*StorageSystem, error)

GetStorageSystem returns a struct detailing the storage system.

func (*Client) GetTargetIQN

func (d *Client) GetTargetIQN() (string, error)

GetTargetIQN returns the IQN for the array.

func (*Client) GetTargetSettings

func (d *Client) GetTargetSettings() (*IscsiTargetSettings, error)

GetTargetSettings returns the iSCSI target settings for the array.

func (Client) GetVolume

func (d Client) GetVolume(name string) (VolumeEx, error)

GetVolume returns a volume structure from the array whose label matches the specified name. Use this method sparingly, at most once per workflow, because the Web Services Proxy does not support server-side filtering so the only choice is to read all volumes to find the one of interest. Most methods in this module operate on the returned VolumeEx structure, not the volume name, to minimize the need for calling this method.

func (Client) GetVolumeByRef

func (d Client) GetVolumeByRef(volumeRef string) (VolumeEx, error)

GetVolumeByRef gets a single volume from the array.

func (Client) GetVolumePoolByRef

func (d Client) GetVolumePoolByRef(volumeGroupRef string) (VolumeGroupEx, error)

GetVolumePoolByRef returns the pool with the specified volumeGroupRef.

func (Client) GetVolumePools

func (d Client) GetVolumePools(mediaType string, minFreeSpaceBytes uint64, poolName string) ([]VolumeGroupEx, error)

GetVolumePools reads all pools on the array, including volume groups and dynamic disk pools. It then filters them based on several selection parameters and returns the ones that match.

func (Client) GetVolumes

func (d Client) GetVolumes() ([]VolumeEx, error)

GetVolumes returns an array containing all the volumes on the array.

func (Client) InvokeAPI

func (d Client) InvokeAPI(requestBody []byte, method string, resourcePath string) (*http.Response, []byte, error)

InvokeAPI makes a REST call to the Web Services Proxy. The body must be a marshaled JSON byte array (or nil). The method is the HTTP verb (i.e. GET, POST, ...). The resource path is appended to the base URL to identify the desired server resource; it should start with '/'.

func (Client) IsRefValid

func (d Client) IsRefValid(ref string) bool

IsRefValid checks whether the supplied string is a valid E-series object reference as used by its REST API. Ref values are strings of all numerical digits that aren't all zeros (i.e. the null ref).

func (Client) ListVolumes

func (d Client) ListVolumes() ([]string, error)

ListVolumes returns an array containing all the volume names on the array.

func (Client) MapVolume

func (d Client) MapVolume(volume VolumeEx, host HostEx) (LUNMapping, error)

MapVolume maps a volume to the specified host and returns the resulting LUN mapping. If the volume is already mapped to the specified host, either directly or to the containing host group, no action is taken. If the volume is mapped to a different host, the method returns an error. Note that if the host is in a group, the volume will actually be mapped to the group instead of the individual host.

func (Client) ResizeVolume

func (d Client) ResizeVolume(volume VolumeEx, size uint64) error

ResizeVolume expands a volume's size. Thin provisioning is not supported on E-series so we only call the API for expanding thick provisioned volumes.

func (Client) ResizingVolume

func (d Client) ResizingVolume(volume VolumeEx) (bool, error)

ResizingVolume checks to see if an expand operation is in progress for the volume.

func (Client) UnmapVolume

func (d Client) UnmapVolume(volume VolumeEx) error

UnmapVolume removes a mapping from the specified volume. If no map exists, no action is taken.

type ClientConfig

type ClientConfig struct {
	// Web Proxy Services Info
	WebProxyHostname  string
	WebProxyPort      string
	WebProxyUseHTTP   bool
	WebProxyVerifyTLS bool
	Username          string
	Password          string

	// Array Info
	ControllerA   string
	ControllerB   string
	PasswordArray string

	// Options
	PoolNameSearchPattern string
	DebugTraceFlags       map[string]bool

	// Host Connectivity
	HostDataIP string //for iSCSI with multipathing this can be either IP or host

	// Internal Config Variables
	ArrayID                       string // Unique ID for array once added to web proxy services
	CompiledPoolNameSearchPattern *regexp.Regexp

	// Storage protocol of the driver (iSCSI, FC, etc)
	Protocol    string
	AccessGroup string
	HostType    string

	DriverName    string
	Telemetry     map[string]string
	ConfigVersion int
}

ClientConfig holds configuration data for the API driver object.

type Error

type Error struct {
	Code    int
	Message string
}

Error wrapper

func (Error) Error

func (e Error) Error() string

type HostCreateRequest

type HostCreateRequest struct {
	Name     string `json:"name"`
	HostType `json:"hostType"`
	GroupID  string     `json:"groupId,omitempty"`
	Ports    []HostPort `json:"ports"`
}

type HostEx

type HostEx struct {
	HostRef       string            `json:"hostRef"`
	ClusterRef    string            `json:"clusterRef"`
	Label         string            `json:"label"`
	HostTypeIndex int               `json:"hostTypeIndex"`
	Initiators    []HostExInitiator `json:"initiators"`
}

type HostExInitiator

type HostExInitiator struct {
	InitiatorRef string             `json:"initiatorRef"`
	NodeName     HostExScsiNodeName `json:"nodeName"`
	Label        string             `json:"label"`
}

type HostExScsiNodeName

type HostExScsiNodeName struct {
	IoInterfaceType string `json:"ioInterfaceType"`
	IscsiNodeName   string `json:"iscsiNodeName"`
}

type HostGroup

type HostGroup struct {
	ClusterRef string `json:"clusterRef"`
	Label      string `json:"label"`
}

type HostGroupCreateRequest

type HostGroupCreateRequest struct {
	Name  string   `json:"name"`
	Hosts []string `json:"hosts"`
}

type HostPort

type HostPort struct {
	Type  string `json:"type"`
	Port  string `json:"port"`
	Label string `json:"label"`
}

type HostType

type HostType struct {
	Name  string `json:"name,omitempty"`
	Index int    `json:"index"`
	Code  string `json:"code,omitempty"`
}

type IscsiTargetSettings

type IscsiTargetSettings struct {
	TargetRef string `json:"targetRef"`
	NodeName  struct {
		IoInterfaceType string      `json:"ioInterfaceType"`
		IscsiNodeName   string      `json:"iscsiNodeName"`
		RemoteNodeWWN   interface{} `json:"remoteNodeWWN"`
	} `json:"nodeName"`
	Alias struct {
		IoInterfaceType string `json:"ioInterfaceType"`
		IscsiAlias      string `json:"iscsiAlias"`
	} `json:"alias"`
	ConfiguredAuthMethods struct {
		AuthMethodData []struct {
			AuthMethod string      `json:"authMethod"`
			ChapSecret interface{} `json:"chapSecret"`
		} `json:"authMethodData"`
	} `json:"configuredAuthMethods"`
	Portals []struct {
		GroupTag  int `json:"groupTag"`
		IPAddress struct {
			AddressType string      `json:"addressType"`
			Ipv4Address string      `json:"ipv4Address"`
			Ipv6Address interface{} `json:"ipv6Address"`
		} `json:"ipAddress"`
		TCPListenPort int `json:"tcpListenPort"`
	} `json:"portals"`
}

type LUNMapping

type LUNMapping struct {
	LunMappingRef string `json:"lunMappingRef"`
	LunNumber     int    `json:"lun"`
	VolumeRef     string `json:"volumeRef"`
	MapRef        string `json:"mapRef"`
	Type          string `json:"type"`
}

type MsgConnect

type MsgConnect struct {
	ControllerAddresses []string `json:"controllerAddresses"`
	Password            string   `json:"password,omitempty"`
}

Add array to Web Services Proxy

type MsgConnectResponse

type MsgConnectResponse struct {
	ArrayID       string `json:"id"`
	AlreadyExists bool   `json:"alreadyExists"`
}

type StorageSystem

type StorageSystem struct {
	ID              string   `json:"id"`
	Name            string   `json:"name"`
	Wwn             string   `json:"wwn"`
	PasswordStatus  string   `json:"passwordStatus"`
	PasswordSet     bool     `json:"passwordSet"`
	Status          string   `json:"status"`
	IP1             string   `json:"ip1"`
	IP2             string   `json:"ip2"`
	ManagementPaths []string `json:"managementPaths"`
	Controllers     []struct {
		ControllerID      string   `json:"controllerId"`
		IPAddresses       []string `json:"ipAddresses"`
		CertificateStatus string   `json:"certificateStatus"`
	} `json:"controllers"`
	DriveCount              int           `json:"driveCount"`
	TrayCount               int           `json:"trayCount"`
	TraceEnabled            bool          `json:"traceEnabled"`
	Types                   string        `json:"types"`
	Model                   string        `json:"model"`
	MetaTags                []interface{} `json:"metaTags"`
	HotSpareSize            string        `json:"hotSpareSize"`
	UsedPoolSpace           string        `json:"usedPoolSpace"`
	FreePoolSpace           string        `json:"freePoolSpace"`
	UnconfiguredSpace       string        `json:"unconfiguredSpace"`
	DriveTypes              []string      `json:"driveTypes"`
	HostSpareCountInStandby int           `json:"hostSpareCountInStandby"`
	HotSpareCount           int           `json:"hotSpareCount"`
	HostSparesUsed          int           `json:"hostSparesUsed"`
	BootTime                string        `json:"bootTime"`
	FwVersion               string        `json:"fwVersion"`
	AppVersion              string        `json:"appVersion"`
	BootVersion             string        `json:"bootVersion"`
	NvsramVersion           string        `json:"nvsramVersion"`
	ChassisSerialNumber     string        `json:"chassisSerialNumber"`
	AccessVolume            struct {
		Enabled               bool   `json:"enabled"`
		VolumeHandle          int    `json:"volumeHandle"`
		Capacity              string `json:"capacity"`
		AccessVolumeRef       string `json:"accessVolumeRef"`
		Reserved1             string `json:"reserved1"`
		ObjectType            string `json:"objectType"`
		Wwn                   string `json:"wwn"`
		PreferredControllerID string `json:"preferredControllerId"`
		TotalSizeInBytes      string `json:"totalSizeInBytes"`
		ListOfMappings        []struct {
			LunMappingRef string `json:"lunMappingRef"`
			Lun           int    `json:"lun"`
			Ssid          int    `json:"ssid"`
			Perms         int    `json:"perms"`
			VolumeRef     string `json:"volumeRef"`
			Type          string `json:"type"`
			MapRef        string `json:"mapRef"`
			ID            string `json:"id"`
		} `json:"listOfMappings"`
		Mapped              bool   `json:"mapped"`
		CurrentControllerID string `json:"currentControllerId"`
		Name                string `json:"name"`
		ID                  string `json:"id"`
	} `json:"accessVolume"`
	UnconfiguredSpaceByDriveType struct {
	} `json:"unconfiguredSpaceByDriveType"`
	MediaScanPeriod                  int         `json:"mediaScanPeriod"`
	DriveChannelPortDisabled         bool        `json:"driveChannelPortDisabled"`
	RecoveryModeEnabled              bool        `json:"recoveryModeEnabled"`
	AutoLoadBalancingEnabled         bool        `json:"autoLoadBalancingEnabled"`
	HostConnectivityReportingEnabled bool        `json:"hostConnectivityReportingEnabled"`
	RemoteMirroringEnabled           bool        `json:"remoteMirroringEnabled"`
	FcRemoteMirroringState           string      `json:"fcRemoteMirroringState"`
	AsupEnabled                      bool        `json:"asupEnabled"`
	SecurityKeyEnabled               bool        `json:"securityKeyEnabled"`
	ExternalKeyEnabled               bool        `json:"externalKeyEnabled"`
	LastContacted                    string      `json:"lastContacted"`
	DefinedPartitionCount            int         `json:"definedPartitionCount"`
	SimplexModeEnabled               bool        `json:"simplexModeEnabled"`
	EnabledManagementPorts           interface{} `json:"enabledManagementPorts"`
	FreePoolSpaceAsString            string      `json:"freePoolSpaceAsString"`
	HotSpareSizeAsString             string      `json:"hotSpareSizeAsString"`
	UnconfiguredSpaceAsStrings       string      `json:"unconfiguredSpaceAsStrings"`
	UsedPoolSpaceAsString            string      `json:"usedPoolSpaceAsString"`
}

type VolumeCreateRequest

type VolumeCreateRequest struct {
	VolumeGroupRef   string      `json:"poolId"`
	Name             string      `json:"name"`
	SizeUnit         string      `json:"sizeUnit"` //bytes, b, kb, mb, gb, tb, pb, eb, zb, yb
	Size             int         `json:"size"`
	SegmentSize      int         `json:"segSize"`
	DataAssurance    bool        `json:"dataAssuranceEnabled,omitempty"`
	OwningController string      `json:"owningControllerId,omitempty"`
	VolumeTags       []VolumeTag `json:"metaTags,omitempty"`
}

type VolumeEx

type VolumeEx struct {
	IsOffline      bool         `json:"offline"`
	Label          string       `json:"label"`
	VolumeSize     string       `json:"capacity"`
	SegmentSize    int          `json:"segmentSize"`
	VolumeRef      string       `json:"volumeRef"`
	VolumeGroupRef string       `json:"volumeGroupRef"`
	Mappings       []LUNMapping `json:"listOfMappings"`
	IsMapped       bool         `json:"mapped"`
	VolumeTags     []VolumeTag  `json:"metadata"`
}

type VolumeGroupEx

type VolumeGroupEx struct {
	IsOffline      bool   `json:"offline"`
	WorldWideName  string `json:"worldWideName"`
	VolumeGroupRef string `json:"volumeGroupRef"`
	Label          string `json:"label"`
	FreeSpace      string `json:"freeSpace"`      // Documentation says this is an int but really it is a string!
	DriveMediaType string `json:"driveMediaType"` // 'hdd', 'ssd'
}

type VolumeMappingCreateRequest

type VolumeMappingCreateRequest struct {
	MappableObjectID string `json:"mappableObjectId"`
	TargetID         string `json:"targetId"`
	LunNumber        int    `json:"lun,omitempty"`
}

type VolumeResizeRequest

type VolumeResizeRequest struct {
	ExpansionSize int    `json:"expansionSize"`
	SizeUnit      string `json:"sizeUnit"` //bytes, b, kb, mb, gb, tb, pb, eb, zb, yb
}

type VolumeResizeStatusResponse

type VolumeResizeStatusResponse struct {
	PercentComplete  int    `json:"percentComplete"`
	TimeToCompletion int    `json:"timeToCompletion"`
	Action           string `json:"action"`
}

type VolumeTag

type VolumeTag struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

func (VolumeTag) Equals

func (t VolumeTag) Equals(otherTag VolumeTag) bool

Jump to

Keyboard shortcuts

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