goscaleio

package module
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2021 License: Apache-2.0 Imports: 24 Imported by: 4

README

Goscaleio

The Goscaleio project represents API bindings that can be used to provide ScaleIO functionality into other Go applications.

Use Cases

Any application written in Go can take advantage of these bindings. Specifically, things that are involved in monitoring, management, and more specifically infrastructrue as code would find these bindings relevant.

Current State

Early build-out and pre-documentation stages. The basics around authentication and object models are there.

Usage

Logging in
client, err := goscaleio.NewClient()
if err != nil {
  log.Fatalf("err: %v", err)
}

_, err = client.Authenticate(&goscaleio.ConfigConnect{endpoint, username, password})
if err != nil {
  log.Fatalf("error authenticating: %v", err)
}

fmt.Println("Successfuly logged in to ScaleIO Gateway at", client.SIOEndpoint.String())
Reusing the authentication token

Once a client struct is created via the NewClient() function, you can replace the Token with the saved token.

client, err := goscaleio.NewClient()
if err != nil {
  log.Fatalf("error with NewClient: %s", err)
}

client.SetToken(oldToken)
Get Systems

Retrieving systems is the first step after authentication which enables you to work with other necessary methods.

All Systems
systems, err := client.GetInstance()
if err != nil {
  log.Fatalf("err: problem getting instance %v", err)
}
Find a System
system, err := client.FindSystem(systemid,"","")
if err != nil {
  log.Fatalf("err: problem getting instance %v", err)
}
Get Protection Domains

Once you have a System struct you can then get other things like Protection Domains.

protectiondomains, err := system.GetProtectionDomain()
if err != nil {
  log.Fatalf("error getting protection domains: %v", err)
}

Debugging

Two environment variables can be set to aid in debugging

Env Var Default Value
GOSCALEIO_DEBUG false
GOSCALEIO_SHOWHTTP false

Setting GOSCALEIO_DEBUG well enable logging to stdout. Setting GOSCALEIO_SHOWHTTP will log all HTTP requests and responses to stdout.

Licensing

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Support

Please file bugs and issues on the Github issues page for this project. This is to help keep track and document everything related to this repo. For general discussions and further support you can join the {code} Community slack channel. The code and documentation are released with no warranties or SLAs and are intended to be supported through a community driven process.

Documentation

Index

Constants

View Source
const (

	// IOCTLDevice is the default device to send queries to
	IOCTLDevice = "/dev/scini"
)

Variables

View Source
var (
	// SDCDevice is the device used to communicate with the SDC
	SDCDevice = IOCTLDevice
	// SCINIMockMode is used for testing upper layer code that attempts to call these methods
	SCINIMockMode = false
)
View Source
var ExternalTimeRecorder func(string, time.Duration)
View Source
var FSDevDirectoryPrefix string = ""

For unit testing on Windows - dev is not in the same place

Functions

func DrvCfgIsSDCInstalled added in v1.3.0

func DrvCfgIsSDCInstalled() bool

DrvCfgIsSDCInstalled will check to see if the SDC kernel module is loaded

func DrvCfgQueryGUID added in v1.3.0

func DrvCfgQueryGUID() (string, error)

DrvCfgQueryGUID will return the GUID of the locally installed SDC

func DrvCfgQueryRescan added in v1.4.0

func DrvCfgQueryRescan() (string, error)

func DrvCfgQuerySystems added in v1.3.0

func DrvCfgQuerySystems() (*[]ConfiguredCluster, error)

DrvCfgQuerySystems will return the configured MDM endpoints for the locally installed SDC

func GetLink(links []*types.Link, rel string) (*types.Link, error)

func GetSdcLocalGUID

func GetSdcLocalGUID() (string, error)

func TimeSpent added in v1.2.0

func TimeSpent(functionName string, startTime time.Time)

Types

type Client

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

func NewClient

func NewClient() (client *Client, err error)

func NewClientWithArgs

func NewClientWithArgs(
	endpoint string,
	version string,
	insecure,
	useCerts bool) (client *Client, err error)

func (*Client) Authenticate

func (c *Client) Authenticate(configConnect *ConfigConnect) (Cluster, error)

func (*Client) CreateVolume

func (c *Client) CreateVolume(
	volume *types.VolumeParam,
	storagePoolName string) (*types.VolumeResp, error)

func (*Client) FindStoragePool

func (c *Client) FindStoragePool(
	id, name, href string) (*types.StoragePool, error)

func (*Client) FindSystem

func (c *Client) FindSystem(
	instanceID, name, href string) (*System, error)

func (*Client) FindVolumeID

func (c *Client) FindVolumeID(volumename string) (string, error)

func (*Client) GetInstance

func (c *Client) GetInstance(systemhref string) ([]*types.System, error)

func (*Client) GetStoragePool

func (c *Client) GetStoragePool(
	storagepoolhref string) ([]*types.StoragePool, error)

func (*Client) GetSystems added in v1.3.0

func (c *Client) GetSystems() ([]*types.System, error)

func (*Client) GetToken

func (c *Client) GetToken() string

func (*Client) GetVolume

func (c *Client) GetVolume(
	volumehref, volumeid, ancestorvolumeid, volumename string,
	getSnapshots bool) ([]*types.Volume, error)

func (*Client) SetToken

func (c *Client) SetToken(token string)

type ClientPersistent

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

type Cluster

type Cluster struct {
}

type ConfigConnect

type ConfigConnect struct {
	Endpoint string
	Version  string
	Username string
	Password string
}

type ConfiguredCluster added in v1.3.0

type ConfiguredCluster struct {
	// SystemID is the MDM cluster system ID
	SystemID string
	// SdcID is the ID of the SDC as known to the MDM cluster
	SdcID string
}

ConfiguredCluster contains configuration information for one connected system

type Device

type Device struct {
	Device *types.Device
	// contains filtered or unexported fields
}

func NewDevice

func NewDevice(client *Client) *Device

func NewDeviceEx

func NewDeviceEx(client *Client, device *types.Device) *Device

type ProtectionDomain

type ProtectionDomain struct {
	ProtectionDomain *types.ProtectionDomain
	// contains filtered or unexported fields
}

func NewProtectionDomain

func NewProtectionDomain(client *Client) *ProtectionDomain

func NewProtectionDomainEx

func NewProtectionDomainEx(client *Client, pd *types.ProtectionDomain) *ProtectionDomain

func (*ProtectionDomain) CreateSds

func (pd *ProtectionDomain) CreateSds(
	name string, ipList []string) (string, error)

func (*ProtectionDomain) CreateStoragePool

func (pd *ProtectionDomain) CreateStoragePool(name string, mediaType string) (string, error)

func (*ProtectionDomain) DeleteStoragePool added in v1.3.0

func (pd *ProtectionDomain) DeleteStoragePool(name string) error

DeleteStoragePool will delete a storage pool

func (*ProtectionDomain) FindSds

func (pd *ProtectionDomain) FindSds(
	field, value string) (*types.Sds, error)

func (*ProtectionDomain) FindStoragePool

func (pd *ProtectionDomain) FindStoragePool(
	id, name, href string) (*types.StoragePool, error)

func (*ProtectionDomain) GetSds

func (pd *ProtectionDomain) GetSds() ([]types.Sds, error)

func (*ProtectionDomain) GetStoragePool

func (pd *ProtectionDomain) GetStoragePool(
	storagepoolhref string) ([]*types.StoragePool, error)

type Sdc

type Sdc struct {
	Sdc *types.Sdc
	// contains filtered or unexported fields
}

func NewSdc

func NewSdc(client *Client, sdc *types.Sdc) *Sdc

func (*Sdc) FindVolumes added in v1.2.0

func (sdc *Sdc) FindVolumes() ([]*Volume, error)

func (*Sdc) GetStatistics

func (sdc *Sdc) GetStatistics() (*types.SdcStatistics, error)

func (*Sdc) GetVolume

func (sdc *Sdc) GetVolume() ([]*types.Volume, error)

type SdcMappedVolume

type SdcMappedVolume struct {
	MdmID     string
	VolumeID  string
	SdcDevice string
}

func GetLocalVolumeMap

func GetLocalVolumeMap() (mappedVolumes []*SdcMappedVolume, err error)

GetLocalVolumeMap will return all SdcMappedVolume entries

func GetLocalVolumeMapByRegex added in v1.2.0

func GetLocalVolumeMapByRegex(systemIDRegex string, volumeIDRegex string) (mappedVolumes []*SdcMappedVolume, err error)

