coprhd

package module
v0.0.0-...-ff91946 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2016 License: MIT Imports: 8 Imported by: 1

README

coprhd

MIT License

coprhd go library

###Installation

go get github.com/ModelRocket/coprhd/...

###Library

The coprhd.Client interface provides a simple means for managing coprhd/vipr resources.

import (
 "github.com/ModelRocket/coprhd"
 "fmt"
)

func main() {
     // You only need to get your token once, or use the coprtop tool
	token, _ := corphd.GetProxyToken(host, username, password)
     
	vols, err := client.Volume().List()
	if err != nil {
		fmt.Fatalf("Failed to get volume list:", err.Error())
	}

	for i, vol := range vols {
		fmt.Printf("Volume %d: %s\n", i, vol)
	}

	// Query a volume by urn
	vol, _ := client.Volume().
		Id(urn).  // or by Name(name)
		Query()

	fmt.Printf("Volume name %s\n", vol.Name)
}

###Tool You can use the coprtop cli tool to get a proxy token to use with the client.

$GOPATH/bin/coprtop -u root -p pass -H 172.31.32.100 token

Documentation

Index

Constants

View Source
const (
	ErrCodeOK               = 0
	ErrCodeInvalidParam     = 1008
	ErrCodeCreateNotAllowed = 1054
)
View Source
const (
	ExportTypeExclusive = "Exclusive"
)

Variables

View Source
var (
	ErrLoginFailed = errors.New("Login failed")
	ErrAuthFailed  = errors.New("Authorization failed")
)
View Source
var (
	// ErrCreateResponse is returned when the api call returns an unexptected result
	ErrCreateResponse = errors.New("Invalid create response received")
)
View Source
var (
	ErrResourceNotFound = errors.New("resource not found")
)
View Source
var (
	ErrTaskWaitTimeout = errors.New("WaitDone timeout")
)
View Source
var (
	ErrWorkflowWaitTimeout = errors.New("WaitDone timeout")
)

Functions

func GetProxyToken

func GetProxyToken(host string, username string, password string) (string, error)

GetProxyToken is a helper function for creating a new proxy token for the user

Types

type ApiError

type ApiError struct {
	Code        int    `json:"code"`
	Retryable   bool   `json:"retryable"`
	Description string `json:"description"`
	Details     string `json:"details"`
}

func (ApiError) IsDup

func (err ApiError) IsDup() bool

func (ApiError) IsOK

func (err ApiError) IsOK() bool

type Client

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

func NewClient

func NewClient(host string, token string) *Client

NewClient returns a new coprhd rest api client using the specified proxy token The proxy token can be generated programmatically using the GetProxyToken method or better using the `coprtop` tool

func (*Client) Copy

func (this *Client) Copy() *Client

Copy creates a clone of the client

func (*Client) Export

func (this *Client) Export() *ExportService

Export gets an instance to the ExportService

func (*Client) Group

func (this *Client) Group() *GroupService

func (*Client) Host

func (this *Client) Host() *HostService

Host returns an instance of the HostService

func (*Client) Initiator

func (this *Client) Initiator() *InitiatorService

func (*Client) LastError

func (this *Client) LastError() ApiError

LastError return the last ApiError If a method returns an error object, you can check this to get more specific details

func (*Client) Project

func (this *Client) Project() *ProjectService

Project returns an instances the ProjectService

func (*Client) Search

func (this *Client) Search(path string) ([]Resource, error)

func (*Client) Task

func (this *Client) Task() *TaskService

func (*Client) VArray

func (this *Client) VArray() *VArrayService

func (*Client) VPool

func (this *Client) VPool() *VPoolService

func (*Client) Volume

func (this *Client) Volume() *VolumeService

Volume returns an instance of the VolumeService

func (*Client) Workflow

func (this *Client) Workflow() *WorkflowService

type Export

type Export struct {
	StorageObject `json:",inline"`
	Volumes       []ExportVolume  `json:"volumes"`
	Initiators    []Initiator     `json:"initiators"`
	Hosts         []NamedResource `json:"hosts"`
	Clustsers     []NamedResource `json:"clusters"`
	GeneratedName string          `json:"generated_name"`
	PathParams    []string        `json:"path_parameters"`
}

Export represents a storage export group

type ExportService

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

ExportService provices a means for querying or creating volume export groups

func (*ExportService) Array

