Help us shape the future of Go! Take the 2026 Go Developer Survey

volumeattach

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package volumeattach provides the ability to attach and detach volumes from servers.

Example to Attach a Volume

serverID := "7ac8686c-de71-4acb-9600-ec18b1a1ed6d"
volumeID := "87463836-f0e2-4029-abf6-20c8892a3103"

createOpts := volumeattach.CreateOpts{
	Device:   "/dev/vdc",
	VolumeID: volumeID,
}

result, err := volumeattach.Create(computeClient, serverID, createOpts).Extract()
if err != nil {
	panic(err)
}

Example to Detach a Volume

serverID := "7ac8686c-de71-4acb-9600-ec18b1a1ed6d"
attachmentID := "ed081613-1c9b-4231-aa5e-ebfd4d87f983"

err := volumeattach.Delete(computeClient, serverID, attachmentID).ExtractErr()
if err != nil {
	panic(err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

func List(client *gophercloud.ServiceClient, serverID string) pagination.Pager

List returns a Pager that allows you to iterate over a collection of VolumeAttachments.

Types

type CreateOpts

type CreateOpts struct {
	// Device is the device that the volume will attach to the instance as.
	// Omit for "auto".
	Device string `json:"device,omitempty"`

	// VolumeID is the ID of the volume to attach to the instance.
	VolumeID string `json:"volumeId" required:"true"`

	// Tag is a device role tag that can be applied to a volume when attaching
	// it to the VM. Requires 2.49 microversion
	Tag string `json:"tag,omitempty"`

	// DeleteOnTermination specifies whether or not to delete the volume when the server
	// is destroyed. Requires 2.79 microversion
	DeleteOnTermination bool `json:"delete_on_termination,omitempty"`
}

CreateOpts specifies volume attachment creation or import parameters.

func (CreateOpts) ToVolumeAttachmentCreateMap

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

ToVolumeAttachmentCreateMap constructs a request body from CreateOpts.

type CreateOptsBuilder

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

CreateOptsBuilder allows extensions to add parameters to the Create request.

type CreateResult

type CreateResult struct {
	VolumeAttachmentResult
}

CreateResult is the response from a Create operation. Call its Extract method to interpret it as a VolumeAttachment.

func Create

func Create(client *gophercloud.ServiceClient, serverID string, opts CreateOptsBuilder) (r CreateResult)

Create requests the creation of a new volume attachment on the server.

type DeleteResult

type DeleteResult struct {
	gophercloud.ErrResult
}

DeleteResult is the response from a Delete operation. Call its ExtractErr method to determine if the call succeeded or failed.

func Delete

func Delete(client *gophercloud.ServiceClient, serverID, attachmentID string) (r DeleteResult)

Delete requests the deletion of a previous stored VolumeAttachment from the server.

type GetResult

type GetResult struct {
	VolumeAttachmentResult
}

GetResult is the response from a Get operation. Call its Extract method to interpret it as a VolumeAttachment.

func Get

func Get(client *gophercloud.ServiceClient, serverID, attachmentID string) (r GetResult)

Get returns public data about a previously created VolumeAttachment.

type VolumeAttachment

type VolumeAttachment struct {
	// ID is a unique id of the attachment.
	ID string `json:"id"`

	// Device is what device the volume is attached as.
	Device string `json:"device"`

	// VolumeID is the ID of the attached volume.
	VolumeID string `json:"volumeId"`

	// ServerID is the ID of the instance that has the volume attached.
	ServerID string `json:"serverId"`

	// Tag is a device role tag that can be applied to a volume when attaching
	// it to the VM. Requires 2.70 microversion
	Tag *string `json:"tag"`

	// DeleteOnTermination specifies whether or not to delete the volume when the server
	// is destroyed. Requires 2.79 microversion
	DeleteOnTermination *bool `json:"delete_on_termination"`
}

VolumeAttachment contains attachment information between a volume and server.

func ExtractVolumeAttachments

func ExtractVolumeAttachments(r pagination.Page) ([]VolumeAttachment, error)

ExtractVolumeAttachments interprets a page of results as a slice of VolumeAttachment.

type VolumeAttachmentPage

type VolumeAttachmentPage struct {
	pagination.SinglePageBase
}

VolumeAttachmentPage stores a single page all of VolumeAttachment results from a List call.

func (VolumeAttachmentPage) IsEmpty

func (page VolumeAttachmentPage) IsEmpty() (bool, error)

IsEmpty determines whether or not a VolumeAttachmentPage is empty.

type VolumeAttachmentResult

type VolumeAttachmentResult struct {
	gophercloud.Result
}

VolumeAttachmentResult is the result from a volume attachment operation.

func (VolumeAttachmentResult) Extract

Extract is a method that attempts to interpret any VolumeAttachment resource response as a VolumeAttachment struct.

Directories

Path Synopsis
volumeattach unit tests
volumeattach unit tests

Jump to

Keyboard shortcuts

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