Documentation ¶
Overview ¶
Package volumeactions provides information and interaction with volumes in the Enterprise Cloud 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: eclcloud.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: eclcloud.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 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 ¶
ExtendSizeOptsBuilder allows extensions to add additional parameters to the ExtendSize request.
type ExtendSizeResult ¶
ExtendSizeResult contains the response body and error from an ExtendSize request.
func ExtendSize ¶
func ExtendSize(client *eclcloud.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 ¶
ForceDeleteResult contains the response body and error from a ForceDelete request.
func ForceDelete ¶
func ForceDelete(client *eclcloud.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 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 ¶
UploadImageOptsBuilder allows extensions to add additional parameters to the UploadImage request.
type UploadImageResult ¶
UploadImageResult contains the response body and error from an UploadImage request.
func UploadImage ¶
func UploadImage(client *eclcloud.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