func (this *ExportService) Array(array string) *ExportService

func (*ExportService) Create

func (this *ExportService) Create() (*Export, error)

Create creates and export with the specfied name

func (*ExportService) Delete

func (this *ExportService) Delete() error

func (*ExportService) Id

func (this *ExportService) Id(id string) *ExportService

Id sets the id urn for the export group, use for query, ignored for create

func (*ExportService) Initiators

func (this *ExportService) Initiators(itrs ...string) *ExportService

func (*ExportService) Name

func (this *ExportService) Name(name string) *ExportService

Name sets the name for the export group

func (*ExportService) Project

func (this *ExportService) Project(project string) *ExportService

func (*ExportService) Query

func (this *ExportService) Query() (*Export, error)

func (*ExportService) Search

func (this *ExportService) Search(query string) (*Export, error)

func (*ExportService) Type

func (this *ExportService) Type(t ExportType) *ExportService

func (*ExportService) Volumes

func (this *ExportService) Volumes(vols ...string) *ExportService

type ExportType

type ExportType string

ExportType is a string value of the export type

type ExportVolume

type ExportVolume struct {
	ResourceId `json:",inline"`
	Lun        int `json:"lun,omitempty"`
}

type Group

type Group struct {
	StorageObject `json:",inline"`
}

type GroupService

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

func (*GroupService) Id

func (this *GroupService) Id(id string) *GroupService

func (*GroupService) Name

func (this *GroupService) Name(name string) *GroupService

func (*GroupService) Query

func (this *GroupService) Query() (*Group, error)

func (*GroupService) Search

func (this *GroupService) Search(query string) (*Group, error)

type Host

type Host struct {
	StorageObject      `json:",inline"`
	Type               HostType `json:"type"`
	OSVersion          string   `json:"os_version,omitempty"`
	HostName           string   `json:"host_name"`
	Port               int      `json:"port_number,omitempty"`
	Username           string   `json:"user_name,omitempty"`
	SSL                bool     `json:"use_ssl,omitempty"`
	Discoverable       bool     `json:"discoverable"`
	RegistrationStatus string   `json:"registration_status"`
	Tenant             Resource `json:"tenant"`
	Cluster            Resource `json:"cluster,omitempty"`
}

Host represents a physical host resource

type HostService

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

HostService provides host creation and querying

func (*HostService) Create

func (this *HostService) Create(host string) (*Host, error)

Create creates a new host with the name and host

func (*HostService) Discover

func (this *HostService) Discover(host, username, password string, port int, ssl bool) (*Host, error)

Discover creates and attempts to discover a new host

func (*HostService) Id

func (this *HostService) Id(id string) *HostService

Id sets the id for the host query

func (*HostService) Initiators

func (this *HostService) Initiators() ([]Initiator, error)

Initiators returns a slice of Initiator objects for the host

func (*HostService) Name

func (this *HostService) Name(name string) *HostService

Name sets the name for the host creation or query

func (*HostService) OSVersion

func (this *HostService) OSVersion(v string) *HostService

OSVersion sets the os version string for the creation

func (*HostService) Query

func (this *HostService) Query() (*Host, error)

Query locates a Host record by id or name

func (*HostService) Search

func (this *HostService) Search(query string) (*Host, error)

Search performs a search for the host using the query string

func (*HostService) Tenant

func (this *HostService) Tenant(id string) *HostService

Tenant sets the tenant id for the creation

func (*HostService) Type

func (this *HostService) Type(t HostType) *HostService

Type sets the HostType for the creation

type HostType

type HostType string

HostType is a string type for the host

const (
	HostTypeLinux   HostType = "Linux"
	HostTypeWindows HostType = "Windows"
	HostTypeHPUX    HostType = "HPUX"
	HostTypeEsx     HostType = "Esx"
	HostTypeOther   HostType = "Other"
)

type Initiator

type Initiator struct {
	StorageObject `json:",inline"`
	Host          Resource      `json:"host"`
	Protocol      InitiatorType `json:"protocol"`
	Status        string        `json:"registration_status"`
	Hostname      string        `json:"hostname"`
	Node          string        `json:"initiator_node"`
	Port          string        `json:"initiator_port"`
}

type InitiatorService

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

func (*InitiatorService) Id

func (*InitiatorService) Port

func (this *InitiatorService) Port(port string) *InitiatorService

func (*InitiatorService) Query

