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)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 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.