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(context.TODO(), computeClient, serverID, createOpts).Extract()
if err != nil {
	panic(err)
}
Example to Detach a Volume
serverID := "7ac8686c-de71-4acb-9600-ec18b1a1ed6d"
volumeID := "ed081613-1c9b-4231-aa5e-ebfd4d87f983"
err := volumeattach.Delete(context.TODO(), computeClient, serverID, volumeID).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]any, error)
ToVolumeAttachmentCreateMap constructs a request body from CreateOpts.
type CreateOptsBuilder ¶
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(ctx context.Context, 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.
type GetResult ¶
type GetResult struct {
	VolumeAttachmentResult
}
    GetResult is the response from a Get operation. Call its Extract method to interpret it as a 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 ¶
func (r VolumeAttachmentResult) Extract() (*VolumeAttachment, error)
Extract is a method that attempts to interpret any VolumeAttachment resource response as a VolumeAttachment struct.