Documentation ¶
Overview ¶
Package shares enables management and retrieval of shares Share service. Example to List Shares
listshares := shares.ListOpts{} allshares, err := shares.List(client,listshares) if err != nil { panic(err) } fmt.Println(allshares)
Example to Create a share
share:=shares.CreateOpts{ Name:"sfs-test", ShareProto:"NFS", Size:1, } outshare,err:=shares.Create(client,share).Extract() if err != nil { panic(err) } fmt.Println(outshare)
Example to Update a share
updateshare:=shares.UpdateOpts{DisplayName:"sfs-test-1",DisplayDescription:"test sfs"} out,err:=shares.Update(client,"6149e448-dcac-4691-96d9-041e09ef617f",updateshare).Extract() if err != nil { panic(err) } fmt.Println(out)
Example to Delete a share
out:=shares.Delete(client,"6149e448-dcac-4691-96d9-041e09ef617f") fmt.Println(out) if err != nil { panic(err) }
Example to Get share
getshare,err:=shares.Get(client, "6149e448-dcac-4691-96d9-041e09ef617f").Extract() fmt.Println(getshare) if err != nil { panic(err) }
Example to Allow Access createSet:=shares.GrantAccessOpts{AccessLevel:"rw",AccessTo:"5232f396-d6cc-4a81-8de3-afd7a7ecdfd8",AccessType:"cert"}
access,err:=shares.GrantAccess(client,"dff2df5f-00e7-4517-ac32-1d0ab8dc0d68",createSet).Extract() fmt.Println(access) if err != nil { panic(err) }
Example to Deny Access
deleteSet := shares.DeleteAccessOpts{AccessID:"fc32500f-fa78-4f06-8caf-06ad7fb9726c"} remove:=shares.DeleteAccess(client,"1b8facf8-b822-4349-a033-e078b2a84b7f",deleteSet) fmt.Println(remove) if err != nil { panic(err) }
Example to Get Access Rule Detail
rule_list,err:= shares.ListAccessRights(client,"42381b5b-f8cb-445e-9465-89a718e071a7").ExtractAccessRights() if err != nil { panic(err) } fmt.Println(rule_list)
Example to Get Mount Location Details
mount, err := shares.GetExportLocations(client, "dff2df5f-00e7-4517-ac32-1d0ab8dc0d68").ExtractExportLocations() fmt.Println(mount) if err != nil { panic(err) }
Example to Extend share
extendsfs:=shares.ExpandOpts{OSExtend: shares.OSExtendOpts{NewSize: 512}} shares.Expand(client,"45a3af18-8ab0-405c-9ead-06c51a415f79",extendsfs)
Example to Shrink share
shrinksfs:=shares.ShrinkOpts{OSShrink: shares.OSShrinkOpts{NewSize: 8}} shares.Shrink(client,"45a3af18-8ab0-405c-9ead-06c51a415f79",shrinksfs)
Index ¶
- Variables
- type AccessRight
- type AccessRightsResult
- type CreateOpts
- type CreateOptsBuilder
- type CreateResult
- type DeleteAccessOpts
- type DeleteAccessOptsBuilder
- type DeleteAccessResult
- type DeleteResult
- type ExpandOpts
- type ExpandOptsBuilder
- type ExpandResult
- type ExportLocation
- type GetExportLocationsResult
- type GetResult
- type GrantAccessOpts
- type GrantAccessOptsBuilder
- type GrantAccessResult
- type ListOpts
- type ListOptsBuilder
- type OSExtendOpts
- type OSShrinkOpts
- type Share
- type SharePage
- type ShrinkOpts
- type ShrinkOptsBuilder
- type ShrinkResult
- type SortDir
- type SortKey
- type UpdateOpts
- type UpdateOptsBuilder
- type UpdateResult
Constants ¶
This section is empty.
Variables ¶
var ( // SortAsc is used to sort a list of Shares in ascending order. SortAsc SortDir = "asc" // SortDesc is used to sort a list of Shares in descending order. SortDesc SortDir = "desc" // SortId is used to sort a list of Shares by id. SortId SortKey = "id" // SortName is used to sort a list of Shares by name. SortName SortKey = "name" // SortSize is used to sort a list of Shares by size. SortSize SortKey = "size" // SortHost is used to sort a list of Shares by host. SortHost SortKey = "host" SortShareProto SortKey = "share_proto" // SortStatus is used to sort a list of Shares by status. SortStatus SortKey = "status" // SortProjectId is used to sort a list of Shares by project_id. SortProjectId SortKey = "project_id" SortShareTypeId SortKey = "share_type_id" SortShareNetworkId SortKey = "share_network_id" // SortSnapshotId is used to sort a list of Shares by snapshot_id. SortSnapshotId SortKey = "snapshot_id" // SortCreatedAt is used to sort a list of Shares by date created. SortCreatedAt SortKey = "created_at" // SortUpdatedAt is used to sort a list of Shares by date updated. SortUpdatedAt SortKey = "updated_at" )
var RequestOpts = golangsdk.RequestOpts{ MoreHeaders: map[string]string{"Content-Type": "application/json", "X-Openstack-Manila-Api-Version": "2.9"}, }
Functions ¶
This section is empty.
Types ¶
type AccessRight ¶
type AccessRight struct { // The access rule type that can be "ip", "cert" or "user". AccessType string `json:"access_type"` // The value that defines the access that can be a valid format of IP, cert or user. AccessTo string `json:"access_to"` // The access level to the share is either "rw" or "ro". AccessLevel string `json:"access_level"` // The state of the access rule State string `json:"state"` // The access rule ID. ID string `json:"id"` }
AccessRight contains all information associated with an OpenStack share Grant Access Response
type AccessRightsResult ¶
type AccessRightsResult struct {
golangsdk.Result
}
AccessRightsResult contains the result body and error from a AccessRight request.
func ListAccessRights ¶
func ListAccessRights(client *golangsdk.ServiceClient, share_id string) (r AccessRightsResult)
ListAccessRights lists all access rules assigned to a Share based on its id. To extract the AccessRight slice from the response, call the Extract method on the AccessRightsResult. Client must have Microversion set; minimum supported microversion for ListAccessRights is 2.7.
func (AccessRightsResult) ExtractAccessRights ¶
func (r AccessRightsResult) ExtractAccessRights() ([]AccessRight, error)
Extract will get a slice of AccessRight objects from the AccessRightsResult
type CreateOpts ¶
type CreateOpts struct { string `json:"share_proto" required:"true"` // Size in GB Size int `json:"size" required:"true"` // Defines the share name Name string `json:"name,omitempty"` // Share description Description string `json:"description,omitempty"` ShareType string `json:"share_type,omitempty"` // The UUID from which to create a share SnapshotID string `json:"snapshot_id,omitempty"` // Determines whether or not the share is public IsPublic bool `json:"is_public,omitempty"` // Key value pairs of user defined metadata Metadata map[string]string `json:"metadata,omitempty"` ShareNetworkID string `json:"share_network_id,omitempty"` // The UUID of the consistency group to which the share belongs to ConsistencyGroupID string `json:"consistency_group_id,omitempty"` // The availability zone of the share AvailabilityZone string `json:"availability_zone,omitempty"` }ShareProto
CreateOpts contains the options for create a Share. This object is passed to shares.Create(). For more information about these parameters, please refer to the Share object, or the shared file systems API v2 documentation
func (CreateOpts) ToShareCreateMap ¶
func (opts CreateOpts) ToShareCreateMap() (map[string]interface{}, error)
ToShareCreateMap assembles a request body based on the contents of a CreateOpts.
type CreateOptsBuilder ¶
type CreateOptsBuilder interface {
}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 *golangsdk.ServiceClient, opts CreateOptsBuilder) (r CreateResult)
Create will create a new Share based on the values in CreateOpts. To extract the Share object from the response, call the Extract method on the CreateResult.
type DeleteAccessOpts ¶
type DeleteAccessOpts struct { // The access ID to be deleted AccessID string `json:"access_id"` }
func (DeleteAccessOpts) ToDeleteAccessMap ¶
func (opts DeleteAccessOpts) ToDeleteAccessMap() (map[string]interface{}, error)
type DeleteAccessOptsBuilder ¶
Delete the Access Rule
type DeleteAccessResult ¶
type DeleteAccessResult struct {
golangsdk.Result
}
DeleteAccessResult contains the response body from DeleteAccess rights
func DeleteAccess ¶
func DeleteAccess(client *golangsdk.ServiceClient, share_id string, opts DeleteAccessOptsBuilder) (r DeleteAccessResult)
Deletes the Access Rule
type DeleteResult ¶
type DeleteResult struct {
golangsdk.ErrResult
}
DeleteResult contains the response body and error from a Delete request.
func Delete ¶
func Delete(client *golangsdk.ServiceClient, id string) (r DeleteResult)
Delete will delete an existing Share with the given UUID.
type ExpandOpts ¶
type ExpandOpts struct { // Specifies the os-extend object. OSExtend OSExtendOpts `json:"os-extend" required:"true"` }
ExpandOpts contains the options for expanding a Share. This object is passed to shares.Expand(). For more information about these parameters, please refer to the Share object, or the shared file systems API v2 documentation
func (ExpandOpts) ToShareExpandMap ¶
func (opts ExpandOpts) ToShareExpandMap() (map[string]interface{}, error)
ToShareExpandMap assembles a request body based on the contents of a ExpandOpts.
type ExpandOptsBuilder ¶
type ExpandOptsBuilder interface {
}ExpandOptsBuilder allows extensions to add additional parameters to the Expand request.
type ExpandResult ¶
type ExpandResult struct {
golangsdk.ErrResult
}
ExpandResult contains the response body and error from a Expand request.
func Expand ¶
func Expand(client *golangsdk.ServiceClient, share_id string, opts ExpandOptsBuilder) (r ExpandResult)
Expand will expand a Share based on the values in ExpandOpts.
type ExportLocation ¶
type ExportLocation struct { // The export location path that should be used for mount operation. Path string `json:"path"` ShareInstanceID string `json:"share_instance_id"` // Defines purpose of an export location. // If set to true, then it is expected to be used for service needs // and by administrators only. // If it is set to false, then this export location can be used by end users. IsAdminOnly bool `json:"is_admin_only"` // The share export location UUID. ID string `json:"id"` Preferred bool `json:"preferred"` }
ExportLocation contains all information associated with a share export location
type GetExportLocationsResult ¶
type GetExportLocationsResult struct {
golangsdk.Result
}
GetExportLocationsResult contains the response body from GetExportLocations
func GetExportLocations ¶
func GetExportLocations(client *golangsdk.ServiceClient, id string) (r GetExportLocationsResult)
Gets the Mount/Export Locations of the SFS specified
func (GetExportLocationsResult) ExtractExportLocations ¶
func (r GetExportLocationsResult) ExtractExportLocations() ([]ExportLocation, error)
Extract will get the Export Locations from the commonResult
type GetResult ¶
type GetResult struct {
// contains filtered or unexported fields
}
GetResult contains the response body and error from a Get request.
type GrantAccessOpts ¶
type GrantAccessOpts struct { // The access rule type that can be "ip", "cert" or "user". AccessType string `json:"access_type"` // The value that defines the access that can be a valid format of IP, cert or user. AccessTo string `json:"access_to"` // The access level to the share is either "rw" or "ro". AccessLevel string `json:"access_level"` }
GrantAccessOpts contains the options for creation of an GrantAccess request. For more information about these parameters, please, refer to the shared file systems API v2, Share Actions, Grant Access documentation
func (GrantAccessOpts) ToGrantAccessMap ¶
func (opts GrantAccessOpts) ToGrantAccessMap() (map[string]interface{}, error)
ToGrantAccessMap assembles a request body based on the contents of a GrantAccessOpts.
type GrantAccessOptsBuilder ¶
GrantAccessOptsBuilder allows extensions to add additional parameters to the GrantAccess request.
type GrantAccessResult ¶
type GrantAccessResult struct {
// contains filtered or unexported fields
}
GrantAccessResult contains the result body and error from an GrantAccess request.
func GrantAccess ¶
func GrantAccess(client *golangsdk.ServiceClient, share_id string, opts GrantAccessOptsBuilder) (r GrantAccessResult)
GrantAccess will grant access to a Share based on the values in GrantAccessOpts. To extract the GrantAccess object from the response, call the Extract method on the GrantAccessResult. Client must have Microversion set; minimum supported microversion for GrantAccess is 2.7.
func (GrantAccessResult) ExtractAccess ¶
func (r GrantAccessResult) ExtractAccess() (*AccessRight, error)
Extract will get the GrantAccess object from the commonResult
type ListOpts ¶
type ListOpts struct { ID string Status string `q:"status"` Name string `q:"name"` Limit int `q:"limit"` Offset int `q:"offset"` SortKey SortKey `q:"sort_key"` SortDir SortDir `q:"sort_dir"` IsPublic bool `q:"is_public"` }
ListOpts allows the filtering and sorting of paginated collections through the API. Filtering is achieved by passing in struct field values that map to the share attributes you want to see returned. SortKey allows you to sort by a particular share attribute. SortDir sets the direction, and is either `asc' or `desc'. Marker and Limit are used for pagination.
type ListOptsBuilder ¶
type ListOptsBuilder interface {
}ListOptsBuilder allows extensions to add additional parameters to the List request.
type OSExtendOpts ¶
type OSExtendOpts struct { // Specifies the post-expansion capacity (GB) of the shared file system. NewSize int `json:"new_size" required:"true"` }
type OSShrinkOpts ¶
type OSShrinkOpts struct { // Specifies the post-shrinking capacity (GB) of the shared file system. NewSize int `json:"new_size" required:"true"` }
type Share ¶
type Share struct { string `json:"availability_zone"` Description string `json:"description"` Host string `json:"host"` ID string `json:"id"` IsPublic bool `json:"is_public"` Links []map[string]string `json:"links"` Metadata map[string]string `json:"metadata"` Name string `json:"name"` ProjectID string `json:"project_id"` ShareNetworkID string `json:"share_network_id"` ShareProto string `json:"share_proto"` ShareType string `json:"share_type"` Size int `json:"size"` SnapshotID string `json:"snapshot_id"` Status string `json:"status"` VolumeType string `json:"volume_type"` CreatedAt time.Time `json:"-"` ExportLocation string `json:"export_location"` ExportLocations []string `json:"export_locations"` }AvailabilityZone
Share contains all information associated with an OpenStack Share
func ExtractShares ¶
func ExtractShares(r pagination.Page) ([]Share, error)
ExtractShares accepts a Page struct, specifically a SharePage struct, and extracts the elements into a slice of share structs. In other words, a generic collection is mapped into a relevant slice.
func List ¶
List returns a Pager which allows you to iterate over a collection of share resources. It accepts a ListOpts struct, which allows you to filter the returned collection for greater efficiency.
func (*Share) UnmarshalJSON ¶
type SharePage ¶
type SharePage struct {
}SharePage is the page returned by a pager when traversing over a collection of Shares.
func (SharePage) NextPageURL ¶
NextPageURL is invoked when a paginated collection of shares has reached the end of a page and the pager seeks to traverse over a new one. In order to do this, it needs to construct the next page's URL.
type ShrinkOpts ¶
type ShrinkOpts struct { // Specifies the os-shrink object. OSShrink OSShrinkOpts `json:"os-shrink" required:"true"` }
ShrinkOpts contains the options for shrinking a Share. This object is passed to shares.Shrink(). For more information about these parameters, please refer to the Share object, or the shared file systems API v2 documentation
func (ShrinkOpts) ToShareShrinkMap ¶
func (opts ShrinkOpts) ToShareShrinkMap() (map[string]interface{}, error)
ToShareShrinkMap assembles a request body based on the contents of a ShrinkOpts.
type ShrinkOptsBuilder ¶
type ShrinkOptsBuilder interface {
}ShrinkOptsBuilder allows extensions to add additional parameters to the Shrink request.
type ShrinkResult ¶
type ShrinkResult struct {
golangsdk.ErrResult
}
ShrinkResult contains the response body and error from a Shrink request.
func Shrink ¶
func Shrink(client *golangsdk.ServiceClient, share_id string, opts ShrinkOptsBuilder) (r ShrinkResult)
Shrink will shrink a Share based on the values in ShrinkOpts.
type SortDir ¶
type SortDir string
SortDir is a type for specifying in which direction to sort a list of Shares.
type SortKey ¶
type SortKey string
SortKey is a type for specifying by which key to sort a list of Shares.
type UpdateOpts ¶
type UpdateOpts struct { // DisplayName is equivalent to Name. The API supports using both // This is an inherited attribute from the block storage API DisplayName string `json:"display_name" required:"true"` // DisplayDescription is equivalent to Description. The API supports using bot // This is an inherited attribute from the block storage API DisplayDescription string `json:"display_description,omitempty"` }
UpdateOpts contains the values used when updating a Share.
func (UpdateOpts) ToShareUpdateMap ¶
func (opts UpdateOpts) ToShareUpdateMap() (map[string]interface{}, error)
ToShareUpdateMap builds an update body based on UpdateOpts.
type UpdateOptsBuilder ¶
type UpdateOptsBuilder interface {
}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 a update request.
func Update ¶
func Update(c *golangsdk.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult)
Update allows shares to be updated. You can update the DisplayName, DisplayDescription.