Documentation ¶
Overview ¶
Package policies provides information and interaction with the QoS policy extension for the OpenStack Networking service.
Example to Get a Port with a QoS policy
var portWithQoS struct { ports.Port policies.QoSPolicyExt } portID := "46d4bfb9-b26e-41f3-bd2e-e6dcc1ccedb2" err = ports.Get(client, portID).ExtractInto(&portWithQoS) if err != nil { log.Fatal(err) } fmt.Printf("Port: %+v\n", portWithQoS)
Example to Create a Port with a QoS policy
var portWithQoS struct { ports.Port policies.QoSPolicyExt } policyID := "d6ae28ce-fcb5-4180-aa62-d260a27e09ae" networkID := "7069db8d-e817-4b39-a654-d2dd76e73d36" portCreateOpts := ports.CreateOpts{ NetworkID: networkID, } createOpts := policies.PortCreateOptsExt{ CreateOptsBuilder: portCreateOpts, QoSPolicyID: policyID, } err = ports.Create(client, createOpts).ExtractInto(&portWithQoS) if err != nil { panic(err) } fmt.Printf("Port: %+v\n", portWithQoS)
Example to Add a QoS policy to an existing Port
var portWithQoS struct { ports.Port policies.QoSPolicyExt } portUpdateOpts := ports.UpdateOpts{} policyID := "d6ae28ce-fcb5-4180-aa62-d260a27e09ae" updateOpts := policies.PortUpdateOptsExt{ UpdateOptsBuilder: portUpdateOpts, QoSPolicyID: &policyID, } err := ports.Update(client, "65c0ee9f-d634-4522-8954-51021b570b0d", updateOpts).ExtractInto(&portWithQoS) if err != nil { panic(err) } fmt.Printf("Port: %+v\n", portWithQoS)
Example to Delete a QoS policy from the existing Port
var portWithQoS struct { ports.Port policies.QoSPolicyExt } portUpdateOpts := ports.UpdateOpts{} policyID := "" updateOpts := policies.PortUpdateOptsExt{ UpdateOptsBuilder: portUpdateOpts, QoSPolicyID: &policyID, } err := ports.Update(client, "65c0ee9f-d634-4522-8954-51021b570b0d", updateOpts).ExtractInto(&portWithQoS) if err != nil { panic(err) } fmt.Printf("Port: %+v\n", portWithQoS)
Example to Get a Network with a QoS policy
var networkWithQoS struct { networks.Network policies.QoSPolicyExt } networkID := "46d4bfb9-b26e-41f3-bd2e-e6dcc1ccedb2" err = networks.Get(client, networkID).ExtractInto(&networkWithQoS) if err != nil { log.Fatal(err) } fmt.Printf("Network: %+v\n", networkWithQoS)
Example to Create a Network with a QoS policy
var networkWithQoS struct { networks.Network policies.QoSPolicyExt } policyID := "d6ae28ce-fcb5-4180-aa62-d260a27e09ae" networkID := "7069db8d-e817-4b39-a654-d2dd76e73d36" networkCreateOpts := networks.CreateOpts{ NetworkID: networkID, } createOpts := policies.NetworkCreateOptsExt{ CreateOptsBuilder: networkCreateOpts, QoSPolicyID: policyID, } err = networks.Create(client, createOpts).ExtractInto(&networkWithQoS) if err != nil { panic(err) } fmt.Printf("Network: %+v\n", networkWithQoS)
Example to add a QoS policy to an existing Network
var networkWithQoS struct { networks.Network policies.QoSPolicyExt } networkUpdateOpts := networks.UpdateOpts{} policyID := "d6ae28ce-fcb5-4180-aa62-d260a27e09ae" updateOpts := policies.NetworkUpdateOptsExt{ UpdateOptsBuilder: networkUpdateOpts, QoSPolicyID: &policyID, } err := networks.Update(client, "65c0ee9f-d634-4522-8954-51021b570b0d", updateOpts).ExtractInto(&networkWithQoS) if err != nil { panic(err) } fmt.Printf("Network: %+v\n", networkWithQoS)
Example to delete a QoS policy from the existing Network
var networkWithQoS struct { networks.Network policies.QoSPolicyExt } networkUpdateOpts := networks.UpdateOpts{} policyID := "" updateOpts := policies.NetworkUpdateOptsExt{ UpdateOptsBuilder: networkUpdateOpts, QoSPolicyID: &policyID, } err := networks.Update(client, "65c0ee9f-d634-4522-8954-51021b570b0d", updateOpts).ExtractInto(&networkWithQoS) if err != nil { panic(err) } fmt.Printf("Network: %+v\n", networkWithQoS)
Example to List QoS policies
shared := true listOpts := policies.ListOpts{ Name: "shared-policy", Shared: &shared, } allPages, err := policies.List(networkClient, listOpts).AllPages() if err != nil { panic(err) } allPolicies, err := policies.ExtractPolicies(allPages) if err != nil { panic(err) } for _, policy := range allPolicies { fmt.Printf("%+v\n", policy) }
Example to Get a specific QoS policy
policyID := "30a57f4a-336b-4382-8275-d708babd2241" policy, err := policies.Get(networkClient, policyID).Extract() if err != nil { panic(err) } fmt.Printf("%+v\n", policy)
Example to Create a QoS policy
createOpts := policies.CreateOpts{ Name: "shared-default-policy", Shared: true, IsDefault: true, } policy, err := policies.Create(networkClient, createOpts).Extract() if err != nil { panic(err) } fmt.Printf("%+v\n", policy)
Example to Update a QoS policy
shared := true isDefault := false opts := policies.UpdateOpts{ Name: "new-name", Shared: &shared, IsDefault: &isDefault, } policyID := "30a57f4a-336b-4382-8275-d708babd2241" policy, err := policies.Update(networkClient, policyID, opts).Extract() if err != nil { panic(err) } fmt.Printf("%+v\n", policy)
Example to Delete a QoS policy
policyID := "30a57f4a-336b-4382-8275-d708babd2241" err := policies.Delete(networkClient, policyID).ExtractErr() if err != nil { panic(err) }
Index ¶
- func ExtractPolicysInto(r pagination.Page, v interface{}) error
- func List(c *gophercloud.ServiceClient, opts PolicyListOptsBuilder) pagination.Pager
- type CreateOpts
- type CreateOptsBuilder
- type CreateResult
- type DeleteResult
- type GetResult
- type ListOpts
- type NetworkCreateOptsExt
- type NetworkUpdateOptsExt
- type Policy
- type PolicyListOptsBuilder
- type PolicyPage
- type PortCreateOptsExt
- type PortUpdateOptsExt
- type QoSPolicyExt
- type UpdateOpts
- type UpdateOptsBuilder
- type UpdateResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractPolicysInto ¶
func ExtractPolicysInto(r pagination.Page, v interface{}) error
ExtractPoliciesInto extracts the elements into a slice of RBAC Policy structs.
func List ¶
func List(c *gophercloud.ServiceClient, opts PolicyListOptsBuilder) pagination.Pager
List returns a Pager which allows you to iterate over a collection of Policy. It accepts a ListOpts struct, which allows you to filter and sort the returned collection for greater efficiency.
Types ¶
type CreateOpts ¶
type CreateOpts struct { // Name is the human-readable name of the QoS policy. Name string `json:"name"` // TenantID is the id of the Identity project. TenantID string `json:"tenant_id,omitempty"` // ProjectID is the id of the Identity project. ProjectID string `json:"project_id,omitempty"` Shared bool `json:"shared,omitempty"` // Description is the human-readable description for the QoS policy. Description string `json:"description,omitempty"` // IsDefault indicates if this QoS policy is default policy or not. IsDefault bool `json:"is_default,omitempty"` }
CreateOpts specifies parameters of a new QoS policy.
func (CreateOpts) ToPolicyCreateMap ¶
func (opts CreateOpts) ToPolicyCreateMap() (map[string]interface{}, error)
ToPolicyCreateMap constructs a request body from CreateOpts.
type CreateOptsBuilder ¶
CreateOptsBuilder allows to add additional parameters to the Create request.
type CreateResult ¶
type CreateResult struct {
// contains filtered or unexported fields
}
CreateResult represents the result of a Create operation. Call its Extract method to interpret it as a QoS policy.
func Create ¶
func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult)
Create requests the creation of a new QoS policy on the server.
type DeleteResult ¶
type DeleteResult struct {
gophercloud.ErrResult
}
DeleteResult represents the result of a delete operation. Call its ExtractErr method to determine if the request succeeded or failed.
func Delete ¶
func Delete(c *gophercloud.ServiceClient, id string) (r DeleteResult)
Delete accepts a unique ID and deletes the QoS policy associated with it.
type GetResult ¶
type GetResult struct {
// contains filtered or unexported fields
}
GetResult represents the result of a get operation. Call its Extract method to interpret it as a QoS policy.
func Get ¶
func Get(c *gophercloud.ServiceClient, id string) (r GetResult)
Get retrieves a specific QoS policy based on its ID.
type ListOpts ¶
type ListOpts struct { ID string `q:"id"` TenantID string `q:"tenant_id"` ProjectID string `q:"project_id"` Name string `q:"name"` Description string `q:"description"` RevisionNumber *int `q:"revision_number"` IsDefault *bool `q:"is_default"` Limit int `q:"limit"` Marker string `q:"marker"` SortKey string `q:"sort_key"` SortDir string `q:"sort_dir"` Tags string `q:"tags"` TagsAny string `q:"tags-any"` NotTags string `q:"not-tags"` NotTagsAny string `q:"not-tags-any"` }
ListOpts allows the filtering and sorting of paginated collections through the Neutron API. Filtering is achieved by passing in struct field values that map to the Policy attributes you want to see returned. SortKey allows you to sort by a particular Policy attribute. SortDir sets the direction, and is either `asc' or `desc'. Marker and Limit are used for the pagination.
func (ListOpts) ToPolicyListQuery ¶
ToPolicyListQuery formats a ListOpts into a query string.
type NetworkCreateOptsExt ¶
type NetworkCreateOptsExt struct { networks.CreateOptsBuilder // QoSPolicyID represents an associated QoS policy. QoSPolicyID string `json:"qos_policy_id,omitempty"` }
NetworkCreateOptsExt adds QoS options to the base networks.CreateOpts.
func (NetworkCreateOptsExt) ToNetworkCreateMap ¶
func (opts NetworkCreateOptsExt) ToNetworkCreateMap() (map[string]interface{}, error)
ToNetworkCreateMap casts a CreateOpts struct to a map.
type NetworkUpdateOptsExt ¶
type NetworkUpdateOptsExt struct { networks.UpdateOptsBuilder // QoSPolicyID represents an associated QoS policy. // Setting it to a pointer of an empty string will remove associated QoS policy from network. QoSPolicyID *string `json:"qos_policy_id,omitempty"` }
NetworkUpdateOptsExt adds QoS options to the base networks.UpdateOpts.
func (NetworkUpdateOptsExt) ToNetworkUpdateMap ¶
func (opts NetworkUpdateOptsExt) ToNetworkUpdateMap() (map[string]interface{}, error)
ToNetworkUpdateMap casts a UpdateOpts struct to a map.
type Policy ¶
type Policy struct { // ID is the id of the policy. ID string `json:"id"` // Name is the human-readable name of the policy. Name string `json:"name"` // TenantID is the id of the Identity project. TenantID string `json:"tenant_id"` // ProjectID is the id of the Identity project. ProjectID string `json:"project_id"` // CreatedAt is the time at which the policy has been created. CreatedAt time.Time `json:"created_at"` // UpdatedAt is the time at which the policy has been created. UpdatedAt time.Time `json:"updated_at"` // IsDefault indicates if the policy is default policy or not. IsDefault bool `json:"is_default"` // Description is thehuman-readable description for the resource. Description string `json:"description"` Shared bool `json:"shared"` // RevisionNumber represents revision number of the policy. RevisionNumber int `json:"revision_number"` // Rules represents QoS rules of the policy. Rules []map[string]interface{} `json:"rules"` // Tags optionally set via extensions/attributestags Tags []string `json:"tags"` }
Policy represents a QoS policy.
func ExtractPolicies ¶
func ExtractPolicies(r pagination.Page) ([]Policy, error)
ExtractPolicies accepts a PolicyPage, and extracts the elements into a slice of Policies.
type PolicyListOptsBuilder ¶
PolicyListOptsBuilder allows extensions to add additional parameters to the List request.
type PolicyPage ¶
type PolicyPage struct {
pagination.LinkedPageBase
}
PolicyPage stores a single page of Policies from a List() API call.
func (PolicyPage) IsEmpty ¶
func (r PolicyPage) IsEmpty() (bool, error)
IsEmpty checks whether a PolicyPage is empty.
func (PolicyPage) NextPageURL ¶
func (r PolicyPage) NextPageURL() (string, error)
NextPageURL is invoked when a paginated collection of policies 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 PortCreateOptsExt ¶
type PortCreateOptsExt struct { ports.CreateOptsBuilder // QoSPolicyID represents an associated QoS policy. QoSPolicyID string `json:"qos_policy_id,omitempty"` }
PortCreateOptsExt adds QoS options to the base ports.CreateOpts.
func (PortCreateOptsExt) ToPortCreateMap ¶
func (opts PortCreateOptsExt) ToPortCreateMap() (map[string]interface{}, error)
ToPortCreateMap casts a CreateOpts struct to a map.
type PortUpdateOptsExt ¶
type PortUpdateOptsExt struct { ports.UpdateOptsBuilder // QoSPolicyID represents an associated QoS policy. // Setting it to a pointer of an empty string will remove associated QoS policy from port. QoSPolicyID *string `json:"qos_policy_id,omitempty"` }
PortUpdateOptsExt adds QoS options to the base ports.UpdateOpts.
func (PortUpdateOptsExt) ToPortUpdateMap ¶
func (opts PortUpdateOptsExt) ToPortUpdateMap() (map[string]interface{}, error)
ToPortUpdateMap casts a UpdateOpts struct to a map.
type QoSPolicyExt ¶
type QoSPolicyExt struct { // QoSPolicyID represents an associated QoS policy. QoSPolicyID string `json:"qos_policy_id"` }
QoSPolicyExt represents additional resource attributes available with the QoS extension.
type UpdateOpts ¶
type UpdateOpts struct { // Name is the human-readable name of the QoS policy. Name string `json:"name,omitempty"` Shared *bool `json:"shared,omitempty"` // Description is the human-readable description for the QoS policy. Description *string `json:"description,omitempty"` // IsDefault indicates if this QoS policy is default policy or not. IsDefault *bool `json:"is_default,omitempty"` }
UpdateOpts represents options used to update a QoS policy.
func (UpdateOpts) ToPolicyUpdateMap ¶
func (opts UpdateOpts) ToPolicyUpdateMap() (map[string]interface{}, error)
ToPolicyUpdateMap builds a request body from 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 represents the result of a Create operation. Call its Extract method to interpret it as a QoS policy.
func Update ¶
func Update(c *gophercloud.ServiceClient, policyID string, opts UpdateOptsBuilder) (r UpdateResult)
Update accepts a UpdateOpts struct and updates an existing policy using the values provided.