Add sourceName override option to vg-mux
[demo.git] / vnfs / vCPE / vpp-ves-agent-for-vgmux / src / patches / Hc2vpp-Add-VES-agent-for-vG-MUX.patch
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
5
6 Signed-off-by: Johnson Li <johnson.li@intel.com>
7
8 diff --git a/pom.xml b/pom.xml
9 index 538a5d9..581bedf 100644
10 --- a/pom.xml
11 +++ b/pom.xml
12 @@ -44,13 +44,14 @@
13      <module>nat</module>
14      <module>lisp</module>
15      <module>release-notes</module>
16 -    <module>vpp-integration</module>
17      <module>acl</module>
18      <module>dhcp</module>
19 +    <module>ves</module>
20      <module>samples</module>
21      <module>vpp-classifier</module>
22      <module>l3</module>
23      <module>vpp-management</module>
24 +    <module>vpp-integration</module>
25      <module>it</module>
26    </modules>
27  </project>
28 \ No newline at end of file
29 diff --git a/ves/asciidoc/Readme.adoc b/ves/asciidoc/Readme.adoc
30 new file mode 100644
31 index 0000000..682e755
32 --- /dev/null
33 +++ b/ves/asciidoc/Readme.adoc
34 @@ -0,0 +1,3 @@
35 += ves-agent
36 +
37 +Overview of ves-agent
38 diff --git a/ves/pom.xml b/ves/pom.xml
39 new file mode 100644
40 index 0000000..1ded010
41 --- /dev/null
42 +++ b/ves/pom.xml
43 @@ -0,0 +1,56 @@
44 +<?xml version="1.0" encoding="UTF-8"?>
45 +<!--
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:
50 +
51 +     http://www.apache.org/licenses/LICENSE-2.0
52 +
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">
59 +
60 +  <parent>
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>
65 +  </parent>
66 +
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>
74 +
75 +  <modules>
76 +    <module>ves-api</module>
77 +    <module>ves-impl</module>
78 +  </modules>
79 +
80 +  <!-- DO NOT install or deploy the repo root pom as it's only needed to initiate a build -->
81 +  <build>
82 +    <plugins>
83 +      <plugin>
84 +        <groupId>org.apache.maven.plugins</groupId>
85 +        <artifactId>maven-deploy-plugin</artifactId>
86 +        <configuration>
87 +          <skip>true</skip>
88 +        </configuration>
89 +      </plugin>
90 +      <plugin>
91 +        <groupId>org.apache.maven.plugins</groupId>
92 +        <artifactId>maven-install-plugin</artifactId>
93 +        <configuration>
94 +          <skip>true</skip>
95 +        </configuration>
96 +      </plugin>
97 +    </plugins>
98 +  </build>
99 +</project>
100 diff --git a/ves/ves-api/asciidoc/Readme.adoc b/ves/ves-api/asciidoc/Readme.adoc
101 new file mode 100644
102 index 0000000..b561268
103 --- /dev/null
104 +++ b/ves/ves-api/asciidoc/Readme.adoc
105 @@ -0,0 +1,3 @@
106 += vesagent-api
107 +
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
111 new file mode 100644
112 index 0000000..78bf47b
113 --- /dev/null
114 +++ b/ves/ves-api/pom.xml
115 @@ -0,0 +1,52 @@
116 +<?xml version="1.0" encoding="UTF-8"?>
117 +<!--
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:
122 +
123 +     http://www.apache.org/licenses/LICENSE-2.0
124 +
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">
131 +  <parent>
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>
136 +  </parent>
137 +
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>
144 +
145 +  <dependencies>
146 +    <dependency>
147 +      <groupId>org.opendaylight.mdsal.model</groupId>
148 +      <artifactId>iana-if-type-2014-05-08</artifactId>
149 +    </dependency>
150 +    <dependency>
151 +      <groupId>org.opendaylight.mdsal.model</groupId>
152 +      <artifactId>ietf-yang-types-20130715</artifactId>
153 +    </dependency>
154 +    <dependency>
155 +      <groupId>org.opendaylight.mdsal.model</groupId>
156 +      <artifactId>ietf-interfaces</artifactId>
157 +    </dependency>
158 +    <dependency>
159 +      <groupId>org.opendaylight.mdsal.model</groupId>
160 +      <artifactId>ietf-inet-types-2013-07-15</artifactId>
161 +    </dependency>
162 +    <dependency>
163 +      <groupId>org.opendaylight.mdsal.model</groupId>
164 +      <artifactId>yang-ext</artifactId>
165 +    </dependency>
166 +  </dependencies>
167 +</project>
168 diff --git a/ves/ves-api/src/main/yang/vesagent.yang b/ves/ves-api/src/main/yang/vesagent.yang
169 new file mode 100644
170 index 0000000..dde09c2
171 --- /dev/null
172 +++ b/ves/ves-api/src/main/yang/vesagent.yang
173 @@ -0,0 +1,77 @@
174 +module vesagent {
175 +
176 +    yang-version 1;
177 +    namespace "urn:opendaylight:params:xml:ns:yang:vpp:vesagent";
178 +    prefix "vesagent";
179 +
180 +    description
181 +        "This YANG module defines the generic configuration and
182 +        operational data for VES Agent in VPP";
183 +
184 +    revision "2017-08-01" {
185 +        description
186 +            "Initial revision of VES Agent model";
187 +    }
188 +
189 +    import ietf-inet-types {
190 +        prefix inet;
191 +    }
192 +
193 +    grouping vesagent-attributes {
194 +        container config {
195 +            description
196 +                "VNF Event Stream Agent configuration";
197 +
198 +            leaf server-addr {
199 +                type inet:ipv4-address;
200 +                description
201 +                    "VES Collector's IP address.";
202 +            }
203 +
204 +            leaf server-port {
205 +                type uint32;
206 +                description
207 +                    "VES Collector's Server Port.";
208 +            }
209 +
210 +            leaf read-interval {
211 +                type uint32;
212 +                description
213 +                    "Seconds of time period for each loop.";
214 +            }
215 +
216 +            leaf is-add {
217 +                type uint32;
218 +                description
219 +                    "0-Delete VES agent, NonZero-Start VES agent.";
220 +            }
221 +        }
222 +
223 +        container mode {
224 +            description
225 +                "VNF Event Stream Agent Working Mode.";
226 +
227 +            leaf base-packet-loss {
228 +                type uint32;
229 +                description
230 +                    "Base packet Loss for Demo Mode";
231 +            }
232 +
233 +            leaf working-mode {
234 +                type string;
235 +                description
236 +                    "VES Working Mode, Demo Or Real Only.";
237 +            }
238 +
239 +            leaf source-name {
240 +                type string;
241 +                description
242 +                    "Override for the sourceName field in the VES event";
243 +            }
244 +        }
245 +    }
246 +
247 +    container vesagent {
248 +        uses vesagent-attributes;
249 +    }
250 +}
251 diff --git a/ves/ves-impl/asciidoc/Readme.adoc b/ves/ves-impl/asciidoc/Readme.adoc
252 new file mode 100644
253 index 0000000..e07fb05
254 --- /dev/null
255 +++ b/ves/ves-impl/asciidoc/Readme.adoc
256 @@ -0,0 +1,3 @@
257 += vesagent-impl
258 +
259 +Overview of vesagent-impl
260 \ No newline at end of file
261 diff --git a/ves/ves-impl/pom.xml b/ves/ves-impl/pom.xml
262 new file mode 100644
263 index 0000000..5ed2c1b
264 --- /dev/null
265 +++ b/ves/ves-impl/pom.xml
266 @@ -0,0 +1,157 @@
267 +<?xml version="1.0" encoding="UTF-8"?>
268 +<!--
269 + Copyright (c) 2017 Cisco and/or its affiliates.
270 + Licensed under the Apache License, Version 2.0 (the "License");
271 + you may not use this file except in compliance with the License.
272 + You may obtain a copy of the License at:
273 +
274 +     http://www.apache.org/licenses/LICENSE-2.0
275 +
276 + Unless required by applicable law or agreed to in writing, software
277 + distributed under the License is distributed on an "AS IS" BASIS,
278 + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
279 + See the License for the specific language governing permissions and
280 + limitations under the License.
281 +--><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">
282 +    <parent>
283 +        <groupId>io.fd.hc2vpp.common</groupId>
284 +        <artifactId>vpp-impl-parent</artifactId>
285 +        <version>1.17.04.1-SNAPSHOT</version>
286 +        <relativePath>../../vpp-common/vpp-impl-parent</relativePath>
287 +    </parent>
288 +
289 +    <modelVersion>4.0.0</modelVersion>
290 +    <groupId>io.fd.hc2vpp.ves</groupId>
291 +    <artifactId>ves-impl</artifactId>
292 +    <name>${project.artifactId}</name>
293 +    <version>1.17.04.1-SNAPSHOT</version>
294 +    <packaging>bundle</packaging>
295 +
296 +    <properties>
297 +        <honeycomb.infra.version>1.17.04.1-SNAPSHOT</honeycomb.infra.version>
298 +        <hc2vpp.common.version>1.17.04.1-SNAPSHOT</hc2vpp.common.version>
299 +    </properties>
300 +
301 +    <dependencies>
302 +        <dependency>
303 +            <groupId>${project.groupId}</groupId>
304 +            <artifactId>ves-api</artifactId>
305 +            <version>${project.version}</version>
306 +        </dependency>
307 +
308 +        <!--VPP common-->
309 +        <dependency>
310 +            <groupId>io.fd.hc2vpp.common</groupId>
311 +            <artifactId>vpp-translate-utils</artifactId>
312 +        </dependency>
313 +
314 +        <!-- JVPP -->
315 +        <dependency>
316 +            <groupId>io.fd.vpp</groupId>
317 +            <artifactId>jvpp-registry</artifactId>
318 +        </dependency>
319 +        <dependency>
320 +            <groupId>io.fd.vpp</groupId>
321 +            <artifactId>jvpp-ves</artifactId>
322 +            <version>17.04.2-SNAPSHOT</version>
323 +        </dependency>
324 +
325 +        <!-- Honeycomb infrastructure-->
326 +        <dependency>
327 +            <groupId>io.fd.honeycomb</groupId>
328 +            <artifactId>minimal-distribution</artifactId>
329 +            <version>${honeycomb.infra.version}</version>
330 +        </dependency>
331 +
332 +        <dependency>
333 +            <groupId>io.fd.honeycomb</groupId>
334 +            <artifactId>translate-api</artifactId>
335 +            <version>${honeycomb.infra.version}</version>
336 +        </dependency>
337 +
338 +        <dependency>
339 +            <groupId>io.fd.honeycomb</groupId>
340 +            <artifactId>translate-spi</artifactId>
341 +            <version>${honeycomb.infra.version}</version>
342 +        </dependency>
343 +
344 +        <dependency>
345 +            <groupId>io.fd.honeycomb</groupId>
346 +            <artifactId>cfg-init</artifactId>
347 +            <version>${honeycomb.infra.version}</version>
348 +        </dependency>
349 +
350 +        <!-- Translation -->
351 +        <dependency>
352 +            <groupId>io.fd.hc2vpp.common</groupId>
353 +            <artifactId>vpp-translate-utils</artifactId>
354 +        </dependency>
355 +
356 +        <!-- DI -->
357 +        <dependency>
358 +            <groupId>com.google.inject</groupId>
359 +            <artifactId>guice</artifactId>
360 +        </dependency>
361 +        <dependency>
362 +            <groupId>net.jmob</groupId>
363 +            <artifactId>guice.conf</artifactId>
364 +        </dependency>
365 +        <dependency>
366 +            <groupId>com.google.inject.extensions</groupId>
367 +            <artifactId>guice-multibindings</artifactId>
368 +        </dependency>
369 +        <dependency>
370 +            <groupId>io.fd.honeycomb</groupId>
371 +            <artifactId>translate-impl</artifactId>
372 +            <version>1.17.04.1-SNAPSHOT</version>
373 +        </dependency>
374 +
375 +
376 +        <!-- Testing dependencies-->
377 +        <dependency>
378 +            <groupId>com.google.inject</groupId>
379 +            <artifactId>guice</artifactId>
380 +        </dependency>
381 +        <dependency>
382 +            <groupId>net.jmob</groupId>
383 +            <artifactId>guice.conf</artifactId>
384 +        </dependency>
385 +        <dependency>
386 +            <groupId>com.google.inject.extensions</groupId>
387 +            <artifactId>guice-multibindings</artifactId>
388 +        </dependency>
389 +
390 +        <dependency>
391 +            <groupId>junit</groupId>
392 +            <artifactId>junit</artifactId>
393 +            <scope>test</scope>
394 +        </dependency>
395 +        <dependency>
396 +            <groupId>io.fd.hc2vpp.common</groupId>
397 +            <artifactId>vpp-translate-test</artifactId>
398 +            <version>${hc2vpp.common.version}</version>
399 +            <scope>test</scope>
400 +        </dependency>
401 +        <dependency>
402 +            <groupId>org.mockito</groupId>
403 +            <artifactId>mockito-core</artifactId>
404 +            <scope>test</scope>
405 +        </dependency>
406 +        <dependency>
407 +            <groupId>com.google.inject.extensions</groupId>
408 +            <artifactId>guice-testlib</artifactId>
409 +            <scope>test</scope>
410 +        </dependency>
411 +        <dependency>
412 +            <groupId>org.hamcrest</groupId>
413 +            <artifactId>hamcrest-all</artifactId>
414 +            <scope>test</scope>
415 +        </dependency>
416 +        <dependency>
417 +            <groupId>io.fd.honeycomb.infra</groupId>
418 +            <artifactId>test-tools</artifactId>
419 +            <version>${project.version}</version>
420 +            <scope>test</scope>
421 +        </dependency>
422 +    </dependencies>
423 +</project>
424 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
425 new file mode 100644
426 index 0000000..0cd6006
427 --- /dev/null
428 +++ b/ves/ves-impl/src/main/java/io/fd/hc2vpp/ves/VesModule.java
429 @@ -0,0 +1,67 @@
430 +/*
431 + * Copyright (c) 2017 Intel Corp and/or its affiliates.
432 + *
433 + * Licensed under the Apache License, Version 2.0 (the "License");
434 + * you may not use this file except in compliance with the License.
435 + * You may obtain a copy of the License at:
436 + *
437 + *     http://www.apache.org/licenses/LICENSE-2.0
438 + *
439 + * Unless required by applicable law or agreed to in writing, software
440 + * distributed under the License is distributed on an "AS IS" BASIS,
441 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
442 + * See the License for the specific language governing permissions and
443 + * limitations under the License.
444 + */
445 +
446 +package io.fd.hc2vpp.ves;
447 +
448 +import com.google.common.annotations.VisibleForTesting;
449 +import com.google.inject.AbstractModule;
450 +import com.google.inject.Provider;
451 +import com.google.inject.Singleton;
452 +import com.google.inject.multibindings.Multibinder;
453 +import io.fd.hc2vpp.ves.jvpp.JVppVesProvider;
454 +import io.fd.hc2vpp.ves.read.VesReaderFactory;
455 +import io.fd.hc2vpp.ves.write.VesWriterFactory;
456 +import io.fd.honeycomb.translate.read.ReaderFactory;
457 +import io.fd.honeycomb.translate.write.WriterFactory;
458 +import io.fd.vpp.jvpp.ves.future.FutureJVppVesFacade;
459 +import org.slf4j.Logger;
460 +import org.slf4j.LoggerFactory;
461 +
462 +/**
463 + * VesModule class instantiating ves plugin components.
464 + */
465 +public final class VesModule extends AbstractModule {
466 +
467 +    private static final Logger LOG = LoggerFactory.getLogger(VesModule.class);
468 +    private final Class<? extends Provider<FutureJVppVesFacade>> jvppVesProviderClass;
469 +
470 +    public VesModule() {
471 +        this(JVppVesProvider.class);
472 +    }
473 +
474 +    @VisibleForTesting
475 +    VesModule(Class<? extends Provider<FutureJVppVesFacade>> jvppVesProvider) {
476 +        this.jvppVesProviderClass = jvppVesProvider;
477 +    }
478 +
479 +    @Override
480 +    protected void configure() {
481 +        LOG.info("Installing VES Agent module");
482 +
483 +        // Bind to Plugin's JVPP
484 +        bind(FutureJVppVesFacade.class).toProvider(jvppVesProviderClass).in(Singleton.class);
485 +
486 +        LOG.info("Injecting writers factories");
487 +        final Multibinder<WriterFactory> writerFactoryBinder = Multibinder.newSetBinder(binder(), WriterFactory.class);
488 +        writerFactoryBinder.addBinding().to(VesWriterFactory.class);
489 +
490 +        LOG.info("Injecting readers factories");
491 +        final Multibinder<ReaderFactory> readerFactoryBinder = Multibinder.newSetBinder(binder(), ReaderFactory.class);
492 +        readerFactoryBinder.addBinding().to(VesReaderFactory.class);
493 +
494 +        LOG.info("Module VES Agent successfully configured");
495 +    }
496 +}
497 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
498 new file mode 100644
499 index 0000000..8afed84
500 --- /dev/null
501 +++ b/ves/ves-impl/src/main/java/io/fd/hc2vpp/ves/jvpp/JVppVesProvider.java
502 @@ -0,0 +1,59 @@
503 +/*
504 + * Copyright (c) 2017 Intel Corp and/or its affiliates.
505 + *
506 + * Licensed under the Apache License, Version 2.0 (the "License");
507 + * you may not use this file except in compliance with the License.
508 + * You may obtain a copy of the License at:
509 + *
510 + *     http://www.apache.org/licenses/LICENSE-2.0
511 + *
512 + * Unless required by applicable law or agreed to in writing, software
513 + * distributed under the License is distributed on an "AS IS" BASIS,
514 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
515 + * See the License for the specific language governing permissions and
516 + * limitations under the License.
517 + */
518 +
519 +package io.fd.hc2vpp.ves.jvpp;
520 +
521 +import com.google.inject.Inject;
522 +import io.fd.honeycomb.infra.distro.ProviderTrait;
523 +import io.fd.vpp.jvpp.JVppRegistry;
524 +import io.fd.vpp.jvpp.ves.JVppVesImpl;
525 +import io.fd.vpp.jvpp.ves.future.FutureJVppVesFacade;
526 +import java.io.IOException;
527 +import org.slf4j.Logger;
528 +import org.slf4j.LoggerFactory;
529 +
530 +/**
531 + * Provides future API for jvpp-ves plugin. Must be a singleton due to shutdown hook usage.
532 + * Registers shutdown hook to free plugin's resources on shutdown.
533 + */
534 +public final class JVppVesProvider extends ProviderTrait<FutureJVppVesFacade> {
535 +
536 +    private static final Logger LOG = LoggerFactory.getLogger(JVppVesProvider.class);
537 +
538 +    @Inject
539 +    private JVppRegistry registry;
540 +
541 +    @Override
542 +    protected FutureJVppVesFacade create() {
543 +        try {
544 +            final JVppVesImpl jvppVes = new JVppVesImpl();
545 +            Runtime.getRuntime().addShutdownHook(new Thread() {
546 +                @Override
547 +                public void run() {
548 +                    LOG.info("Unloading jvpp-ves plugin");
549 +                    jvppVes.close();
550 +                    LOG.info("Successfully unloaded jvpp-ves plugin");
551 +                }
552 +            });
553 +
554 +            LOG.info("Successfully loaded jvpp-ves plugin");
555 +            return new FutureJVppVesFacade(registry, jvppVes);
556 +        } catch (IOException e) {
557 +            throw new IllegalStateException("Unable to open VPP management connection", e);
558 +        }
559 +    }
560 +}
561 +
562 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
563 new file mode 100644
564 index 0000000..bef652f
565 --- /dev/null
566 +++ b/ves/ves-impl/src/main/java/io/fd/hc2vpp/ves/read/VesReaderFactory.java
567 @@ -0,0 +1,50 @@
568 +/*
569 + * Copyright (c) 2017 Intel Corp and/or its affiliates.
570 + *
571 + * Licensed under the Apache License, Version 2.0 (the "License");
572 + * you may not use this file except in compliance with the License.
573 + * You may obtain a copy of the License at:
574 + *
575 + *     http://www.apache.org/licenses/LICENSE-2.0
576 + *
577 + * Unless required by applicable law or agreed to in writing, software
578 + * distributed under the License is distributed on an "AS IS" BASIS,
579 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
580 + * See the License for the specific language governing permissions and
581 + * limitations under the License.
582 + */
583 +
584 +package io.fd.hc2vpp.ves.read;
585 +
586 +import com.google.inject.Inject;
587 +import io.fd.honeycomb.translate.read.ReaderFactory;
588 +import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder;
589 +import io.fd.vpp.jvpp.core.future.FutureJVppCore;
590 +import javax.annotation.Nonnull;
591 +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vesagent.rev170801.Vesagent;
592 +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vesagent.rev170801.VesagentBuilder;
593 +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vesagent.rev170801.vesagent.attributes.Config;
594 +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vesagent.rev170801.vesagent.attributes.ConfigBuilder;
595 +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vesagent.rev170801.vesagent.attributes.Mode;
596 +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vesagent.rev170801.vesagent.attributes.ModeBuilder;
597 +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
598 +
599 +/**
600 + * Factory producing writers for VES Agent plugin's data.
601 + */
602 +public final class VesReaderFactory implements ReaderFactory {
603 +
604 +    private static final InstanceIdentifier<Vesagent> VESAGENT_ID = InstanceIdentifier.create(Vesagent.class);
605 +    private static final InstanceIdentifier<Config> CONFIG_ID = InstanceIdentifier.create(Config.class);
606 +    private static final InstanceIdentifier<Mode> MODE_ID = InstanceIdentifier.create(Mode.class);
607 +
608 +    @Inject
609 +    private FutureJVppCore vppApi;
610 +
611 +    @Override
612 +    public void init(@Nonnull final ModifiableReaderRegistryBuilder registry) {
613 +        registry.addStructuralReader(VESAGENT_ID, VesagentBuilder.class);
614 +        registry.addStructuralReader(CONFIG_ID, ConfigBuilder.class);
615 +        registry.addStructuralReader(MODE_ID, ModeBuilder.class);
616 +    }
617 +}
618 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
619 new file mode 100644
620 index 0000000..e06afa7
621 --- /dev/null
622 +++ b/ves/ves-impl/src/main/java/io/fd/hc2vpp/ves/write/VesConfigCustomizer.java
623 @@ -0,0 +1,127 @@
624 +/*
625 + * Copyright (c) 2017 Intel Corp and/or its affiliates.
626 + *
627 + * Licensed under the Apache License, Version 2.0 (the "License");
628 + * you may not use this file except in compliance with the License.
629 + * You may obtain a copy of the License at:
630 + *
631 + *     http://www.apache.org/licenses/LICENSE-2.0
632 + *
633 + * Unless required by applicable law or agreed to in writing, software
634 + * distributed under the License is distributed on an "AS IS" BASIS,
635 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
636 + * See the License for the specific language governing permissions and
637 + * limitations under the License.
638 + */
639 +
640 +package io.fd.hc2vpp.ves.write;
641 +
642 +import static com.google.common.base.Preconditions.checkArgument;
643 +
644 +import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
645 +import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
646 +import io.fd.hc2vpp.common.translate.util.Ipv4Translator;
647 +import io.fd.hc2vpp.common.translate.util.Ipv6Translator;
648 +import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
649 +import io.fd.honeycomb.translate.spi.write.WriterCustomizer;
650 +import io.fd.honeycomb.translate.write.WriteContext;
651 +import io.fd.honeycomb.translate.write.WriteFailedException;
652 +import io.fd.vpp.jvpp.core.future.FutureJVppCore;
653 +//import io.fd.vpp.jvpp.ves.future.FutureJVppVes;
654 +import io.fd.vpp.jvpp.ves.dto.VesAgentConfig;
655 +import io.fd.vpp.jvpp.ves.future.FutureJVppVesFacade;
656 +import javax.annotation.Nonnull;
657 +//import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vesagent.rev170801.Vesagent;
658 +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vesagent.rev170801.vesagent.attributes.Config;
659 +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vesagent.rev170801.vesagent.attributes.ConfigBuilder;
660 +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
661 +import org.slf4j.Logger;
662 +import org.slf4j.LoggerFactory;
663 +
664 +final class VesConfigCustomizer extends FutureJVppCustomizer implements WriterCustomizer<Config>,
665 +    JvppReplyConsumer, ByteDataTranslator, Ipv6Translator, Ipv4Translator {
666 +    private static final Logger LOG = LoggerFactory.getLogger(VesConfigCustomizer.class);
667 +
668 +    private final FutureJVppVesFacade jvppVes;
669 +
670 +    VesConfigCustomizer(final FutureJVppCore vppApi, final FutureJVppVesFacade jvppVes) {
671 +        super(vppApi);
672 +        this.jvppVes = jvppVes;
673 +    }
674 +
675 +    @Override
676 +    public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<Config> iid, @Nonnull final Config dataAfter,
677 +                                       @Nonnull final WriteContext writeContext) throws WriteFailedException {
678 +        ConfigBuilder configBuilder = new ConfigBuilder();
679 +        InstanceIdentifier<Config> id = iid;
680 +
681 +        LOG.debug("Writing VES Agent Config {} dataAfter={}", id, dataAfter);
682 +        checkArgument(dataAfter.getServerAddr() != null && dataAfter.getServerAddr().getValue() != null
683 +            && dataAfter.getServerPort() != 0, "VES Server Address and Port need to be configured");
684 +
685 +        configBuilder.setServerAddr(dataAfter.getServerAddr())
686 +                     .setServerPort(dataAfter.getServerPort())
687 +                     .setReadInterval(dataAfter.getReadInterval())
688 +                     .setIsAdd(1L);
689 +
690 +        setVesAgentConfig(id, configBuilder.build());
691 +    }
692 +
693 +    @Override
694 +    public void updateCurrentAttributes(@Nonnull final InstanceIdentifier<Config> iid, @Nonnull final Config dataBefore,
695 +                                        @Nonnull final Config dataAfter, @Nonnull final WriteContext writeContext)
696 +        throws WriteFailedException {
697 +        ConfigBuilder configBuilder = new ConfigBuilder();
698 +        InstanceIdentifier<Config> id = iid;
699 +
700 +        checkArgument(dataBefore.getServerAddr() != null && dataBefore.getServerAddr().getValue() != null
701 +            && dataBefore.getServerPort() != 0, "VES Server Address and Port need to be configured");
702 +        checkArgument(dataAfter.getServerAddr() != null && dataAfter.getServerAddr().getValue() != null
703 +            && dataAfter.getServerPort() != 0, "VES Server Address and Port need to be configured");
704 +
705 +        // remove old configuration:
706 +        configBuilder.setServerAddr(dataBefore.getServerAddr())
707 +                     .setServerPort(dataBefore.getServerPort())
708 +                     .setReadInterval(dataBefore.getReadInterval())
709 +                     .setIsAdd(0L);
710 +        setVesAgentConfig(id, configBuilder.build());
711 +
712 +        // and add new one:
713 +        configBuilder.setServerAddr(dataAfter.getServerAddr())
714 +                     .setServerPort(dataAfter.getServerPort())
715 +                     .setReadInterval(dataAfter.getReadInterval())
716 +                     .setIsAdd(1L);
717 +        setVesAgentConfig(id, configBuilder.build());
718 +    }
719 +
720 +    @Override
721 +    public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<Config> iid, @Nonnull final Config dataBefore,
722 +                                        @Nonnull final WriteContext writeContext) throws WriteFailedException {
723 +        ConfigBuilder configBuilder = new ConfigBuilder();
724 +        InstanceIdentifier<Config> id = iid;
725 +        LOG.debug("Removing VES Agent {} dataBefore={}", id, dataBefore);
726 +
727 +        checkArgument(dataBefore.getServerAddr() != null && dataBefore.getServerAddr().getValue() != null
728 +            && dataBefore.getServerPort() != 0, "VES Server Address and Port need to be dataBeforeured");
729 +
730 +        configBuilder.setServerAddr(dataBefore.getServerAddr())
731 +                     .setServerPort(dataBefore.getServerPort())
732 +                     .setReadInterval(dataBefore.getReadInterval())
733 +                     .setIsAdd(0L);
734 +
735 +        setVesAgentConfig(id, configBuilder.build());
736 +    }
737 +
738 +    private void setVesAgentConfig(final InstanceIdentifier<Config> id, final Config config)
739 +        throws WriteFailedException {
740 +        final VesAgentConfig request = new VesAgentConfig();
741 +
742 +        request.serverPort = config.getServerPort().byteValue();
743 +        request.readInterval = config.getReadInterval().byteValue();
744 +        request.isAdd = config.getIsAdd().byteValue();
745 +        request.serverAddr = ipv4AddressNoZoneToArray(config.getServerAddr().getValue());
746 +
747 +        LOG.debug("VES agent config change id={} request={}", id, request);
748 +        getReplyForWrite(jvppVes.vesAgentConfig(request).toCompletableFuture(), id);
749 +    }
750 +}
751 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
752 new file mode 100644
753 index 0000000..248d819
754 --- /dev/null
755 +++ b/ves/ves-impl/src/main/java/io/fd/hc2vpp/ves/write/VesModeCustomizer.java
756 @@ -0,0 +1,99 @@
757 +/*
758 + * Copyright (c) 2017 Intel Corp and/or its affiliates.
759 + *
760 + * Licensed under the Apache License, Version 2.0 (the "License");
761 + * you may not use this file except in compliance with the License.
762 + * You may obtain a copy of the License at:
763 + *
764 + *     http://www.apache.org/licenses/LICENSE-2.0
765 + *
766 + * Unless required by applicable law or agreed to in writing, software
767 + * distributed under the License is distributed on an "AS IS" BASIS,
768 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
769 + * See the License for the specific language governing permissions and
770 + * limitations under the License.
771 + */
772 +
773 +package io.fd.hc2vpp.ves.write;
774 +
775 +import static com.google.common.base.Preconditions.checkArgument;
776 +
777 +import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
778 +import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
779 +import io.fd.hc2vpp.common.translate.util.Ipv4Translator;
780 +import io.fd.hc2vpp.common.translate.util.Ipv6Translator;
781 +import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
782 +import io.fd.honeycomb.translate.spi.write.WriterCustomizer;
783 +import io.fd.honeycomb.translate.write.WriteContext;
784 +import io.fd.honeycomb.translate.write.WriteFailedException;
785 +import io.fd.vpp.jvpp.core.future.FutureJVppCore;
786 +//import io.fd.vpp.jvpp.ves.future.FutureJVppVes;
787 +import io.fd.vpp.jvpp.ves.dto.VesAgentMode;
788 +import io.fd.vpp.jvpp.ves.future.FutureJVppVesFacade;
789 +import javax.annotation.Nonnull;
790 +//import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vesagent.rev170801.Vesagent;
791 +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vesagent.rev170801.vesagent.attributes.Mode;
792 +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vesagent.rev170801.vesagent.attributes.ModeBuilder;
793 +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
794 +import org.slf4j.Logger;
795 +import org.slf4j.LoggerFactory;
796 +
797 +final class VesModeCustomizer extends FutureJVppCustomizer implements WriterCustomizer<Mode>,
798 +    JvppReplyConsumer, ByteDataTranslator, Ipv6Translator, Ipv4Translator {
799 +    private static final Logger LOG = LoggerFactory.getLogger(VesModeCustomizer.class);
800 +
801 +    private final FutureJVppVesFacade jvppVes;
802 +
803 +    VesModeCustomizer(final FutureJVppCore vppApi, final FutureJVppVesFacade jvppVes) {
804 +        super(vppApi);
805 +        this.jvppVes = jvppVes;
806 +    }
807 +
808 +    @Override
809 +    public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<Mode> iid, @Nonnull final Mode dataAfter,
810 +                                       @Nonnull final WriteContext writeContext) throws WriteFailedException {
811 +        LOG.debug("Writing VES Agent Working Mode {} dataAfter={}", iid, dataAfter);
812 +
813 +        checkArgument(dataAfter.getSourceName() != null && dataAfter.getWorkingMode() != null && dataAfter.getBasePacketLoss() <= 100,
814 +                      "VES Agent Working Mode need to be correctly configured.");
815 +
816 +        setVesAgentMode(iid, dataAfter);
817 +    }
818 +
819 +    @Override
820 +    public void updateCurrentAttributes(@Nonnull final InstanceIdentifier<Mode> iid, @Nonnull final Mode dataBefore,
821 +                                        @Nonnull final Mode dataAfter, @Nonnull final WriteContext writeContext)
822 +        throws WriteFailedException {
823 +        LOG.debug("Writing VES Agent Working Mode {} {}-->{}", iid, dataBefore, dataAfter);
824 +
825 +        checkArgument(dataAfter.getSourceName() != null && dataAfter.getWorkingMode() != null && dataAfter.getBasePacketLoss() <= 100,
826 +                      "VES Agent Working Mode need to be correctly configured.");
827 +
828 +        setVesAgentMode(iid, dataAfter);
829 +    }
830 +
831 +    @Override
832 +    public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<Mode> iid, @Nonnull final Mode dataBefore,
833 +                                        @Nonnull final WriteContext writeContext) throws WriteFailedException {
834 +        ModeBuilder modeBuilder = new ModeBuilder();
835 +        LOG.debug("Restoring VES Mode {} dataBefore={} to default.", iid, dataBefore);
836 +
837 +        modeBuilder.setWorkingMode("Real")
838 +                   .setBasePacketLoss(0L)
839 +                   .setSourceName("");
840 +
841 +        setVesAgentMode(iid, modeBuilder.build());
842 +    }
843 +
844 +    private void setVesAgentMode(final InstanceIdentifier<Mode> id, final Mode mode)
845 +        throws WriteFailedException {
846 +        final VesAgentMode request = new VesAgentMode();
847 +
848 +        request.pktLossRate = mode.getBasePacketLoss().byteValue();
849 +        request.workMode = mode.getWorkingMode().getBytes();
850 +        request.sourceName = mode.getSourceName().getBytes();
851 +
852 +        LOG.debug("VES agent working mode change id={} request={}", id, request);
853 +        getReplyForWrite(jvppVes.vesAgentMode(request).toCompletableFuture(), id);
854 +    }
855 +}
856 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
857 new file mode 100644
858 index 0000000..581f046
859 --- /dev/null
860 +++ b/ves/ves-impl/src/main/java/io/fd/hc2vpp/ves/write/VesWriterFactory.java
861 @@ -0,0 +1,54 @@
862 +/*
863 + * Copyright (c) 2017 Intel Corp and/or its affiliates.
864 + *
865 + * Licensed under the Apache License, Version 2.0 (the "License");
866 + * you may not use this file except in compliance with the License.
867 + * You may obtain a copy of the License at:
868 + *
869 + *     http://www.apache.org/licenses/LICENSE-2.0
870 + *
871 + * Unless required by applicable law or agreed to in writing, software
872 + * distributed under the License is distributed on an "AS IS" BASIS,
873 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
874 + * See the License for the specific language governing permissions and
875 + * limitations under the License.
876 + */
877 +
878 +package io.fd.hc2vpp.ves.write;
879 +
880 +import com.google.common.collect.ImmutableSet;
881 +import com.google.inject.Inject;
882 +import io.fd.honeycomb.translate.impl.write.GenericWriter;
883 +import io.fd.honeycomb.translate.write.WriterFactory;
884 +import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder;
885 +import io.fd.vpp.jvpp.core.future.FutureJVppCore;
886 +import io.fd.vpp.jvpp.ves.future.FutureJVppVesFacade;
887 +import javax.annotation.Nonnull;
888 +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vesagent.rev170801.Vesagent;
889 +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vesagent.rev170801.vesagent.attributes.Config;
890 +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vesagent.rev170801.vesagent.attributes.Mode;
891 +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
892 +
893 +/**
894 + * Factory producing writers for VES Agent plugin's data.
895 + */
896 +public final class VesWriterFactory implements WriterFactory {
897 +
898 +    private static final InstanceIdentifier<Vesagent> VESAGENT_ID = InstanceIdentifier.create(Vesagent.class);
899 +
900 +    @Inject
901 +    private FutureJVppCore vppApi;
902 +
903 +    @Inject
904 +    protected FutureJVppVesFacade futureVesFacade;
905 +
906 +    @Override
907 +    public void init(@Nonnull final ModifiableWriterRegistryBuilder registry) {
908 +         registry.add(new GenericWriter<>(VESAGENT_ID,
909 +             new VesagentCustomizer(vppApi, futureVesFacade)));
910 +         registry.add(new GenericWriter<>(VESAGENT_ID.child(Config.class),
911 +             new VesConfigCustomizer(vppApi, futureVesFacade)));
912 +         registry.add(new GenericWriter<>(VESAGENT_ID.child(Mode.class),
913 +             new VesModeCustomizer(vppApi, futureVesFacade)));
914 +    }
915 +}
916 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
917 new file mode 100644
918 index 0000000..62e46cd
919 --- /dev/null
920 +++ b/ves/ves-impl/src/main/java/io/fd/hc2vpp/ves/write/VesagentCustomizer.java
921 @@ -0,0 +1,131 @@
922 +/*
923 + * Copyright (c) 2017 Intel Corp and/or its affiliates.
924 + *
925 + * Licensed under the Apache License, Version 2.0 (the "License");
926 + * you may not use this file except in compliance with the License.
927 + * You may obtain a copy of the License at:
928 + *
929 + *     http://www.apache.org/licenses/LICENSE-2.0
930 + *
931 + * Unless required by applicable law or agreed to in writing, software
932 + * distributed under the License is distributed on an "AS IS" BASIS,
933 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
934 + * See the License for the specific language governing permissions and
935 + * limitations under the License.
936 + */
937 +
938 +package io.fd.hc2vpp.ves.write;
939 +
940 +import static com.google.common.base.Preconditions.checkArgument;
941 +
942 +import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
943 +import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
944 +import io.fd.hc2vpp.common.translate.util.Ipv4Translator;
945 +import io.fd.hc2vpp.common.translate.util.Ipv6Translator;
946 +import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
947 +import io.fd.honeycomb.translate.spi.write.WriterCustomizer;
948 +import io.fd.honeycomb.translate.write.WriteContext;
949 +import io.fd.honeycomb.translate.write.WriteFailedException;
950 +import io.fd.vpp.jvpp.core.future.FutureJVppCore;
951 +//import io.fd.vpp.jvpp.ves.future.FutureJVppVes;
952 +import io.fd.vpp.jvpp.ves.dto.VesAgentConfig;
953 +import io.fd.vpp.jvpp.ves.future.FutureJVppVesFacade;
954 +import javax.annotation.Nonnull;
955 +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vesagent.rev170801.Vesagent;
956 +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vesagent.rev170801.vesagent.attributes.Config;
957 +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vesagent.rev170801.vesagent.attributes.ConfigBuilder;
958 +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
959 +import org.slf4j.Logger;
960 +import org.slf4j.LoggerFactory;
961 +
962 +final class VesagentCustomizer extends FutureJVppCustomizer implements WriterCustomizer<Vesagent>,
963 +    JvppReplyConsumer, ByteDataTranslator, Ipv6Translator, Ipv4Translator {
964 +    private static final Logger LOG = LoggerFactory.getLogger(VesagentCustomizer.class);
965 +
966 +    private final FutureJVppVesFacade jvppVes;
967 +
968 +    VesagentCustomizer(final FutureJVppCore vppApi, final FutureJVppVesFacade jvppVes) {
969 +        super(vppApi);
970 +        this.jvppVes = jvppVes;
971 +    }
972 +
973 +    @Override
974 +    public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<Vesagent> iid, @Nonnull final Vesagent dataAfter,
975 +                                       @Nonnull final WriteContext writeContext) throws WriteFailedException {
976 +        Config config = dataAfter.getConfig();
977 +        ConfigBuilder configBuilder = new ConfigBuilder();
978 +        InstanceIdentifier<Config> id = iid.child(Config.class);
979 +
980 +        LOG.debug("Writing VES Agent Config {} dataAfter={}", id, config);
981 +        checkArgument(config.getServerAddr() != null && config.getServerAddr().getValue() != null
982 +            && config.getServerPort() != 0, "VES Server Address and Port need to be configured");
983 +
984 +        configBuilder.setServerAddr(config.getServerAddr())
985 +                     .setServerPort(config.getServerPort())
986 +                     .setReadInterval(config.getReadInterval())
987 +                     .setIsAdd(1L);
988 +
989 +        setVesAgentConfig(id, configBuilder.build());
990 +    }
991 +
992 +    @Override
993 +    public void updateCurrentAttributes(@Nonnull final InstanceIdentifier<Vesagent> iid, @Nonnull final Vesagent dataBefore,
994 +                                        @Nonnull final Vesagent dataAfter, @Nonnull final WriteContext writeContext)
995 +        throws WriteFailedException {
996 +        Config configBefore = dataBefore.getConfig();
997 +        Config configAfter = dataAfter.getConfig();
998 +        ConfigBuilder configBuilder = new ConfigBuilder();
999 +        InstanceIdentifier<Config> id = iid.child(Config.class);
1000 +
1001 +        checkArgument(configBefore.getServerAddr() != null && configBefore.getServerAddr().getValue() != null
1002 +            && configBefore.getServerPort() != 0, "VES Server Address and Port need to be configured");
1003 +        checkArgument(configAfter.getServerAddr() != null && configAfter.getServerAddr().getValue() != null
1004 +            && configAfter.getServerPort() != 0, "VES Server Address and Port need to be configured");
1005 +
1006 +        // remove old configuration:
1007 +        configBuilder.setServerAddr(configBefore.getServerAddr())
1008 +                     .setServerPort(configBefore.getServerPort())
1009 +                     .setReadInterval(configBefore.getReadInterval())
1010 +                     .setIsAdd(0L);
1011 +        setVesAgentConfig(id, configBuilder.build());
1012 +
1013 +        // and add new one:
1014 +        configBuilder.setServerAddr(configAfter.getServerAddr())
1015 +                     .setServerPort(configAfter.getServerPort())
1016 +                     .setReadInterval(configAfter.getReadInterval())
1017 +                     .setIsAdd(1L);
1018 +        setVesAgentConfig(id, configBuilder.build());
1019 +    }
1020 +
1021 +    @Override
1022 +    public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<Vesagent> iid, @Nonnull final Vesagent dataBefore,
1023 +                                        @Nonnull final WriteContext writeContext) throws WriteFailedException {
1024 +        Config config = dataBefore.getConfig();
1025 +        InstanceIdentifier<Config> id = iid.child(Config.class);
1026 +        LOG.debug("Removing VES Agent {} dataBefore={}", id, config);
1027 +
1028 +        checkArgument(config.getServerAddr() != null && config.getServerAddr().getValue() != null
1029 +            && config.getServerPort() != 0, "VES Server Address and Port need to be configured");
1030 +
1031 +        ConfigBuilder configBuilder = new ConfigBuilder();
1032 +        configBuilder.setServerAddr(config.getServerAddr())
1033 +                     .setServerPort(config.getServerPort())
1034 +                     .setReadInterval(config.getReadInterval())
1035 +                     .setIsAdd(0L);
1036 +
1037 +        setVesAgentConfig(id, configBuilder.build());
1038 +    }
1039 +
1040 +    private void setVesAgentConfig(final InstanceIdentifier<Config> id, final Config config)
1041 +        throws WriteFailedException {
1042 +        final VesAgentConfig request = new VesAgentConfig();
1043 +
1044 +        request.serverPort = config.getServerPort().byteValue();
1045 +        request.readInterval = config.getReadInterval().byteValue();
1046 +        request.isAdd = config.getIsAdd().byteValue();
1047 +        request.serverAddr = ipv4AddressNoZoneToArray(config.getServerAddr().getValue());
1048 +
1049 +        LOG.debug("VES agent config change id={} request={}", id, request);
1050 +        getReplyForWrite(jvppVes.vesAgentConfig(request).toCompletableFuture(), id);
1051 +    }
1052 +}
1053 diff --git a/vpp-integration/minimal-distribution/pom.xml b/vpp-integration/minimal-distribution/pom.xml
1054 index e126114..ca0e5b2 100644
1055 --- a/vpp-integration/minimal-distribution/pom.xml
1056 +++ b/vpp-integration/minimal-distribution/pom.xml
1057 @@ -40,6 +40,7 @@
1058      <routing.version>1.17.04.1-SNAPSHOT</routing.version>
1059      <acl.version>1.17.04.1-SNAPSHOT</acl.version>
1060      <dhcp.version>1.17.04.1-SNAPSHOT</dhcp.version>
1061 +    <vesagent.version>1.17.04.1-SNAPSHOT</vesagent.version>
1062      <vpp.classifier.version>1.17.04.1-SNAPSHOT</vpp.classifier.version>
1063      <l3-impl.version>1.17.04.1-SNAPSHOT</l3-impl.version>
1064      <vpp-management-impl.version>1.17.04.1-SNAPSHOT</vpp-management-impl.version>
1065 @@ -63,6 +64,7 @@
1066        io.fd.hc2vpp.routing.RoutingModule,
1067        io.fd.hc2vpp.acl.AclModule,
1068        io.fd.hc2vpp.dhcp.DhcpModule,
1069 +      io.fd.hc2vpp.ves.VesModule,
1070        io.fd.hc2vpp.policer.PolicerModule,
1071        // io.fd.hc2vpp.vppnsh.impl.VppNshModule,
1072        <!-- Nsh module by default disabled, because it needs vpp-nsh plugin, which is not part of vpp codebase.-->
1073 @@ -151,6 +153,11 @@
1074        <version>${dhcp.version}</version>
1075      </dependency>
1076      <dependency>
1077 +      <groupId>io.fd.hc2vpp.ves</groupId>
1078 +      <artifactId>ves-impl</artifactId>
1079 +      <version>${vesagent.version}</version>
1080 +    </dependency>
1081 +    <dependency>
1082        <groupId>io.fd.hc2vpp.management</groupId>
1083        <artifactId>vpp-management-impl</artifactId>
1084        <version>${vpp-management-impl.version}</version>