qos

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 28, 2023 License: Apache-2.0 Imports: 2 Imported by: 7

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(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(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()
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(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(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(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(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(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(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()
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

Constants

This section is empty.

Variables

This section is empty.

Functions

func List added in v0.19.0

List instructs OpenStack to provide a list of QoS. You may provide criteria by which List curtails its results for easier processing.

func ListAssociations added in v0.24.0

func ListAssociations(client *gophercloud.ServiceClient, qosID string) pagination.Pager

ListAssociations retrieves the associations of a QoS.

func Update added in v0.24.0

func Update(client *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r updateResult)

Update will update an existing QoS based on the values in UpdateOpts. To extract the QoS object from the response, call the Extract method on the UpdateResult.

Types

type AssociateOpts added in v0.24.0

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 added in v0.24.0

func (opts AssociateOpts) ToQosAssociateQuery() (string, error)

ToQosAssociateQuery formats an AssociateOpts into a query string

type AssociateOptsBuilder added in v0.24.0

type AssociateOptsBuilder interface {
	ToQosAssociateQuery() (string, error)
}

AssociateOpitsBuilder allows extensions to define volume type id to the associate query

type AssociateResult added in v0.24.0

type AssociateResult struct {
	gophercloud.ErrResult
}

AssociateResult contains the response body and error from a Associate request.

func Associate added in v0.24.0

func Associate(client *gophercloud.ServiceClient, qosID string, opts AssociateOptsBuilder) (r AssociateResult)

Associate will associate a qos with a volute type

type AssociationPage added in v0.24.0

type AssociationPage struct {
	pagination.SinglePageBase
}

AssociationPage contains a single page of all Associations of a QoS

func (AssociationPage) IsEmpty added in v0.24.0

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]interface{}, error)

ToQoSCreateMap assembles a request body based on the contents of a CreateOpts.

type CreateOptsBuilder

type CreateOptsBuilder interface {
	ToQoSCreateMap() (map[string]interface{}, error)
}

type CreateQosSpecsOptsBuilder added in v0.24.0

type CreateQosSpecsOptsBuilder interface {
	ToQosSpecsCreateMap() (map[string]interface{}, error)
}

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(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) Extract

func (r CreateResult) Extract() (*QoS, error)

Extract will get the QoS object out of the commonResult object.

func (CreateResult) ExtractInto

func (r CreateResult) ExtractInto(qos interface{}) error

ExtractInto converts our response data into a QoS struct

type DeleteKeysOpts added in v0.24.0

type DeleteKeysOpts []string

DeleteKeysOpts is a string slice that contains keys to be deleted.

func (DeleteKeysOpts) ToDeleteKeysCreateMap added in v0.24.0

func (opts DeleteKeysOpts) ToDeleteKeysCreateMap() (map[string]interface{}, error)

ToDeleteKeysCreateMap assembles a body for a Create request based on the contents of ExtraSpecsOpts.

type DeleteKeysOptsBuilder added in v0.24.0

type DeleteKeysOptsBuilder interface {
	ToDeleteKeysCreateMap() (map[string]interface{}, error)
}

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

type DeleteOptsBuilder interface {
	ToQoSDeleteQuery() (string, error)
}

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(client *gophercloud.ServiceClient, id string, opts DeleteOptsBuilder) (r DeleteResult)

Delete will delete the existing QoS with the provided ID.

func DeleteKeys added in v0.24.0

func DeleteKeys(client *gophercloud.ServiceClient, qosID string, opts DeleteKeysOptsBuilder) (r DeleteResult)

DeleteKeys will delete the keys/specs from the specified QoS

type DisassociateAllResult added in v0.24.0

type DisassociateAllResult struct {
	gophercloud.ErrResult
}

DisassociateAllResult contains the response body and error from a DisassociateAll request.

func DisassociateAll added in v0.24.0

func DisassociateAll(client *gophercloud.ServiceClient, qosID string) (r DisassociateAllResult)

DisassociateAll will disassociate a qos from all volute types

type DisassociateOpts added in v0.24.0

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 added in v0.24.0

func (opts DisassociateOpts) ToQosDisassociateQuery() (string, error)

ToQosDisassociateQuery formats a DisassociateOpts into a query string

type DisassociateOptsBuilder added in v0.24.0

type DisassociateOptsBuilder interface {
	ToQosDisassociateQuery() (string, error)
}

DisassociateOpitsBuilder allows extensions to define volume type id to the disassociate query

type DisassociateResult added in v0.24.0

type DisassociateResult struct {
	gophercloud.ErrResult
}

DisassociateResult contains the response body and error from a Disassociate request.

func Disassociate added in v0.24.0

func Disassociate(client *gophercloud.ServiceClient, qosID string, opts DisassociateOptsBuilder) (r DisassociateResult)

Disassociate will disassociate a qos from a volute type

type GetResult added in v0.24.0

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 Get added in v0.24.0

func Get(client *gophercloud.ServiceClient, id string) (r GetResult)

Get retrieves details of a single qos. Use Extract to convert its result into a QoS.

func (GetResult) Extract added in v0.24.0

func (r GetResult) Extract() (*QoS, error)

Extract will get the QoS object out of the commonResult object.

func (GetResult) ExtractInto added in v0.24.0

func (r GetResult) ExtractInto(qos interface{}) error

ExtractInto converts our response data into a QoS struct

type ListOpts added in v0.19.0

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 added in v0.19.0

func (opts ListOpts) ToQoSListQuery() (string, error)

ToQoSListQuery formats a ListOpts into a query string.

type ListOptsBuilder added in v0.19.0

type ListOptsBuilder interface {
	ToQoSListQuery() (string, error)
}

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 added in v0.19.0

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 added in v0.19.0

type QoSPage struct {
	pagination.LinkedPageBase
}

func (QoSPage) IsEmpty added in v0.19.0

func (page QoSPage) IsEmpty() (bool, error)

IsEmpty determines if a QoSPage contains any results.

func (QoSPage) NextPageURL added in v0.19.0

func (page QoSPage) NextPageURL() (string, error)

NextPageURL uses the response's embedded link reference to navigate to the next page of results.

type QosAssociation added in v0.24.0

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 added in v0.24.0

func ExtractAssociations(r pagination.Page) ([]QosAssociation, error)

ExtractAssociations interprets a page of results as a slice of QosAssociations

type UpdateOpts added in v0.24.0

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 added in v0.24.0

func (opts UpdateOpts) ToQoSUpdateMap() (map[string]interface{}, error)

ToQoSUpdateMap assembles a request body based on the contents of a UpdateOpts.

type UpdateOptsBuilder added in v0.24.0

type UpdateOptsBuilder interface {
	ToQoSUpdateMap() (map[string]interface{}, error)
}

Directories

Path Synopsis
Package testing for qos_v3
Package testing for qos_v3

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL