Documentation ¶
Overview ¶
Package attachments provides access to OpenStack Block Storage Attachment API's. Use of this package requires Cinder version 3.27 at a minimum.
For more information, see: https://docs.openstack.org/api-ref/block-storage/v3/index.html#attachments
Example to List Attachments
listOpts := &attachments.ListOpts{ InstanceID: "uuid", } client.Microversion = "3.27" allPages, err := attachments.List(client, listOpts).AllPages() if err != nil { panic(err) } allAttachments, err := attachments.ExtractAttachments(allPages) if err != nil { panic(err) } for _, attachment := range allAttachments { fmt.Println(attachment) }
Example to Create Attachment
createOpts := &attachments.CreateOpts{ InstanceUUID: "uuid", VolumeUUID: "uuid" } client.Microversion = "3.27" attachment, err := attachments.Create(client, createOpts).Extract() if err != nil { panic(err) } fmt.Println(attachment)
Example to Get Attachment
client.Microversion = "3.27" attachment, err := attachments.Get(client, "uuid").Extract() if err != nil { panic(err) } fmt.Println(attachment)
Example to Update Attachment
opts := &attachments.UpdateOpts{ Connector: map[string]interface{}{ "mode": "ro", } } client.Microversion = "3.27" attachment, err := attachments.Update(client, "uuid", opts).Extract() if err != nil { panic(err) } fmt.Println(attachment)
Example to Complete Attachment
client.Microversion = "3.44" err := attachments.Complete(client, "uuid").ExtractErr() if err != nil { panic(err) }
Example to Delete Attachment
client.Microversion = "3.27" err := attachments.Delete(client, "uuid").ExtractErr() if err != nil { panic(err) }
Package attachments provides access to OpenStack Block Storage Attachment API's. Use of this package requires Cinder version 3.27 at a minimum.
Index ¶
- func ExtractAttachmentsInto(r pagination.Page, a interface{}) error
- func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
- func WaitForStatus(c *gophercloud.ServiceClient, id, status string, secs int) error
- type Attachment
- type AttachmentPage
- type CompleteResult
- type CreateOpts
- type CreateOptsBuilder
- type CreateResult
- type DeleteResult
- type GetResult
- type ListOpts
- type ListOptsBuilder
- type UpdateOpts
- type UpdateOptsBuilder
- type UpdateResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractAttachmentsInto ¶
func ExtractAttachmentsInto(r pagination.Page, a interface{}) error
ExtractAttachmentsInto similar to ExtractInto but operates on a List of attachments.
func List ¶
func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
List returns Attachments optionally limited by the conditions provided in ListOpts.
func WaitForStatus ¶
func WaitForStatus(c *gophercloud.ServiceClient, id, status string, secs int) error
WaitForStatus will continually poll the resource, checking for a particular status. It will do this for the amount of seconds defined.
Types ¶
type Attachment ¶
type Attachment struct { // ID is the Unique identifier for the attachment. ID string `json:"id"` // VolumeID is the UUID of the Volume associated with this attachment. VolumeID string `json:"volume_id"` // Instance is the Instance/Server UUID associated with this attachment. Instance string `json:"instance"` // AttachedAt is the time the attachment was created. AttachedAt time.Time `json:"-"` // DetachedAt is the time the attachment was detached. DetachedAt time.Time `json:"-"` // Status is the current attach status. Status string `json:"status"` // AttachMode includes things like Read Only etc. AttachMode string `json:"attach_mode"` // ConnectionInfo is the required info for a node to make a connection // provided by the driver. ConnectionInfo map[string]interface{} `json:"connection_info"` }
Attachment contains all the information associated with an OpenStack Attachment.
func ExtractAttachments ¶
func ExtractAttachments(r pagination.Page) ([]Attachment, error)
ExtractAttachments extracts and returns Attachments. It is used while iterating over a attachment.List call.
func (*Attachment) UnmarshalJSON ¶
func (r *Attachment) UnmarshalJSON(b []byte) error
UnmarshalJSON is our unmarshalling helper
type AttachmentPage ¶
type AttachmentPage struct {
pagination.LinkedPageBase
}
AttachmentPage is a pagination.pager that is returned from a call to the List function.
func (AttachmentPage) IsEmpty ¶
func (r AttachmentPage) IsEmpty() (bool, error)
IsEmpty returns true if a ListResult contains no Attachments.
type CompleteResult ¶
type CompleteResult struct {
gophercloud.ErrResult
}
CompleteResult contains the response body and error from a Complete request.
func Complete ¶
func Complete(client *gophercloud.ServiceClient, id string) (r CompleteResult)
Complete will complete an attachment for a cinder volume. Available starting in the 3.44 microversion.
type CreateOpts ¶
type CreateOpts struct { // VolumeUUID is the UUID of the Cinder volume to create the attachment // record for. VolumeUUID string `json:"volume_uuid"` // InstanceUUID is the ID of the Server to create the attachment for. // When attaching to a Nova Server this is the Nova Server (Instance) // UUID. InstanceUUID string `json:"instance_uuid"` // Connector is an optional map containing all of the needed atachment // information for exmaple initiator IQN, etc. Connector map[string]interface{} `json:"connector,omitempty"` // Mode is an attachment mode. Acceptable values are read-only ('ro') // and read-and-write ('rw'). Available only since 3.54 microversion. // For APIs from 3.27 till 3.53 use Connector["mode"] = "rw|ro". Mode string `json:"mode,omitempty"` }
CreateOpts contains options for creating a Volume attachment. This object is passed to the Create function. For more information about these parameters, see the Attachment object.
func (CreateOpts) ToAttachmentCreateMap ¶
func (opts CreateOpts) ToAttachmentCreateMap() (map[string]interface{}, error)
ToAttachmentCreateMap assembles a request body based on the contents of a CreateOpts.
type CreateOptsBuilder ¶
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(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult)
Create will create a new Attachment based on the values in CreateOpts. To extract the Attachment object from the response, call the Extract method on the CreateResult.
func (CreateResult) Extract ¶
func (r CreateResult) Extract() (*Attachment, error)
Extract will get the Attachment object out of the commonResult object.
func (CreateResult) ExtractInto ¶
func (r CreateResult) ExtractInto(a interface{}) error
ExtractInto converts our response data into a attachment struct.
type DeleteResult ¶
type DeleteResult struct {
gophercloud.ErrResult
}
DeleteResult contains the response body and error from a Delete request.
func Delete ¶
func Delete(client *gophercloud.ServiceClient, id string) (r DeleteResult)
Delete will delete the existing Attachment with the provided ID.
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(client *gophercloud.ServiceClient, id string) (r GetResult)
Get retrieves the Attachment with the provided ID. To extract the Attachment object from the response, call the Extract method on the GetResult.
func (GetResult) Extract ¶
func (r GetResult) Extract() (*Attachment, error)
Extract will get the Attachment object out of the commonResult object.
func (GetResult) ExtractInto ¶
func (r GetResult) ExtractInto(a interface{}) error
ExtractInto converts our response data into a attachment struct.
type ListOpts ¶
type ListOpts struct { // AllTenants will retrieve attachments of all tenants/projects. AllTenants bool `q:"all_tenants"` // Status will filter by the specified status. Status string `q:"status"` // ProjectID will filter by a specific tenant/project ID. ProjectID string `q:"project_id"` // VolumeID will filter by a specific volume ID. VolumeID string `q:"volume_id"` // InstanceID will filter by a specific instance ID. InstanceID string `q:"instance_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"` }
ListOpts holds options for listing Attachments. It is passed to the attachments.List function.
func (ListOpts) ToAttachmentListQuery ¶
ToAttachmentListQuery formats a ListOpts into a query string.
type ListOptsBuilder ¶
ListOptsBuilder allows extensions to add additional parameters to the List request.
type UpdateOpts ¶
type UpdateOpts struct {
Connector map[string]interface{} `json:"connector"`
}
UpdateOpts contain options for updating an existing Attachment. This is used to finalize an attachment that was created without a connector (reserve).
func (UpdateOpts) ToAttachmentUpdateMap ¶
func (opts UpdateOpts) ToAttachmentUpdateMap() (map[string]interface{}, error)
ToAttachmentUpdateMap assembles a request body based on the contents of an UpdateOpts.
type UpdateOptsBuilder ¶
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(client *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult)
Update will update the Attachment with provided information. To extract the updated Attachment from the response, call the Extract method on the UpdateResult.
func (UpdateResult) Extract ¶
func (r UpdateResult) Extract() (*Attachment, error)
Extract will get the Attachment object out of the commonResult object.
func (UpdateResult) ExtractInto ¶
func (r UpdateResult) ExtractInto(a interface{}) error
ExtractInto converts our response data into a attachment struct.