8c2e31b70d572f555267d5128be5675b62b8b899
[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 538a5d98..581bedfc 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 00000000..682e7555
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 00000000..1ded0109
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 00000000..b561268c
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 00000000..78bf47b9
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 00000000..a3c79797
171 --- /dev/null
172 +++ b/ves/ves-api/src/main/yang/vesagent.yang
173 @@ -0,0 +1,71 @@
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 +    }
240 +
241 +    container vesagent {
242 +        uses vesagent-attributes;
243 +    }
244 +}
245 diff --git a/ves/ves-impl/asciidoc/Readme.adoc b/ves/ves-impl/asciidoc/Readme.adoc
246 new file mode 100644
247 index 00000000..e07fb05f
248 --- /dev/null
249 +++ b/ves/ves-impl/asciidoc/Readme.adoc
250 @@ -0,0 +1,3 @@
251 += vesagent-impl
252 +
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
256 new file mode 100644
257 index 00000000..5ed2c1b4
258 --- /dev/null
259 +++ b/ves/ves-impl/pom.xml
260 @@ -0,0 +1,157 @@
261 +<?xml version="1.0" encoding="UTF-8"?>
262 +<!--
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:
267 +
268 +     http://www.apache.org/licenses/LICENSE-2.0
269 +
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">
276 +    <parent>
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>
281 +    </parent>
282 +
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>
289 +
290 +    <properties>
291 +        <honeycomb.infra.version>1.17.04.1-SNAPSHOT</honeycomb.infra.version>
292 +        <hc2vpp.common.version>1.17.04.1-SNAPSHOT</hc2vpp.common.version>
293 +    </properties>
294 +
295 +    <dependencies>
296 +        <dependency>
297 +            <groupId>${project.groupId}</groupId>
298 +            <artifactId>ves-api</artifactId>
299 +            <version>${project.version}</version>
300 +        </dependency>
301 +
302 +        <!--VPP common-->
303 +        <dependency>
304 +            <groupId>io.fd.hc2vpp.common</groupId>
305 +            <artifactId>vpp-translate-utils</artifactId>
306 +        </dependency>
307 +
308 +        <!-- JVPP -->
309 +        <dependency>
310 +            <groupId>io.fd.vpp</groupId>
311 +            <artifactId>jvpp-registry</artifactId>
312 +        </dependency>
313 +        <dependency>
314 +            <groupId>io.fd.vpp</groupId>
315 +            <artifactId>jvpp-ves</artifactId>
316 +            <version>17.04.2-SNAPSHOT</version>
317 +        </dependency>
318 +
319 +        <!-- Honeycomb infrastructure-->
320 +        <dependency>
321 +            <groupId>io.fd.honeycomb</groupId>
322 +            <artifactId>minimal-distribution</artifactId>
323 +            <version>${honeycomb.infra.version}</version>
324 +        </dependency>
325 +
326 +        <dependency>
327 +            <groupId>io.fd.honeycomb</groupId>
328 +            <artifactId>translate-api</artifactId>
329 +            <version>${honeycomb.infra.version}</version>
330 +        </dependency>
331 +
332 +        <dependency>
333 +            <groupId>io.fd.honeycomb</groupId>
334 +            <artifactId>translate-spi</artifactId>
335 +            <version>${honeycomb.infra.version}</version>
336 +        </dependency>
337 +
338 +        <dependency>
339 +            <groupId>io.fd.honeycomb</groupId>
340 +            <artifactId>cfg-init</artifactId>
341 +            <version>${honeycomb.infra.version}</version>
342 +        </dependency>
343 +
344 +        <!-- Translation -->
345 +        <dependency>
346 +            <groupId>io.fd.hc2vpp.common</groupId>
347 +            <artifactId>vpp-translate-utils</artifactId>
348 +        </dependency>
349 +
350 +        <!-- DI -->
351 +        <dependency>
352 +            <groupId>com.google.inject</groupId>
353 +            <artifactId>guice</artifactId>
354 +        </dependency>
355 +        <dependency>
356 +            <groupId>net.jmob</groupId>
357 +            <artifactId>guice.conf</artifactId>
358 +        </dependency>
359 +        <dependency>
360 +            <groupId>com.google.inject.extensions</groupId>
361 +            <artifactId>guice-multibindings</artifactId>
362 +        </dependency>
363 +        <dependency>
364 +            <groupId>io.fd.honeycomb</groupId>
365 +            <artifactId>translate-impl</artifactId>
366 +            <version>1.17.04.1-SNAPSHOT</version>
367 +        </dependency>
368 +
369 +
370 +        <!-- Testing dependencies-->
371 +        <dependency>
372 +            <groupId>com.google.inject</groupId>
373 +            <artifactId>guice</artifactId>
374 +        </dependency>
375 +        <dependency>
376 +            <groupId>net.jmob</groupId>
377 +            <artifactId>guice.conf</artifactId>
378 +        </dependency>
379 +        <dependency>
380 +            <groupId>com.google.inject.extensions</groupId>
381 +            <artifactId>guice-multibindings</artifactId>
382 +        </dependency>
383 +
384 +        <dependency>
385 +            <groupId>junit</groupId>
386 +            <artifactId>junit</artifactId>
387 +            <scope>test</scope>
388 +        </dependency>
389 +        <dependency>
390 +            <groupId>io.fd.hc2vpp.common</groupId>
391 +            <artifactId>vpp-translate-test</artifactId>
392 +            <version>${hc2vpp.common.version}</version>
393 +            <scope>test</scope>
394 +        </dependency>
395 +        <dependency>
396 +            <groupId>org.mockito</groupId>
397 +            <artifactId>mockito-core</artifactId>
398 +            <scope>test</scope>
399 +        </dependency>
400 +        <dependency>
401 +            <groupId>com.google.inject.extensions</groupId>
402 +            <artifactId>guice-testlib</artifactId>
403 +            <scope>test</scope>
404 +        </dependency>
405 +        <dependency>
406 +            <groupId>org.hamcrest</groupId>
407 +            <artifactId>hamcrest-all</artifactId>
408 +            <scope>test</scope>
409 +        </dependency>
410 +        <dependency>
411 +            <groupId>io.fd.honeycomb.infra</groupId>
412 +            <artifactId>test-tools</artifactId>
413 +            <version>${project.version}</version>
414 +            <scope>test</scope>
415 +        </dependency>
416 +    </dependencies>
417 +</project>
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
419 new file mode 100644
420 index 00000000..0cd60068
421 --- /dev/null
422 +++ b/ves/ves-impl/src/main/java/io/fd/hc2vpp/ves/VesModule.java
423 @@ -0,0 +1,67 @@
424 +/*
425 + * Copyright (c) 2017 Intel Corp and/or its affiliates.
426 + *
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:
430 + *
431 + *     http://www.apache.org/licenses/LICENSE-2.0
432 + *
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.
438 + */
439 +
440 +package io.fd.hc2vpp.ves;
441 +
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;
455 +
456 +/**
457 + * VesModule class instantiating ves plugin components.
458 + */
459 +public final class VesModule extends AbstractModule {
460 +
461 +    private static final Logger LOG = LoggerFactory.getLogger(VesModule.class);
462 +    private final Class<? extends Provider<FutureJVppVesFacade>> jvppVesProviderClass;
463 +
464 +    public VesModule() {
465 +        this(JVppVesProvider.class);
466 +    }
467 +
468 +    @VisibleForTesting
469 +    VesModule(Class<? extends Provider<FutureJVppVesFacade>> jvppVesProvider) {
470 +        this.jvppVesProviderClass = jvppVesProvider;
471 +    }
472 +
473 +    @Override
474 +    protected void configure() {
475 +        LOG.info("Installing VES Agent module");
476 +
477 +        // Bind to Plugin's JVPP
478 +        bind(FutureJVppVesFacade.class).toProvider(jvppVesProviderClass).in(Singleton.class);
479 +
480 +        LOG.info("Injecting writers factories");
481 +        final Multibinder<WriterFactory> writerFactoryBinder = Multibinder.newSetBinder(binder(), WriterFactory.class);
482 +        writerFactoryBinder.addBinding().to(VesWriterFactory.class);
483 +
484 +        LOG.info("Injecting readers factories");
485 +        final Multibinder<ReaderFactory> readerFactoryBinder = Multibinder.newSetBinder(binder(), ReaderFactory.class);
486 +        readerFactoryBinder.addBinding().to(VesReaderFactory.class);
487 +
488 +        LOG.info("Module VES Agent successfully configured");
489 +    }
490 +}
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
492 new file mode 100644
493 index 00000000..8afed84e
494 --- /dev/null
495 +++ b/ves/ves-impl/src/main/java/io/fd/hc2vpp/ves/jvpp/JVppVesProvider.java
496 @@ -0,0 +1,59 @@
497 +/*
498 + * Copyright (c) 2017 Intel Corp and/or its affiliates.
499 + *
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:
503 + *
504 + *     http://www.apache.org/licenses/LICENSE-2.0
505 + *
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.
511 + */
512 +
513 +package io.fd.hc2vpp.ves.jvpp;
514 +
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;
523 +
524 +/**
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.
527 + */
528 +public final class JVppVesProvider extends ProviderTrait<FutureJVppVesFacade> {
529 +
530 +    private static final Logger LOG = LoggerFactory.getLogger(JVppVesProvider.class);
531 +
532 +    @Inject
533 +    private JVppRegistry registry;
534 +
535 +    @Override
536 +    protected FutureJVppVesFacade create() {
537 +        try {
538 +            final JVppVesImpl jvppVes = new JVppVesImpl();
539 +            Runtime.getRuntime().addShutdownHook(new Thread() {
540 +                @Override
541 +                public void run() {
542 +                    LOG.info("Unloading jvpp-ves plugin");
543 +                    jvppVes.close();
544 +                    LOG.info("Successfully unloaded jvpp-ves plugin");
545 +                }
546 +            });
547 +
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);
552 +        }
553 +    }
554 +}
555 +
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
557 new file mode 100644
558 index 00000000..bef652fd
559 --- /dev/null
560 +++ b/ves/ves-impl/src/main/java/io/fd/hc2vpp/ves/read/VesReaderFactory.java
561 @@ -0,0 +1,50 @@
562 +/*
563 + * Copyright (c) 2017 Intel Corp and/or its affiliates.
564 + *
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:
568 + *
569 + *     http://www.apache.org/licenses/LICENSE-2.0
570 + *
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.
576 + */
577 +
578 +package io.fd.hc2vpp.ves.read;
579 +
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;
592 +
593 +/**
594 + * Factory producing writers for VES Agent plugin's data.
595 + */
596 +public final class VesReaderFactory implements ReaderFactory {
597 +
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);
601 +
602 +    @Inject
603 +    private FutureJVppCore vppApi;
604 +
605 +    @Override
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);
610 +    }
611 +}
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
613 new file mode 100644
614 index 00000000..e06afa73
615 --- /dev/null
616 +++ b/ves/ves-impl/src/main/java/io/fd/hc2vpp/ves/write/VesConfigCustomizer.java
617 @@ -0,0 +1,127 @@
618 +/*
619 + * Copyright (c) 2017 Intel Corp and/or its affiliates.
620 + *
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:
624 + *
625 + *     http://www.apache.org/licenses/LICENSE-2.0
626 + *
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.
632 + */
633 +
634 +package io.fd.hc2vpp.ves.write;
635 +
636 +import static com.google.common.base.Preconditions.checkArgument;
637 +
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;
657 +
658 +final class VesConfigCustomizer extends FutureJVppCustomizer implements WriterCustomizer<Config>,
659 +    JvppReplyConsumer, ByteDataTranslator, Ipv6Translator, Ipv4Translator {
660 +    private static final Logger LOG = LoggerFactory.getLogger(VesConfigCustomizer.class);
661 +
662 +    private final FutureJVppVesFacade jvppVes;
663 +
664 +    VesConfigCustomizer(final FutureJVppCore vppApi, final FutureJVppVesFacade jvppVes) {
665 +        super(vppApi);
666 +        this.jvppVes = jvppVes;
667 +    }
668 +
669 +    @Override
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;
674 +
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");
678 +
679 +        configBuilder.setServerAddr(dataAfter.getServerAddr())
680 +                     .setServerPort(dataAfter.getServerPort())
681 +                     .setReadInterval(dataAfter.getReadInterval())
682 +                     .setIsAdd(1L);
683 +
684 +        setVesAgentConfig(id, configBuilder.build());
685 +    }
686 +
687 +    @Override
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;
693 +
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");
698 +
699 +        // remove old configuration:
700 +        configBuilder.setServerAddr(dataBefore.getServerAddr())
701 +                     .setServerPort(dataBefore.getServerPort())
702 +                     .setReadInterval(dataBefore.getReadInterval())
703 +                     .setIsAdd(0L);
704 +        setVesAgentConfig(id, configBuilder.build());
705 +
706 +        // and add new one:
707 +        configBuilder.setServerAddr(dataAfter.getServerAddr())
708 +                     .setServerPort(dataAfter.getServerPort())
709 +                     .setReadInterval(dataAfter.getReadInterval())
710 +                     .setIsAdd(1L);
711 +        setVesAgentConfig(id, configBuilder.build());
712 +    }
713 +
714 +    @Override
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);
720 +
721 +        checkArgument(dataBefore.getServerAddr() != null && dataBefore.getServerAddr().getValue() != null
722 +            && dataBefore.getServerPort() != 0, "VES Server Address and Port need to be dataBeforeured");
723 +
724 +        configBuilder.setServerAddr(dataBefore.getServerAddr())
725 +                     .setServerPort(dataBefore.getServerPort())
726 +                     .setReadInterval(dataBefore.getReadInterval())
727 +                     .setIsAdd(0L);
728 +
729 +        setVesAgentConfig(id, configBuilder.build());
730 +    }
731 +
732 +    private void setVesAgentConfig(final InstanceIdentifier<Config> id, final Config config)
733 +        throws WriteFailedException {
734 +        final VesAgentConfig request = new VesAgentConfig();
735 +
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());
740 +
741 +        LOG.debug("VES agent config change id={} request={}", id, request);
742 +        getReplyForWrite(jvppVes.vesAgentConfig(request).toCompletableFuture(), id);
743 +    }
744 +}
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
746 new file mode 100644
747 index 00000000..8b6d5a9a
748 --- /dev/null
749 +++ b/ves/ves-impl/src/main/java/io/fd/hc2vpp/ves/write/VesModeCustomizer.java
750 @@ -0,0 +1,97 @@
751 +/*
752 + * Copyright (c) 2017 Intel Corp and/or its affiliates.
753 + *
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:
757 + *
758 + *     http://www.apache.org/licenses/LICENSE-2.0
759 + *
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.
765 + */
766 +
767 +package io.fd.hc2vpp.ves.write;
768 +
769 +import static com.google.common.base.Preconditions.checkArgument;
770 +
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;
790 +
791 +final class VesModeCustomizer extends FutureJVppCustomizer implements WriterCustomizer<Mode>,
792 +    JvppReplyConsumer, ByteDataTranslator, Ipv6Translator, Ipv4Translator {
793 +    private static final Logger LOG = LoggerFactory.getLogger(VesModeCustomizer.class);
794 +
795 +    private final FutureJVppVesFacade jvppVes;
796 +
797 +    VesModeCustomizer(final FutureJVppCore vppApi, final FutureJVppVesFacade jvppVes) {
798 +        super(vppApi);
799 +        this.jvppVes = jvppVes;
800 +    }
801 +
802 +    @Override
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);
806 +
807 +        checkArgument(dataAfter.getWorkingMode() != null && dataAfter.getBasePacketLoss() <= 100,
808 +                      "VES Agent Working Mode need to be correctly configured.");
809 +
810 +        setVesAgentMode(iid, dataAfter);
811 +    }
812 +
813 +    @Override
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);
818 +
819 +        checkArgument(dataAfter.getWorkingMode() != null && dataAfter.getBasePacketLoss() <= 100,
820 +                      "VES Agent Working Mode need to be correctly configured.");
821 +
822 +        setVesAgentMode(iid, dataAfter);
823 +    }
824 +
825 +    @Override
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);
830 +
831 +        modeBuilder.setWorkingMode("Real")
832 +                   .setBasePacketLoss(0L);
833 +
834 +        setVesAgentMode(iid, modeBuilder.build());
835 +    }
836 +
837 +    private void setVesAgentMode(final InstanceIdentifier<Mode> id, final Mode mode)
838 +        throws WriteFailedException {
839 +        final VesAgentMode request = new VesAgentMode();
840 +
841 +        request.pktLossRate = mode.getBasePacketLoss().byteValue();
842 +        request.workMode = mode.getWorkingMode().getBytes();
843 +
844 +        LOG.debug("VES agent working mode change id={} request={}", id, request);
845 +        getReplyForWrite(jvppVes.vesAgentMode(request).toCompletableFuture(), id);
846 +    }
847 +}
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
849 new file mode 100644
850 index 00000000..581f0460
851 --- /dev/null
852 +++ b/ves/ves-impl/src/main/java/io/fd/hc2vpp/ves/write/VesWriterFactory.java
853 @@ -0,0 +1,54 @@
854 +/*
855 + * Copyright (c) 2017 Intel Corp and/or its affiliates.
856 + *
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:
860 + *
861 + *     http://www.apache.org/licenses/LICENSE-2.0
862 + *
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.
868 + */
869 +
870 +package io.fd.hc2vpp.ves.write;
871 +
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;
884 +
885 +/**
886 + * Factory producing writers for VES Agent plugin's data.
887 + */
888 +public final class VesWriterFactory implements WriterFactory {
889 +
890 +    private static final InstanceIdentifier<Vesagent> VESAGENT_ID = InstanceIdentifier.create(Vesagent.class);
891 +
892 +    @Inject
893 +    private FutureJVppCore vppApi;
894 +
895 +    @Inject
896 +    protected FutureJVppVesFacade futureVesFacade;
897 +
898 +    @Override
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)));
906 +    }
907 +}
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
909 new file mode 100644
910 index 00000000..62e46cdb
911 --- /dev/null
912 +++ b/ves/ves-impl/src/main/java/io/fd/hc2vpp/ves/write/VesagentCustomizer.java
913 @@ -0,0 +1,131 @@
914 +/*
915 + * Copyright (c) 2017 Intel Corp and/or its affiliates.
916 + *
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:
920 + *
921 + *     http://www.apache.org/licenses/LICENSE-2.0
922 + *
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.
928 + */
929 +
930 +package io.fd.hc2vpp.ves.write;
931 +
932 +import static com.google.common.base.Preconditions.checkArgument;
933 +
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;
953 +
954 +final class VesagentCustomizer extends FutureJVppCustomizer implements WriterCustomizer<Vesagent>,
955 +    JvppReplyConsumer, ByteDataTranslator, Ipv6Translator, Ipv4Translator {
956 +    private static final Logger LOG = LoggerFactory.getLogger(VesagentCustomizer.class);
957 +
958 +    private final FutureJVppVesFacade jvppVes;
959 +
960 +    VesagentCustomizer(final FutureJVppCore vppApi, final FutureJVppVesFacade jvppVes) {
961 +        super(vppApi);
962 +        this.jvppVes = jvppVes;
963 +    }
964 +
965 +    @Override
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);
971 +
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");
975 +
976 +        configBuilder.setServerAddr(config.getServerAddr())
977 +                     .setServerPort(config.getServerPort())
978 +                     .setReadInterval(config.getReadInterval())
979 +                     .setIsAdd(1L);
980 +
981 +        setVesAgentConfig(id, configBuilder.build());
982 +    }
983 +
984 +    @Override
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);
992 +
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");
997 +
998 +        // remove old configuration:
999 +        configBuilder.setServerAddr(configBefore.getServerAddr())
1000 +                     .setServerPort(configBefore.getServerPort())
1001 +                     .setReadInterval(configBefore.getReadInterval())
1002 +                     .setIsAdd(0L);
1003 +        setVesAgentConfig(id, configBuilder.build());
1004 +
1005 +        // and add new one:
1006 +        configBuilder.setServerAddr(configAfter.getServerAddr())
1007 +                     .setServerPort(configAfter.getServerPort())
1008 +                     .setReadInterval(configAfter.getReadInterval())
1009 +                     .setIsAdd(1L);
1010 +        setVesAgentConfig(id, configBuilder.build());
1011 +    }
1012 +
1013 +    @Override
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);
1019 +
1020 +        checkArgument(config.getServerAddr() != null && config.getServerAddr().getValue() != null
1021 +            && config.getServerPort() != 0, "VES Server Address and Port need to be configured");
1022 +
1023 +        ConfigBuilder configBuilder = new ConfigBuilder();
1024 +        configBuilder.setServerAddr(config.getServerAddr())
1025 +                     .setServerPort(config.getServerPort())
1026 +                     .setReadInterval(config.getReadInterval())
1027 +                     .setIsAdd(0L);
1028 +
1029 +        setVesAgentConfig(id, configBuilder.build());
1030 +    }
1031 +
1032 +    private void setVesAgentConfig(final InstanceIdentifier<Config> id, final Config config)
1033 +        throws WriteFailedException {
1034 +        final VesAgentConfig request = new VesAgentConfig();
1035 +
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());
1040 +
1041 +        LOG.debug("VES agent config change id={} request={}", id, request);
1042 +        getReplyForWrite(jvppVes.vesAgentConfig(request).toCompletableFuture(), id);
1043 +    }
1044 +}
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
1049 @@ -40,6 +40,7 @@
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>
1057 @@ -63,6 +64,7 @@
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>
1067      </dependency>
1068      <dependency>
1069 +      <groupId>io.fd.hc2vpp.ves</groupId>
1070 +      <artifactId>ves-impl</artifactId>
1071 +      <version>${vesagent.version}</version>
1072 +    </dependency>
1073 +    <dependency>
1074        <groupId>io.fd.hc2vpp.management</groupId>
1075        <artifactId>vpp-management-impl</artifactId>
1076        <version>${vpp-management-impl.version}</version>
1077 -- 
1078 2.12.2.windows.2
1079