func (this *InitiatorService) Query() (*Initiator, error)

func (*InitiatorService) Search

func (this *InitiatorService) Search(query string) (*Initiator, error)

type InitiatorType

type InitiatorType string
const (
	InitiatorTypeISCSI   InitiatorType = "iSCSI"
	InitiatorTypeFC      InitiatorType = "FC"
	InitiatorTypeScaleIO               = "ScaleIO"
)

type NamedResource

type NamedResource struct {
	Resource `json:",inline"`
	Name     string `json:"name"`
}

NameResource is a resource with a name

type Project

type Project struct {
	StorageObject `json:",inline"`
}

Project represents a storage project object

type ProjectService

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

ProjectService provides an interface for querying projects

func (*ProjectService) Id

func (this *ProjectService) Id(id string) *ProjectService

Id sets the id urn for the query

func (*ProjectService) Name

func (this *ProjectService) Name(name string) *ProjectService

Name sets the name for the query

func (*ProjectService) Query

func (this *ProjectService) Query() (*Project, error)

Query locates a Project by id or name

func (*ProjectService) Search

func (this *ProjectService) Search(query string) (*Project, error)

Search locates a project using the specified query

type Resource

type Resource struct {
	ResourceId `json:",inline"`
	Link       ResourceLink `json:"link,omitempty"`
}

Resource is a resource id with a link

type ResourceId

type ResourceId struct {
	Id string `json:"id"`
}

ResourceId contains an id string urn for a resource

type ResourceLink struct {
	Rel  string `json:"rel,omitempty"`
	Href string `json:"href,omitempty"`
}

ResourceLink represents the uri for a urn

type SearchResult

type SearchResult struct {
	Resources []Resource `json:"resource"`
}

type StorageObject

type StorageObject struct {
	NamedResource `json:",inline"`
	Inactive      bool     `json:"inactive"`
	Global        bool     `json:"global"`
	Remote        bool     `json:"remote"`
	Vdc           Resource `json:"vdc"`
	Tags          []string `json:"tags"`
	Internal      bool     `json:"internal"`
	Project       Resource `json:"project,omitempty"`
	Tenant        Resource `json:"tenant,omitempty"`
	CreationTime  int64    `json:"creation_time"`
	VArray        Resource `json:"varray,omitempty"`
	Owner         string   `json:"owner,omitempty"`
	Type          string   `json:"type,omitempty"`
}

StorageObject is the base object structure for the storageos platform

type Task

type Task struct {
	Name        string        `json:"name"`
	Id          string        `json:"id"`
	State       TaskState     `json:"state"`
	Message     string        `json:"message"`
	Description string        `json:"description"`
	Progress    int           `json:"progress"`
	Resource    NamedResource `json:"resource"`
	Workflow    Resource      `json:"workflow"`
}

type TaskService

type TaskService struct {
	*Client
}

func (*TaskService) Query

func (this *TaskService) Query(id string) (Task, error)

Query returns the task object

func (*TaskService) WaitDone

func (this *TaskService) WaitDone(id string, state TaskState, to time.Duration) error

WaitDone does a busy poll to wait for a task to reach the specified state with the timeout

type TaskState

type TaskState string
const (
	TaskPollDelay              = time.Millisecond * 250
	TaskStatePending TaskState = "pending"
	TaskStateError   TaskState = "error"
	TaskStateReady   TaskState = "ready"
)

type VArray

type VArray struct {
	StorageObject  `json:",inline"`
	BlockSettings  VArrayBlockSettings  `json:"block_settings"`
	ObjectSettings VArrayObjectSettings `json:"object_settings"`
	AutoSanZoning  bool                 `json:"auto_san_zoning"`
}

type VArrayBlockSettings

type VArrayBlockSettings struct {
	AutoSanZoning bool `json:"auto_san_zoning"`
}

type VArrayObjectSettings

type VArrayObjectSettings struct {
	DeviceRegistered bool   `json:"device_registered"`
	ProtectionType   string `json:"protection_type"`
}

type VArrayService

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

func (*VArrayService) Id

func (this *VArrayService) Id(id string) *VArrayService

func (*VArrayService) Name

func (this *VArrayService) Name(name string) *VArrayService

func (*VArrayService) Query

func (this *VArrayService) Query() (*VArray, error)

func (*VArrayService) Search

func (this *VArrayService) Search(query string) (*VArray, error)

type VPool

type VPool struct {
	StorageObject `json:",inline"`
	Protocols     []InitiatorType `json:"protocols"`
}

func (*VPool) HasProtocol

func (this *VPool) HasProtocol(p InitiatorType) bool

func (*VPool) IsBlock

func (this *VPool) IsBlock() bool

type VPoolService

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

func (*VPoolService) Id

func (this *VPoolService) Id(id string) *VPoolService

func (*VPoolService) Name

func (this *VPoolService) Name(name string) *VPoolService

func (*VPoolService) Query

func (this *VPoolService) Query() (*VPool, error)

func (*VPoolService) Search

func (this *VPoolService) Search(query string) (*VPool, error)

type Volume

type Volume struct {
	StorageObject       `json:",inline"`
	WWN                 string      `json:"wwn"`
	Protocols           []string    `json:"protocols"`
	Protection          interface{} `json:"protection"`
	ConsistencyGroup    string      `json:"consistency_group,omitempty"`
	StorageController   string      `json:"storage_controller"`
	DeviceLabel         string      `json:"device_label"`
	NativeId            string      `json:"native_id"`
	ProvisionedCapacity string      `json:"provisioned_capacity_gb"`
	AllocatedCapacity   string      `json:"allocated_capacity_gb"`
	RequestedCapacity   string      `json:"requested_capacity_gb"`
	PreAllocationSize   string      `json:"pre_allocation_size_gb"`
	IsComposite         bool        `json:"is_composite"`
	ThinlyProvisioned   bool        `json:"thinly_provisioned"`
	HABackingVolumes    []string    `json:"high_availability_backing_volumes"`
	AccessState         string      `json:"access_state"`
	StoragePool         Resource    `json:"storage_pool"`
}

Volume is a complete coprhd volume object

func (Volume) UUID

func (v Volume) UUID() string

type VolumeService

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

VolumeService is used to create, search, and query for volumes

func (*VolumeService) Array

func (this *VolumeService) Array(array string) *VolumeService

Array sets the varray urn for the VolumeService instance

func (*VolumeService) Create

func (this *VolumeService) Create(size uint64) (*Volume, error)

Create creates a new volume with the specified name and size using the volume service

func (*VolumeService) Delete

func (this *VolumeService) Delete(force bool) error

Delete deactivates the volume using the volume service

func (*VolumeService) Group

func (this *VolumeService) Group(group string) *VolumeService

Group sets the consistency group urn for the VolumeService instance

func (*VolumeService) Id

func (this *VolumeService) Id(id string) *VolumeService

Id sets the volume id urn for the VolumeService instance

func (*VolumeService) List

func (this *VolumeService) List() ([]string, error)

func (*VolumeService) Name

func (this *VolumeService) Name(name string) *VolumeService

Name sets the volume name for the VolumeService instance

func (*VolumeService) Pool

func (this *VolumeService) Pool(pool string) *VolumeService

Pool sets the vpool urn for the VolumeService instance

func (*VolumeService) Project

func (this *VolumeService) Project(project string) *VolumeService

Project sets the project urn for the VolumeService instance

func (*VolumeService) Query

func (this *VolumeService) Query() (*Volume, error)

Query returns the volume object using the specified id

func (*VolumeService) Search

func (this *VolumeService) Search(query string) (*Volume, error)

Search searches for a volume using the specified query string For example:

Search("name=foo")

func (*VolumeService) WWN

func (this *VolumeService) WWN(wwn string) *VolumeService

type Workflow

type Workflow struct {
	StorageObject `json:",inline"`
	Completed     bool          `json:"completed"`
	State         WorkflowState `json:"completion_state"`
	Message       string        `json:"completion_message"`
}

type WorkflowService

type WorkflowService struct {
	*Client
}

func (*WorkflowService) Query

func (this *WorkflowService) Query(id string) (Workflow, error)

Query returns the task object

func (*WorkflowService) WaitDone

func (this *WorkflowService) WaitDone(id string, state WorkflowState, to time.Duration) error

WaitDone does a busy poll to wait for a task to reach the specified state with the timeout

type WorkflowState

type WorkflowState string
const (
	WorkflowPollDelay                  = time.Millisecond * 250
	WorkflowStateError   WorkflowState = "ERROR"
	WorkflowStateSuccess WorkflowState = "SUCCESS"
)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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