volumeactions

package
v1.0.19 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2019 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Overview

Package volumeactions provides information and interaction with volumes in the OpenStack Block Storage service. A volume is a detachable block storage device, akin to a USB hard drive.

Example of Attaching a Volume to an Instance

attachOpts := volumeactions.AttachOpts{
	MountPoint:   "/mnt",
	Mode:         "rw",
	InstanceUUID: server.ID,
}

err := volumeactions.Attach(client, volume.ID, attachOpts).ExtractErr()
if err != nil {
	panic(err)
}

detachOpts := volumeactions.DetachOpts{
	AttachmentID: volume.Attachments[0].AttachmentID,
}

err = volumeactions.Detach(client, volume.ID, detachOpts).ExtractErr()
if err != nil {
	panic(err)
}

Example of Creating an Image from a Volume

uploadImageOpts := volumeactions.UploadImageOpts{
	ImageName: "my_vol",
	Force:     true,
}

volumeImage, err := volumeactions.UploadImage(client, volume.ID, uploadImageOpts).Extract()
if err != nil {
	panic(err)
}

fmt.Printf("%+v\n", volumeImage)

Example of Extending a Volume's Size

extendOpts := volumeactions.ExtendSizeOpts{
	NewSize: 100,
}

err := volumeactions.ExtendSize(client, volume.ID, extendOpts).ExtractErr()
if err != nil {
	panic(err)
}

Example of Initializing a Volume Connection

connectOpts := &volumeactions.InitializeConnectionOpts{
	IP:        "127.0.0.1",
	Host:      "stack",
	Initiator: "iqn.1994-05.com.redhat:17cf566367d2",
	Multipath: gophercloud.Disabled,
	Platform:  "x86_64",
	OSType:    "linux2",
}

connectionInfo, err := volumeactions.InitializeConnection(client, volume.ID, connectOpts).Extract()
if err != nil {
	panic(err)
}

fmt.Printf("%+v\n", connectionInfo["data"])

terminateOpts := &volumeactions.InitializeConnectionOpts{
	IP:        "127.0.0.1",
	Host:      "stack",
	Initiator: "iqn.1994-05.com.redhat:17cf566367d2",
	Multipath: gophercloud.Disabled,
	Platform:  "x86_64",
	OSType:    "linux2",
}

err = volumeactions.TerminateConnection(client, volume.ID, terminateOpts).ExtractErr()
if err != nil {
	panic(err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AttachMode

type AttachMode string

AttachMode describes the attachment mode for volumes.

const (
	ReadOnly  AttachMode = "ro"
	ReadWrite AttachMode = "rw"
)

These constants determine how a volume is attached.

type AttachOpts

type AttachOpts struct {
	// The mountpoint of this volume.
	MountPoint string `json:"mountpoint,omitempty"`

	// The nova instance ID, can't set simultaneously with HostName.
	InstanceUUID string `json:"instance_uuid,omitempty"`

	// The hostname of baremetal host, can't set simultaneously with InstanceUUID.
	HostName string `json:"host_name,omitempty"`

	// Mount mode of this volume.
	Mode AttachMode `json:"mode,omitempty"`
}

AttachOpts contains options for attaching a Volume.

func (AttachOpts) ToVolumeAttachMap

func (opts AttachOpts) ToVolumeAttachMap() (map[string]interface{}, error)

ToVolumeAttachMap assembles a request body based on the contents of a AttachOpts.

type AttachOptsBuilder

type AttachOptsBuilder interface {
	ToVolumeAttachMap() (map[string]interface{}, error)
}

AttachOptsBuilder allows extensions to add additional parameters to the Attach request.

type AttachResult

type AttachResult struct {
	gophercloud.ErrResult
}

AttachResult contains the response body and error from an Attach request.

func Attach

func Attach(client *gophercloud.ServiceClient, id string, opts AttachOptsBuilder) (r AttachResult)

Attach will attach a volume based on the values in AttachOpts.

type BeginDetachingResult

type BeginDetachingResult struct {
	gophercloud.ErrResult
}

BeginDetachingResult contains the response body and error from a BeginDetach request.

func BeginDetaching

func BeginDetaching(client *gophercloud.ServiceClient, id string) (r BeginDetachingResult)

BeginDetach will mark the volume as detaching.

type DetachOpts

type DetachOpts struct {
	// AttachmentID is the ID of the attachment between a volume and instance.
	AttachmentID string `json:"attachment_id,omitempty"`
}

DetachOpts contains options for detaching a Volume.

func (DetachOpts) ToVolumeDetachMap

func (opts DetachOpts) ToVolumeDetachMap() (map[string]interface{}, error)

ToVolumeDetachMap assembles a request body based on the contents of a DetachOpts.

type DetachOptsBuilder

type DetachOptsBuilder interface {
	ToVolumeDetachMap() (map[string]interface{}, error)
}

DetachOptsBuilder allows extensions to add additional parameters to the Detach request.

type DetachResult

type DetachResult struct {
	gophercloud.ErrResult
}

DetachResult contains the response body and error from a Detach request.

func Detach

func Detach(client *gophercloud.ServiceClient, id string, opts DetachOptsBuilder) (r DetachResult)

Detach will detach a volume based on volume ID.

type ExtendSizeOpts

type ExtendSizeOpts struct {
	// NewSize is the new size of the volume, in GB.
	NewSize int `json:"new_size" required:"true"`
}

ExtendSizeOpts contains options for extending the size of an existing Volume. This object is passed to the volumes.ExtendSize function.

func (ExtendSizeOpts) ToVolumeExtendSizeMap

func (opts ExtendSizeOpts) ToVolumeExtendSizeMap() (map[string]interface{}, error)

ToVolumeExtendSizeMap assembles a request body based on the contents of an ExtendSizeOpts.

type ExtendSizeOptsBuilder

type ExtendSizeOptsBuilder interface {
	ToVolumeExtendSizeMap() (map[string]interface{}, error)
}

ExtendSizeOptsBuilder allows extensions to add additional parameters to the ExtendSize request.

type ExtendSizeResult

type ExtendSizeResult struct {
	gophercloud.ErrResult
}

ExtendSizeResult contains the response body and error from an ExtendSize request.

func ExtendSize

func ExtendSize(client *gophercloud.ServiceClient, id string, opts ExtendSizeOptsBuilder) (r ExtendSizeResult)

ExtendSize will extend the size of the volume based on the provided information. This operation does not return a response body.

type ForceDeleteResult

type ForceDeleteResult struct {
	gophercloud.ErrResult
}

ForceDeleteResult contains the response body and error from a ForceDelete request.

func ForceDelete

func ForceDelete(client *gophercloud.ServiceClient, id string) (r ForceDeleteResult)

ForceDelete will delete the volume regardless of state.

type ImageVolumeType

type ImageVolumeType struct {
	// The ID of a volume type.
	ID string `json:"id"`

	// Human-readable display name for the volume type.
	Name string `json:"name"`

	// Human-readable description for the volume type.
	Description string `json:"display_description"`

	// Flag for public access.
	IsPublic bool `json:"is_public"`

	// Extra specifications for volume type.
	ExtraSpecs map[string]interface{} `json:"extra_specs"`

	// ID of quality of service specs.
	QosSpecsID string `json:"qos_specs_id"`

	// Flag for deletion status of volume type.
	Deleted bool `json:"deleted"`

	// The date when volume type was deleted.
	DeletedAt time.Time `json:"-"`

	// The date when volume type was created.
	CreatedAt time.Time `json:"-"`

	// The date when this volume was last updated.
	UpdatedAt time.Time `json:"-"`
}

ImageVolumeType contains volume type information obtained from UploadImage action.

func (*ImageVolumeType) UnmarshalJSON

func (r *ImageVolumeType) UnmarshalJSON(b []byte) error

type InitializeConnectionOpts

type InitializeConnectionOpts struct {
	IP        string   `json:"ip,omitempty"`
	Host      string   `json:"host,omitempty"`
	Initiator string   `json:"initiator,omitempty"`
	Wwpns     []string `json:"wwpns,omitempty"`
	Wwnns     string   `json:"wwnns,omitempty"`
	Multipath *bool    `json:"multipath,omitempty"`
	Platform  string   `json:"platform,omitempty"`
	OSType    string   `json:"os_type,omitempty"`
}

InitializeConnectionOpts hosts options for InitializeConnection. The fields are specific to the storage driver in use and the destination attachment.

func (InitializeConnectionOpts) ToVolumeInitializeConnectionMap

func (opts InitializeConnectionOpts) ToVolumeInitializeConnectionMap() (map[string]interface{}, error)

ToVolumeInitializeConnectionMap assembles a request body based on the contents of a InitializeConnectionOpts.

type InitializeConnectionOptsBuilder

type InitializeConnectionOptsBuilder interface {
	ToVolumeInitializeConnectionMap() (map[string]interface{}, error)
}

InitializeConnectionOptsBuilder allows extensions to add additional parameters to the InitializeConnection request.

type InitializeConnectionResult

type InitializeConnectionResult struct {
	gophercloud.Result
}

InitializeConnectionResult contains the response body and error from an InitializeConnection request.

func InitializeConnection

func InitializeConnection(client *gophercloud.ServiceClient, id string, opts InitializeConnectionOptsBuilder) (r InitializeConnectionResult)

InitializeConnection initializes an iSCSI connection by volume ID.

func (InitializeConnectionResult) Extract

func (r InitializeConnectionResult) Extract() (map[string]interface{}, error)

Extract will get the connection information out of the InitializeConnectionResult object.

This will be a generic map[string]interface{} and the results will be dependent on the type of connection made.

type ReserveResult

type ReserveResult struct {
	gophercloud.ErrResult
}

ReserveResult contains the response body and error from a Reserve request.

func Reserve

func Reserve(client *gophercloud.ServiceClient, id string) (r ReserveResult)

Reserve will reserve a volume based on volume ID.

type TerminateConnectionOpts

type TerminateConnectionOpts struct {
	IP        string   `json:"ip,omitempty"`
	Host      string   `json:"host,omitempty"`
	Initiator string   `json:"initiator,omitempty"`
	Wwpns     []string `json:"wwpns,omitempty"`
	Wwnns     string   `json:"wwnns,omitempty"`
	Multipath *bool    `json:"multipath,omitempty"`
	Platform  string   `json:"platform,omitempty"`
	OSType    string   `json:"os_type,omitempty"`
}

TerminateConnectionOpts hosts options for TerminateConnection.

func (TerminateConnectionOpts) ToVolumeTerminateConnectionMap

func (opts TerminateConnectionOpts) ToVolumeTerminateConnectionMap() (map[string]interface{}, error)

ToVolumeTerminateConnectionMap assembles a request body based on the contents of a TerminateConnectionOpts.

type TerminateConnectionOptsBuilder

type TerminateConnectionOptsBuilder interface {
	ToVolumeTerminateConnectionMap() (map[string]interface{}, error)
}

TerminateConnectionOptsBuilder allows extensions to add additional parameters to the TerminateConnection request.

type TerminateConnectionResult

type TerminateConnectionResult struct {
	gophercloud.ErrResult
}

TerminateConnectionResult contains the response body and error from a TerminateConnection request.

func TerminateConnection

func TerminateConnection(client *gophercloud.ServiceClient, id string, opts TerminateConnectionOptsBuilder) (r TerminateConnectionResult)

TerminateConnection terminates an iSCSI connection by volume ID.

type UnreserveResult

type UnreserveResult struct {
	gophercloud.ErrResult
}

UnreserveResult contains the response body and error from an Unreserve request.

func Unreserve

func Unreserve(client *gophercloud.ServiceClient, id string) (r UnreserveResult)

Unreserve will unreserve a volume based on volume ID.

type UploadImageOpts

type UploadImageOpts struct {
	// Container format, may be bare, ofv, ova, etc.
	ContainerFormat string `json:"container_format,omitempty"`

	// Disk format, may be raw, qcow2, vhd, vdi, vmdk, etc.
	DiskFormat string `json:"disk_format,omitempty"`

	// The name of image that will be stored in glance.
	ImageName string `json:"image_name,omitempty"`

	// Force image creation, usable if volume attached to instance.
	Force bool `json:"force,omitempty"`
}

UploadImageOpts contains options for uploading a Volume to image storage.

func (UploadImageOpts) ToVolumeUploadImageMap

func (opts UploadImageOpts) ToVolumeUploadImageMap() (map[string]interface{}, error)

ToVolumeUploadImageMap assembles a request body based on the contents of a UploadImageOpts.

type UploadImageOptsBuilder

type UploadImageOptsBuilder interface {
	ToVolumeUploadImageMap() (map[string]interface{}, error)
}

UploadImageOptsBuilder allows extensions to add additional parameters to the UploadImage request.

type UploadImageResult

type UploadImageResult struct {
	gophercloud.Result
}

UploadImageResult contains the response body and error from an UploadImage request.

func UploadImage

func UploadImage(client *gophercloud.ServiceClient, id string, opts UploadImageOptsBuilder) (r UploadImageResult)

UploadImage will upload an image based on the values in UploadImageOptsBuilder.

func (UploadImageResult) Extract

func (r UploadImageResult) Extract() (VolumeImage, error)

Extract will get an object with info about the uploaded image out of the UploadImageResult object.

type VolumeImage

type VolumeImage struct {
	// The ID of a volume an image is created from.
	VolumeID string `json:"id"`

	// Container format, may be bare, ofv, ova, etc.
	ContainerFormat string `json:"container_format"`

	// Disk format, may be raw, qcow2, vhd, vdi, vmdk, etc.
	DiskFormat string `json:"disk_format"`

	// Human-readable description for the volume.
	Description string `json:"display_description"`

	// The ID of the created image.
	ImageID string `json:"image_id"`

	// Human-readable display name for the image.
	ImageName string `json:"image_name"`

	// Size of the volume in GB.
	Size int `json:"size"`

	// Current status of the volume.
	Status string `json:"status"`

	// The date when this volume was last updated.
	UpdatedAt time.Time `json:"-"`

	// Volume type object of used volume.
	VolumeType ImageVolumeType `json:"volume_type"`
}

VolumeImage contains information about volume uploaded to an image service.

func (*VolumeImage) UnmarshalJSON

func (r *VolumeImage) UnmarshalJSON(b []byte) error

Directories

Path Synopsis
volumeactions unit tests
volumeactions unit tests

Jump to

Keyboard shortcuts

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