Added a tunable parameter for host tracking. 44/29544/1
authorShigeru Yasuda <s-yasuda@da.jp.nec.com>
Wed, 11 Nov 2015 11:57:16 +0000 (20:57 +0900)
committerShigeru Yasuda <s-yasuda@da.jp.nec.com>
Wed, 11 Nov 2015 11:57:16 +0000 (20:57 +0900)
host-tracking field in vtn-config keeps a boolean value that determines
whether to enable host tracking for hosts learned in the vBridge.

Change-Id: I3c4a6a2b6a43ce077f367456e00c89c8063e2232
Signed-off-by: Shigeru Yasuda <s-yasuda@da.jp.nec.com>
manager/implementation/src/main/java/org/opendaylight/vtn/manager/internal/VTNConfig.java
manager/implementation/src/main/java/org/opendaylight/vtn/manager/internal/config/VTNConfigImpl.java
manager/implementation/src/main/java/org/opendaylight/vtn/manager/internal/config/VTNConfigManager.java
manager/implementation/src/test/java/org/opendaylight/vtn/manager/internal/config/ConfigType.java
manager/implementation/src/test/java/org/opendaylight/vtn/manager/internal/config/TestVTNConfig.java
manager/implementation/src/test/java/org/opendaylight/vtn/manager/internal/config/VTNConfigImplTest.java
manager/implementation/src/test/java/org/opendaylight/vtn/manager/internal/util/XmlConfigFileTest.java
manager/model/src/main/yang/vtn-config.yang

index 961029970b2d91134cf61b3da5d0d32eb2af6788..e80b31f0fa0278e98532c25a771fd80fdf7a7691 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015 NEC Corporation.  All rights reserved.
+ * Copyright (c) 2013, 2015 NEC Corporation. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -61,6 +61,15 @@ public interface VTNConfig {
      */
     int getMaxRedirections();
 
+    /**
+     * Return a boolean value that determines whether to enable host tracking
+     * in the vBridge.
+     *
+     * @return  {@code true} if host tracking in the vBridge is enabled.
+     *          {@code false} otherwise.
+     */
+    boolean isHostTracking();
+
     /**
      * Return MAC address of the controller used as source MAC address of
      * ARP packet.
index fed85d93e22b7895c8f62ff475f365aa797ef216..b1003754afe07b751a5a5c5c3c49d9e0eaa10202 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 NEC Corporation.  All rights reserved.
+ * Copyright (c) 2015 NEC Corporation. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -120,6 +120,13 @@ public final class VTNConfigImpl implements VTNConfig {
      */
     private int  maxRedirections;
 
+    /**
+     * A boolean value that determines whether to enable host tracking in the
+     * vBridge.
+     */
+    @XmlElement(name = "host-tracking")
+    private Boolean  hostTracking;
+
     /**
      * MAC address of the controller used as source MAC address of ARP packet.
      * It is determined by the controller if omitted.
@@ -165,6 +172,10 @@ public final class VTNConfigImpl implements VTNConfig {
             builder.setMaxRedirections(DEFAULT_MAX_REDIRECTIONS);
         }
 
+        if (builder.isHostTracking() == null) {
+            builder.setHostTracking(true);
+        }
+
         if (builder.getControllerMacAddress() == null) {
             builder.setControllerMacAddress(mac.getMacAddress());
         }
@@ -215,6 +226,7 @@ public final class VTNConfigImpl implements VTNConfig {
                 setBulkFlowModTimeout(vcfg.getBulkFlowModTimeout()).
                 setInitTimeout(vcfg.getInitTimeout()).
                 setMaxRedirections(vcfg.getMaxRedirections()).
+                setHostTracking(vcfg.isHostTracking()).
                 setControllerMacAddress(vcfg.getControllerMacAddress());
         }
 
@@ -244,6 +256,8 @@ public final class VTNConfigImpl implements VTNConfig {
              newConf.getInitTimeout());
         diff(list, "max-redirections", oldConf.getMaxRedirections(),
              newConf.getMaxRedirections());
+        diff(list, "host-tracking", oldConf.isHostTracking(),
+             newConf.isHostTracking());
 
         EtherAddress oldMac = oldConf.getControllerMacAddress();
         EtherAddress newMac = newConf.getControllerMacAddress();
@@ -276,6 +290,24 @@ public final class VTNConfigImpl implements VTNConfig {
         }
     }
 
+    /**
+     * Add a string that indicates the change of parameter to the given list.
+     *
+     * @param list  A list of strings that indicates diferrences of parameters.
+     * @param name  The name of the parameter.
+     * @param o     Old value of the parameter.
+     * @param n     New value of the parameter.
+     */
+    private static void diff(List<String> list, String name, boolean o,
+                             boolean n) {
+        if (o != n) {
+            StringBuilder builder = new StringBuilder(name);
+            builder.append("=(").append(o).append(RIGHT_ARROW).append(n).
+                append(')');
+            list.add(builder.toString());
+        }
+    }
+
     /**
      * Construct a new instance which contains default parameter values.
      *
@@ -328,6 +360,7 @@ public final class VTNConfigImpl implements VTNConfig {
         bulkFlowModTimeout = decode(vcfg.getBulkFlowModTimeout());
         initTimeout = decode(vcfg.getInitTimeout());
         maxRedirections = decode(vcfg.getMaxRedirections());
+        hostTracking = vcfg.isHostTracking();
         controllerMacAddress = decode(vcfg.getControllerMacAddress());
         if (mac != null && controllerMacAddress == null) {
             controllerMacAddress = mac;
@@ -347,6 +380,7 @@ public final class VTNConfigImpl implements VTNConfig {
             setBulkFlowModTimeout(encode(bulkFlowModTimeout)).
             setInitTimeout(encode(initTimeout)).
             setMaxRedirections(encode(maxRedirections)).
+            setHostTracking(hostTracking).
             setControllerMacAddress(encode(controllerMacAddress));
 
         return builder.build();
@@ -362,6 +396,7 @@ public final class VTNConfigImpl implements VTNConfig {
      */
     public VtnConfigBuilder getJaxbValue() {
         return createJaxbValue().
+            setHostTracking(hostTracking).
             setControllerMacAddress(encode(controllerMacAddress));
     }
 
@@ -389,17 +424,14 @@ public final class VTNConfigImpl implements VTNConfig {
      */
     @Override
     public boolean equals(Object o) {
-        if (o == this) {
-            return true;
-        }
-
-        boolean result = false;
-        if (o != null && getClass().equals(o.getClass())) {
+        boolean result = (o == this);
+        if (!result && o != null && getClass().equals(o.getClass())) {
             VTNConfigImpl vconf = (VTNConfigImpl)o;
             if (topologyWait == vconf.topologyWait &&
                 initTimeout == vconf.initTimeout &&
                 maxRedirections == vconf.maxRedirections) {
                 result = (equalsFlowParams(vconf) &&
+                          Objects.equals(hostTracking, vconf.hostTracking) &&
                           Objects.equals(controllerMacAddress,
                                          vconf.controllerMacAddress));
             }
@@ -416,8 +448,8 @@ public final class VTNConfigImpl implements VTNConfig {
     @Override
     public int hashCode() {
         return Objects.hash(topologyWait, l2FlowPriority, flowModTimeout,
-                            bulkFlowModTimeout, initTimeout,
-                            maxRedirections, controllerMacAddress);
+                            bulkFlowModTimeout, initTimeout, maxRedirections,
+                            hostTracking, controllerMacAddress);
     }
 
     // JAXB methods.
@@ -645,6 +677,19 @@ public final class VTNConfigImpl implements VTNConfig {
         return (i == null) ? UNDEFINED : i.intValue();
     }
 
+    /**
+     * Determine whether the given object is {@code null} or not.
+     *
+     * @param obj  An object to be tested.
+     * @param def  The default value.
+     * @param <T>  The type of the object.
+     * @return  {@code obj} if it is not {@code null}.
+     *          {@code def} if {@code obj} is {@code null}.
+     */
+    private <T> T checkNotNull(T obj, T def) {
+        return (obj == null) ? def : obj;
+    }
+
     /**
      * Return an {@link EtherAddress} instance that represents the given
      * {@link MacAddress} instance.
@@ -744,6 +789,14 @@ public final class VTNConfigImpl implements VTNConfig {
         return intValue(maxRedirections, DEFAULT_MAX_REDIRECTIONS);
     }
 
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean isHostTracking() {
+        return (hostTracking == null || hostTracking.booleanValue());
+    }
+
     /**
      * {@inheritDoc}
      */
index 0af47195b7600e038d1a058ba59dba1561ac6d48..77956f50d814d2a3d2f60677d0dad9d2c19c3818 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 NEC Corporation.  All rights reserved.
+ * Copyright (c) 2015 NEC Corporation. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -464,6 +464,14 @@ public final class VTNConfigManager implements AutoCloseable, VTNConfig {
         return current.get().getMaxRedirections();
     }
 
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean isHostTracking() {
+        return current.get().isHostTracking();
+    }
+
     /**
      * {@inheritDoc}
      */
index 5040924ba236ec9c270aad5779637659378b1c5d..25c4dc88a8f7d5b54ce86e52df23e5673de0c3f6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 NEC Corporation.  All rights reserved.
+ * Copyright (c) 2015 NEC Corporation. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -65,6 +65,12 @@ public enum ConfigType {
                      Integer.valueOf(100), Integer.valueOf(10),
                      Integer.valueOf(100000)),
 
+    /**
+     * A symbol which indicates the value returned by
+     * {@link org.opendaylight.vtn.manager.internal.VTNConfig#isHostTracking()}.
+     */
+    HOST_TRACKING("isHostTracking", "host-tracking", Boolean.TRUE),
+
     /**
      * A symbol which indicates the value returned by
      * {@link org.opendaylight.vtn.manager.internal.VTNConfig#getControllerMacAddress()}.
@@ -200,4 +206,15 @@ public enum ConfigType {
         return builder.append(elementName).append('>').append(v).
             append("</").append(elementName).append('>').toString();
     }
+
+    /**
+     * Determine whether the type of the parameter specified by this instance
+     * is boolean or not.
+     *
+     * @return  {@code true} only if this instance indicates a boolean
+     *          parameter.
+     */
+    public boolean isBoolean() {
+        return (this == HOST_TRACKING);
+    }
 }
index f140fd6090683bc819c5e4fce2083d0919392cf7..353d0ab1e02ab2c88e27968f1686f2bf098c9633 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 NEC Corporation.  All rights reserved.
+ * Copyright (c) 2015 NEC Corporation. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -42,11 +42,11 @@ public final class TestVTNConfig extends TestBase {
     }
 
     /**
-     * Reset all the numerical parameters.
+     * Reset all the parameters except controller-mac-address.
      *
      * @return  This instance.
      */
-    public TestVTNConfig resetIntegers() {
+    public TestVTNConfig reset() {
         for (ConfigType type: ConfigType.values()) {
             if (type != ConfigType.CONTROLLER_MAC_ADDRESS) {
                 expectedValues.remove(type);
index 11b89a858a6c6132f6be9cd4ad35d26247ec5cd0..3e322657001ceb5cfd8b25f61dfefb40aa38b54e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 NEC Corporation.  All rights reserved.
+ * Copyright (c) 2015 NEC Corporation. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -135,6 +135,19 @@ public class VTNConfigImplTest extends TestBase {
         all.setMaxRedirections(value);
         allTest.set(ConfigType.MAX_REDIRECTIONS, value);
 
+        // Set host-tracking.
+        Boolean htrack = Boolean.FALSE;
+        builder = new VtnConfigBuilder().setHostTracking(htrack);
+        assertSame(builder, VTNConfigImpl.fillDefault(builder, mac));
+        new TestVtnConfigBuilder().set(ConfigType.HOST_TRACKING, htrack).
+            set(ConfigType.CONTROLLER_MAC_ADDRESS, defMac).fillDefault().
+            verify(builder);
+        assertEquals(null, builder.isInitState());
+
+        htrack = Boolean.TRUE;
+        all.setHostTracking(htrack);
+        allTest.set(ConfigType.HOST_TRACKING, htrack);
+
         // Set controller-mac-address.
         MacAddress macAddr = new MacAddress("12:34:56:78:9a:bc");
         builder = new VtnConfigBuilder().setControllerMacAddress(macAddr);
@@ -256,6 +269,19 @@ public class VTNConfigImplTest extends TestBase {
         all.setMaxRedirections(value);
         allTest.set(ConfigType.MAX_REDIRECTIONS, value);
 
+        // Set host-tracking.
+        Boolean htrack = Boolean.FALSE;
+        vcfg = new VtnConfigBuilder().setHostTracking(htrack).build();
+        builder = VTNConfigImpl.builder(vcfg, mac);
+        new TestVtnConfigBuilder().set(ConfigType.HOST_TRACKING, htrack).
+            set(ConfigType.CONTROLLER_MAC_ADDRESS, defMac).fillDefault().
+            verify(builder);
+        assertEquals(null, builder.isInitState());
+
+        htrack = Boolean.TRUE;
+        all.setHostTracking(htrack);
+        allTest.set(ConfigType.HOST_TRACKING, htrack);
+
         // Set controller-mac-address.
         MacAddress macAddr = new MacAddress("12:34:56:78:9a:bc");
         vcfg = new VtnConfigBuilder().setControllerMacAddress(macAddr).
@@ -364,6 +390,18 @@ public class VTNConfigImplTest extends TestBase {
         all2.setMaxRedirections(nv1);
         diffList.add("max-redirections=(" + nv + "->" + nv1 + ")");
 
+        // Change host-tracking.
+        boolean ob = vconfOld.isHostTracking();
+        boolean nb = false;
+        vcfg = new VtnConfigBuilder().setHostTracking(nb).build();
+        vconfNew = new VTNConfigImpl(vcfg);
+        expected = "host-tracking=(" + ob + "->" + nb + ")";
+        assertEquals(expected, VTNConfigImpl.diff(vconfOld, vconfNew));
+
+        all1.setHostTracking(nb);
+        all2.setHostTracking(ob);
+        diffList.add("host-tracking=(" + nb + "->" + ob + ")");
+
         // Change controller-mac-address.
         EtherAddress omac = vconfOld.getControllerMacAddress();
         EtherAddress nmac = new EtherAddress(0xfafbfcfdfeffL);
@@ -443,7 +481,7 @@ public class VTNConfigImplTest extends TestBase {
             vcfg = new VtnConfigBuilder().setTopologyWait(value).build();
             vconf = (mac == null)
                 ? new VTNConfigImpl(vcfg) : new VTNConfigImpl(vcfg, mac);
-            test.resetIntegers().set(type, value).verify(vconf);
+            test.reset().set(type, value).verify(vconf);
 
             value = 1;
             all.setTopologyWait(value);
@@ -455,7 +493,7 @@ public class VTNConfigImplTest extends TestBase {
             vcfg = new VtnConfigBuilder().setL2FlowPriority(value).build();
             vconf = (mac == null)
                 ? new VTNConfigImpl(vcfg) : new VTNConfigImpl(vcfg, mac);
-            test.resetIntegers().set(type, value).verify(vconf);
+            test.reset().set(type, value).verify(vconf);
 
             value = 1;
             all.setL2FlowPriority(value);
@@ -467,7 +505,7 @@ public class VTNConfigImplTest extends TestBase {
             vcfg = new VtnConfigBuilder().setFlowModTimeout(value).build();
             vconf = (mac == null)
                 ? new VTNConfigImpl(vcfg) : new VTNConfigImpl(vcfg, mac);
-            test.resetIntegers().set(type, value).verify(vconf);
+            test.reset().set(type, value).verify(vconf);
 
             value = 200;
             all.setFlowModTimeout(value);
@@ -479,7 +517,7 @@ public class VTNConfigImplTest extends TestBase {
             vcfg = new VtnConfigBuilder().setBulkFlowModTimeout(value).build();
             vconf = (mac == null)
                 ? new VTNConfigImpl(vcfg) : new VTNConfigImpl(vcfg, mac);
-            test.resetIntegers().set(type, value).verify(vconf);
+            test.reset().set(type, value).verify(vconf);
 
             value = 3300;
             all.setBulkFlowModTimeout(value);
@@ -491,7 +529,7 @@ public class VTNConfigImplTest extends TestBase {
             vcfg = new VtnConfigBuilder().setInitTimeout(value).build();
             vconf = (mac == null)
                 ? new VTNConfigImpl(vcfg) : new VTNConfigImpl(vcfg, mac);
-            test.resetIntegers().set(type, value).verify(vconf);
+            test.reset().set(type, value).verify(vconf);
 
             value = 200;
             all.setInitTimeout(value);
@@ -503,12 +541,20 @@ public class VTNConfigImplTest extends TestBase {
             vcfg = new VtnConfigBuilder().setMaxRedirections(value).build();
             vconf = (mac == null)
                 ? new VTNConfigImpl(vcfg) : new VTNConfigImpl(vcfg, mac);
-            test.resetIntegers().set(type, value).verify(vconf);
+            test.reset().set(type, value).verify(vconf);
 
             value = 11;
             all.setMaxRedirections(value);
             allTest.set(type, value);
 
+            // Set host-tracking.
+            type = ConfigType.HOST_TRACKING;
+            Boolean htrack = Boolean.FALSE;
+            vcfg = new VtnConfigBuilder().setHostTracking(htrack).build();
+            vconf = (mac == null)
+                ? new VTNConfigImpl(vcfg) : new VTNConfigImpl(vcfg, mac);
+            test.reset().set(type, htrack).verify(vconf);
+
             // Set ccontroller-mac-address.
             MacAddress macAddr = new MacAddress("12:34:56:78:9a:bc");
             type = ConfigType.CONTROLLER_MAC_ADDRESS;
@@ -516,7 +562,7 @@ public class VTNConfigImplTest extends TestBase {
                 build();
             vconf = (mac == null)
                 ? new VTNConfigImpl(vcfg) : new VTNConfigImpl(vcfg, mac);
-            test.resetIntegers().set(type, macAddr).verify(vconf);
+            test.reset().set(type, macAddr).verify(vconf);
 
             macAddr = new MacAddress("11:22:33:44:55:66");
             all.setControllerMacAddress(macAddr);
@@ -611,6 +657,18 @@ public class VTNConfigImplTest extends TestBase {
         all.setMaxRedirections(value);
         allTest.set(ConfigType.MAX_REDIRECTIONS, value);
 
+        // Set host-tracking.
+        Boolean htrack = Boolean.FALSE;
+        vcfg = new VtnConfigBuilder().setHostTracking(htrack).build();
+        vcfg = new VTNConfigImpl(vcfg).toVtnConfig();
+        new TestVtnConfigBuilder().set(ConfigType.HOST_TRACKING, htrack).
+            verify(vcfg);
+        assertEquals(null, vcfg.isInitState());
+
+        value = 10;
+        all.setHostTracking(htrack);
+        allTest.set(ConfigType.HOST_TRACKING, htrack);
+
         // Set controller-mac-address.
         MacAddress macAddr = new MacAddress("12:34:56:78:9a:bc");
         vcfg = new VtnConfigBuilder().setControllerMacAddress(macAddr).
@@ -719,6 +777,15 @@ public class VTNConfigImplTest extends TestBase {
             testEquals(set, vconf1, vconf2);
         }
 
+        boolean[] bools = {true, false};
+        for (boolean b: bools) {
+            builder.setHostTracking(b);
+            VTNConfigImpl vconf1 = new VTNConfigImpl(builder.build());
+            VTNConfigImpl vconf2 = new VTNConfigImpl(builder.build());
+            assertEquals(b, vconf1.isHostTracking());
+            testEquals(set, vconf1, vconf2);
+        }
+
         String[] addrs = {
             "aa:bb:cc:dd:ee:ff",
             "99:88:77:66:55:44",
@@ -736,7 +803,8 @@ public class VTNConfigImplTest extends TestBase {
 
         int expected = neWaits.length + l2Priorities.length +
             flowModTimeouts.length + bulkFlowModTimeouts.length +
-            initTimeouts.length + maxRedirections.length + addrs.length + 1;
+            initTimeouts.length + maxRedirections.length + bools.length +
+            addrs.length + 1;
         assertEquals(expected, set.size());
     }
 
@@ -764,7 +832,7 @@ public class VTNConfigImplTest extends TestBase {
             VtnConfig vcfg = new VtnConfigBuilder().setTopologyWait(v).build();
             vconf = jaxbTest(new VTNConfigImpl(vcfg), VTNConfigImpl.class,
                              XML_ROOT);
-            test.resetIntegers().set(type, v).verify(vconf);
+            test.reset().set(type, v).verify(vconf);
             assertEquals(vcfg, vconf.getJaxbValue().build());
 
             allBuilder.setTopologyWait(v);
@@ -788,7 +856,7 @@ public class VTNConfigImplTest extends TestBase {
                 build();
             vconf = jaxbTest(new VTNConfigImpl(vcfg), VTNConfigImpl.class,
                              XML_ROOT);
-            test.resetIntegers().set(type, v).verify(vconf);
+            test.reset().set(type, v).verify(vconf);
             assertEquals(vcfg, vconf.getJaxbValue().build());
 
             allBuilder.setL2FlowPriority(v);
@@ -813,7 +881,7 @@ public class VTNConfigImplTest extends TestBase {
                 build();
             vconf = jaxbTest(new VTNConfigImpl(vcfg), VTNConfigImpl.class,
                              XML_ROOT);
-            test.resetIntegers().set(type, v).verify(vconf);
+            test.reset().set(type, v).verify(vconf);
             assertEquals(vcfg, vconf.getJaxbValue().build());
 
             allBuilder.setFlowModTimeout(v);
@@ -838,7 +906,7 @@ public class VTNConfigImplTest extends TestBase {
                 build();
             vconf = jaxbTest(new VTNConfigImpl(vcfg), VTNConfigImpl.class,
                              XML_ROOT);
-            test.resetIntegers().set(type, v).verify(vconf);
+            test.reset().set(type, v).verify(vconf);
             assertEquals(vcfg, vconf.getJaxbValue().build());
 
             allBuilder.setBulkFlowModTimeout(v);
@@ -862,7 +930,7 @@ public class VTNConfigImplTest extends TestBase {
             VtnConfig vcfg = new VtnConfigBuilder().setInitTimeout(v).build();
             vconf = jaxbTest(new VTNConfigImpl(vcfg), VTNConfigImpl.class,
                              XML_ROOT);
-            test.resetIntegers().set(type, v).verify(vconf);
+            test.reset().set(type, v).verify(vconf);
             assertEquals(vcfg, vconf.getJaxbValue().build());
 
             allBuilder.setInitTimeout(v);
@@ -887,7 +955,7 @@ public class VTNConfigImplTest extends TestBase {
                 build();
             vconf = jaxbTest(new VTNConfigImpl(vcfg), VTNConfigImpl.class,
                              XML_ROOT);
-            test.resetIntegers().set(type, v).verify(vconf);
+            test.reset().set(type, v).verify(vconf);
             assertEquals(vcfg, vconf.getJaxbValue().build());
 
             allBuilder.setMaxRedirections(v);
@@ -900,6 +968,24 @@ public class VTNConfigImplTest extends TestBase {
         vconf.setJaxbMaxRedirections(null);
         assertEquals(null, vconf.getJaxbMaxRedirections());
 
+        type = ConfigType.HOST_TRACKING;
+        Boolean[] bools = {null, Boolean.TRUE, Boolean.FALSE};
+        for (Boolean b: bools) {
+            VtnConfig vcfg = new VtnConfigBuilder().setHostTracking(b).
+                build();
+            vconf = jaxbTest(new VTNConfigImpl(vcfg), VTNConfigImpl.class,
+                             XML_ROOT);
+            test.reset().set(type, b).verify(vconf);
+            assertEquals(vcfg, vconf.getJaxbValue().build());
+
+            allBuilder.setHostTracking(b);
+            VtnConfig all = allBuilder.build();
+            vconf = jaxbTest(new VTNConfigImpl(all), VTNConfigImpl.class,
+                             XML_ROOT);
+            allTest.set(type, b).verify(vconf);
+            assertEquals(all, vconf.getJaxbValue().build());
+        }
+
         type = ConfigType.CONTROLLER_MAC_ADDRESS;
         String[] addrs = {
             "aa:bb:cc:dd:ee:ff",
@@ -913,7 +999,7 @@ public class VTNConfigImplTest extends TestBase {
                 setControllerMacAddress(maddr).build();
             vconf = jaxbTest(new VTNConfigImpl(vcfg), VTNConfigImpl.class,
                              XML_ROOT);
-            test.resetIntegers().set(type, maddr).verify(vconf);
+            test.reset().set(type, maddr).verify(vconf);
             assertEquals(vcfg, vconf.getJaxbValue().build());
 
             allBuilder.setControllerMacAddress(maddr);
@@ -959,17 +1045,17 @@ public class VTNConfigImplTest extends TestBase {
         jaxbErrorTest(VTNConfigImpl.class,
                       new XmlValueType("controller-mac-address",
                                        EtherAddress.class).add(XML_ROOT),
-                      new XmlValueType("topology-wait", Integer.class).
-                      add(XML_ROOT),
-                      new XmlValueType("l2-flow-priority", Integer.class).
-                      add(XML_ROOT),
-                      new XmlValueType("flow-mod-timeout", Integer.class).
-                      add(XML_ROOT),
-                      new XmlValueType("bulk-flow-mod-timeout", Integer.class).
-                      add(XML_ROOT),
-                      new XmlValueType("init-timeout", Integer.class).
-                      add(XML_ROOT),
-                      new XmlValueType("max-redirections", Integer.class).
-                      add(XML_ROOT));
+                      new XmlValueType("topology-wait",
+                                       Integer.class).add(XML_ROOT),
+                      new XmlValueType("l2-flow-priority",
+                                       Integer.class).add(XML_ROOT),
+                      new XmlValueType("flow-mod-timeout",
+                                       Integer.class).add(XML_ROOT),
+                      new XmlValueType("bulk-flow-mod-timeout",
+                                       Integer.class).add(XML_ROOT),
+                      new XmlValueType("init-timeout",
+                                       Integer.class).add(XML_ROOT),
+                      new XmlValueType("max-redirections",
+                                       Integer.class).add(XML_ROOT));
     }
 }
index a853793390b4af61d1101367c348e07a65a19d7b..aac43af49e254cb4baedb07456e738f1b5c03a02 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 NEC Corporation.  All rights reserved.
+ * Copyright (c) 2015 NEC Corporation. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -294,6 +294,7 @@ public class XmlConfigFileTest extends TestBase {
 
         // Write configuration with the minimum values.
         String minimum = "minimum";
+        Boolean minBool = Boolean.FALSE;
         EtherAddress minMac = new EtherAddress(0L);
         File baseDir = getConfigDir();
         File dir = new File(baseDir, type.toString());
@@ -304,7 +305,7 @@ public class XmlConfigFileTest extends TestBase {
         for (ConfigType ctype: configTypes) {
             Object min = ctype.getMinimumValue();
             if (min == null) {
-                min = minMac;
+                min = (ctype.isBoolean()) ? minBool : minMac;
             }
             ps.println(ctype.getXmlElement(min));
         }
@@ -313,6 +314,7 @@ public class XmlConfigFileTest extends TestBase {
 
         // Write configuration with the maximum values.
         String maximum = "maximum";
+        Boolean maxBool = Boolean.TRUE;
         EtherAddress maxMac = new EtherAddress(0xffffffffffffL);
         file = new File(dir, maximum + ".xml");
         ps = new PrintStream(new FileOutputStream(file));
@@ -320,7 +322,7 @@ public class XmlConfigFileTest extends TestBase {
         for (ConfigType ctype: configTypes) {
             Object max = ctype.getMaximumValue();
             if (max == null) {
-                max = maxMac;
+                max = (ctype.isBoolean()) ? maxBool : maxMac;
             }
             ps.println(ctype.getXmlElement(max));
         }
@@ -335,7 +337,7 @@ public class XmlConfigFileTest extends TestBase {
                 Object value = ctype.get(min);
                 Object expected = ctype.getMinimumValue();
                 if (expected == null) {
-                    expected = minMac;
+                    expected = (ctype.isBoolean()) ? minBool : minMac;
                 }
                 assertEquals(expected, value);
             }
@@ -346,7 +348,7 @@ public class XmlConfigFileTest extends TestBase {
                 Object value = ctype.get(max);
                 Object expected = ctype.getMaximumValue();
                 if (expected == null) {
-                    expected = maxMac;
+                    expected = (ctype.isBoolean()) ? maxBool : maxMac;
                 }
                 assertEquals(expected, value);
             }
@@ -355,16 +357,18 @@ public class XmlConfigFileTest extends TestBase {
         // Test with broken value.
         String bad = "bad";
         for (ConfigType ctype: configTypes) {
-            file = new File(dir, bad + ".xml");
-            ps = new PrintStream(new FileOutputStream(file));
-            ps.printf("<vtn-config>\n");
-            ps.println(ctype.getXmlElement("bad value"));
-            ps.printf("</vtn-config>\n");
-            ps.close();
-            assertEquals(true, file.isFile());
-            assertEquals(ctype.toString(), null,
-                         XmlConfigFile.load(type, bad, cls));
-            assertEquals(false, file.isFile());
+            if (!ctype.isBoolean()) {
+                file = new File(dir, bad + ".xml");
+                ps = new PrintStream(new FileOutputStream(file));
+                ps.printf("<vtn-config>\n");
+                ps.println(ctype.getXmlElement("bad value"));
+                ps.printf("</vtn-config>\n");
+                ps.close();
+                assertEquals(true, file.isFile());
+                assertEquals(ctype.toString(), null,
+                             XmlConfigFile.load(type, bad, cls));
+                assertEquals(false, file.isFile());
+            }
         }
 
         // Test with too small values.
index cc39261ebda5c6030a8a69d5d8863c314572c3db..a99c752aed3bcec545877c8c0cdb8eeb185dc95b 100644 (file)
@@ -100,6 +100,15 @@ module vtn-config {
             type yang:mac-address;
         }
 
+        leaf host-tracking {
+            description
+              "A boolean value that determines whether to enable host tracking
+               in the vBridge. If true, a packet for IP address probing will
+               be sent to hosts learned in the vBridge periodically.";
+            type boolean;
+            default true;
+        }
+
         leaf init-state {
             description
               "Internal data used to determine whether the VTN Manager is