-
Notifications
You must be signed in to change notification settings - Fork 103
add (Neutron) qos policy bandwidth limit rule extension. #112
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
Open
bboyHan
wants to merge
1
commit into
openstack4j:main
Choose a base branch
from
bboyHan:BandwidthLimitRule
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
core-test/src/main/java/org/openstack4j/api/network/NetQosBandwidthLimitRuleTests.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| package org.openstack4j.api.network; | ||
|
|
||
| import org.openstack4j.api.AbstractTest; | ||
| import org.openstack4j.model.common.ActionResponse; | ||
| import org.openstack4j.model.network.ext.NetQosPolicyBandwidthLimitRule; | ||
| import org.openstack4j.openstack.networking.domain.ext.NeutronNetQosPolicyBandwidthLimitRule; | ||
| import org.testng.annotations.Test; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.List; | ||
|
|
||
| import static org.testng.Assert.assertEquals; | ||
| import static org.testng.Assert.assertTrue; | ||
|
|
||
| /** | ||
| * Test cases for (Neutron) qos policy bandwidth limit rule extension based Services | ||
| * | ||
| * @author bboyHan | ||
| */ | ||
| @Test(suiteName = "Network/qosPolicyBandwidthLimitRule") | ||
| public class NetQosBandwidthLimitRuleTests extends AbstractTest { | ||
|
|
||
| private static final String QOS_POLICY_BANDWIDTH_LIMIT_RULE_JSON = "/network/qos_bandwidth_limit_rule.json"; | ||
| private static final String QOS_POLICY_BANDWIDTH_LIMIT_RULES_JSON = "/network/qos_bandwidth_limit_rules.json"; | ||
|
|
||
| public void list() throws IOException { | ||
| respondWith(QOS_POLICY_BANDWIDTH_LIMIT_RULES_JSON); | ||
| List<? extends NetQosPolicyBandwidthLimitRule> qosPolicyBandwidthLimitRules = osv3().networking().netQosPolicyBandWidthLimitRule().list("policyId"); | ||
| assertEquals(1, qosPolicyBandwidthLimitRules.size()); | ||
| assertEquals(10000, (int)qosPolicyBandwidthLimitRules.get(0).getMaxKbps()); | ||
| } | ||
|
|
||
| public void get() throws IOException { | ||
| respondWith(QOS_POLICY_BANDWIDTH_LIMIT_RULE_JSON); | ||
| NetQosPolicyBandwidthLimitRule netQosPolicyBandwidthLimitRule = osv3().networking().netQosPolicyBandWidthLimitRule().get("networkId", "ruleId"); | ||
| assertEquals("5f126d84-551a-4dcf-bb01-0e9c0df0c793", netQosPolicyBandwidthLimitRule.getId()); | ||
| assertEquals("egress", netQosPolicyBandwidthLimitRule.getDirection()); | ||
| } | ||
|
|
||
| public void delete() { | ||
| respondWith(204); | ||
| ActionResponse response = osv3().networking().netQosPolicyBandWidthLimitRule().delete("policyId", "ruleId"); | ||
| assertTrue(response.isSuccess()); | ||
| } | ||
|
|
||
| public void create() throws IOException { | ||
| respondWith(QOS_POLICY_BANDWIDTH_LIMIT_RULE_JSON); | ||
| NetQosPolicyBandwidthLimitRule netQosPolicyBandwidthLimitRule = osv3().networking().netQosPolicyBandWidthLimitRule() | ||
| .create("policyId", NeutronNetQosPolicyBandwidthLimitRule.builder().maxKbps(10000).build()); | ||
| assertEquals("5f126d84-551a-4dcf-bb01-0e9c0df0c793", netQosPolicyBandwidthLimitRule.getId()); | ||
| assertEquals("egress", netQosPolicyBandwidthLimitRule.getDirection()); | ||
| } | ||
|
|
||
| @Override | ||
| protected Service service() { | ||
| return Service.NETWORK; | ||
| } | ||
| } |
8 changes: 8 additions & 0 deletions
8
core-test/src/main/resources/network/qos_bandwidth_limit_rule.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "bandwidth_limit_rule": { | ||
| "id": "5f126d84-551a-4dcf-bb01-0e9c0df0c793", | ||
| "max_kbps": 10000, | ||
| "max_burst_kbps": 0, | ||
| "direction": "egress" | ||
| } | ||
| } |
10 changes: 10 additions & 0 deletions
10
core-test/src/main/resources/network/qos_bandwidth_limit_rules.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "bandwidth_limit_rules": [ | ||
| { | ||
| "id": "5f126d84-551a-4dcf-bb01-0e9c0df0c793", | ||
| "max_kbps": 10000, | ||
| "max_burst_kbps": 0, | ||
| "direction": "egress" | ||
| } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
core/src/main/java/org/openstack4j/api/networking/ext/NetQosPolicyBLRuleService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| package org.openstack4j.api.networking.ext; | ||
|
|
||
| import org.openstack4j.common.RestService; | ||
| import org.openstack4j.model.common.ActionResponse; | ||
| import org.openstack4j.model.network.ext.NetQosPolicyBandwidthLimitRule; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| /** | ||
| * Networking (Neutron) Qos Policy Bandwidth Limit Rule Extension API | ||
| * | ||
| * @author bboyHan | ||
| */ | ||
| public interface NetQosPolicyBLRuleService extends RestService { | ||
|
|
||
| /** | ||
| * Lists qos policy bandwidth-limit-rules for tenants | ||
| * | ||
| * @param policyId policy id | ||
| * @return the list of qos policy bandwidth limit rules | ||
| */ | ||
| List<? extends NetQosPolicyBandwidthLimitRule> list(String policyId); | ||
|
|
||
| /** | ||
| * Fetches the network qos policy bandwidth-limit-rule for the specified tenant | ||
| * | ||
| * @param policyId policy id | ||
| * @return NetQosPolicyBandwidthLimitRule | ||
| */ | ||
| NetQosPolicyBandwidthLimitRule get(String policyId, String ruleId); | ||
|
|
||
| /** | ||
| * Updates the network qos policy bandwidth limit rule for the current tenant | ||
| * | ||
| * @param policyId policy id | ||
| * @param bandwidthLimitRule the net qos policy bandwidth limit rule to update | ||
| * @return NetQosPolicyBandwidthLimitRule | ||
| */ | ||
| NetQosPolicyBandwidthLimitRule update(String policyId, NetQosPolicyBandwidthLimitRule bandwidthLimitRule); | ||
|
|
||
| /** | ||
| * Create the current network qos policy bandwidth limit rule for the current tenant back to defaults | ||
| * | ||
| * @param policyId policy id | ||
| * @return NetQosPolicyBandwidthLimitRule the response object | ||
| */ | ||
| NetQosPolicyBandwidthLimitRule create(String policyId, NetQosPolicyBandwidthLimitRule bandwidthLimitRule); | ||
|
|
||
| /** | ||
| * Delete the current network qos policy bandwidth limit rule for the current tenant back to defaults | ||
| * | ||
| * @param policyId policy id | ||
| * @param ruleId the net qos policy bandwidth limit rule uuid | ||
| * @return the action response | ||
| */ | ||
| ActionResponse delete(String policyId, String ruleId); | ||
| } |
45 changes: 45 additions & 0 deletions
45
core/src/main/java/org/openstack4j/model/network/ext/NetQosPolicyBandwidthLimitRule.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| package org.openstack4j.model.network.ext; | ||
|
|
||
| import org.openstack4j.common.Buildable; | ||
| import org.openstack4j.model.common.IdEntity; | ||
| import org.openstack4j.model.network.ext.builder.NetQosPolicyBandwidthLimitRuleBuilder; | ||
| import org.openstack4j.openstack.networking.domain.ext.NeutronNetQosPolicyRuleTag; | ||
|
|
||
| /** | ||
| * Network qos policy band-width-limit that are bound to a Tenant | ||
| * | ||
| * @author bboyHan | ||
| */ | ||
| public interface NetQosPolicyBandwidthLimitRule extends IdEntity, Buildable<NetQosPolicyBandwidthLimitRuleBuilder> { | ||
|
|
||
| /** | ||
| * The maximum KBPS (kilobits per second) value. | ||
| * If you specify this value, must be greater than 0 otherwise max_kbps will have no value. | ||
| * | ||
| * @return maxKbps | ||
| */ | ||
| Integer getMaxKbps(); | ||
|
|
||
| /** | ||
| * The maximum burst size (in kilobits). | ||
| * | ||
| * @return maxBurstKbps | ||
| */ | ||
| Integer getMaxBurstKbps(); | ||
|
|
||
| /** | ||
| * The direction of the traffic to which the QoS rule is applied, as seen from the point of view of the port. | ||
| * Valid values are egress and ingress. Default value is egress. | ||
| * | ||
| * @return direction | ||
| */ | ||
| String getDirection(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be cleaner to have an |
||
|
|
||
| /** | ||
| * The list of tags on the resource. | ||
| * | ||
| * @return tags | ||
| */ | ||
| NeutronNetQosPolicyRuleTag getTags(); | ||
|
|
||
| } | ||
37 changes: 37 additions & 0 deletions
37
...java/org/openstack4j/model/network/ext/builder/NetQosPolicyBandwidthLimitRuleBuilder.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| package org.openstack4j.model.network.ext.builder; | ||
|
|
||
| import org.openstack4j.common.Buildable.Builder; | ||
| import org.openstack4j.model.network.ext.NetQosPolicyBandwidthLimitRule; | ||
|
|
||
| /** | ||
| * A Builder which creates a NetQosPolicyBandwidthLimitRule entity | ||
| * | ||
| * @author bboyHan | ||
| */ | ||
| public interface NetQosPolicyBandwidthLimitRuleBuilder extends Builder<NetQosPolicyBandwidthLimitRuleBuilder, NetQosPolicyBandwidthLimitRule> { | ||
|
|
||
| /** | ||
| * See {@link NetQosPolicyBandwidthLimitRule#getMaxKbps()} for details | ||
| * | ||
| * @param maxKbps maxKbps | ||
| * @return NetQosPolicyBandwidthLimitRuleBuilder | ||
| */ | ||
| NetQosPolicyBandwidthLimitRuleBuilder maxKbps(Integer maxKbps); | ||
|
|
||
| /** | ||
| * See {@link NetQosPolicyBandwidthLimitRule#getMaxBurstKbps()} for details | ||
| * | ||
| * @param maxBurstKbps maxBurstKbps | ||
| * @return NetQosPolicyBandwidthLimitRuleBuilder | ||
| */ | ||
| NetQosPolicyBandwidthLimitRuleBuilder maxBurstKbps(Integer maxBurstKbps); | ||
|
|
||
| /** | ||
| * See {@link NetQosPolicyBandwidthLimitRule#getDirection()} for details | ||
| * | ||
| * @param direction direction | ||
| * @return NetQosPolicyBandwidthLimitRuleBuilder | ||
| */ | ||
| NetQosPolicyBandwidthLimitRuleBuilder direction(String direction); | ||
|
|
||
| } |
132 changes: 132 additions & 0 deletions
132
...rg/openstack4j/openstack/networking/domain/ext/NeutronNetQosPolicyBandwidthLimitRule.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| package org.openstack4j.openstack.networking.domain.ext; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import com.fasterxml.jackson.annotation.JsonRootName; | ||
| import org.openstack4j.model.network.ext.NetQosPolicyBandwidthLimitRule; | ||
| import org.openstack4j.model.network.ext.builder.NetQosPolicyBandwidthLimitRuleBuilder; | ||
| import org.openstack4j.openstack.common.ListResult; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import static com.google.common.base.MoreObjects.toStringHelper; | ||
|
|
||
| /** | ||
| * Network qos policy band-width-limit that are bound to a Tenant | ||
| * | ||
| * @author bboyHan | ||
| */ | ||
| @JsonRootName("bandwidth_limit_rule") | ||
| public class NeutronNetQosPolicyBandwidthLimitRule implements NetQosPolicyBandwidthLimitRule { | ||
|
|
||
| private static final long serialVersionUID = 1L; | ||
|
|
||
| @JsonProperty | ||
| private String id; | ||
| @JsonProperty("max_kbps") | ||
| private Integer maxKbps; | ||
| @JsonProperty("max_burst_kbps") | ||
| private Integer maxBurstKbps; | ||
| @JsonProperty | ||
| private String direction; | ||
| @JsonProperty | ||
| private NeutronNetQosPolicyRuleTag tags; | ||
|
|
||
| public static NetQosPolicyBandwidthLimitRuleBuilder builder() { | ||
| return new NetQosPolicyBandwidthLimitRuleConcreteBuilder(); | ||
| } | ||
|
|
||
| @Override | ||
| public NetQosPolicyBandwidthLimitRuleBuilder toBuilder() { | ||
| return new NetQosPolicyBandwidthLimitRuleConcreteBuilder(this); | ||
| } | ||
|
|
||
| public String getId() { | ||
| return id; | ||
| } | ||
|
|
||
| @Override | ||
| public void setId(String id) { | ||
| this.id = id; | ||
| } | ||
|
|
||
| public Integer getMaxKbps() { | ||
| return maxKbps; | ||
| } | ||
|
|
||
| public Integer getMaxBurstKbps() { | ||
| return maxBurstKbps; | ||
| } | ||
|
|
||
| public String getDirection() { | ||
| return direction; | ||
| } | ||
|
|
||
| public NeutronNetQosPolicyRuleTag getTags() { | ||
| return tags; | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return toStringHelper(this) | ||
| .add("id", id).add("maxKbps", maxKbps).add("maxBurstKbps", maxBurstKbps) | ||
| .add("direction", direction).add("tags", tags) | ||
| .toString(); | ||
| } | ||
|
|
||
| public static class NetQosPolicyBandwidthLimitRuleConcreteBuilder implements NetQosPolicyBandwidthLimitRuleBuilder { | ||
|
|
||
| private NeutronNetQosPolicyBandwidthLimitRule model; | ||
|
|
||
| public NetQosPolicyBandwidthLimitRuleConcreteBuilder() { | ||
| model = new NeutronNetQosPolicyBandwidthLimitRule(); | ||
| } | ||
|
|
||
| public NetQosPolicyBandwidthLimitRuleConcreteBuilder(NeutronNetQosPolicyBandwidthLimitRule model) { | ||
| this.model = model; | ||
| } | ||
|
|
||
| @Override | ||
| public NetQosPolicyBandwidthLimitRule build() { | ||
| return model; | ||
| } | ||
|
|
||
| @Override | ||
| public NetQosPolicyBandwidthLimitRuleBuilder from(NetQosPolicyBandwidthLimitRule in) { | ||
| model = (NeutronNetQosPolicyBandwidthLimitRule) in; | ||
| return this; | ||
| } | ||
|
|
||
| @Override | ||
| public NetQosPolicyBandwidthLimitRuleBuilder maxKbps(Integer maxKbps) { | ||
| model.maxKbps = maxKbps; | ||
| return this; | ||
| } | ||
|
|
||
| @Override | ||
| public NetQosPolicyBandwidthLimitRuleBuilder maxBurstKbps(Integer maxBurstKbps) { | ||
| model.maxBurstKbps = maxBurstKbps; | ||
| return this; | ||
| } | ||
|
|
||
| @Override | ||
| public NetQosPolicyBandwidthLimitRuleBuilder direction(String direction) { | ||
| model.direction = direction; | ||
| return this; | ||
| } | ||
|
|
||
| } | ||
|
|
||
| public static class NeutronNetQosPolicyBLRules extends ListResult<NeutronNetQosPolicyBandwidthLimitRule> { | ||
|
|
||
| private static final long serialVersionUID = 1L; | ||
|
|
||
| @JsonProperty("bandwidth_limit_rules") | ||
| private List<NeutronNetQosPolicyBandwidthLimitRule> bandwidthLimitRules; | ||
|
|
||
| @Override | ||
| protected List<NeutronNetQosPolicyBandwidthLimitRule> value() { | ||
| return bandwidthLimitRules; | ||
| } | ||
| } | ||
|
|
||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please unify the
BandWidth/Bandwidthspelling. Latter is better imo.