Documentation
¶
Overview ¶
Package qos provides information and interaction with the QoS specifications for the Openstack Blockstorage service.
Example to create a QoS specification
createOpts := qos.CreateOpts{ Name: "test", Consumer: qos.ConsumerFront, Specs: map[string]string{ "read_iops_sec": "20000", }, } test, err := qos.Create(context.TODO(), client, createOpts).Extract() if err != nil { log.Fatal(err) } fmt.Printf("QoS: %+v\n", test)
Example to delete a QoS specification
qosID := "d6ae28ce-fcb5-4180-aa62-d260a27e09ae" deleteOpts := qos.DeleteOpts{ Force: false, } err = qos.Delete(context.TODO(), client, qosID, deleteOpts).ExtractErr() if err != nil { log.Fatal(err) }
Example to list QoS specifications
listOpts := qos.ListOpts{} allPages, err := qos.List(client, listOpts).AllPages(context.TODO()) if err != nil { panic(err) } allQoS, err := qos.ExtractQoS(allPages) if err != nil { panic(err) } for _, qos := range allQoS { fmt.Printf("List: %+v\n", qos) }
Example to get a single QoS specification
qosID := "de075d5e-8afc-4e23-9388-b84a5183d1c0" singleQos, err := qos.Get(context.TODO(), client, test.ID).Extract() if err != nil { panic(err) } fmt.Printf("Get: %+v\n", singleQos)
Example of updating QoSSpec
qosID := "de075d5e-8afc-4e23-9388-b84a5183d1c0" updateOpts := qos.UpdateOpts{ Consumer: qos.ConsumerBack, Specs: map[string]string{ "read_iops_sec": "40000", }, } specs, err := qos.Update(context.TODO(), client, qosID, updateOpts).Extract() if err != nil { panic(err) } fmt.Printf("%+v\n", specs)
Example of deleting specific keys/specs from a QoS
qosID := "de075d5e-8afc-4e23-9388-b84a5183d1c0" keysToDelete := qos.DeleteKeysOpts{"read_iops_sec"} err = qos.DeleteKeys(context.TODO(), client, qosID, keysToDelete).ExtractErr() if err != nil { panic(err) }
Example of associating a QoS with a volume type
qosID := "de075d5e-8afc-4e23-9388-b84a5183d1c0" volID := "b596be6a-0ce9-43fa-804a-5c5e181ede76" associateOpts := qos.AssociateOpts{ VolumeTypeID: volID, } err = qos.Associate(context.TODO(), client, qosID, associateOpts).ExtractErr() if err != nil { panic(err) }
Example of disassociating a QoS from a volume type
qosID := "de075d5e-8afc-4e23-9388-b84a5183d1c0" volID := "b596be6a-0ce9-43fa-804a-5c5e181ede76" disassociateOpts := qos.DisassociateOpts{ VolumeTypeID: volID, } err = qos.Disassociate(context.TODO(), client, qosID, disassociateOpts).ExtractErr() if err != nil { panic(err) }
Example of disaassociating a Qos from all volume types
qosID := "de075d5e-8afc-4e23-9388-b84a5183d1c0" err = qos.DisassociateAll(context.TODO(), client, qosID).ExtractErr() if err != nil { panic(err) }
Example of listing all associations of a QoS
qosID := "de075d5e-8afc-4e23-9388-b84a5183d1c0" allQosAssociations, err := qos.ListAssociations(client, qosID).AllPages(context.TODO()) if err != nil { panic(err) } allAssociations, err := qos.ExtractAssociations(allQosAssociations) if err != nil { panic(err) } for _, association := range allAssociations { fmt.Printf("Association: %+v\n", association) }
Index ¶
- func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
- func ListAssociations(client *gophercloud.ServiceClient, qosID string) pagination.Pager
- func Update(ctx context.Context, client *gophercloud.ServiceClient, id string, ...) (r updateResult)
- type AssociateOpts
- type AssociateOptsBuilder
- type AssociateResult
- type AssociationPage
- type CreateOpts
- type CreateOptsBuilder
- type CreateQosSpecsOptsBuilder
- type CreateResult
- type DeleteKeysOpts
- type DeleteKeysOptsBuilder
- type DeleteOpts
- type DeleteOptsBuilder
- type DeleteResult
- type DisassociateAllResult
- type DisassociateOpts
- type DisassociateOptsBuilder
- type DisassociateResult
- type GetResult
- type ListOpts
- type ListOptsBuilder
- type QoS
- type QoSConsumer
- type QoSPage
- type QosAssociation
- type UpdateOpts
- type UpdateOptsBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func List ¶
func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
List instructs OpenStack to provide a list of QoS. You may provide criteria by which List curtails its results for easier processing.
func ListAssociations ¶
func ListAssociations(client *gophercloud.ServiceClient, qosID string) pagination.Pager
ListAssociations retrieves the associations of a QoS.
Types ¶
type AssociateOpts ¶
type AssociateOpts struct {
VolumeTypeID string `q:"vol_type_id" required:"true"`
}
AssociateOpts contains options for associating a QoS with a volume type
func (AssociateOpts) ToQosAssociateQuery ¶
func (opts AssociateOpts) ToQosAssociateQuery() (string, error)
ToQosAssociateQuery formats an AssociateOpts into a query string
type AssociateOptsBuilder ¶
AssociateOpitsBuilder allows extensions to define volume type id to the associate query
type AssociateResult ¶
type AssociateResult struct {
gophercloud.ErrResult
}
AssociateResult contains the response body and error from a Associate request.
func Associate ¶
func Associate(ctx context.Context, client *gophercloud.ServiceClient, qosID string, opts AssociateOptsBuilder) (r AssociateResult)
Associate will associate a qos with a volute type
type AssociationPage ¶
type AssociationPage struct {
pagination.SinglePageBase
}
AssociationPage contains a single page of all Associations of a QoS
func (AssociationPage) IsEmpty ¶
func (page AssociationPage) IsEmpty() (bool, error)
IsEmpty indicates whether an Association page is empty.
type CreateOpts ¶
type CreateOpts struct { // The name of the QoS spec Name string `json:"name"` // The consumer of the QoS spec. Possible values are // both, front-end, back-end. Consumer QoSConsumer `json:"consumer,omitempty"` // Specs is a collection of miscellaneous key/values used to set // specifications for the QoS Specs map[string]string `json:"-"` }
CreateOpts contains options for creating a QoS specification. This object is passed to the qos.Create function.
func (CreateOpts) ToQoSCreateMap ¶
func (opts CreateOpts) ToQoSCreateMap() (map[string]any, error)
ToQoSCreateMap assembles a request body based on the contents of a CreateOpts.
type CreateOptsBuilder ¶
type CreateQosSpecsOptsBuilder ¶
CreateQosSpecsOptsBuilder allows extensions to add additional parameters to the CreateQosSpecs requests.
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(ctx context.Context, client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult)
Create will create a new QoS based on the values in CreateOpts. To extract the QoS object from the response, call the Extract method on the CreateResult.
func (CreateResult) ExtractInto ¶
ExtractInto converts our response data into a QoS struct
type DeleteKeysOpts ¶
type DeleteKeysOpts []string
DeleteKeysOpts is a string slice that contains keys to be deleted.
func (DeleteKeysOpts) ToDeleteKeysCreateMap ¶
func (opts DeleteKeysOpts) ToDeleteKeysCreateMap() (map[string]any, error)
ToDeleteKeysCreateMap assembles a body for a Create request based on the contents of ExtraSpecsOpts.
type DeleteKeysOptsBuilder ¶
DeleteKeysOptsBuilder allows extensions to add additional parameters to the CreateExtraSpecs requests.
type DeleteOpts ¶
type DeleteOpts struct { // Delete a QoS specification even if it is in-use Force bool `q:"force"` }
DeleteOpts contains options for deleting a QoS. This object is passed to the qos.Delete function.
func (DeleteOpts) ToQoSDeleteQuery ¶
func (opts DeleteOpts) ToQoSDeleteQuery() (string, error)
ToQoSDeleteQuery formats a DeleteOpts into a query string.
type DeleteOptsBuilder ¶
DeleteOptsBuilder allows extensions to add additional parameters to the Delete request.
type DeleteResult ¶
type DeleteResult struct {
gophercloud.ErrResult
}
DeleteResult contains the response body and error from a Delete request.
func Delete ¶
func Delete(ctx context.Context, client *gophercloud.ServiceClient, id string, opts DeleteOptsBuilder) (r DeleteResult)
Delete will delete the existing QoS with the provided ID.
func DeleteKeys ¶
func DeleteKeys(ctx context.Context, client *gophercloud.ServiceClient, qosID string, opts DeleteKeysOptsBuilder) (r DeleteResult)
DeleteKeys will delete the keys/specs from the specified QoS
type DisassociateAllResult ¶
type DisassociateAllResult struct {
gophercloud.ErrResult
}
DisassociateAllResult contains the response body and error from a DisassociateAll request.
func DisassociateAll ¶
func DisassociateAll(ctx context.Context, client *gophercloud.ServiceClient, qosID string) (r DisassociateAllResult)
DisassociateAll will disassociate a qos from all volute types
type DisassociateOpts ¶
type DisassociateOpts struct {
VolumeTypeID string `q:"vol_type_id" required:"true"`
}
DisassociateOpts contains options for disassociating a QoS from a volume type
func (DisassociateOpts) ToQosDisassociateQuery ¶
func (opts DisassociateOpts) ToQosDisassociateQuery() (string, error)
ToQosDisassociateQuery formats a DisassociateOpts into a query string
type DisassociateOptsBuilder ¶
DisassociateOpitsBuilder allows extensions to define volume type id to the disassociate query
type DisassociateResult ¶
type DisassociateResult struct {
gophercloud.ErrResult
}
DisassociateResult contains the response body and error from a Disassociate request.
func Disassociate ¶
func Disassociate(ctx context.Context, client *gophercloud.ServiceClient, qosID string, opts DisassociateOptsBuilder) (r DisassociateResult)
Disassociate will disassociate a qos from a volute type
type GetResult ¶
type GetResult struct {
// contains filtered or unexported fields
}
GetResult is the response of a Get operations. Call its Extract method to interpret it as a Flavor.
func (GetResult) ExtractInto ¶
ExtractInto converts our response data into a QoS struct
type ListOpts ¶
type ListOpts struct { // Sort is Comma-separated list of sort keys and optional sort // directions in the form of < key > [: < direction > ]. A valid //direction is asc (ascending) or desc (descending). Sort string `q:"sort"` // Marker and Limit control paging. // Marker instructs List where to start listing from. Marker string `q:"marker"` // Limit instructs List to refrain from sending excessively large lists of // QoS. Limit int `q:"limit"` }
func (ListOpts) ToQoSListQuery ¶
ToQoSListQuery formats a ListOpts into a query string.
type ListOptsBuilder ¶
ListOptsBuilder allows extensions to add additional parameters to the List request.
type QoS ¶
type QoS struct { // Name is the name of the QoS. Name string `json:"name"` // Unique identifier for the QoS. ID string `json:"id"` // Consumer of QoS Consumer string `json:"consumer"` // Arbitrary key-value pairs defined by the user. Specs map[string]string `json:"specs"` }
QoS contains all the information associated with an OpenStack QoS specification.
func ExtractQoS ¶
func ExtractQoS(r pagination.Page) ([]QoS, error)
ExtractQoS provides access to the list of qos in a page acquired from the List operation.
type QoSConsumer ¶
type QoSConsumer string
const ( ConsumerFront QoSConsumer = "front-end" ConsumerBack QoSConsumer = "back-end" ConsumerBoth QoSConsumer = "both" )
type QoSPage ¶
type QoSPage struct {
pagination.LinkedPageBase
}
func (QoSPage) NextPageURL ¶
NextPageURL uses the response's embedded link reference to navigate to the next page of results.
type QosAssociation ¶
type QosAssociation struct { // Name is the name of the associated resource Name string `json:"name"` // Unique identifier of the associated resources ID string `json:"id"` // AssociationType of the QoS Association AssociationType string `json:"association_type"` }
QoS contains all the information associated with an OpenStack QoS specification.
func ExtractAssociations ¶
func ExtractAssociations(r pagination.Page) ([]QosAssociation, error)
ExtractAssociations interprets a page of results as a slice of QosAssociations
type UpdateOpts ¶
type UpdateOpts struct { // The consumer of the QoS spec. Possible values are // both, front-end, back-end. Consumer QoSConsumer `json:"consumer,omitempty"` // Specs is a collection of miscellaneous key/values used to set // specifications for the QoS Specs map[string]string `json:"-"` }
UpdateOpts contains options for creating a QoS specification. This object is passed to the qos.Update function.
func (UpdateOpts) ToQoSUpdateMap ¶
func (opts UpdateOpts) ToQoSUpdateMap() (map[string]any, error)
ToQoSUpdateMap assembles a request body based on the contents of a UpdateOpts.