1 From 9a00b1af18dfe4c2df185299b8bd2db7f5d061c0 Mon Sep 17 00:00:00 2001
2 From: Johnson Li <johnson.li@intel.com>
3 Date: Fri, 8 Sep 2017 17:35:16 +0800
4 Subject: [PATCH] Add VES agent configuration for vG-MUX
6 Signed-off-by: Johnson Li <johnson.li@intel.com>
8 diff --git a/pom.xml b/pom.xml
9 index 538a5d98..581bedfc 100644
15 <module>release-notes</module>
16 - <module>vpp-integration</module>
19 + <module>ves</module>
20 <module>samples</module>
21 <module>vpp-classifier</module>
23 <module>vpp-management</module>
24 + <module>vpp-integration</module>
28 \ No newline at end of file
29 diff --git a/ves/asciidoc/Readme.adoc b/ves/asciidoc/Readme.adoc
31 index 00000000..682e7555
33 +++ b/ves/asciidoc/Readme.adoc
37 +Overview of ves-agent
38 diff --git a/ves/pom.xml b/ves/pom.xml
40 index 00000000..1ded0109
44 +<?xml version="1.0" encoding="UTF-8"?>
46 + Copyright (c) 2017 Cisco and/or its affiliates.
47 + Licensed under the Apache License, Version 2.0 (the "License");
48 + you may not use this file except in compliance with the License.
49 + You may obtain a copy of the License at:
51 + http://www.apache.org/licenses/LICENSE-2.0
53 + Unless required by applicable law or agreed to in writing, software
54 + distributed under the License is distributed on an "AS IS" BASIS,
55 + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
56 + See the License for the specific language governing permissions and
57 + limitations under the License.
58 +--><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
61 + <groupId>io.fd.hc2vpp.common</groupId>
62 + <artifactId>hc2vpp-parent</artifactId>
63 + <version>1.17.04.1-SNAPSHOT</version>
64 + <relativePath>../common/hc2vpp-parent</relativePath>
67 + <groupId>io.fd.hc2vpp.ves</groupId>
68 + <artifactId>ves-agent</artifactId>
69 + <version>1.17.04.1-SNAPSHOT</version>
70 + <name>ves-agent</name>
71 + <packaging>pom</packaging>
72 + <modelVersion>4.0.0</modelVersion>
73 + <description>Agent for VNF Event Stream plugin</description>
76 + <module>ves-api</module>
77 + <module>ves-impl</module>
80 + <!-- DO NOT install or deploy the repo root pom as it's only needed to initiate a build -->
84 + <groupId>org.apache.maven.plugins</groupId>
85 + <artifactId>maven-deploy-plugin</artifactId>
91 + <groupId>org.apache.maven.plugins</groupId>
92 + <artifactId>maven-install-plugin</artifactId>
100 diff --git a/ves/ves-api/asciidoc/Readme.adoc b/ves/ves-api/asciidoc/Readme.adoc
102 index 00000000..b561268c
104 +++ b/ves/ves-api/asciidoc/Readme.adoc
108 +Overview of vesagent-api
109 \ No newline at end of file
110 diff --git a/ves/ves-api/pom.xml b/ves/ves-api/pom.xml
112 index 00000000..78bf47b9
114 +++ b/ves/ves-api/pom.xml
116 +<?xml version="1.0" encoding="UTF-8"?>
118 + Copyright (c) 2017 Cisco and/or its affiliates.
119 + Licensed under the Apache License, Version 2.0 (the "License");
120 + you may not use this file except in compliance with the License.
121 + You may obtain a copy of the License at:
123 + http://www.apache.org/licenses/LICENSE-2.0
125 + Unless required by applicable law or agreed to in writing, software
126 + distributed under the License is distributed on an "AS IS" BASIS,
127 + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
128 + See the License for the specific language governing permissions and
129 + limitations under the License.
130 +--><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
132 + <groupId>io.fd.hc2vpp.common</groupId>
133 + <artifactId>api-parent</artifactId>
134 + <version>1.17.04.1-SNAPSHOT</version>
135 + <relativePath>../../common/api-parent</relativePath>
138 + <modelVersion>4.0.0</modelVersion>
139 + <groupId>io.fd.hc2vpp.ves</groupId>
140 + <artifactId>ves-api</artifactId>
141 + <name>ves-api</name>
142 + <version>1.17.04.1-SNAPSHOT</version>
143 + <packaging>bundle</packaging>
147 + <groupId>org.opendaylight.mdsal.model</groupId>
148 + <artifactId>iana-if-type-2014-05-08</artifactId>
151 + <groupId>org.opendaylight.mdsal.model</groupId>
152 + <artifactId>ietf-yang-types-20130715</artifactId>
155 + <groupId>org.opendaylight.mdsal.model</groupId>
156 + <artifactId>ietf-interfaces</artifactId>
159 + <groupId>org.opendaylight.mdsal.model</groupId>
160 + <artifactId>ietf-inet-types-2013-07-15</artifactId>
163 + <groupId>org.opendaylight.mdsal.model</groupId>
164 + <artifactId>yang-ext</artifactId>
168 diff --git a/ves/ves-api/src/main/yang/vesagent.yang b/ves/ves-api/src/main/yang/vesagent.yang
170 index 00000000..a3c79797
172 +++ b/ves/ves-api/src/main/yang/vesagent.yang
177 + namespace "urn:opendaylight:params:xml:ns:yang:vpp:vesagent";
181 + "This YANG module defines the generic configuration and
182 + operational data for VES Agent in VPP";
184 + revision "2017-08-01" {
186 + "Initial revision of VES Agent model";
189 + import ietf-inet-types {
193 + grouping vesagent-attributes {
196 + "VNF Event Stream Agent configuration";
199 + type inet:ipv4-address;
201 + "VES Collector's IP address.";
207 + "VES Collector's Server Port.";
210 + leaf read-interval {
213 + "Seconds of time period for each loop.";
219 + "0-Delete VES agent, NonZero-Start VES agent.";
225 + "VNF Event Stream Agent Working Mode.";
227 + leaf base-packet-loss {
230 + "Base packet Loss for Demo Mode";
233 + leaf working-mode {
236 + "VES Working Mode, Demo Or Real Only.";
241 + container vesagent {
242 + uses vesagent-attributes;
245 diff --git a/ves/ves-impl/asciidoc/Readme.adoc b/ves/ves-impl/asciidoc/Readme.adoc
247 index 00000000..e07fb05f
249 +++ b/ves/ves-impl/asciidoc/Readme.adoc
253 +Overview of vesagent-impl
254 \ No newline at end of file
255 diff --git a/ves/ves-impl/pom.xml b/ves/ves-impl/pom.xml
257 index 00000000..5ed2c1b4
259 +++ b/ves/ves-impl/pom.xml
261 +<?xml version="1.0" encoding="UTF-8"?>
263 + Copyright (c) 2017 Cisco and/or its affiliates.
264 + Licensed under the Apache License, Version 2.0 (the "License");
265 + you may not use this file except in compliance with the License.
266 + You may obtain a copy of the License at:
268 + http://www.apache.org/licenses/LICENSE-2.0
270 + Unless required by applicable law or agreed to in writing, software
271 + distributed under the License is distributed on an "AS IS" BASIS,
272 + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
273 + See the License for the specific language governing permissions and
274 + limitations under the License.
275 +--><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
277 + <groupId>io.fd.hc2vpp.common</groupId>
278 + <artifactId>vpp-impl-parent</artifactId>
279 + <version>1.17.04.1-SNAPSHOT</version>
280 + <relativePath>../../vpp-common/vpp-impl-parent</relativePath>
283 + <modelVersion>4.0.0</modelVersion>
284 + <groupId>io.fd.hc2vpp.ves</groupId>
285 + <artifactId>ves-impl</artifactId>
286 + <name>${project.artifactId}</name>
287 + <version>1.17.04.1-SNAPSHOT</version>
288 + <packaging>bundle</packaging>
291 + <honeycomb.infra.version>1.17.04.1-SNAPSHOT</honeycomb.infra.version>
292 + <hc2vpp.common.version>1.17.04.1-SNAPSHOT</hc2vpp.common.version>
297 + <groupId>${project.groupId}</groupId>
298 + <artifactId>ves-api</artifactId>
299 + <version>${project.version}</version>
304 + <groupId>io.fd.hc2vpp.common</groupId>
305 + <artifactId>vpp-translate-utils</artifactId>
310 + <groupId>io.fd.vpp</groupId>
311 + <artifactId>jvpp-registry</artifactId>
314 + <groupId>io.fd.vpp</groupId>
315 + <artifactId>jvpp-ves</artifactId>
316 + <version>17.04.2-SNAPSHOT</version>
319 + <!-- Honeycomb infrastructure-->
321 + <groupId>io.fd.honeycomb</groupId>
322 + <artifactId>minimal-distribution</artifactId>
323 + <version>${honeycomb.infra.version}</version>
327 + <groupId>io.fd.honeycomb</groupId>
328 + <artifactId>translate-api</artifactId>
329 + <version>${honeycomb.infra.version}</version>
333 + <groupId>io.fd.honeycomb</groupId>
334 + <artifactId>translate-spi</artifactId>
335 + <version>${honeycomb.infra.version}</version>
339 + <groupId>io.fd.honeycomb</groupId>
340 + <artifactId>cfg-init</artifactId>
341 + <version>${honeycomb.infra.version}</version>
344 + <!-- Translation -->
346 + <groupId>io.fd.hc2vpp.common</groupId>
347 + <artifactId>vpp-translate-utils</artifactId>
352 + <groupId>com.google.inject</groupId>
353 + <artifactId>guice</artifactId>
356 + <groupId>net.jmob</groupId>
357 + <artifactId>guice.conf</artifactId>
360 + <groupId>com.google.inject.extensions</groupId>
361 + <artifactId>guice-multibindings</artifactId>
364 + <groupId>io.fd.honeycomb</groupId>
365 + <artifactId>translate-impl</artifactId>
366 + <version>1.17.04.1-SNAPSHOT</version>
370 + <!-- Testing dependencies-->
372 + <groupId>com.google.inject</groupId>
373 + <artifactId>guice</artifactId>
376 + <groupId>net.jmob</groupId>
377 + <artifactId>guice.conf</artifactId>
380 + <groupId>com.google.inject.extensions</groupId>
381 + <artifactId>guice-multibindings</artifactId>
385 + <groupId>junit</groupId>
386 + <artifactId>junit</artifactId>
387 + <scope>test</scope>
390 + <groupId>io.fd.hc2vpp.common</groupId>
391 + <artifactId>vpp-translate-test</artifactId>
392 + <version>${hc2vpp.common.version}</version>
393 + <scope>test</scope>
396 + <groupId>org.mockito</groupId>
397 + <artifactId>mockito-core</artifactId>
398 + <scope>test</scope>
401 + <groupId>com.google.inject.extensions</groupId>
402 + <artifactId>guice-testlib</artifactId>
403 + <scope>test</scope>
406 + <groupId>org.hamcrest</groupId>
407 + <artifactId>hamcrest-all</artifactId>
408 + <scope>test</scope>
411 + <groupId>io.fd.honeycomb.infra</groupId>
412 + <artifactId>test-tools</artifactId>
413 + <version>${project.version}</version>
414 + <scope>test</scope>
418 diff --git a/ves/ves-impl/src/main/java/io/fd/hc2vpp/ves/VesModule.java b/ves/ves-impl/src/main/java/io/fd/hc2vpp/ves/VesModule.java
420 index 00000000..0cd60068
422 +++ b/ves/ves-impl/src/main/java/io/fd/hc2vpp/ves/VesModule.java
425 + * Copyright (c) 2017 Intel Corp and/or its affiliates.
427 + * Licensed under the Apache License, Version 2.0 (the "License");
428 + * you may not use this file except in compliance with the License.
429 + * You may obtain a copy of the License at:
431 + * http://www.apache.org/licenses/LICENSE-2.0
433 + * Unless required by applicable law or agreed to in writing, software
434 + * distributed under the License is distributed on an "AS IS" BASIS,
435 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
436 + * See the License for the specific language governing permissions and
437 + * limitations under the License.
440 +package io.fd.hc2vpp.ves;
442 +import com.google.common.annotations.VisibleForTesting;
443 +import com.google.inject.AbstractModule;
444 +import com.google.inject.Provider;
445 +import com.google.inject.Singleton;
446 +import com.google.inject.multibindings.Multibinder;
447 +import io.fd.hc2vpp.ves.jvpp.JVppVesProvider;
448 +import io.fd.hc2vpp.ves.read.VesReaderFactory;
449 +import io.fd.hc2vpp.ves.write.VesWriterFactory;
450 +import io.fd.honeycomb.translate.read.ReaderFactory;
451 +import io.fd.honeycomb.translate.write.WriterFactory;
452 +import io.fd.vpp.jvpp.ves.future.FutureJVppVesFacade;
453 +import org.slf4j.Logger;
454 +import org.slf4j.LoggerFactory;
457 + * VesModule class instantiating ves plugin components.
459 +public final class VesModule extends AbstractModule {
461 + private static final Logger LOG = LoggerFactory.getLogger(VesModule.class);
462 + private final Class<? extends Provider<FutureJVppVesFacade>> jvppVesProviderClass;
464 + public VesModule() {
465 + this(JVppVesProvider.class);
469 + VesModule(Class<? extends Provider<FutureJVppVesFacade>> jvppVesProvider) {
470 + this.jvppVesProviderClass = jvppVesProvider;
474 + protected void configure() {
475 + LOG.info("Installing VES Agent module");
477 + // Bind to Plugin's JVPP
478 + bind(FutureJVppVesFacade.class).toProvider(jvppVesProviderClass).in(Singleton.class);
480 + LOG.info("Injecting writers factories");
481 + final Multibinder<WriterFactory> writerFactoryBinder = Multibinder.newSetBinder(binder(), WriterFactory.class);
482 + writerFactoryBinder.addBinding().to(VesWriterFactory.class);
484 + LOG.info("Injecting readers factories");
485 + final Multibinder<ReaderFactory> readerFactoryBinder = Multibinder.newSetBinder(binder(), ReaderFactory.class);
486 + readerFactoryBinder.addBinding().to(VesReaderFactory.class);
488 + LOG.info("Module VES Agent successfully configured");
491 diff --git a/ves/ves-impl/src/main/java/io/fd/hc2vpp/ves/jvpp/JVppVesProvider.java b/ves/ves-impl/src/main/java/io/fd/hc2vpp/ves/jvpp/JVppVesProvider.java
493 index 00000000..8afed84e
495 +++ b/ves/ves-impl/src/main/java/io/fd/hc2vpp/ves/jvpp/JVppVesProvider.java
498 + * Copyright (c) 2017 Intel Corp and/or its affiliates.
500 + * Licensed under the Apache License, Version 2.0 (the "License");
501 + * you may not use this file except in compliance with the License.
502 + * You may obtain a copy of the License at:
504 + * http://www.apache.org/licenses/LICENSE-2.0
506 + * Unless required by applicable law or agreed to in writing, software
507 + * distributed under the License is distributed on an "AS IS" BASIS,
508 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
509 + * See the License for the specific language governing permissions and
510 + * limitations under the License.
513 +package io.fd.hc2vpp.ves.jvpp;
515 +import com.google.inject.Inject;
516 +import io.fd.honeycomb.infra.distro.ProviderTrait;
517 +import io.fd.vpp.jvpp.JVppRegistry;
518 +import io.fd.vpp.jvpp.ves.JVppVesImpl;
519 +import io.fd.vpp.jvpp.ves.future.FutureJVppVesFacade;
520 +import java.io.IOException;
521 +import org.slf4j.Logger;
522 +import org.slf4j.LoggerFactory;
525 + * Provides future API for jvpp-ves plugin. Must be a singleton due to shutdown hook usage.
526 + * Registers shutdown hook to free plugin's resources on shutdown.
528 +public final class JVppVesProvider extends ProviderTrait<FutureJVppVesFacade> {
530 + private static final Logger LOG = LoggerFactory.getLogger(JVppVesProvider.class);
533 + private JVppRegistry registry;
536 + protected FutureJVppVesFacade create() {
538 + final JVppVesImpl jvppVes = new JVppVesImpl();
539 + Runtime.getRuntime().addShutdownHook(new Thread() {
541 + public void run() {
542 + LOG.info("Unloading jvpp-ves plugin");
544 + LOG.info("Successfully unloaded jvpp-ves plugin");
548 + LOG.info("Successfully loaded jvpp-ves plugin");
549 + return new FutureJVppVesFacade(registry, jvppVes);
550 + } catch (IOException e) {
551 + throw new IllegalStateException("Unable to open VPP management connection", e);
556 diff --git a/ves/ves-impl/src/main/java/io/fd/hc2vpp/ves/read/VesReaderFactory.java b/ves/ves-impl/src/main/java/io/fd/hc2vpp/ves/read/VesReaderFactory.java
558 index 00000000..bef652fd
560 +++ b/ves/ves-impl/src/main/java/io/fd/hc2vpp/ves/read/VesReaderFactory.java
563 + * Copyright (c) 2017 Intel Corp and/or its affiliates.
565 + * Licensed under the Apache License, Version 2.0 (the "License");
566 + * you may not use this file except in compliance with the License.
567 + * You may obtain a copy of the License at:
569 + * http://www.apache.org/licenses/LICENSE-2.0
571 + * Unless required by applicable law or agreed to in writing, software
572 + * distributed under the License is distributed on an "AS IS" BASIS,
573 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
574 + * See the License for the specific language governing permissions and
575 + * limitations under the License.
578 +package io.fd.hc2vpp.ves.read;
580 +import com.google.inject.Inject;
581 +import io.fd.honeycomb.translate.read.ReaderFactory;
582 +import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder;
583 +import io.fd.vpp.jvpp.core.future.FutureJVppCore;
584 +import javax.annotation.Nonnull;
585 +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vesagent.rev170801.Vesagent;
586 +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vesagent.rev170801.VesagentBuilder;
587 +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vesagent.rev170801.vesagent.attributes.Config;
588 +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vesagent.rev170801.vesagent.attributes.ConfigBuilder;
589 +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vesagent.rev170801.vesagent.attributes.Mode;
590 +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vesagent.rev170801.vesagent.attributes.ModeBuilder;
591 +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
594 + * Factory producing writers for VES Agent plugin's data.
596 +public final class VesReaderFactory implements ReaderFactory {
598 + private static final InstanceIdentifier<Vesagent> VESAGENT_ID = InstanceIdentifier.create(Vesagent.class);
599 + private static final InstanceIdentifier<Config> CONFIG_ID = InstanceIdentifier.create(Config.class);
600 + private static final InstanceIdentifier<Mode> MODE_ID = InstanceIdentifier.create(Mode.class);
603 + private FutureJVppCore vppApi;
606 + public void init(@Nonnull final ModifiableReaderRegistryBuilder registry) {
607 + registry.addStructuralReader(VESAGENT_ID, VesagentBuilder.class);
608 + registry.addStructuralReader(CONFIG_ID, ConfigBuilder.class);
609 + registry.addStructuralReader(MODE_ID, ModeBuilder.class);
612 diff --git a/ves/ves-impl/src/main/java/io/fd/hc2vpp/ves/write/VesConfigCustomizer.java b/ves/ves-impl/src/main/java/io/fd/hc2vpp/ves/write/VesConfigCustomizer.java
614 index 00000000..e06afa73
616 +++ b/ves/ves-impl/src/main/java/io/fd/hc2vpp/ves/write/VesConfigCustomizer.java
619 + * Copyright (c) 2017 Intel Corp and/or its affiliates.
621 + * Licensed under the Apache License, Version 2.0 (the "License");
622 + * you may not use this file except in compliance with the License.
623 + * You may obtain a copy of the License at:
625 + * http://www.apache.org/licenses/LICENSE-2.0
627 + * Unless required by applicable law or agreed to in writing, software
628 + * distributed under the License is distributed on an "AS IS" BASIS,
629 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
630 + * See the License for the specific language governing permissions and
631 + * limitations under the License.
634 +package io.fd.hc2vpp.ves.write;
636 +import static com.google.common.base.Preconditions.checkArgument;
638 +import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
639 +import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
640 +import io.fd.hc2vpp.common.translate.util.Ipv4Translator;
641 +import io.fd.hc2vpp.common.translate.util.Ipv6Translator;
642 +import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
643 +import io.fd.honeycomb.translate.spi.write.WriterCustomizer;
644 +import io.fd.honeycomb.translate.write.WriteContext;
645 +import io.fd.honeycomb.translate.write.WriteFailedException;
646 +import io.fd.vpp.jvpp.core.future.FutureJVppCore;
647 +//import io.fd.vpp.jvpp.ves.future.FutureJVppVes;
648 +import io.fd.vpp.jvpp.ves.dto.VesAgentConfig;
649 +import io.fd.vpp.jvpp.ves.future.FutureJVppVesFacade;
650 +import javax.annotation.Nonnull;
651 +//import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vesagent.rev170801.Vesagent;
652 +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vesagent.rev170801.vesagent.attributes.Config;
653 +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vesagent.rev170801.vesagent.attributes.ConfigBuilder;
654 +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
655 +import org.slf4j.Logger;
656 +import org.slf4j.LoggerFactory;
658 +final class VesConfigCustomizer extends FutureJVppCustomizer implements WriterCustomizer<Config>,
659 + JvppReplyConsumer, ByteDataTranslator, Ipv6Translator, Ipv4Translator {
660 + private static final Logger LOG = LoggerFactory.getLogger(VesConfigCustomizer.class);
662 + private final FutureJVppVesFacade jvppVes;
664 + VesConfigCustomizer(final FutureJVppCore vppApi, final FutureJVppVesFacade jvppVes) {
666 + this.jvppVes = jvppVes;
670 + public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<Config> iid, @Nonnull final Config dataAfter,
671 + @Nonnull final WriteContext writeContext) throws WriteFailedException {
672 + ConfigBuilder configBuilder = new ConfigBuilder();
673 + InstanceIdentifier<Config> id = iid;
675 + LOG.debug("Writing VES Agent Config {} dataAfter={}", id, dataAfter);
676 + checkArgument(dataAfter.getServerAddr() != null && dataAfter.getServerAddr().getValue() != null
677 + && dataAfter.getServerPort() != 0, "VES Server Address and Port need to be configured");
679 + configBuilder.setServerAddr(dataAfter.getServerAddr())
680 + .setServerPort(dataAfter.getServerPort())
681 + .setReadInterval(dataAfter.getReadInterval())
684 + setVesAgentConfig(id, configBuilder.build());
688 + public void updateCurrentAttributes(@Nonnull final InstanceIdentifier<Config> iid, @Nonnull final Config dataBefore,
689 + @Nonnull final Config dataAfter, @Nonnull final WriteContext writeContext)
690 + throws WriteFailedException {
691 + ConfigBuilder configBuilder = new ConfigBuilder();
692 + InstanceIdentifier<Config> id = iid;
694 + checkArgument(dataBefore.getServerAddr() != null && dataBefore.getServerAddr().getValue() != null
695 + && dataBefore.getServerPort() != 0, "VES Server Address and Port need to be configured");
696 + checkArgument(dataAfter.getServerAddr() != null && dataAfter.getServerAddr().getValue() != null
697 + && dataAfter.getServerPort() != 0, "VES Server Address and Port need to be configured");
699 + // remove old configuration:
700 + configBuilder.setServerAddr(dataBefore.getServerAddr())
701 + .setServerPort(dataBefore.getServerPort())
702 + .setReadInterval(dataBefore.getReadInterval())
704 + setVesAgentConfig(id, configBuilder.build());
706 + // and add new one:
707 + configBuilder.setServerAddr(dataAfter.getServerAddr())
708 + .setServerPort(dataAfter.getServerPort())
709 + .setReadInterval(dataAfter.getReadInterval())
711 + setVesAgentConfig(id, configBuilder.build());
715 + public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<Config> iid, @Nonnull final Config dataBefore,
716 + @Nonnull final WriteContext writeContext) throws WriteFailedException {
717 + ConfigBuilder configBuilder = new ConfigBuilder();
718 + InstanceIdentifier<Config> id = iid;
719 + LOG.debug("Removing VES Agent {} dataBefore={}", id, dataBefore);
721 + checkArgument(dataBefore.getServerAddr() != null && dataBefore.getServerAddr().getValue() != null
722 + && dataBefore.getServerPort() != 0, "VES Server Address and Port need to be dataBeforeured");
724 + configBuilder.setServerAddr(dataBefore.getServerAddr())
725 + .setServerPort(dataBefore.getServerPort())
726 + .setReadInterval(dataBefore.getReadInterval())
729 + setVesAgentConfig(id, configBuilder.build());
732 + private void setVesAgentConfig(final InstanceIdentifier<Config> id, final Config config)
733 + throws WriteFailedException {
734 + final VesAgentConfig request = new VesAgentConfig();
736 + request.serverPort = config.getServerPort().byteValue();
737 + request.readInterval = config.getReadInterval().byteValue();
738 + request.isAdd = config.getIsAdd().byteValue();
739 + request.serverAddr = ipv4AddressNoZoneToArray(config.getServerAddr().getValue());
741 + LOG.debug("VES agent config change id={} request={}", id, request);
742 + getReplyForWrite(jvppVes.vesAgentConfig(request).toCompletableFuture(), id);
745 diff --git a/ves/ves-impl/src/main/java/io/fd/hc2vpp/ves/write/VesModeCustomizer.java b/ves/ves-impl/src/main/java/io/fd/hc2vpp/ves/write/VesModeCustomizer.java
747 index 00000000..8b6d5a9a
749 +++ b/ves/ves-impl/src/main/java/io/fd/hc2vpp/ves/write/VesModeCustomizer.java
752 + * Copyright (c) 2017 Intel Corp and/or its affiliates.
754 + * Licensed under the Apache License, Version 2.0 (the "License");
755 + * you may not use this file except in compliance with the License.
756 + * You may obtain a copy of the License at:
758 + * http://www.apache.org/licenses/LICENSE-2.0
760 + * Unless required by applicable law or agreed to in writing, software
761 + * distributed under the License is distributed on an "AS IS" BASIS,
762 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
763 + * See the License for the specific language governing permissions and
764 + * limitations under the License.
767 +package io.fd.hc2vpp.ves.write;
769 +import static com.google.common.base.Preconditions.checkArgument;
771 +import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
772 +import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
773 +import io.fd.hc2vpp.common.translate.util.Ipv4Translator;
774 +import io.fd.hc2vpp.common.translate.util.Ipv6Translator;
775 +import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
776 +import io.fd.honeycomb.translate.spi.write.WriterCustomizer;
777 +import io.fd.honeycomb.translate.write.WriteContext;
778 +import io.fd.honeycomb.translate.write.WriteFailedException;
779 +import io.fd.vpp.jvpp.core.future.FutureJVppCore;
780 +//import io.fd.vpp.jvpp.ves.future.FutureJVppVes;
781 +import io.fd.vpp.jvpp.ves.dto.VesAgentMode;
782 +import io.fd.vpp.jvpp.ves.future.FutureJVppVesFacade;
783 +import javax.annotation.Nonnull;
784 +//import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vesagent.rev170801.Vesagent;
785 +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vesagent.rev170801.vesagent.attributes.Mode;
786 +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vesagent.rev170801.vesagent.attributes.ModeBuilder;
787 +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
788 +import org.slf4j.Logger;
789 +import org.slf4j.LoggerFactory;
791 +final class VesModeCustomizer extends FutureJVppCustomizer implements WriterCustomizer<Mode>,
792 + JvppReplyConsumer, ByteDataTranslator, Ipv6Translator, Ipv4Translator {
793 + private static final Logger LOG = LoggerFactory.getLogger(VesModeCustomizer.class);
795 + private final FutureJVppVesFacade jvppVes;
797 + VesModeCustomizer(final FutureJVppCore vppApi, final FutureJVppVesFacade jvppVes) {
799 + this.jvppVes = jvppVes;
803 + public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<Mode> iid, @Nonnull final Mode dataAfter,
804 + @Nonnull final WriteContext writeContext) throws WriteFailedException {
805 + LOG.debug("Writing VES Agent Working Mode {} dataAfter={}", iid, dataAfter);
807 + checkArgument(dataAfter.getWorkingMode() != null && dataAfter.getBasePacketLoss() <= 100,
808 + "VES Agent Working Mode need to be correctly configured.");
810 + setVesAgentMode(iid, dataAfter);
814 + public void updateCurrentAttributes(@Nonnull final InstanceIdentifier<Mode> iid, @Nonnull final Mode dataBefore,
815 + @Nonnull final Mode dataAfter, @Nonnull final WriteContext writeContext)
816 + throws WriteFailedException {
817 + LOG.debug("Writing VES Agent Working Mode {} {}-->{}", iid, dataBefore, dataAfter);
819 + checkArgument(dataAfter.getWorkingMode() != null && dataAfter.getBasePacketLoss() <= 100,
820 + "VES Agent Working Mode need to be correctly configured.");
822 + setVesAgentMode(iid, dataAfter);
826 + public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<Mode> iid, @Nonnull final Mode dataBefore,
827 + @Nonnull final WriteContext writeContext) throws WriteFailedException {
828 + ModeBuilder modeBuilder = new ModeBuilder();
829 + LOG.debug("Restoring VES Mode {} dataBefore={} to default.", iid, dataBefore);
831 + modeBuilder.setWorkingMode("Real")
832 + .setBasePacketLoss(0L);
834 + setVesAgentMode(iid, modeBuilder.build());
837 + private void setVesAgentMode(final InstanceIdentifier<Mode> id, final Mode mode)
838 + throws WriteFailedException {
839 + final VesAgentMode request = new VesAgentMode();
841 + request.pktLossRate = mode.getBasePacketLoss().byteValue();
842 + request.workMode = mode.getWorkingMode().getBytes();
844 + LOG.debug("VES agent working mode change id={} request={}", id, request);
845 + getReplyForWrite(jvppVes.vesAgentMode(request).toCompletableFuture(), id);
848 diff --git a/ves/ves-impl/src/main/java/io/fd/hc2vpp/ves/write/VesWriterFactory.java b/ves/ves-impl/src/main/java/io/fd/hc2vpp/ves/write/VesWriterFactory.java
850 index 00000000..581f0460
852 +++ b/ves/ves-impl/src/main/java/io/fd/hc2vpp/ves/write/VesWriterFactory.java
855 + * Copyright (c) 2017 Intel Corp and/or its affiliates.
857 + * Licensed under the Apache License, Version 2.0 (the "License");
858 + * you may not use this file except in compliance with the License.
859 + * You may obtain a copy of the License at:
861 + * http://www.apache.org/licenses/LICENSE-2.0
863 + * Unless required by applicable law or agreed to in writing, software
864 + * distributed under the License is distributed on an "AS IS" BASIS,
865 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
866 + * See the License for the specific language governing permissions and
867 + * limitations under the License.
870 +package io.fd.hc2vpp.ves.write;
872 +import com.google.common.collect.ImmutableSet;
873 +import com.google.inject.Inject;
874 +import io.fd.honeycomb.translate.impl.write.GenericWriter;
875 +import io.fd.honeycomb.translate.write.WriterFactory;
876 +import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder;
877 +import io.fd.vpp.jvpp.core.future.FutureJVppCore;
878 +import io.fd.vpp.jvpp.ves.future.FutureJVppVesFacade;
879 +import javax.annotation.Nonnull;
880 +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vesagent.rev170801.Vesagent;
881 +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vesagent.rev170801.vesagent.attributes.Config;
882 +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vesagent.rev170801.vesagent.attributes.Mode;
883 +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
886 + * Factory producing writers for VES Agent plugin's data.
888 +public final class VesWriterFactory implements WriterFactory {
890 + private static final InstanceIdentifier<Vesagent> VESAGENT_ID = InstanceIdentifier.create(Vesagent.class);
893 + private FutureJVppCore vppApi;
896 + protected FutureJVppVesFacade futureVesFacade;
899 + public void init(@Nonnull final ModifiableWriterRegistryBuilder registry) {
900 + registry.add(new GenericWriter<>(VESAGENT_ID,
901 + new VesagentCustomizer(vppApi, futureVesFacade)));
902 + registry.add(new GenericWriter<>(VESAGENT_ID.child(Config.class),
903 + new VesConfigCustomizer(vppApi, futureVesFacade)));
904 + registry.add(new GenericWriter<>(VESAGENT_ID.child(Mode.class),
905 + new VesModeCustomizer(vppApi, futureVesFacade)));
908 diff --git a/ves/ves-impl/src/main/java/io/fd/hc2vpp/ves/write/VesagentCustomizer.java b/ves/ves-impl/src/main/java/io/fd/hc2vpp/ves/write/VesagentCustomizer.java
910 index 00000000..62e46cdb
912 +++ b/ves/ves-impl/src/main/java/io/fd/hc2vpp/ves/write/VesagentCustomizer.java
915 + * Copyright (c) 2017 Intel Corp and/or its affiliates.
917 + * Licensed under the Apache License, Version 2.0 (the "License");
918 + * you may not use this file except in compliance with the License.
919 + * You may obtain a copy of the License at:
921 + * http://www.apache.org/licenses/LICENSE-2.0
923 + * Unless required by applicable law or agreed to in writing, software
924 + * distributed under the License is distributed on an "AS IS" BASIS,
925 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
926 + * See the License for the specific language governing permissions and
927 + * limitations under the License.
930 +package io.fd.hc2vpp.ves.write;
932 +import static com.google.common.base.Preconditions.checkArgument;
934 +import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
935 +import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
936 +import io.fd.hc2vpp.common.translate.util.Ipv4Translator;
937 +import io.fd.hc2vpp.common.translate.util.Ipv6Translator;
938 +import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
939 +import io.fd.honeycomb.translate.spi.write.WriterCustomizer;
940 +import io.fd.honeycomb.translate.write.WriteContext;
941 +import io.fd.honeycomb.translate.write.WriteFailedException;
942 +import io.fd.vpp.jvpp.core.future.FutureJVppCore;
943 +//import io.fd.vpp.jvpp.ves.future.FutureJVppVes;
944 +import io.fd.vpp.jvpp.ves.dto.VesAgentConfig;
945 +import io.fd.vpp.jvpp.ves.future.FutureJVppVesFacade;
946 +import javax.annotation.Nonnull;
947 +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vesagent.rev170801.Vesagent;
948 +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vesagent.rev170801.vesagent.attributes.Config;
949 +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vesagent.rev170801.vesagent.attributes.ConfigBuilder;
950 +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
951 +import org.slf4j.Logger;
952 +import org.slf4j.LoggerFactory;
954 +final class VesagentCustomizer extends FutureJVppCustomizer implements WriterCustomizer<Vesagent>,
955 + JvppReplyConsumer, ByteDataTranslator, Ipv6Translator, Ipv4Translator {
956 + private static final Logger LOG = LoggerFactory.getLogger(VesagentCustomizer.class);
958 + private final FutureJVppVesFacade jvppVes;
960 + VesagentCustomizer(final FutureJVppCore vppApi, final FutureJVppVesFacade jvppVes) {
962 + this.jvppVes = jvppVes;
966 + public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<Vesagent> iid, @Nonnull final Vesagent dataAfter,
967 + @Nonnull final WriteContext writeContext) throws WriteFailedException {
968 + Config config = dataAfter.getConfig();
969 + ConfigBuilder configBuilder = new ConfigBuilder();
970 + InstanceIdentifier<Config> id = iid.child(Config.class);
972 + LOG.debug("Writing VES Agent Config {} dataAfter={}", id, config);
973 + checkArgument(config.getServerAddr() != null && config.getServerAddr().getValue() != null
974 + && config.getServerPort() != 0, "VES Server Address and Port need to be configured");
976 + configBuilder.setServerAddr(config.getServerAddr())
977 + .setServerPort(config.getServerPort())
978 + .setReadInterval(config.getReadInterval())
981 + setVesAgentConfig(id, configBuilder.build());
985 + public void updateCurrentAttributes(@Nonnull final InstanceIdentifier<Vesagent> iid, @Nonnull final Vesagent dataBefore,
986 + @Nonnull final Vesagent dataAfter, @Nonnull final WriteContext writeContext)
987 + throws WriteFailedException {
988 + Config configBefore = dataBefore.getConfig();
989 + Config configAfter = dataAfter.getConfig();
990 + ConfigBuilder configBuilder = new ConfigBuilder();
991 + InstanceIdentifier<Config> id = iid.child(Config.class);
993 + checkArgument(configBefore.getServerAddr() != null && configBefore.getServerAddr().getValue() != null
994 + && configBefore.getServerPort() != 0, "VES Server Address and Port need to be configured");
995 + checkArgument(configAfter.getServerAddr() != null && configAfter.getServerAddr().getValue() != null
996 + && configAfter.getServerPort() != 0, "VES Server Address and Port need to be configured");
998 + // remove old configuration:
999 + configBuilder.setServerAddr(configBefore.getServerAddr())
1000 + .setServerPort(configBefore.getServerPort())
1001 + .setReadInterval(configBefore.getReadInterval())
1003 + setVesAgentConfig(id, configBuilder.build());
1005 + // and add new one:
1006 + configBuilder.setServerAddr(configAfter.getServerAddr())
1007 + .setServerPort(configAfter.getServerPort())
1008 + .setReadInterval(configAfter.getReadInterval())
1010 + setVesAgentConfig(id, configBuilder.build());
1014 + public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<Vesagent> iid, @Nonnull final Vesagent dataBefore,
1015 + @Nonnull final WriteContext writeContext) throws WriteFailedException {
1016 + Config config = dataBefore.getConfig();
1017 + InstanceIdentifier<Config> id = iid.child(Config.class);
1018 + LOG.debug("Removing VES Agent {} dataBefore={}", id, config);
1020 + checkArgument(config.getServerAddr() != null && config.getServerAddr().getValue() != null
1021 + && config.getServerPort() != 0, "VES Server Address and Port need to be configured");
1023 + ConfigBuilder configBuilder = new ConfigBuilder();
1024 + configBuilder.setServerAddr(config.getServerAddr())
1025 + .setServerPort(config.getServerPort())
1026 + .setReadInterval(config.getReadInterval())
1029 + setVesAgentConfig(id, configBuilder.build());
1032 + private void setVesAgentConfig(final InstanceIdentifier<Config> id, final Config config)
1033 + throws WriteFailedException {
1034 + final VesAgentConfig request = new VesAgentConfig();
1036 + request.serverPort = config.getServerPort().byteValue();
1037 + request.readInterval = config.getReadInterval().byteValue();
1038 + request.isAdd = config.getIsAdd().byteValue();
1039 + request.serverAddr = ipv4AddressNoZoneToArray(config.getServerAddr().getValue());
1041 + LOG.debug("VES agent config change id={} request={}", id, request);
1042 + getReplyForWrite(jvppVes.vesAgentConfig(request).toCompletableFuture(), id);
1045 diff --git a/vpp-integration/minimal-distribution/pom.xml b/vpp-integration/minimal-distribution/pom.xml
1046 index e126114a..ca0e5b24 100644
1047 --- a/vpp-integration/minimal-distribution/pom.xml
1048 +++ b/vpp-integration/minimal-distribution/pom.xml
1050 <routing.version>1.17.04.1-SNAPSHOT</routing.version>
1051 <acl.version>1.17.04.1-SNAPSHOT</acl.version>
1052 <dhcp.version>1.17.04.1-SNAPSHOT</dhcp.version>
1053 + <vesagent.version>1.17.04.1-SNAPSHOT</vesagent.version>
1054 <vpp.classifier.version>1.17.04.1-SNAPSHOT</vpp.classifier.version>
1055 <l3-impl.version>1.17.04.1-SNAPSHOT</l3-impl.version>
1056 <vpp-management-impl.version>1.17.04.1-SNAPSHOT</vpp-management-impl.version>
1058 io.fd.hc2vpp.routing.RoutingModule,
1059 io.fd.hc2vpp.acl.AclModule,
1060 io.fd.hc2vpp.dhcp.DhcpModule,
1061 + io.fd.hc2vpp.ves.VesModule,
1062 io.fd.hc2vpp.policer.PolicerModule,
1063 // io.fd.hc2vpp.vppnsh.impl.VppNshModule,
1064 <!-- Nsh module by default disabled, because it needs vpp-nsh plugin, which is not part of vpp codebase.-->
1065 @@ -151,6 +153,11 @@
1066 <version>${dhcp.version}</version>
1069 + <groupId>io.fd.hc2vpp.ves</groupId>
1070 + <artifactId>ves-impl</artifactId>
1071 + <version>${vesagent.version}</version>
1074 <groupId>io.fd.hc2vpp.management</groupId>
1075 <artifactId>vpp-management-impl</artifactId>
1076 <version>${vpp-management-impl.version}</version>