GetLocalVolumeMapByRegex will return the SdcMappedVolume entries matching supplied regex values

type Sds

type Sds struct {
	Sds *types.Sds
	// contains filtered or unexported fields
}

func NewSds

func NewSds(client *Client) *Sds

func NewSdsEx

func NewSdsEx(client *Client, sds *types.Sds) *Sds

type StoragePool

type StoragePool struct {
	StoragePool *types.StoragePool
	// contains filtered or unexported fields
}

func NewStoragePool

func NewStoragePool(client *Client) *StoragePool

func NewStoragePoolEx

func NewStoragePoolEx(client *Client, pool *types.StoragePool) *StoragePool

func (*StoragePool) AttachDevice

func (sp *StoragePool) AttachDevice(
	path string,
	sdsID string) (string, error)

func (*StoragePool) CreateVolume

func (sp *StoragePool) CreateVolume(
	volume *types.VolumeParam) (*types.VolumeResp, error)

func (*StoragePool) FindDevice

func (sp *StoragePool) FindDevice(
	field, value string) (*types.Device, error)

func (*StoragePool) FindVolumeID

func (sp *StoragePool) FindVolumeID(volumename string) (string, error)

func (*StoragePool) GetDevice

func (sp *StoragePool) GetDevice() ([]types.Device, error)

func (*StoragePool) GetStatistics

func (sp *StoragePool) GetStatistics() (*types.Statistics, error)

func (*StoragePool) GetVolume

func (sp *StoragePool) GetVolume(
	volumehref, volumeid, ancestorvolumeid, volumename string,
	getSnapshots bool) ([]*types.Volume, error)

type System

type System struct {
	System *types.System
	// contains filtered or unexported fields
}

func NewSystem

func NewSystem(client *Client) *System

func (*System) CreateProtectionDomain

func (s *System) CreateProtectionDomain(name string) (string, error)

func (*System) CreateSnapshotConsistencyGroup

func (s *System) CreateSnapshotConsistencyGroup(
	snapshotVolumesParam *types.SnapshotVolumesParam) (*types.SnapshotVolumesResp, error)

func (*System) DeleteProtectionDomain added in v1.3.0

func (s *System) DeleteProtectionDomain(name string) error

DeleteProtectionDomain will delete a protection domain

func (*System) FindProtectionDomain

func (s *System) FindProtectionDomain(
	id, name, href string) (*types.ProtectionDomain, error)

func (*System) FindSdc

func (s *System) FindSdc(field, value string) (*Sdc, error)

func (*System) GetProtectionDomain

func (s *System) GetProtectionDomain(
	pdhref string) ([]*types.ProtectionDomain, error)

func (*System) GetScsiInitiator

func (s *System) GetScsiInitiator() ([]types.ScsiInitiator, error)

func (*System) GetSdc

func (s *System) GetSdc() ([]types.Sdc, error)

func (*System) GetStatistics

func (s *System) GetStatistics() (*types.Statistics, error)

func (*System) GetUser

func (s *System) GetUser() ([]types.User, error)

type Volume

type Volume struct {
	Volume *types.Volume
	// contains filtered or unexported fields
}

func NewVolume

func NewVolume(client *Client) *Volume

func (*Volume) GetVTree

func (v *Volume) GetVTree() (*types.VTree, error)

func (*Volume) GetVolumeStatistics added in v1.2.0

func (v *Volume) GetVolumeStatistics() (*types.VolumeStatistics, error)

func (*Volume) MapVolumeSdc

func (v *Volume) MapVolumeSdc(
	mapVolumeSdcParam *types.MapVolumeSdcParam) error

func (*Volume) RemoveVolume

func (v *Volume) RemoveVolume(removeMode string) error

func (*Volume) SetMappedSdcLimits

func (v *Volume) SetMappedSdcLimits(
	setMappedSdcLimitsParam *types.SetMappedSdcLimitsParam) error

func (*Volume) SetVolumeSize added in v1.2.0

func (v *Volume) SetVolumeSize(sizeInGB string) error

func (*Volume) UnmapVolumeSdc

func (v *Volume) UnmapVolumeSdc(
	unmapVolumeSdcParam *types.UnmapVolumeSdcParam) error

Directories

Path Synopsis
types
v1

Jump to

Keyboard shortcuts

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