From c428881044008b3865c8e934dd53240b43c084f1 Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Fri, 29 Jun 2018 14:36:59 +0200 Subject: HC2VPP-348: use vpp-fib-management module instead of FIB table index Change-Id: Iba1f6d4c556c8ef839eb309b990f32945e6494fb Signed-off-by: Marek Gradzki --- dhcp/dhcp-api/pom.xml | 5 + dhcp/dhcp-api/src/main/yang/dhcp@2018-01-03.yang | 115 --------------------- dhcp/dhcp-api/src/main/yang/dhcp@2018-06-29.yang | 104 +++++++++++++++++++ .../io/fd/hc2vpp/dhcp/read/DhcpReaderFactory.java | 12 +-- .../fd/hc2vpp/dhcp/read/DhcpRelayCustomizer.java | 23 +++-- .../fd/hc2vpp/dhcp/write/DhcpRelayCustomizer.java | 12 +-- .../io/fd/hc2vpp/dhcp/write/DhcpWriterFactory.java | 8 +- .../dhcp/helpers/SchemaContextTestHelper.java | 2 +- .../hc2vpp/dhcp/read/DhcpRelayCustomizerTest.java | 27 ++--- .../hc2vpp/dhcp/write/DhcpRelayCustomizerTest.java | 19 ++-- .../src/test/resources/relay/ipv4DhcpRelay.json | 2 +- .../test/resources/relay/ipv6DhcpRelayAfter.json | 2 +- .../test/resources/relay/ipv6DhcpRelayBefore.json | 2 +- dhcp/dhcp_postman_collection.json | 32 +++--- 14 files changed, 177 insertions(+), 188 deletions(-) delete mode 100644 dhcp/dhcp-api/src/main/yang/dhcp@2018-01-03.yang create mode 100644 dhcp/dhcp-api/src/main/yang/dhcp@2018-06-29.yang diff --git a/dhcp/dhcp-api/pom.xml b/dhcp/dhcp-api/pom.xml index dce4cf1ab..c9c1668b3 100644 --- a/dhcp/dhcp-api/pom.xml +++ b/dhcp/dhcp-api/pom.xml @@ -48,5 +48,10 @@ org.opendaylight.mdsal.model yang-ext + + io.fd.hc2vpp.fib.management + fib-management-api + ${project.version} + diff --git a/dhcp/dhcp-api/src/main/yang/dhcp@2018-01-03.yang b/dhcp/dhcp-api/src/main/yang/dhcp@2018-01-03.yang deleted file mode 100644 index 8ce48edc9..000000000 --- a/dhcp/dhcp-api/src/main/yang/dhcp@2018-01-03.yang +++ /dev/null @@ -1,115 +0,0 @@ -module dhcp { - yang-version 1; - namespace "urn:opendaylight:params:xml:ns:yang:vpp:dhcp"; - prefix "dhcp"; - - import ietf-inet-types { - prefix inet; - } - - organization - "FD.io - The Fast Data Project"; - - contact - "Hc2vpp Wiki - Mailing List "; - - description - "This module contains a collection of YANG definitions for - managing DHCP in VPP. - - Copyright (c) 2017-2018 Cisco and/or its affiliates. - - Licensed under the Apache License, Version 2.0 (the 'License'); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at: - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an 'AS IS' BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License."; - - revision "2018-01-03" { - description - "Changes type of ip-addresses from inet:ip-address to inet:ip-address-no-zone."; - reference - "https://jira.fd.io/browse/HC2VPP-79"; - } - - revision "2017-03-15" { - description - "Initial revision of dhcp model"; - } - - identity address-family { - description - "Base identity from which identities describing address - families are derived."; - } - - identity ipv4 { - base address-family; - description - "This identity represents IPv4 address family."; - } - - identity ipv6 { - base address-family; - description - "This identity represents IPv6 address family."; - } - - typedef address-type { - type identityref { - base address-family; - } - } - - grouping relay-attributes { - list server { - key "vrf-id address"; - leaf address { - type inet:ip-address-no-zone; - description - "IP address of the server DHCP packets will be forwarded to."; - } - leaf vrf-id { - type uint32; - description - "Used to send DHCP messages to the server"; - } - } - - leaf gateway-address { - type inet:ip-address-no-zone; - mandatory true; - description - "IP address of the relay agent."; - } - // TODO(HC2VPP-44): add configurable circut-id (option-82/remote-id) - } - - grouping dhcp-attributes { - container relays { - list relay { - key "address-type rx-vrf-id"; - leaf address-type { - type address-type; - } - leaf rx-vrf-id { - type uint32; - description - "Used to receive DHCP messages from clients."; - } - uses relay-attributes; - } - } - } - - container dhcp { - uses dhcp-attributes; - } -} \ No newline at end of file diff --git a/dhcp/dhcp-api/src/main/yang/dhcp@2018-06-29.yang b/dhcp/dhcp-api/src/main/yang/dhcp@2018-06-29.yang new file mode 100644 index 000000000..a6bd4e3da --- /dev/null +++ b/dhcp/dhcp-api/src/main/yang/dhcp@2018-06-29.yang @@ -0,0 +1,104 @@ +module dhcp { + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:vpp:dhcp"; + prefix "dhcp"; + + import ietf-inet-types { + prefix inet; + } + + import vpp-fib-table-management { + prefix fib-management; + revision-date 2018-05-21; + } + + + organization + "FD.io - The Fast Data Project"; + + contact + "Hc2vpp Wiki + Mailing List "; + + description + "This module contains a collection of YANG definitions for + managing DHCP in VPP. + + Copyright (c) 2017-2018 Cisco and/or its affiliates. + + Licensed under the Apache License, Version 2.0 (the 'License'); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at: + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an 'AS IS' BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License."; + + revision "2018-06-29" { + description + "Uses references to vrf-management module insted of table identifiers."; + reference + "https://jira.fd.io/browse/HC2VPP-317"; + } + + revision "2018-01-03" { + description + "Changes type of ip-addresses from inet:ip-address to inet:ip-address-no-zone."; + reference + "https://jira.fd.io/browse/HC2VPP-79"; + } + + revision "2017-03-15" { + description + "Initial revision of dhcp model"; + } + + grouping relay-attributes { + list server { + key "vrf-id address"; + leaf address { + type inet:ip-address-no-zone; + description + "IP address of the server DHCP packets will be forwarded to."; + } + leaf vrf-id { + type uint32; + description + "Used to send DHCP messages to the server"; + } + } + + leaf gateway-address { + type inet:ip-address-no-zone; + mandatory true; + description + "IP address of the relay agent."; + } + // TODO(HC2VPP-44): add configurable circut-id (option-82/remote-id) + } + + grouping dhcp-attributes { + container relays { + list relay { + key "address-family rx-vrf-id"; + leaf address-family { + type fib-management:address-family-type; + } + leaf rx-vrf-id { + type fib-management:fib-table-list-ref; + description + "VRF used to receive DHCP messages from clients."; + } + uses relay-attributes; + } + } + } + + container dhcp { + uses dhcp-attributes; + } +} \ No newline at end of file diff --git a/dhcp/dhcp-impl/src/main/java/io/fd/hc2vpp/dhcp/read/DhcpReaderFactory.java b/dhcp/dhcp-impl/src/main/java/io/fd/hc2vpp/dhcp/read/DhcpReaderFactory.java index 83b737057..f2f02efef 100644 --- a/dhcp/dhcp-impl/src/main/java/io/fd/hc2vpp/dhcp/read/DhcpReaderFactory.java +++ b/dhcp/dhcp-impl/src/main/java/io/fd/hc2vpp/dhcp/read/DhcpReaderFactory.java @@ -23,12 +23,12 @@ import io.fd.honeycomb.translate.read.ReaderFactory; import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder; import io.fd.vpp.jvpp.core.future.FutureJVppCore; import javax.annotation.Nonnull; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180103.Dhcp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180103.DhcpBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180103.dhcp.attributes.Relays; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180103.dhcp.attributes.RelaysBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180103.dhcp.attributes.relays.Relay; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180103.relay.attributes.Server; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180629.Dhcp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180629.DhcpBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180629.dhcp.attributes.Relays; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180629.dhcp.attributes.RelaysBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180629.dhcp.attributes.relays.Relay; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180629.relay.attributes.Server; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; /** diff --git a/dhcp/dhcp-impl/src/main/java/io/fd/hc2vpp/dhcp/read/DhcpRelayCustomizer.java b/dhcp/dhcp-impl/src/main/java/io/fd/hc2vpp/dhcp/read/DhcpRelayCustomizer.java index e055a2b36..064133453 100644 --- a/dhcp/dhcp-impl/src/main/java/io/fd/hc2vpp/dhcp/read/DhcpRelayCustomizer.java +++ b/dhcp/dhcp-impl/src/main/java/io/fd/hc2vpp/dhcp/read/DhcpRelayCustomizer.java @@ -40,13 +40,14 @@ import java.util.concurrent.CompletionStage; import java.util.stream.Collectors; import javax.annotation.Nonnull; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180103.Ipv4; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180103.Ipv6; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180103.dhcp.attributes.RelaysBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180103.dhcp.attributes.relays.Relay; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180103.dhcp.attributes.relays.RelayBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180103.dhcp.attributes.relays.RelayKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180103.relay.attributes.ServerBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180629.dhcp.attributes.RelaysBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180629.dhcp.attributes.relays.Relay; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180629.dhcp.attributes.relays.RelayBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180629.dhcp.attributes.relays.RelayKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180629.relay.attributes.ServerBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.fib.table.management.rev180521.Ipv4; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.fib.table.management.rev180521.Ipv6; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.fib.table.management.rev180521.VniReference; import org.opendaylight.yangtools.concepts.Builder; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; @@ -96,7 +97,7 @@ final class DhcpRelayCustomizer extends FutureJVppCustomizer return dump.get().dhcpProxyDetails.stream().map(detail -> new RelayKey(detail.isIpv6 == 1 ? Ipv6.class : Ipv4.class, - UnsignedInts.toLong(detail.rxVrfId))).collect(Collectors.toList()); + new VniReference(UnsignedInts.toLong(detail.rxVrfId)))).collect(Collectors.toList()); } @Override @@ -121,17 +122,17 @@ final class DhcpRelayCustomizer extends FutureJVppCustomizer final RelayKey key = id.firstKeyOf(Relay.class); - final byte isIpv6 = (byte) (Ipv6.class == key.getAddressType() + final byte isIpv6 = (byte) (Ipv6.class == key.getAddressFamily() ? 1 : 0); - final int rxVrfId = key.getRxVrfId().intValue(); + final int rxVrfId = key.getRxVrfId().getValue().intValue(); final java.util.Optional result = dump.get().dhcpProxyDetails.stream().filter(d -> d.isIpv6 == isIpv6 && d.rxVrfId == rxVrfId).findFirst(); if (result.isPresent()) { final DhcpProxyDetails detail = result.get(); - builder.setAddressType(key.getAddressType()); + builder.setAddressFamily(key.getAddressFamily()); builder.setRxVrfId(key.getRxVrfId()); final boolean isIp6 = byteToBoolean(detail.isIpv6); builder.setGatewayAddress(readAddress(detail.dhcpSrcAddress, isIp6)); diff --git a/dhcp/dhcp-impl/src/main/java/io/fd/hc2vpp/dhcp/write/DhcpRelayCustomizer.java b/dhcp/dhcp-impl/src/main/java/io/fd/hc2vpp/dhcp/write/DhcpRelayCustomizer.java index a506f72f1..46ab48db1 100644 --- a/dhcp/dhcp-impl/src/main/java/io/fd/hc2vpp/dhcp/write/DhcpRelayCustomizer.java +++ b/dhcp/dhcp-impl/src/main/java/io/fd/hc2vpp/dhcp/write/DhcpRelayCustomizer.java @@ -31,10 +31,10 @@ import io.fd.vpp.jvpp.core.future.FutureJVppCore; import java.util.List; import javax.annotation.Nonnull; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180103.Ipv6; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180103.dhcp.attributes.relays.Relay; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180103.dhcp.attributes.relays.RelayKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180103.relay.attributes.Server; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180629.dhcp.attributes.relays.Relay; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180629.dhcp.attributes.relays.RelayKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180629.relay.attributes.Server; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.fib.table.management.rev180521.Ipv6; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -98,8 +98,8 @@ final class DhcpRelayCustomizer extends FutureJVppCustomizer implements ListWrit final boolean isAdd) throws WriteFailedException { final DhcpProxyConfig request = new DhcpProxyConfig(); - request.rxVrfId = relay.getRxVrfId().byteValue(); - final boolean isIpv6 = Ipv6.class == relay.getAddressType(); + request.rxVrfId = relay.getRxVrfId().getValue().byteValue(); + final boolean isIpv6 = Ipv6.class == relay.getAddressFamily(); request.isIpv6 = booleanToByte(isIpv6); request.serverVrfId = server.getVrfId().intValue(); request.isAdd = booleanToByte(isAdd); diff --git a/dhcp/dhcp-impl/src/main/java/io/fd/hc2vpp/dhcp/write/DhcpWriterFactory.java b/dhcp/dhcp-impl/src/main/java/io/fd/hc2vpp/dhcp/write/DhcpWriterFactory.java index e69449811..4ee5cbc92 100644 --- a/dhcp/dhcp-impl/src/main/java/io/fd/hc2vpp/dhcp/write/DhcpWriterFactory.java +++ b/dhcp/dhcp-impl/src/main/java/io/fd/hc2vpp/dhcp/write/DhcpWriterFactory.java @@ -23,10 +23,10 @@ import io.fd.honeycomb.translate.write.WriterFactory; import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder; import io.fd.vpp.jvpp.core.future.FutureJVppCore; import javax.annotation.Nonnull; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180103.Dhcp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180103.dhcp.attributes.Relays; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180103.dhcp.attributes.relays.Relay; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180103.relay.attributes.Server; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180629.Dhcp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180629.dhcp.attributes.Relays; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180629.dhcp.attributes.relays.Relay; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180629.relay.attributes.Server; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; /** diff --git a/dhcp/dhcp-impl/src/test/java/io/fd/hc2vpp/dhcp/helpers/SchemaContextTestHelper.java b/dhcp/dhcp-impl/src/test/java/io/fd/hc2vpp/dhcp/helpers/SchemaContextTestHelper.java index bb417eef1..3c1cdadeb 100644 --- a/dhcp/dhcp-impl/src/test/java/io/fd/hc2vpp/dhcp/helpers/SchemaContextTestHelper.java +++ b/dhcp/dhcp-impl/src/test/java/io/fd/hc2vpp/dhcp/helpers/SchemaContextTestHelper.java @@ -27,7 +27,7 @@ public interface SchemaContextTestHelper extends InjectablesProcessor { default ModuleInfoBackedContext getSchemaContext() { return provideSchemaContextFor(ImmutableSet.of( // dhcp - org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180103.$YangModuleInfoImpl + org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180629.$YangModuleInfoImpl .getInstance() )); } diff --git a/dhcp/dhcp-impl/src/test/java/io/fd/hc2vpp/dhcp/read/DhcpRelayCustomizerTest.java b/dhcp/dhcp-impl/src/test/java/io/fd/hc2vpp/dhcp/read/DhcpRelayCustomizerTest.java index 904a2a208..500063d5a 100644 --- a/dhcp/dhcp-impl/src/test/java/io/fd/hc2vpp/dhcp/read/DhcpRelayCustomizerTest.java +++ b/dhcp/dhcp-impl/src/test/java/io/fd/hc2vpp/dhcp/read/DhcpRelayCustomizerTest.java @@ -31,24 +31,25 @@ import io.fd.vpp.jvpp.core.dto.DhcpProxyDump; import io.fd.vpp.jvpp.core.types.DhcpServer; import java.util.List; import org.junit.Test; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180103.Dhcp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180103.Ipv4; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180103.Ipv6; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180103.dhcp.attributes.Relays; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180103.dhcp.attributes.RelaysBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180103.dhcp.attributes.relays.Relay; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180103.dhcp.attributes.relays.RelayBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180103.dhcp.attributes.relays.RelayKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180103.relay.attributes.Server; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180629.Dhcp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180629.dhcp.attributes.Relays; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180629.dhcp.attributes.RelaysBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180629.dhcp.attributes.relays.Relay; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180629.dhcp.attributes.relays.RelayBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180629.dhcp.attributes.relays.RelayKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180629.relay.attributes.Server; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.fib.table.management.rev180521.Ipv4; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.fib.table.management.rev180521.Ipv6; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.fib.table.management.rev180521.VniReference; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; public class DhcpRelayCustomizerTest extends InitializingListReaderCustomizerTest { private static InstanceIdentifier RELAYS = InstanceIdentifier.create(Dhcp.class).child(Relays.class); private KeyedInstanceIdentifier IP4_IID = - RELAYS.child(Relay.class, new RelayKey(Ipv4.class, 123L)); + RELAYS.child(Relay.class, new RelayKey(Ipv4.class, new VniReference(123L))); private KeyedInstanceIdentifier IP6_IID = - RELAYS.child(Relay.class, new RelayKey(Ipv6.class, 321L)); + RELAYS.child(Relay.class, new RelayKey(Ipv6.class, new VniReference(321L))); public DhcpRelayCustomizerTest() { super(Relay.class, RelaysBuilder.class); } @@ -104,7 +105,7 @@ public class DhcpRelayCustomizerTest extends InitializingListReaderCustomizerTes public void testReadIp4() throws ReadFailedException { final RelayBuilder builder = new RelayBuilder(); getCustomizer().readCurrentAttributes(IP4_IID, builder, ctx); - assertEquals(IP4_IID.getKey().getAddressType(), builder.getAddressType()); + assertEquals(IP4_IID.getKey().getAddressFamily(), builder.getAddressFamily()); assertEquals(IP4_IID.getKey().getRxVrfId(), builder.getRxVrfId()); assertArrayEquals("1.2.3.4".toCharArray(), builder.getGatewayAddress().getValue()); final List server = builder.getServer(); @@ -119,7 +120,7 @@ public class DhcpRelayCustomizerTest extends InitializingListReaderCustomizerTes public void testReadIp6() throws ReadFailedException { final RelayBuilder builder = new RelayBuilder(); getCustomizer().readCurrentAttributes(IP6_IID, builder, ctx); - assertEquals(IP6_IID.getKey().getAddressType(), builder.getAddressType()); + assertEquals(IP6_IID.getKey().getAddressFamily(), builder.getAddressFamily()); assertEquals(IP6_IID.getKey().getRxVrfId(), builder.getRxVrfId()); assertEquals(22L, builder.getServer().get(0).getVrfId().longValue()); assertArrayEquals("2001:db8:a0b:12f0::1".toCharArray(), builder.getGatewayAddress().getValue()); diff --git a/dhcp/dhcp-impl/src/test/java/io/fd/hc2vpp/dhcp/write/DhcpRelayCustomizerTest.java b/dhcp/dhcp-impl/src/test/java/io/fd/hc2vpp/dhcp/write/DhcpRelayCustomizerTest.java index 29ceb43f9..4e4e02f35 100644 --- a/dhcp/dhcp-impl/src/test/java/io/fd/hc2vpp/dhcp/write/DhcpRelayCustomizerTest.java +++ b/dhcp/dhcp-impl/src/test/java/io/fd/hc2vpp/dhcp/write/DhcpRelayCustomizerTest.java @@ -29,13 +29,14 @@ import io.fd.vpp.jvpp.core.dto.DhcpProxyConfig; import io.fd.vpp.jvpp.core.dto.DhcpProxyConfigReply; import org.junit.Test; import org.junit.runner.RunWith; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180103.AddressFamily; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180103.Dhcp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180103.Ipv4; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180103.Ipv6; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180103.dhcp.attributes.Relays; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180103.dhcp.attributes.relays.Relay; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180103.dhcp.attributes.relays.RelayKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180629.Dhcp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180629.dhcp.attributes.Relays; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180629.dhcp.attributes.relays.Relay; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev180629.dhcp.attributes.relays.RelayKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.fib.table.management.rev180521.AddressFamilyIdentity; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.fib.table.management.rev180521.Ipv4; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.fib.table.management.rev180521.Ipv6; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.fib.table.management.rev180521.VniReference; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; @RunWith(HoneycombTestRunner.class) @@ -106,7 +107,7 @@ public class DhcpRelayCustomizerTest extends WriterCustomizerTest implements Sch verify(api).dhcpProxyConfig(request); } - private InstanceIdentifier getId(final long rxVrfId, final Class addressType) { - return RELAYS_IID.child(Relay.class, new RelayKey(addressType, rxVrfId)); + private InstanceIdentifier getId(final long rxVrfId, final Class addressType) { + return RELAYS_IID.child(Relay.class, new RelayKey(addressType, new VniReference(rxVrfId))); } } \ No newline at end of file diff --git a/dhcp/dhcp-impl/src/test/resources/relay/ipv4DhcpRelay.json b/dhcp/dhcp-impl/src/test/resources/relay/ipv4DhcpRelay.json index 2c7dda289..6d7ca6392 100644 --- a/dhcp/dhcp-impl/src/test/resources/relay/ipv4DhcpRelay.json +++ b/dhcp/dhcp-impl/src/test/resources/relay/ipv4DhcpRelay.json @@ -2,7 +2,7 @@ "relays": { "relay": [ { - "address-type": "ipv4", + "address-family": "vpp-fib-table-management:ipv4", "rx-vrf-id": 0, "gateway-address": "5.6.7.8", "server" : [ diff --git a/dhcp/dhcp-impl/src/test/resources/relay/ipv6DhcpRelayAfter.json b/dhcp/dhcp-impl/src/test/resources/relay/ipv6DhcpRelayAfter.json index 7c2518b54..c1ebc52ec 100644 --- a/dhcp/dhcp-impl/src/test/resources/relay/ipv6DhcpRelayAfter.json +++ b/dhcp/dhcp-impl/src/test/resources/relay/ipv6DhcpRelayAfter.json @@ -2,7 +2,7 @@ "relays": { "relay": [ { - "address-type": "ipv6", + "address-family": "vpp-fib-table-management:ipv6", "rx-vrf-id": 1, "gateway-address": "2001::2", "server" : [ diff --git a/dhcp/dhcp-impl/src/test/resources/relay/ipv6DhcpRelayBefore.json b/dhcp/dhcp-impl/src/test/resources/relay/ipv6DhcpRelayBefore.json index 94f7c6558..149a6e83e 100644 --- a/dhcp/dhcp-impl/src/test/resources/relay/ipv6DhcpRelayBefore.json +++ b/dhcp/dhcp-impl/src/test/resources/relay/ipv6DhcpRelayBefore.json @@ -2,7 +2,7 @@ "relays": { "relay": [ { - "address-type": "ipv6", + "address-family": "vpp-fib-table-management:ipv6", "rx-vrf-id": 1, "gateway-address": "2001::2", "server" : [ diff --git a/dhcp/dhcp_postman_collection.json b/dhcp/dhcp_postman_collection.json index e140d6d26..ec12607ea 100644 --- a/dhcp/dhcp_postman_collection.json +++ b/dhcp/dhcp_postman_collection.json @@ -1,13 +1,12 @@ { "info": { - "_postman_id": "f5441117-e55c-ba3b-6673-aaa6d383e33c", + "_postman_id": "7053d779-442a-4ec9-bee0-70784789f19c", "name": "DHCP", "description": "Provides DHCP configuration examples for hc2vpp.", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" }, "item": [ { - "_postman_id": "92a6f186-c4ea-4781-85a5-2b9c79884349", "name": "Add IP4 DHCP Relay #1", "request": { "method": "PUT", @@ -23,10 +22,10 @@ ], "body": { "mode": "raw", - "raw": "{\n\t\"relay\": [\n\t\t{\n\t\t\t\"address-type\": \"ipv4\",\n\t\t\t\"rx-vrf-id\": 0,\n\t\t\t\"gateway-address\": \"5.6.7.8\",\n\t\t\t\"server\" : [\n\t\t\t\t{\n\t\t\t\t\t\"vrf-id\": 0,\n\t\t\t\t\t\"address\": \"1.2.3.3\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"vrf-id\": 0,\n\t\t\t\t\t\"address\": \"1.2.3.4\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"vrf-id\": 1,\n\t\t\t\t\t\"address\": \"1.2.3.5\"\n\t\t\t\t}\n \t]\n\t\t}\n\t]\n}\n" + "raw": "{\n\t\"relay\": [\n\t\t{\n\t\t\t\"address-family\": \"vpp-fib-table-management:ipv4\",\n\t\t\t\"rx-vrf-id\": 0,\n\t\t\t\"gateway-address\": \"5.6.7.8\",\n\t\t\t\"server\" : [\n\t\t\t\t{\n\t\t\t\t\t\"vrf-id\": 0,\n\t\t\t\t\t\"address\": \"1.2.3.3\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"vrf-id\": 0,\n\t\t\t\t\t\"address\": \"1.2.3.4\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"vrf-id\": 1,\n\t\t\t\t\t\"address\": \"1.2.3.5\"\n\t\t\t\t}\n \t]\n\t\t}\n\t]\n}\n" }, "url": { - "raw": "http://localhost:8183/restconf/config/dhcp:dhcp/relays/relay/dhcp:ipv4/0", + "raw": "http://localhost:8183/restconf/config/dhcp:dhcp/relays/relay/vpp-fib-table-management:ipv4/0", "protocol": "http", "host": [ "localhost" @@ -38,7 +37,7 @@ "dhcp:dhcp", "relays", "relay", - "dhcp:ipv4", + "vpp-fib-table-management:ipv4", "0" ] }, @@ -47,7 +46,6 @@ "response": [] }, { - "_postman_id": "e0eef0a4-fb27-4a99-933d-2ea4aff476f5", "name": "Add IP4 DHCP Relay #2", "request": { "method": "PUT", @@ -63,10 +61,10 @@ ], "body": { "mode": "raw", - "raw": "{\n\t\"relay\": [\n\t\t{\n\t\t\t\"address-type\": \"ipv4\",\n\t\t\t\"rx-vrf-id\": 1,\n\t\t\t\"gateway-address\": \"5.6.7.9\",\n\t\t\t\"server\" : [\n\t\t\t\t{\n\t\t\t\t\t\"vrf-id\": 0,\n\t\t\t\t\t\"address\": \"1.2.3.6\"\n\t\t\t\t}\n \t]\n\t\t}\n\t]\n}\n" + "raw": "{\n\t\"relay\": [\n\t\t{\n\t\t\t\"address-family\": \"vpp-fib-table-management:ipv4\",\n\t\t\t\"rx-vrf-id\": 1,\n\t\t\t\"gateway-address\": \"5.6.7.9\",\n\t\t\t\"server\" : [\n\t\t\t\t{\n\t\t\t\t\t\"vrf-id\": 0,\n\t\t\t\t\t\"address\": \"1.2.3.6\"\n\t\t\t\t}\n \t]\n\t\t}\n\t]\n}\n" }, "url": { - "raw": "http://localhost:8183/restconf/config/dhcp:dhcp/relays/relay/dhcp:ipv4/1", + "raw": "http://localhost:8183/restconf/config/dhcp:dhcp/relays/relay/vpp-fib-table-management:ipv4/1", "protocol": "http", "host": [ "localhost" @@ -78,7 +76,7 @@ "dhcp:dhcp", "relays", "relay", - "dhcp:ipv4", + "vpp-fib-table-management:ipv4", "1" ] }, @@ -87,7 +85,6 @@ "response": [] }, { - "_postman_id": "10d6a414-e469-4352-b905-a376bf04e530", "name": "Configure IP6 DHCP Relay", "request": { "method": "PUT", @@ -103,10 +100,10 @@ ], "body": { "mode": "raw", - "raw": "{\n\t\"relay\": [\n\t\t{\n\t \"address-type\": \"ipv6\",\n\t \"rx-vrf-id\": 1,\n\t \"gateway-address\": \"2001::2\",\n\t\t\t\"server\" : [\n\t\t\t\t{\n\t\t\t\t\t\"vrf-id\": 2,\n\t\t\t\t\t\"address\": \"2001::1\"\n\t\t\t\t}\n \t]\n\t\t}\n\t]\n}\n" + "raw": "{\n\t\"relay\": [\n\t\t{\n\t \"address-family\": \"vpp-fib-table-management:ipv6\",\n\t \"rx-vrf-id\": 1,\n\t \"gateway-address\": \"2001::2\",\n\t\t\t\"server\" : [\n\t\t\t\t{\n\t\t\t\t\t\"vrf-id\": 2,\n\t\t\t\t\t\"address\": \"2001::1\"\n\t\t\t\t}\n \t]\n\t\t}\n\t]\n}\n" }, "url": { - "raw": "http://localhost:8183/restconf/config/dhcp:dhcp/relays/relay/dhcp:ipv6/1", + "raw": "http://localhost:8183/restconf/config/dhcp:dhcp/relays/relay/vpp-fib-table-management:ipv6/1", "protocol": "http", "host": [ "localhost" @@ -118,7 +115,7 @@ "dhcp:dhcp", "relays", "relay", - "dhcp:ipv6", + "vpp-fib-table-management:ipv6", "1" ] }, @@ -127,7 +124,6 @@ "response": [] }, { - "_postman_id": "ec6ef8ec-689b-4ca8-8b5d-93f5a00618af", "name": "Delete one of DHCP servers", "request": { "method": "DELETE", @@ -170,7 +166,6 @@ "response": [] }, { - "_postman_id": "f249a24a-d940-4a88-9738-b41e9fe16c92", "name": "Delete IP4 DHCP Relay #1", "request": { "method": "DELETE", @@ -210,7 +205,6 @@ "response": [] }, { - "_postman_id": "8d735396-317f-48c5-9af8-b51831f26084", "name": "Delete IP4 DHCP Relay #2", "request": { "method": "DELETE", @@ -250,7 +244,6 @@ "response": [] }, { - "_postman_id": "88cff2b2-7506-43db-abc3-3609f1c93622", "name": "Show DHCP Relay cfg", "request": { "method": "GET", @@ -266,7 +259,7 @@ ], "body": { "mode": "raw", - "raw": "{\n\t\"relay\": [\n\t\t{\n\t\t\t\"address-type\": \"ipv4\",\n\t\t\t\"rx-vrf-id\": 0,\n\t\t\t\"server-address\": \"1.2.3.4\",\n\t\t\t\"gateway-address\": \"5.6.7.8\"}\n\t]\n}\n" + "raw": "{\n\t\"relay\": [\n\t\t{\n\t\t\t\"address-family\": \"vpp-fib-table-management:ipv4\",\n\t\t\t\"rx-vrf-id\": 0,\n\t\t\t\"server-address\": \"1.2.3.4\",\n\t\t\t\"gateway-address\": \"5.6.7.8\"}\n\t]\n}\n" }, "url": { "raw": "http://localhost:8183/restconf/config/dhcp:dhcp/relays/", @@ -287,7 +280,6 @@ "response": [] }, { - "_postman_id": "49d460d8-688e-43b5-a29d-d8fab9a940bd", "name": "Show DHCP Relay oper", "request": { "method": "GET", @@ -303,7 +295,7 @@ ], "body": { "mode": "raw", - "raw": "{\n\t\"relay\": [\n\t\t{\n\t\t\t\"address-type\": \"ipv4\",\n\t\t\t\"rx-vrf-id\": 0,\n\t\t\t\"server-address\": \"1.2.3.4\",\n\t\t\t\"gateway-address\": \"5.6.7.8\"}\n\t]\n}\n" + "raw": "{\n\t\"relay\": [\n\t\t{\n\t\t\t\"address-family\": \"vpp-fib-table-management:ipv4\",\n\t\t\t\"rx-vrf-id\": 0,\n\t\t\t\"server-address\": \"1.2.3.4\",\n\t\t\t\"gateway-address\": \"5.6.7.8\"}\n\t]\n}\n" }, "url": { "raw": "http://localhost:8183/restconf/config/dhcp:dhcp/relays/", -- cgit 1.2.3-korg