volumes

package
v2.0.0-beta.4 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: Apache-2.0 Imports: 6 Imported by: 2

Documentation

Overview

Package volumes 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. It can only be attached to one instance at a time.

Example of creating Volume B on a Different Host than Volume A

schedulerHints := volumes.SchedulerHints{
	DifferentHost: []string{
		"volume-a-uuid",
	}
}

createOpts := volumes.CreateOpts{
	Name:           "volume_b",
	Size:           10,
	SchedulerHints: schedulerHints,
}

volume, err := volumes.Create(context.TODO(), computeClient, createOpts).Extract()
if err != nil {
	panic(err)
}

Example of creating Volume B on the Same Host as Volume A

schedulerHints := volumes.SchedulerHints{
	SameHost: []string{
		"volume-a-uuid",
	}
}

createOpts := volumes.CreateOpts{
	Name:              "volume_b",
	Size:              10
	SchedulerHints:    schedulerHints,
}

volume, err := volumes.Create(context.TODO(), computeClient, createOpts).Extract()
if err != nil {
	panic(err)
}

Example of creating a Volume from a Backup

backupID := "20c792f0-bb03-434f-b653-06ef238e337e"
options := volumes.CreateOpts{
	Name:     "vol-001",
	BackupID: &backupID,
}

client.Microversion = "3.47"
volume, err := volumes.Create(context.TODO(), client, options).Extract()
if err != nil {
	panic(err)
}

fmt.Println(volume)

Example of Creating an Image from a Volume

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

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

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

Example of Extending a Volume's Size

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

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

Example of Initializing a Volume Connection

connectOpts := &volumes.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 := volumes.InitializeConnection(context.TODO(), client, volume.ID, connectOpts).Extract()
if err != nil {
	panic(err)
}

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

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

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

Example of Setting a Volume's Bootable status

options := volumes.BootableOpts{
	Bootable: true,
}

err := volumes.SetBootable(context.TODO(), client, volume.ID, options).ExtractErr()
if err != nil {
	panic(err)
}

Example of Changing Type of a Volume

changeTypeOpts := volumes.ChangeTypeOpts{
	NewType:         "ssd",
	MigrationPolicy: volumes.MigrationPolicyOnDemand,
}

err = volumes.ChangeType(context.TODO(), client, volumeID, changeTypeOpts).ExtractErr()
if err != nil {
	panic(err)
}

Example of Attaching a Volume to an Instance

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

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

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

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractVolumesInto

func ExtractVolumesInto(r pagination.Page, v interface{}) error

ExtractVolumesInto similar to ExtractInto but operates on a `list` of volumes

func List

func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager

List returns Volumes optionally limited by the conditions provided in ListOpts.

func WaitForStatus

func WaitForStatus(ctx context.Context, c *gophercloud.ServiceClient, id, status string) error

WaitForStatus will continually poll the resource, checking for a particular status.

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(ctx context.Context, client *gophercloud.ServiceClient, id string, opts AttachOptsBuilder) (r AttachResult)

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

type Attachment

type Attachment struct {
	AttachedAt   time.Time `json:"-"`
	AttachmentID string    `json:"attachment_id"`
	Device       string    `json:"device"`
	HostName     string    `json:"host_name"`
	ID           string    `json:"id"`
	ServerID     string    `json:"server_id"`
	VolumeID     string    `json:"volume_id"`
}

Attachment represents a Volume Attachment record

func (*Attachment) UnmarshalJSON

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

UnmarshalJSON is our unmarshalling helper

type BeginDetachingResult

type BeginDetachingResult struct {
	gophercloud.ErrResult
}

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

func BeginDetaching

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

BeginDetaching will mark the volume as detaching.

type BootableOpts

type BootableOpts struct {
	// Enables or disables the bootable attribute. You can boot an instance from a bootable volume.
	Bootable bool `json:"bootable"`
}

BootableOpts contains options for setting bootable status to a volume.

func (BootableOpts) ToBootableMap

func (opts BootableOpts) ToBootableMap() (map[string]interface{}, error)

ToBootableMap assembles a request body based on the contents of a BootableOpts.

type ChangeTypeOpts

type ChangeTypeOpts struct {
	// NewType is the name of the new volume type of the volume.
	NewType string `json:"new_type" required:"true"`

	// MigrationPolicy specifies if the volume should be migrated when it is
	// re-typed. Possible values are "on-demand" or "never". If not specified,
	// the default is "never".
	MigrationPolicy MigrationPolicy `json:"migration_policy,omitempty"`
}

