-
Notifications
You must be signed in to change notification settings - Fork 524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Network Port QoS Policy API #1027
Comments
@jtopjian I have a question related to QoS support needed by terraform-provider-openstack#246. Should we add the qos_policy_id port field into the If we add it as extensions how do we need to structure the package? Should we add the Or should we create the separate Or it will be better if we just add the |
Every once in a while I get the urge to combine all network extensions into their "base" resources. But then something comes along that makes me realize that's not a good idea. I recently looked at some DNS extensions which made me think we would run into problems when someone doesn't have the DNS extensions enabled. The networking extensions are a bear to work with and I really want to simply them, but for now, we shouldn't do this.
Yes. We can put everything in If the request opts for Ports and Networks are the same, unfortunately we will have to duplicate the structs. You can see an example of this with port security: https://github.com/gophercloud/gophercloud/blob/master/openstack/networking/v2/extensions/portsecurity/requests.go But if the response fields are the same, we can cheat a little bit. Again, see port security: https://github.com/gophercloud/gophercloud/blob/master/openstack/networking/v2/extensions/portsecurity/results.go Notice how there is only 1 struct, but we can use it for both:
Let me know if that helps. |
@jtopjian thanks! Is started playing with QoS and now I have more questions 😅 1 - Regarding
2 - Regarding design of the policies/rules CRUD. We need to implement To do this we must implement the And the bad thing is that there are different rules objects with different URL paths and different attributes: I guess that it's better to implement each rule in it's separate package. But how in that case we will be able to use slice of those different rules in the Can we do it with the structure composition? I mean can we implement a |
You'll probably want to have the field type as: QosPolicyID *string `json:"qos_policy_id,omitempty"` Then when a user specifies an empty string, set func (opts PortUpdateOptsExt) ToPortUpdateMap() (map[string]interface{}, error) {
base, err := opts.UpdateOptsBuilder.ToPortUpdateMap()
if err != nil {
return nil, err
}
port := base["port"].(map[string]interface{})
if opts.QoSPolicyID != nil {
qosPolicyID := *(opts.QosPolicyID)
if qosPolicyID != "" {
port["qos_policy_id"] = qosPolicyID
} else {
port["qos_policy_id"] = nil
}
}
return base, nil
}
The different types of rules can be in the same package ( However, for a policy's results, the The dev/user using Gophercloud can do it themselves: for _, rule := range policy.Rules {
ruleID := rule["id"].(string)
ruleType := rule["type"].(string)
switch ruleType {
case "bandwidth_limit":
typedRule, err := rules.GetBandWidthLimitRule(client, ruleID).Extract()
}
} or you can create a helper in for _, rule := range policy.Rules {
typedRule, err := qos_utils.ConvertMapToRule(rule)
} Where switch rule["type"].(string) {
case "bandwidth_limit":
typedRule := rules.BandwidthLimitRule{
ID: rule["id"].(string),
Type: rule["type"].(string),
MaxKBPS: rule["max_kbps"].(int64),
}
} However, in above solution, if v, ok := typedRule.(rules.BandwidthLimitRule); ok {
...
} or type BaseRule {
ID string `json:"id"`
Type string `json:"type"`
Extra map[string]interface{}
} And use the Unfortunately none of the solutions are great, but at least they are solvable :) Let me know if this helps or if I'm misunderstanding something. |
@jtopjian thank you, this is really good explanation. I think I will do it an add all of QoS stuff in terraform-provider-openstack in some near future. |
@ozerovandrei Slight nit with the |
@jtopjian sure |
All done. |
Nice work! 😄 |
Adding implementations for the following routes to the client would be desirable:
Specifically, these routes, under network/v2.0/qos (list here, as well: https://developer.openstack.org/api-ref/network/v2/index.html#quality-of-service)
QoS Extenstion common CRUD
GET /rule-types
[WIP] qos: list rule types #1030GET /rule-types/{rule_type}
Networking V2: add QoS rule type Get call #1625GET /policies
Networking V2: add QoS policies List #1591POST /policies
Networking V2: add QoS policy Create call #1595GET /policies/{policy_id}
Networking: add QoS policies Get, cleanup QoS doc #1593PUT /policies/{policy_id}
Networking V2: add QoS policy Update call #1601DELETE /policies/{policy_id}
Networking V2: add QoS policy Delete call #1602GET /policies/{policy_id}/bandwidth_limit_rules
Networking V2: add bw limit rules List #1582POST /policies/{policy_id}/bandwidth_limit_rules
Networking V2: add bw limit rule Create #1584GET /policies/{policy_id}/bandwidth_limit_rules/{rule_id}
Networking V2: add bw limit rules Get #1583PUT /policies/{policy_id}/bandwidth_limit_rules/{rule_id}
Networking V2: add bw limit rule Update #1588DELETE /policies/{policy_id}/bandwidth_limit_rules/{rule_id}
Networking V2: add bw limit rule Delete #1590GET /policies/{policy_id}/dscp_marking_rules
Networking V2: add QoS DSCP marking rules List #1594POST /policies/{policy_id}/dscp_marking_rules
Networking V2: add QoS DSCPMarking rule Create #1604GET /policies/{policy_id}/dscp_marking_rules/{rule_id}
Networking V2: add QoS DSCP rule Get call #1607PUT /policies/{policy_id}/dscp_marking_rules/{rule_id}
Networking V2: add QoS DSCPMarking rule Update #1605DELETE /policies/{policy_id}/dscp_marking_rules/{rule_id}
Networking V2: add QoS DSCP rule Delete call #1608GET /policies/{policy_id}/minimum_bandwidth_rules
Networking V2: add QoS min bw rule List call #1613POST /policies/{policy_id}/minimum_bandwidth_rules
Networking V2: add QoS min bw rule Create call #1615GET /policies/{policy_id}/minimum_bandwidth_rules/{rule_id}
Networking V2: add QoS min bw rule Get call #1614PUT /policies/{policy_id}/minimum_bandwidth_rules/{rule_id}
Networking V2: add QoS min bw rule Update call #1622DELETE /policies/{policy_id}/minimum_bandwidth_rules/{rule_id}
Networking V2: add QoS min bw rule Delete call #1623QoS Extension Ports CRUD
GET /v2.0/ports/{port_id}
Networking V2: add QoS policy extension for Port #1580POST /v2.0/ports/{port_id}
Networking V2: add QoS policy extension for Port #1580PUT /v2.0/ports/{port_id}
Networking V2: add QoS policy extension for Port #1580QoS Extension Networks CRUD
GET /v2.0/networks/{port_id}
Networking V2: add QoS policy extension for Net #1581POST /v2.0/networks/{port_id}
Networking V2: add QoS policy extension for Net #1581PUT /v2.0/networks/{port_id}
Networking V2: add QoS policy extension for Net #1581The text was updated successfully, but these errors were encountered: