From f6ef09f66111ff05feccf38c21fe9583549b1bfa Mon Sep 17 00:00:00 2001 From: Pramod Date: Mon, 10 Jul 2017 15:36:19 -0700 Subject: [PATCH] Adds Minimum Bandwidth Rule to the Qos Policy Qos Feature on Neutron Northbound has supported two rules initially. This patch facilitates the addition of a third rule (minimim bandwidth rule) https://specs.openstack.org/openstack/neutron-specs/specs/newton/ml2-qos-minimum-egress-bw-support.html Change-Id: Ia3681a28e01c886f6e4ab84d16cf3204e0dad709 Signed-off-by: Pramod --- .../e2etest/NeutronQosPolicyTests.java | 17 +++-- .../constants/rev150712/NeutronUtils.java | 40 +++++++++++ model/src/main/yang/neutron-constants.yang | 5 ++ model/src/main/yang/neutron-qos.yang | 19 +++++ .../spi/NeutronQosMinimumBandwidthRule.java | 69 +++++++++++++++++++ .../neutron/spi/NeutronQosPolicy.java | 19 ++++- .../neutron/spi/NeutronQosJAXBTest.java | 23 ++++++- ...orthbound_Qos_Rest.postman_collection.json | 9 +-- .../NeutronMeteringLabelRuleInterface.java | 14 +--- .../NeutronQosPolicyInterface.java | 30 ++++++++ .../NeutronSecurityRuleInterface.java | 12 +--- 11 files changed, 219 insertions(+), 38 deletions(-) create mode 100644 neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronQosMinimumBandwidthRule.java diff --git a/integration/test/src/test/java/org/opendaylight/neutron/e2etest/NeutronQosPolicyTests.java b/integration/test/src/test/java/org/opendaylight/neutron/e2etest/NeutronQosPolicyTests.java index 1c9afcf58..8684de11c 100644 --- a/integration/test/src/test/java/org/opendaylight/neutron/e2etest/NeutronQosPolicyTests.java +++ b/integration/test/src/test/java/org/opendaylight/neutron/e2etest/NeutronQosPolicyTests.java @@ -37,13 +37,16 @@ public class NeutronQosPolicyTests { public void qos_policy_modify_test() { String url = base + "/qos/policies/d6220bbb-35f3-48ab-8eae-69c60aef3546"; String content = "{\"policy\": {\"id\": \"d6220bbb-35f3-48ab-8eae-69c60aef3546\"," - + "\"tenant_id\": \"aa902936679e4ea29bfe1158e3450a13\"," + "\"name\": \"jaxb-test\", " - + "\"shared\": false," - + "\"bandwidth_limit_rules\": [ {\"id\": \"d6220bbb-35f3-48ab-8eae-69c60aef3547\"," - + "\"tenant_id\": \"aa902936679e4ea29bfe1158e3450a14\",\"max_kbps\": 25," - + "\"max_burst_kbps\": 100 } ] ," - + "\"dscp_marking_rules\": [ {\"id\": \"d6220bbb-35f3-48ab-8eae-69c60aef3547\"," - + "\"tenant_id\": \"aa902936679e4ea29bfe1158e3450a14\", " + "\"dscp_mark\": 8 } ] }}"; + + "\"tenant_id\": \"aa902936679e4ea29bfe1158e3450a13\"," + "\"name\": \"jaxb-test\", " + + "\"shared\": false," + + "\"bandwidth_limit_rules\": [ {\"id\": \"d6220bbb-35f3-48ab-8eae-69c60aef3546\"," + + "\"tenant_id\": \"aa902936679e4ea29bfe1158e3450a13\",\"max_kbps\": 25," + + "\"max_burst_kbps\": 100 } ] ," + + "\"dscp_marking_rules\": [ {\"id\": \"d6220bbb-35f3-48ab-8eae-69c60aef3546\"," + + "\"tenant_id\": \"aa902936679e4ea29bfe1158e3450a13\", " + "\"dscp_mark\": 8 } ] ," + + "\"minimum_bandwidth_rules\": [ {\"id\": \"d6220bbb-35f3-48ab-8eae-69c60aef3546\"," + + "\"tenant_id\": \"aa902936679e4ea29bfe1158e3450a13\", " + "\"min_kbps\": 20," + + "\"direction\": \"egress\" } ] }}"; ITNeutronE2E.test_modify(url, content, "Qos Policy Singleton Put failed"); } diff --git a/model/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/neutron/constants/rev150712/NeutronUtils.java b/model/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/neutron/constants/rev150712/NeutronUtils.java index f416382b1..85f507342 100644 --- a/model/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/neutron/constants/rev150712/NeutronUtils.java +++ b/model/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/neutron/constants/rev150712/NeutronUtils.java @@ -62,4 +62,44 @@ public final class NeutronUtils { return inverseMapper.get(key); } } + + // Direction of the Traffic + public static class DirectionMapper { + private DirectionMapper() { + throw new UnsupportedOperationException("Utility class should not be instantiated."); + } + + private static final ImmutableBiMap> MAPPER + = new ImmutableBiMap.Builder>() + .put("egress", DirectionEgress.class) + .put("ingress", DirectionIngress.class) + .build(); + + public static Class get(String key) { + return MAPPER.get(key); + } + + public static String getName(Class key) { + ImmutableBiMap, String> inverseMapper = MAPPER.inverse(); + return inverseMapper.get(key); + } + + private static final ImmutableBiMap> + MINIMUMBANDWIDTHRULE_MAPPER = new ImmutableBiMap.Builder>() + .put("egress", DirectionMinimumBandwidthRule.class) + .build(); + + public static Class + getMinimumBandwidthRuleDirection(String minimumBandwidthKey) { + return MINIMUMBANDWIDTHRULE_MAPPER.get(minimumBandwidthKey); + } + + public static String getMinimumBandwidthRuleDirectionString(Class + minimumBandwidthKey) { + ImmutableBiMap, String> + inverseMinimBandwidthRuleDirectionMapper = MINIMUMBANDWIDTHRULE_MAPPER.inverse(); + return inverseMinimBandwidthRuleDirectionMapper.get(minimumBandwidthKey); + } + } } diff --git a/model/src/main/yang/neutron-constants.yang b/model/src/main/yang/neutron-constants.yang index 74eea62f3..cc942bf04 100644 --- a/model/src/main/yang/neutron-constants.yang +++ b/model/src/main/yang/neutron-constants.yang @@ -115,6 +115,11 @@ module neutron-constants { } + identity direction-minimum-bandwidth-rule { + description "Direction for minimum bandwidth rule."; + base direction-base; + } + // IP VERSION identity ip-version-base { description "the base identity for ip versions"; diff --git a/model/src/main/yang/neutron-qos.yang b/model/src/main/yang/neutron-qos.yang index 746619e81..bfbc959b9 100644 --- a/model/src/main/yang/neutron-qos.yang +++ b/model/src/main/yang/neutron-qos.yang @@ -15,6 +15,7 @@ module neutron-qos { import ietf-yang-types { prefix "yang"; revision-date "2013-07-15"; } import neutron-attrs { prefix "attrs"; } + import neutron-constants { prefix "constants"; } organization "OpenDaylight Neutron Group"; @@ -63,6 +64,19 @@ module neutron-qos { } } + grouping minimumbandwidth-rule-attributes { + leaf min-kbps { + type uint64; + description "The minimum KBPS value"; + } + leaf direction { + type identityref { + base "constants:direction-minimum-bandwidth-rule"; + } + description "The traffic direction"; + } + } + grouping qos-attributes { container qos-policies { list qos-policy { @@ -79,6 +93,11 @@ module neutron-qos { uses attrs:id-attributes; uses dscpmarking-rule-attributes; } + list minimumbandwidth-rules { + key "uuid"; + uses attrs:id-attributes; + uses minimumbandwidth-rule-attributes; + } } } container qos-rule-types { diff --git a/neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronQosMinimumBandwidthRule.java b/neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronQosMinimumBandwidthRule.java new file mode 100644 index 000000000..3f7df0989 --- /dev/null +++ b/neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronQosMinimumBandwidthRule.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2017 Intel Corporation. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.neutron.spi; +import java.io.Serializable; +import java.math.BigInteger; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + + +@XmlRootElement +@XmlAccessorType(XmlAccessType.NONE) +public final class NeutronQosMinimumBandwidthRule extends NeutronObject + implements Serializable, INeutronObject { + private static final long serialVersionUID = 1L; + + @XmlElement(name = "min_kbps") + BigInteger minKbps; + + @XmlElement(defaultValue = "egress", name = "direction") + String direction; + + public BigInteger getMinKbps() { + return minKbps; + } + + public void setMinKbps(BigInteger minKbps) { + this.minKbps = minKbps; + } + + public String getDirection() { + return direction; + } + + public void setDirection(String direction) { + this.direction = direction; + } + + @Override + public boolean extractField(String field, NeutronQosMinimumBandwidthRule ans) { + switch (field) { + case "min_kbps": + ans.setMinKbps(this.getMinKbps()); + break; + case "direction": + ans.setDirection(this.getDirection()); + break; + default: + return super.extractField(field, ans); + } + return true; + } + + @Override + public String toString() { + return "qosMinimumBandwidthRules{" + "qosMinimumBandwidthRuleUUID='" + uuid + '\'' + "," + + " qosMinimumBandwidthRuleTenantID='" + tenantID + + '\'' + ", qosMinimumBandwidthMinValue='" + minKbps + + '\'' + ", qosMinimumBandwidthDirection='" + direction + '\'' + + '}'; + } +} \ No newline at end of file diff --git a/neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronQosPolicy.java b/neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronQosPolicy.java index 46478e618..97965796c 100644 --- a/neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronQosPolicy.java +++ b/neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronQosPolicy.java @@ -30,6 +30,9 @@ public final class NeutronQosPolicy extends NeutronBaseAttributes dscpMarkingRules; + @XmlElement(name = "minimum_bandwidth_rules") + List minimumBandwidthRules; + public Boolean getPolicyIsShared() { return shared; } @@ -54,6 +57,14 @@ public final class NeutronQosPolicy extends NeutronBaseAttributes getMinimumBandwidthRules() { + return minimumBandwidthRules; + } + + public void setMinimumBandwidthRules(List qosMinimumBandwidthRules) { + this.minimumBandwidthRules = qosMinimumBandwidthRules; + } + @Override protected boolean extractField(String field, NeutronQosPolicy ans) { switch (field) { @@ -70,6 +81,11 @@ public final class NeutronQosPolicy extends NeutronBaseAttributes qosMinimumBandwidthRuleList = new ArrayList<>(); + qosMinimumBandwidthRuleList.addAll(this.getMinimumBandwidthRules()); + ans.setMinimumBandwidthRules(qosMinimumBandwidthRuleList); + break; default: return super.extractField(field, ans); } @@ -81,8 +97,7 @@ public final class NeutronQosPolicy extends NeutronBaseAttributes minBandwidthLimitRules = neutronObject.getMinimumBandwidthRules(); + + Assert.assertEquals("NeutronQosPolicy JAXB Test 7.0: Testing Bandwidth Policy length failed", 1, + minBandwidthLimitRules.size()); + + Assert.assertEquals("NeutronQosPolicy JaxB Test 7.2 : Testing Tenant ID failed", + "aa902936679e4ea29bfe1158e3450a14", minBandwidthLimitRules.get(0).tenantID); + + Assert.assertEquals("NeutronQosPolicy JaxB Test 7.3 : Testing Minimum Bandwidth failed", + new BigInteger("20"), minBandwidthLimitRules.get(0).minKbps); + + Assert.assertEquals("NeutronQosPolicy JaxB Test 7.4 : Testing Direction failed", "egress", + minBandwidthLimitRules.get(0).direction); } } diff --git a/resources/Neutron_Northbound_Qos_Rest.postman_collection.json b/resources/Neutron_Northbound_Qos_Rest.postman_collection.json index 02d2bba2c..3f00b6dec 100644 --- a/resources/Neutron_Northbound_Qos_Rest.postman_collection.json +++ b/resources/Neutron_Northbound_Qos_Rest.postman_collection.json @@ -2,7 +2,7 @@ "variables": [], "info": { "name": "Quality_Of_Service", - "_postman_id": "27c8c2eb-995a-b9a2-4a82-af222f6a9806", + "_postman_id": "a85eb530-aab5-a5fd-f5e1-90efc89b76df", "description": "", "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json" }, @@ -71,7 +71,7 @@ ], "body": { "mode": "raw", - "raw": "{\"policy\": {\"id\": \"d6220bbb-35f3-48ab-8eae-69c60aef3546\",\n \"tenant_id\": \"aa902936679e4ea29bfe1158e3450a14\",\n \"name\" : \"qos-test\",\n \"shared\": false,\n \"bandwidth_limit_rules\": [ {\"id\": \"d6220bbb-35f3-48ab-8eae-69c60aef3547\",\n \"tenant_id\": \"aa902936679e4ea29bfe1158e3450a14\",\"max_kbps\": 25,\n \"max_burst_kbps\": 100 } ] ,\n \"dscp_marking_rules\" : [ {\"id\":\"d6220bbb-35f3-48ab-8eae-69c60aef3548\",\n \"tenant_id\": \"aa902936679e4ea29bfe1158e3450a14\",\n \"dscp_mark\": 8 } ] }}\n" + "raw": "{\"policy\": {\"id\": \"d6220bbb-35f3-48ab-8eae-69c60aef3546\",\n \"tenant_id\": \"aa902936679e4ea29bfe1158e3450a14\",\n \"name\" : \"qos-test\",\n \"shared\": false,\n \"bandwidth_limit_rules\": [ {\"id\": \"d6220bbb-35f3-48ab-8eae-69c60aef3547\",\n \"tenant_id\": \"aa902936679e4ea29bfe1158e3450a14\",\"max_kbps\": 25,\n \"max_burst_kbps\": 100 } ] ,\n \"dscp_marking_rules\" : [ {\"id\":\"d6220bbb-35f3-48ab-8eae-69c60aef3548\",\n \"tenant_id\": \"aa902936679e4ea29bfe1158e3450a14\",\n \"dscp_mark\": 8 } ] ,\n \"minimum_bandwidth_rules\": [ {\"id\": \"d6220bbb-35f3-48ab-8eae-69c60aef3549\",\n \"tenant_id\": \"aa902936679e4ea29bfe1158e3450a14\",\"min_kbps\": 25,\n \"direction\": \"egress" } ] }}\n" }, "description": "Update a QOS Policy" }, @@ -89,10 +89,7 @@ "description": "" } ], - "body": { - "mode": "formdata", - "formdata": [] - }, + "body": {}, "description": "View the existing QOS policy" }, "response": [] diff --git a/transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronMeteringLabelRuleInterface.java b/transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronMeteringLabelRuleInterface.java index ccfabb53a..3154b47d1 100644 --- a/transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronMeteringLabelRuleInterface.java +++ b/transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronMeteringLabelRuleInterface.java @@ -8,15 +8,12 @@ package org.opendaylight.neutron.transcriber; -import com.google.common.collect.ImmutableBiMap; import java.util.List; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.neutron.spi.INeutronMeteringLabelRuleCRUD; import org.opendaylight.neutron.spi.NeutronMeteringLabelRule; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix; -import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.DirectionBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.DirectionEgress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.DirectionIngress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.NeutronUtils.DirectionMapper; import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.metering.rev150712.metering.rules.attributes.MeteringRules; import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.metering.rev150712.metering.rules.attributes.metering.rules.MeteringRule; import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.metering.rev150712.metering.rules.attributes.metering.rules.MeteringRuleBuilder; @@ -25,10 +22,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.metering.rev150712. public final class NeutronMeteringLabelRuleInterface extends AbstractNeutronInterface implements INeutronMeteringLabelRuleCRUD { - private static final ImmutableBiMap, - String> DIRECTION_MAP = new ImmutableBiMap.Builder, String>() - .put(DirectionEgress.class, "egress").put(DirectionIngress.class, "ingress").build(); - NeutronMeteringLabelRuleInterface(DataBroker db) { super(MeteringRuleBuilder.class, db); } @@ -47,9 +40,8 @@ public final class NeutronMeteringLabelRuleInterface meteringRuleBuilder.setMeteringLabelId(toUuid(meteringLabelRule.getMeteringLabelRuleLabelID())); } if (meteringLabelRule.getMeteringLabelRuleDirection() != null) { - final ImmutableBiMap> mapper = DIRECTION_MAP.inverse(); meteringRuleBuilder.setDirection( - mapper.get(meteringLabelRule.getMeteringLabelRuleDirection())); + DirectionMapper.get(meteringLabelRule.getMeteringLabelRuleDirection())); } if (meteringLabelRule.getMeteringLabelRuleRemoteIpPrefix() != null) { final IpPrefix ipPrefix = new IpPrefix( @@ -68,7 +60,7 @@ public final class NeutronMeteringLabelRuleInterface answer.setMeteringLabelRuleLabelID(rule.getMeteringLabelId().getValue()); } if (rule.getDirection() != null) { - answer.setMeteringLabelRuleDirection(DIRECTION_MAP.get(rule.getDirection())); + answer.setMeteringLabelRuleDirection(DirectionMapper.getName(rule.getDirection())); } if (rule.getRemoteIpPrefix() != null) { answer.setMeteringLabelRuleRemoteIpPrefix(new String(rule.getRemoteIpPrefix().getValue())); diff --git a/transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronQosPolicyInterface.java b/transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronQosPolicyInterface.java index 9699df0af..4c89de6d1 100644 --- a/transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronQosPolicyInterface.java +++ b/transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronQosPolicyInterface.java @@ -14,7 +14,9 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.neutron.spi.INeutronQosPolicyCRUD; import org.opendaylight.neutron.spi.NeutronQosBandwidthLimitRule; import org.opendaylight.neutron.spi.NeutronQosDscpMarkingRule; +import org.opendaylight.neutron.spi.NeutronQosMinimumBandwidthRule; import org.opendaylight.neutron.spi.NeutronQosPolicy; +import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.NeutronUtils.DirectionMapper; import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.QosPolicies; import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.QosPolicy; import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.QosPolicyBuilder; @@ -23,6 +25,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.a import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.qos.policy.BandwidthLimitRulesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.qos.policy.DscpmarkingRules; import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.qos.policy.DscpmarkingRulesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.qos.policy.MinimumbandwidthRules; +import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.qos.policy.MinimumbandwidthRulesBuilder; public final class NeutronQosPolicyInterface extends AbstractNeutronInterface @@ -65,6 +69,20 @@ public final class NeutronQosPolicyInterface } qosPolicyBuilder.setDscpmarkingRules(listDscpMarking); } + if (qosPolicy.getMinimumBandwidthRules() != null) { + final List listMinimumBandwidth = new ArrayList<>(); + for (final NeutronQosMinimumBandwidthRule minimumBandwidthRule : qosPolicy.getMinimumBandwidthRules()) { + final MinimumbandwidthRulesBuilder minimumBandwidthRulesBuilder = + new MinimumbandwidthRulesBuilder(); + minimumBandwidthRulesBuilder.setUuid(toUuid(minimumBandwidthRule.getID())); + minimumBandwidthRulesBuilder.setTenantId(toUuid(minimumBandwidthRule.getTenantID())); + minimumBandwidthRulesBuilder.setMinKbps(minimumBandwidthRule.getMinKbps()); + minimumBandwidthRulesBuilder.setDirection(DirectionMapper.getMinimumBandwidthRuleDirection( + minimumBandwidthRule.getDirection())); + listMinimumBandwidth.add(minimumBandwidthRulesBuilder.build()); + } + qosPolicyBuilder.setMinimumbandwidthRules(listMinimumBandwidth); + } return qosPolicyBuilder.build(); } @@ -94,6 +112,18 @@ public final class NeutronQosPolicyInterface } result.setDscpMarkingRules(dscpMarkingRules); } + if (qosPolicy.getMinimumbandwidthRules() != null) { + final List minimumBandwidthRules = new ArrayList<>(); + for (final MinimumbandwidthRules rule : qosPolicy.getMinimumbandwidthRules()) { + NeutronQosMinimumBandwidthRule opt = new NeutronQosMinimumBandwidthRule(); + opt.setID(rule.getTenantId().getValue()); + opt.setTenantID(rule.getTenantId().getValue()); + opt.setMinKbps(rule.getMinKbps()); + opt.setDirection(DirectionMapper.getMinimumBandwidthRuleDirectionString(rule.getDirection())); + minimumBandwidthRules.add(opt); + } + result.setMinimumBandwidthRules(minimumBandwidthRules); + } return result; } } diff --git a/transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronSecurityRuleInterface.java b/transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronSecurityRuleInterface.java index ac5a5d391..4808007bb 100644 --- a/transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronSecurityRuleInterface.java +++ b/transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronSecurityRuleInterface.java @@ -15,12 +15,10 @@ import org.opendaylight.neutron.northbound.api.BadRequestException; import org.opendaylight.neutron.spi.INeutronSecurityRuleCRUD; import org.opendaylight.neutron.spi.NeutronSecurityRule; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix; -import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.DirectionBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.DirectionEgress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.DirectionIngress; import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.EthertypeBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.EthertypeV4; import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.EthertypeV6; +import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.NeutronUtils.DirectionMapper; import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.NeutronUtils.ProtocolMapper; import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.SecurityRuleAttributes.Protocol; import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.rules.attributes.SecurityRules; @@ -35,9 +33,6 @@ public final class NeutronSecurityRuleInterface extends implements INeutronSecurityRuleCRUD { private static final Logger LOG = LoggerFactory.getLogger(NeutronSecurityRuleInterface.class); - private static final ImmutableBiMap, - String> DIRECTION_MAP = new ImmutableBiMap.Builder, String>() - .put(DirectionEgress.class, "egress").put(DirectionIngress.class, "ingress").build(); private static final ImmutableBiMap, String> ETHERTYPE_MAP = new ImmutableBiMap.Builder, String>() .put(EthertypeV4.class, "IPv4").put(EthertypeV6.class, "IPv6").build(); @@ -56,7 +51,7 @@ public final class NeutronSecurityRuleInterface extends final NeutronSecurityRule answer = new NeutronSecurityRule(); fromMdIds(rule, answer); if (rule.getDirection() != null) { - answer.setSecurityRuleDirection(DIRECTION_MAP.get(rule.getDirection())); + answer.setSecurityRuleDirection(DirectionMapper.getName(rule.getDirection())); } if (rule.getSecurityGroupId() != null) { answer.setSecurityRuleGroupID(rule.getSecurityGroupId().getValue()); @@ -95,9 +90,8 @@ public final class NeutronSecurityRuleInterface extends final SecurityRuleBuilder securityRuleBuilder = new SecurityRuleBuilder(); toMdIds(securityRule, securityRuleBuilder); if (securityRule.getSecurityRuleDirection() != null) { - final ImmutableBiMap> mapper = DIRECTION_MAP.inverse(); securityRuleBuilder - .setDirection(mapper.get(securityRule.getSecurityRuleDirection())); + .setDirection(DirectionMapper.get(securityRule.getSecurityRuleDirection())); } if (securityRule.getSecurityRuleGroupID() != null) { securityRuleBuilder.setSecurityGroupId(toUuid(securityRule.getSecurityRuleGroupID())); -- 2.36.6