ChangeTypeOpts contains options for changing the type of an existing Volume. This object is passed to the volumes.ChangeType function.

func (ChangeTypeOpts) ToVolumeChangeTypeMap

func (opts ChangeTypeOpts) ToVolumeChangeTypeMap() (map[string]interface{}, error)

ToVolumeChangeTypeMap assembles a request body based on the contents of an ChangeTypeOpts.

type ChangeTypeOptsBuilder

type ChangeTypeOptsBuilder interface {
	ToVolumeChangeTypeMap() (map[string]interface{}, error)
}

ChangeTypeOptsBuilder allows extensions to add additional parameters to the ChangeType request.

type ChangeTypeResult

type ChangeTypeResult struct {
	gophercloud.ErrResult
}

ChangeTypeResult contains the response body and error from an ChangeType request.

func ChangeType

func ChangeType(ctx context.Context, client *gophercloud.ServiceClient, id string, opts ChangeTypeOptsBuilder) (r ChangeTypeResult)

ChangeType will change the volume type of the volume based on the provided information. This operation does not return a response body.

type CreateOpts

type CreateOpts struct {
	// The size of the volume, in GB
	Size int `json:"size,omitempty"`
	// The availability zone
	AvailabilityZone string `json:"availability_zone,omitempty"`
	// ConsistencyGroupID is the ID of a consistency group
	ConsistencyGroupID string `json:"consistencygroup_id,omitempty"`
	// The volume description
	Description string `json:"description,omitempty"`
	// One or more metadata key and value pairs to associate with the volume
	Metadata map[string]string `json:"metadata,omitempty"`
	// The volume name
	Name string `json:"name,omitempty"`
	// the ID of the existing volume snapshot
	SnapshotID string `json:"snapshot_id,omitempty"`
	// SourceReplica is a UUID of an existing volume to replicate with
	SourceReplica string `json:"source_replica,omitempty"`
	// the ID of the existing volume
	SourceVolID string `json:"source_volid,omitempty"`
	// The ID of the image from which you want to create the volume.
	// Required to create a bootable volume.
	ImageID string `json:"imageRef,omitempty"`
	// Specifies the backup ID, from which you want to create the volume.
	// Create a volume from a backup is supported since 3.47 microversion
	BackupID string `json:"backup_id,omitempty"`
	// The associated volume type
	VolumeType string `json:"volume_type,omitempty"`
	// SchedulerHints provides a set of hints to the scheduler.
	SchedulerHints SchedulerHintsCreateOptsBuilder
}

CreateOpts contains options for creating a Volume. This object is passed to the volumes.Create function. For more information about these parameters, see the Volume object.

func (CreateOpts) ToVolumeCreateMap

func (opts CreateOpts) ToVolumeCreateMap() (map[string]interface{}, error)

ToVolumeCreateMap assembles a request body based on the contents of a CreateOpts.

type CreateOptsBuilder

type CreateOptsBuilder interface {
	ToVolumeCreateMap() (map[string]interface{}, error)
}

CreateOptsBuilder allows extensions to add additional parameters to the Create request.

type CreateResult

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

CreateResult contains the response body and error from a Create request.

func Create

func Create(ctx context.Context, client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult)

Create will create a new Volume based on the values in CreateOpts. To extract the Volume object from the response, call the Extract method on the CreateResult.

func (CreateResult) Extract

func (r CreateResult) Extract() (*Volume, error)

Extract will get the Volume object out of the commonResult object.

func (CreateResult) ExtractInto

func (r CreateResult) ExtractInto(v interface{}) error

ExtractInto converts our response data into a volume struct

type DeleteOpts

type DeleteOpts struct {
	// Delete all snapshots of this volume as well.
	Cascade bool `q:"cascade"`
}

DeleteOpts contains options for deleting a Volume. This object is passed to the volumes.Delete function.

func (DeleteOpts) ToVolumeDeleteQuery

func (opts DeleteOpts) ToVolumeDeleteQuery() (string, error)

ToLoadBalancerDeleteQuery formats a DeleteOpts into a query string.

type DeleteOptsBuilder

type DeleteOptsBuilder interface {
	ToVolumeDeleteQuery() (string, error)
}

DeleteOptsBuilder allows extensions to add additional parameters to the Delete request.

type DeleteResult

type DeleteResult struct {
	gophercloud.ErrResult
}

DeleteResult contains the response body and error from a Delete request.

func Delete

func Delete(ctx context.Context, client *gophercloud.ServiceClient, id string, opts DeleteOptsBuilder) (r DeleteResult)

Delete will delete the existing Volume with the provided ID.

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(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, client *gophercloud.ServiceClient, id string) (r ForceDeleteResult)

ForceDelete will delete the volume regardless of state.

type GetResult

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

GetResult contains the response body and error from a Get request.

func Get

func Get(ctx context.Context, client *gophercloud.ServiceClient, id string) (r GetResult)

Get retrieves the Volume with the provided ID. To extract the Volume object from the response, call the Extract method on the GetResult.

func (GetResult) Extract

func (r GetResult) Extract() (*Volume, error)

Extract will get the Volume object out of the commonResult object.

func (GetResult) ExtractInto

func (r GetResult) ExtractInto(v interface{}) error

ExtractInto converts our response data into a volume struct

type ImageMetadataOpts

type ImageMetadataOpts struct {
	// The image metadata to add to the volume as a set of metadata key and value pairs.
	Metadata map[string]string `json:"metadata"`
}

ImageMetadataOpts contains options for setting image metadata to a volume.

func (ImageMetadataOpts) ToImageMetadataMap

func (opts ImageMetadataOpts) ToImageMetadataMap() (map[string]interface{}, error)

ToImageMetadataMap assembles a request body based on the contents of a ImageMetadataOpts.

type ImageMetadataOptsBuilder

type ImageMetadataOptsBuilder interface {
	ToImageMetadataMap() (map[string]interface{}, error)
}

ImageMetadataOptsBuilder allows extensions to add additional parameters to the ImageMetadataRequest request.

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(ctx context.Context, 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 ListOpts

type ListOpts struct {
	// AllTenants will retrieve volumes of all tenants/projects.
	AllTenants bool `q:"all_tenants"`

	// Metadata will filter results based on specified metadata.
	Metadata map[string]string `q:"metadata"`

	// Name will filter by the specified volume name.
	Name string `q:"name"`

	// Status will filter by the specified status.
	Status string `q:"status"`

	// TenantID will filter by a specific tenant/project ID.
	// Setting AllTenants is required for this.
	TenantID string `q:"project_id"`

	// Comma-separated list of sort keys and optional sort directions in the
	// form of <key>[:<direction>].
	Sort string `q:"sort"`

	// Requests a page size of items.
	Limit int `q:"limit"`

	// Used in conjunction with limit to return a slice of items.
	Offset int `q:"offset"`

	// The ID of the last-seen item.
	Marker string `q:"marker"`

	// Bootable will filter results based on whether they are bootable volumes
	Bootable *bool `q:"bootable,omitempty"`
}

ListOpts holds options for listing Volumes. It is passed to the volumes.List function.

func (ListOpts) ToVolumeListQuery

func (opts ListOpts) ToVolumeListQuery() (string, error)

ToVolumeListQuery formats a ListOpts into a query string.

type ListOptsBuilder

type ListOptsBuilder interface {
	ToVolumeListQuery() (string, error)
}

ListOptsBuilder allows extensions to add additional parameters to the List request.

type MigrationPolicy

type MigrationPolicy string

MigrationPolicy type represents a migration_policy when changing types.

const (
	MigrationPolicyNever    MigrationPolicy = "never"
	MigrationPolicyOnDemand MigrationPolicy = "on-demand"
)

Supported attributes for MigrationPolicy attribute for changeType operations.

type ReImageOpts

type ReImageOpts struct {
	// New image id
	ImageID string `json:"image_id"`
	// set true to re-image volumes in reserved state
	ReImageReserved bool `json:"reimage_reserved"`
}

ReImageOpts contains options for Re-image a volume.

func (ReImageOpts) ToReImageMap

func (opts ReImageOpts) ToReImageMap() (map[string]interface{}, error)

ToReImageMap assembles a request body based on the contents of a ReImageOpts.

type ReImageResult

type ReImageResult struct {
	gophercloud.ErrResult
}

ReImageResult contains the response body and error from a ReImage request.

func ReImage

func ReImage(ctx context.Context, client *gophercloud.ServiceClient, id string, opts ReImageOpts) (r ReImageResult)

ReImage will re-image a volume based on the values in ReImageOpts

type ReserveResult

type ReserveResult struct {
	gophercloud.ErrResult
}

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

func Reserve

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

Reserve will reserve a volume based on volume ID.

type ResetStatusOpts

type ResetStatusOpts struct {
	// Status is a volume status to reset to.
	Status string `json:"status"`
	// MigrationStatus is a volume migration status to reset to.
	MigrationStatus string `json:"migration_status,omitempty"`
	// AttachStatus is a volume attach status to reset to.
	AttachStatus string `json:"attach_status,omitempty"`
}

ResetStatusOpts contains options for resetting a Volume status. For more information about these parameters, please, refer to the Block Storage API V3, Volume Actions, ResetStatus volume documentation.

func (ResetStatusOpts) ToResetStatusMap

func (opts ResetStatusOpts) ToResetStatusMap() (map[string]interface{}, error)

ToResetStatusMap assembles a request body based on the contents of a ResetStatusOpts.

type ResetStatusOptsBuilder

type ResetStatusOptsBuilder interface {
	ToResetStatusMap() (map[string]interface{}, error)
}

ResetStatusOptsBuilder allows extensions to add additional parameters to the ResetStatus request.

type ResetStatusResult

type ResetStatusResult struct {
	gophercloud.ErrResult
}

ResetStatusResult contains the response error from a ResetStatus request.

func ResetStatus

func ResetStatus(ctx context.Context, client *gophercloud.ServiceClient, id string, opts ResetStatusOptsBuilder) (r ResetStatusResult)

ResetStatus will reset the existing volume status. ResetStatusResult contains only the error. To extract it, call the ExtractErr method on the ResetStatusResult.

type SchedulerHints

type SchedulerHints struct {
	// DifferentHost will place the volume on a different back-end that does not
	// host the given volumes.
	DifferentHost []string

	// SameHost will place the volume on a back-end that hosts the given volumes.
	SameHost []string

	// LocalToInstance will place volume on same host on a given instance
	LocalToInstance string

	// Query is a conditional statement that results in back-ends able to
	// host the volume.
	Query string

	// AdditionalProperies are arbitrary key/values that are not validated by nova.
	AdditionalProperties map[string]interface{}
}

SchedulerHints represents a set of scheduling hints that are passed to the OpenStack scheduler.

func (SchedulerHints) ToVolumeSchedulerHintsCreateMap

func (opts SchedulerHints) ToVolumeSchedulerHintsCreateMap() (map[string]interface{}, error)

ToVolumeSchedulerHintsCreateMap assembles a request body for the scheduler

type SchedulerHintsCreateOptsBuilder

type SchedulerHintsCreateOptsBuilder interface {
	ToVolumeSchedulerHintsCreateMap() (map[string]interface{}, error)
}

CreateOptsBuilder builds the scheduler hints into a serializable format.

type SetBootableResult

type SetBootableResult struct {
	gophercloud.ErrResult
}

SetBootableResult contains the response body and error from a SetBootable request.

func SetBootable

func SetBootable(ctx context.Context, client *gophercloud.ServiceClient, id string, opts BootableOpts) (r SetBootableResult)

SetBootable will set bootable status on a volume based on the values in BootableOpts

type SetImageMetadataResult

type SetImageMetadataResult struct {
	gophercloud.ErrResult
}

SetImageMetadataResult contains the response body and error from an SetImageMetadata request.

func SetImageMetadata

func SetImageMetadata(ctx context.Context, client *gophercloud.ServiceClient, id string, opts ImageMetadataOptsBuilder) (r SetImageMetadataResult)

SetImageMetadata will set image metadata on a volume based on the values in ImageMetadataOptsBuilder.

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(ctx context.Context, 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(ctx context.Context, client *gophercloud.ServiceClient, id string) (r UnreserveResult)

Unreserve will unreserve a volume based on volume ID.

type UpdateOpts

type UpdateOpts struct {
	Name        *string           `json:"name,omitempty"`
	Description *string           `json:"description,omitempty"`
	Metadata    map[string]string `json:"metadata,omitempty"`
}

UpdateOpts contain options for updating an existing Volume. This object is passed to the volumes.Update function. For more information about the parameters, see the Volume object.

func (UpdateOpts) ToVolumeUpdateMap

func (opts UpdateOpts) ToVolumeUpdateMap() (map[string]interface{}, error)

ToVolumeUpdateMap assembles a request body based on the contents of an UpdateOpts.

type UpdateOptsBuilder

type UpdateOptsBuilder interface {
	ToVolumeUpdateMap() (map[string]interface{}, error)
}

UpdateOptsBuilder allows extensions to add additional parameters to the Update request.

type UpdateResult

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

UpdateResult contains the response body and error from an Update request.

func Update

func Update(ctx context.Context, client *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult)

Update will update the Volume with provided information. To extract the updated Volume from the response, call the Extract method on the UpdateResult.

func (UpdateResult) Extract

func (r UpdateResult) Extract() (*Volume, error)

Extract will get the Volume object out of the commonResult object.

func (UpdateResult) ExtractInto

func (r UpdateResult) ExtractInto(v interface{}) error

ExtractInto converts our response data into a volume struct

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"`

	// Visibility defines who can see/use the image.
	// supported since 3.1 microversion
	Visibility string `json:"visibility,omitempty"`

	// whether the image is not deletable.
	// supported since 3.1 microversion
	Protected bool `json:"protected,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(ctx context.Context, 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 Volume

type Volume struct {
	// Unique identifier for the volume.
	ID string `json:"id"`
	// Current status of the volume.
	Status string `json:"status"`
	// Size of the volume in GB.
	Size int `json:"size"`
	// AvailabilityZone is which availability zone the volume is in.
	AvailabilityZone string `json:"availability_zone"`
	// The date when this volume was created.
	CreatedAt time.Time `json:"-"`
	// The date when this volume was last updated
	UpdatedAt time.Time `json:"-"`
	// Instances onto which the volume is attached.
	Attachments []Attachment `json:"attachments"`
	// Human-readable display name for the volume.
	Name string `json:"name"`
	// Human-readable description for the volume.
	Description string `json:"description"`
	// The type of volume to create, either SATA or SSD.
	VolumeType string `json:"volume_type"`
	// The ID of the snapshot from which the volume was created
	SnapshotID string `json:"snapshot_id"`
	// The ID of another block storage volume from which the current volume was created
	SourceVolID string `json:"source_volid"`
	// The backup ID, from which the volume was restored
	// This field is supported since 3.47 microversion
	BackupID *string `json:"backup_id"`
	// Arbitrary key-value pairs defined by the user.
	Metadata map[string]string `json:"metadata"`
	// UserID is the id of the user who created the volume.
	UserID string `json:"user_id"`
	// Indicates whether this is a bootable volume.
	Bootable string `json:"bootable"`
	// Encrypted denotes if the volume is encrypted.
	Encrypted bool `json:"encrypted"`
	// ReplicationStatus is the status of replication.
	ReplicationStatus string `json:"replication_status"`
	// ConsistencyGroupID is the consistency group ID.
	ConsistencyGroupID string `json:"consistencygroup_id"`
	// Multiattach denotes if the volume is multi-attach capable.
	Multiattach bool `json:"multiattach"`
	// Image metadata entries, only included for volumes that were created from an image, or from a snapshot of a volume originally created from an image.
	VolumeImageMetadata map[string]string `json:"volume_image_metadata"`
	// Host is the identifier of the host holding the volume.
	Host string `json:"os-vol-host-attr:host"`
	// TenantID is the id of the project that owns the volume.
	TenantID string `json:"os-vol-tenant-attr:tenant_id"`
}

Volume contains all the information associated with an OpenStack Volume.

func ExtractVolumes

func ExtractVolumes(r pagination.Page) ([]Volume, error)

ExtractVolumes extracts and returns Volumes. It is used while iterating over a volumes.List call.

func (*Volume) UnmarshalJSON

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

UnmarshalJSON another unmarshalling function

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"`

	// Visibility defines who can see/use the image.
	// supported since 3.1 microversion
	Visibility string `json:"visibility"`

	// whether the image is not deletable.
	// supported since 3.1 microversion
	Protected bool `json:"protected"`

	// 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

type VolumePage

type VolumePage struct {
	pagination.LinkedPageBase
}

VolumePage is a pagination.pager that is returned from a call to the List function.

func (VolumePage) IsEmpty

func (r VolumePage) IsEmpty() (bool, error)

IsEmpty returns true if a ListResult contains no Volumes.

func (VolumePage) NextPageURL

func (page VolumePage) NextPageURL() (string, error)

Directories

Path Synopsis
volumes unit tests
volumes unit tests

Jump to

Keyboard shortcuts

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