Making number of components configurable using the central component configuration subsystem.
Change-Id: Ia32c51480913689339a766d9849e792d62f7d133
diff --git a/apps/fwd/src/main/java/org/onosproject/fwd/ReactiveForwarding.java b/apps/fwd/src/main/java/org/onosproject/fwd/ReactiveForwarding.java
index 46d6446..f28f2a5 100644
--- a/apps/fwd/src/main/java/org/onosproject/fwd/ReactiveForwarding.java
+++ b/apps/fwd/src/main/java/org/onosproject/fwd/ReactiveForwarding.java
@@ -38,6 +38,7 @@
import org.onlab.packet.Ip4Prefix;
import org.onlab.packet.Ip6Prefix;
import org.onlab.packet.VlanId;
+import org.onosproject.cfg.ComponentConfigService;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
import org.onosproject.net.Host;
@@ -87,6 +88,9 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected CoreService coreService;
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected ComponentConfigService cfgService;
+
private ReactivePacketProcessor processor = new ReactivePacketProcessor();
private ApplicationId appId;
@@ -150,6 +154,7 @@
@Activate
public void activate(ComponentContext context) {
+ cfgService.registerProperties(getClass());
appId = coreService.registerApplication("org.onosproject.fwd");
packetService.addProcessor(processor, PacketProcessor.ADVISOR_MAX + 2);
@@ -174,6 +179,7 @@
@Deactivate
public void deactivate() {
+ cfgService.unregisterProperties(getClass(), false);
flowRuleService.removeFlowRulesById(appId);
packetService.removeProcessor(processor);
processor = null;
diff --git a/apps/fwd/src/main/resources/org/onosproject/fwd/ReactiveForwarding.cfgdef b/apps/fwd/src/main/resources/org/onosproject/fwd/ReactiveForwarding.cfgdef
new file mode 100644
index 0000000..47f481c
--- /dev/null
+++ b/apps/fwd/src/main/resources/org/onosproject/fwd/ReactiveForwarding.cfgdef
@@ -0,0 +1,14 @@
+# Temporary: to be auto-generated in near future
+packetOutOnly|BOOLEAN|false|Enable packet-out only forwarding; default is false
+packetOutOfppTable|BOOLEAN|false|Enable first packet forwarding using OFPP_TABLE port instead of PacketOut with actual port; default is false
+flowTimeout|INTEGER|10|Configure Flow Timeout for installed flow rules; default is 10 sec
+flowPriority|INTEGER|10|Configure Flow Priority for installed flow rules; default is 10
+ipv6Forwarding|BOOLEAN|false|Enable IPv6 forwarding; default is false
+matchDstMacOnly|BOOLEAN|false|Enable matching Dst Mac Only; default is false
+matchVlanId|BOOLEAN|false|Enable matching Vlan ID; default is false
+matchIpv4Address|BOOLEAN|false|Enable matching IPv4 Addresses; default is false
+matchIpv4Dscp|BOOLEAN|false|Enable matching IPv4 DSCP and ECN; default is false
+matchIpv6Address|BOOLEAN|false|Enable matching IPv6 Addresses; default is false
+matchIpv6FlowLabel|BOOLEAN|false|Enable matching IPv6 FlowLabel; default is false
+matchTcpUdpPorts|BOOLEAN|false|Enable matching TCP/UDP ports; default is false
+matchIcmpFields|BOOLEAN|false|Enable matching ICMPv4 and ICMPv6 fields; default is false
diff --git a/apps/proxyarp/src/main/java/org/onosproject/proxyarp/ProxyArp.java b/apps/proxyarp/src/main/java/org/onosproject/proxyarp/ProxyArp.java
index 82cdc31..6be06a5 100644
--- a/apps/proxyarp/src/main/java/org/onosproject/proxyarp/ProxyArp.java
+++ b/apps/proxyarp/src/main/java/org/onosproject/proxyarp/ProxyArp.java
@@ -15,8 +15,6 @@
*/
package org.onosproject.proxyarp;
-import java.util.Dictionary;
-
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
@@ -27,6 +25,7 @@
import org.onlab.packet.Ethernet;
import org.onlab.packet.ICMP6;
import org.onlab.packet.IPv6;
+import org.onosproject.cfg.ComponentConfigService;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
import org.onosproject.net.flow.DefaultTrafficSelector;
@@ -39,6 +38,8 @@
import org.osgi.service.component.ComponentContext;
import org.slf4j.Logger;
+import java.util.Dictionary;
+
import static com.google.common.base.Strings.isNullOrEmpty;
import static org.slf4j.LoggerFactory.getLogger;
@@ -61,14 +62,18 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected CoreService coreService;
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected ComponentConfigService cfgService;
+
private ApplicationId appId;
@Property(name = "ipv6NeighborDiscovery", boolValue = false,
- label = "Enable IPv6 Neighbor Discovery; default is false")
+ label = "Enable IPv6 Neighbor Discovery; default is false")
private boolean ipv6NeighborDiscovery = false;
@Activate
public void activate(ComponentContext context) {
+ cfgService.registerProperties(getClass());
appId = coreService.registerApplication("org.onosproject.proxyarp");
readComponentConfiguration(context);
@@ -103,6 +108,7 @@
@Deactivate
public void deactivate() {
+ cfgService.unregisterProperties(getClass(), false);
packetService.removeProcessor(processor);
processor = null;
log.info("Stopped");
@@ -125,7 +131,7 @@
flag = isPropertyEnabled(properties, "ipv6NeighborDiscovery");
if (flag == null) {
log.info("IPv6 Neighbor Discovery is not configured, " +
- "using current value of {}", ipv6NeighborDiscovery);
+ "using current value of {}", ipv6NeighborDiscovery);
} else {
ipv6NeighborDiscovery = flag;
log.info("Configured. IPv6 Neighbor Discovery is {}",
@@ -136,7 +142,7 @@
/**
* Check property name is defined and set to true.
*
- * @param properties properties to be looked up
+ * @param properties properties to be looked up
* @param propertyName the name of the property to look up
* @return value when the propertyName is defined or return null
*/
diff --git a/apps/proxyarp/src/main/resources/org/onosproject/proxyarp/ProxyArp.cfgdef b/apps/proxyarp/src/main/resources/org/onosproject/proxyarp/ProxyArp.cfgdef
new file mode 100644
index 0000000..c39bcb4
--- /dev/null
+++ b/apps/proxyarp/src/main/resources/org/onosproject/proxyarp/ProxyArp.cfgdef
@@ -0,0 +1,2 @@
+# Temporary: to be auto-generated in near future
+ipv6NeighborDiscovery|BOOLEAN|false|Enable IPv6 Neighbor Discovery; default is false
diff --git a/core/api/src/main/java/org/onosproject/net/intent/Intent.java b/core/api/src/main/java/org/onosproject/net/intent/Intent.java
index 7621c7d..7959929 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/Intent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/Intent.java
@@ -62,21 +62,22 @@
/**
* Creates a new intent.
*
- * @param appId application identifier
- * @param resources required network resources (optional)
+ * @param appId application identifier
+ * @param resources required network resources (optional)
*/
protected Intent(ApplicationId appId,
Collection<NetworkResource> resources) {
this(appId, null, resources, DEFAULT_INTENT_PRIORITY);
}
- /**
- * Creates a new intent.
- *
- * @param appId application identifier
- * @param key optional key
- * @param resources required network resources (optional)
- */
+ /**
+ * Creates a new intent.
+ *
+ * @param appId application identifier
+ * @param key optional key
+ * @param resources required network resources (optional)
+ * @param priority flow rule priority
+ */
protected Intent(ApplicationId appId,
Key key,
Collection<NetworkResource> resources,
@@ -156,6 +157,7 @@
* Binds an id generator for unique intent id generation.
*
* Note: A generator cannot be bound if there is already a generator bound.
+ *
* @param newIdGenerator id generator
*/
public static void bindIdGenerator(IdGenerator newIdGenerator) {
@@ -167,6 +169,7 @@
* Unbinds an id generator.
*
* Note: The caller must provide the old id generator to succeed.
+ *
* @param oldIdGenerator the current id generator
*/
public static void unbindIdGenerator(IdGenerator oldIdGenerator) {
diff --git a/core/net/src/main/java/org/onosproject/cfg/impl/ComponentConfigManager.java b/core/net/src/main/java/org/onosproject/cfg/impl/ComponentConfigManager.java
index 25af7ff..1e0ca6b 100644
--- a/core/net/src/main/java/org/onosproject/cfg/impl/ComponentConfigManager.java
+++ b/core/net/src/main/java/org/onosproject/cfg/impl/ComponentConfigManager.java
@@ -203,9 +203,8 @@
// Loads existing property values that may have been set.
private void loadExistingValues(String componentName) {
- // FIXME: implement this by talking to the config admin.
try {
- Configuration cfg = cfgAdmin.getConfiguration(componentName);
+ Configuration cfg = cfgAdmin.getConfiguration(componentName, null);
Map<String, ConfigProperty> map = properties.get(componentName);
Dictionary<String, Object> props = cfg.getProperties();
if (props != null) {
@@ -229,7 +228,7 @@
// after each other.
private void triggerUpdate(String componentName) {
try {
- Configuration cfg = cfgAdmin.getConfiguration(componentName);
+ Configuration cfg = cfgAdmin.getConfiguration(componentName, null);
Map<String, ConfigProperty> map = properties.get(componentName);
Dictionary<String, Object> props = new Hashtable<>();
map.values().forEach(p -> props.put(p.name(), p.value()));
diff --git a/core/net/src/main/java/org/onosproject/net/topology/impl/DefaultTopologyProvider.java b/core/net/src/main/java/org/onosproject/net/topology/impl/DefaultTopologyProvider.java
index 03a7169..956102c 100644
--- a/core/net/src/main/java/org/onosproject/net/topology/impl/DefaultTopologyProvider.java
+++ b/core/net/src/main/java/org/onosproject/net/topology/impl/DefaultTopologyProvider.java
@@ -17,6 +17,7 @@
import static com.google.common.base.Strings.isNullOrEmpty;
import static java.util.concurrent.Executors.newFixedThreadPool;
+import static org.onlab.util.Tools.get;
import static org.onlab.util.Tools.groupedThreads;
import static org.onosproject.core.CoreService.CORE_PROVIDER_ID;
import static org.onosproject.net.device.DeviceEvent.Type.DEVICE_ADDED;
@@ -162,16 +163,16 @@
return;
}
- Dictionary properties = context.getProperties();
+ Dictionary<?, ?> properties = context.getProperties();
int newMaxEvents, newMaxBatchMs, newMaxIdleMs;
try {
- String s = (String) properties.get("maxEvents");
+ String s = get(properties, "maxEvents");
newMaxEvents = isNullOrEmpty(s) ? maxEvents : Integer.parseInt(s.trim());
- s = (String) properties.get("maxBatchMs");
+ s = get(properties, "maxBatchMs");
newMaxBatchMs = isNullOrEmpty(s) ? maxBatchMs : Integer.parseInt(s.trim());
- s = (String) properties.get("maxIdleMs");
+ s = get(properties, "maxIdleMs");
newMaxIdleMs = isNullOrEmpty(s) ? maxIdleMs : Integer.parseInt(s.trim());
} catch (NumberFormatException | ClassCastException e) {
diff --git a/core/net/src/main/resources/org/onosproject/net/topology/impl/DefaultTopologyProvider.cfgdef b/core/net/src/main/resources/org/onosproject/net/topology/impl/DefaultTopologyProvider.cfgdef
index f7819dd..c380f70 100644
--- a/core/net/src/main/resources/org/onosproject/net/topology/impl/DefaultTopologyProvider.cfgdef
+++ b/core/net/src/main/resources/org/onosproject/net/topology/impl/DefaultTopologyProvider.cfgdef
@@ -1,20 +1,4 @@
-#
-# Copyright 2015 Open Networking Laboratory
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# This is for temporary provision for testing purposes and will be auto-generated.
+# Temporary: to be auto-generated in near future
maxEvents|INTEGER|1000|Maximum number of events to accumulate
maxIdleMs|INTEGER|10|Maximum number of millis between events
maxBatchMs|INTEGER|50|Maximum number of millis for whole batch
diff --git a/core/store/dist/src/main/java/org/onosproject/store/flow/impl/DistributedFlowRuleStore.java b/core/store/dist/src/main/java/org/onosproject/store/flow/impl/DistributedFlowRuleStore.java
index 2906775..bcb34ea 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/flow/impl/DistributedFlowRuleStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/flow/impl/DistributedFlowRuleStore.java
@@ -95,6 +95,7 @@
import static com.google.common.base.Strings.isNullOrEmpty;
import static org.apache.felix.scr.annotations.ReferenceCardinality.MANDATORY_UNARY;
+import static org.onlab.util.Tools.get;
import static org.onlab.util.Tools.groupedThreads;
import static org.onosproject.net.flow.FlowRuleEvent.Type.RULE_REMOVED;
import static org.onosproject.store.flow.impl.FlowStoreMessageSubjects.*;
@@ -267,10 +268,10 @@
int newPoolSize;
boolean newBackupEnabled;
try {
- String s = (String) properties.get("msgHandlerPoolSize");
+ String s = get(properties, "msgHandlerPoolSize");
newPoolSize = isNullOrEmpty(s) ? msgHandlerPoolSize : Integer.parseInt(s.trim());
- s = (String) properties.get("backupEnabled");
+ s = get(properties, "backupEnabled");
newBackupEnabled = isNullOrEmpty(s) ? backupEnabled : Boolean.parseBoolean(s.trim());
} catch (NumberFormatException | ClassCastException e) {
diff --git a/core/store/dist/src/main/resource/org/onosproject/store/flow/impl/DistributedFlowRuleStore.cfgdef b/core/store/dist/src/main/resource/org/onosproject/store/flow/impl/DistributedFlowRuleStore.cfgdef
new file mode 100644
index 0000000..a579a92
--- /dev/null
+++ b/core/store/dist/src/main/resource/org/onosproject/store/flow/impl/DistributedFlowRuleStore.cfgdef
@@ -0,0 +1,3 @@
+# Temporary: to be auto-generated in near future
+msgHandlerPoolSize|INTEGER|8|Number of threads in the message handler pool
+backupEnabled|BOOLEAN|false|Indicates whether backups are enabled or not
diff --git a/core/store/src/main/resources/org/onosproject/store/flow/impl/DistributedFlowRuleStore.cfgdef b/core/store/src/main/resources/org/onosproject/store/flow/impl/DistributedFlowRuleStore.cfgdef
new file mode 100644
index 0000000..7d0d6d9
--- /dev/null
+++ b/core/store/src/main/resources/org/onosproject/store/flow/impl/DistributedFlowRuleStore.cfgdef
@@ -0,0 +1,3 @@
+# Temporary: to be auto-generated in near future
+msgHandlerPoolSize|INTEGER|8|Number of threads in the message handler pool
+backupEnabled|BOOLEAN|DEFAULT_BACKUP_ENABLED|Indicates whether backups are enabled or not
diff --git a/providers/host/src/main/java/org/onosproject/provider/host/impl/HostLocationProvider.java b/providers/host/src/main/java/org/onosproject/provider/host/impl/HostLocationProvider.java
index 2d48d20..f6ae2c5 100644
--- a/providers/host/src/main/java/org/onosproject/provider/host/impl/HostLocationProvider.java
+++ b/providers/host/src/main/java/org/onosproject/provider/host/impl/HostLocationProvider.java
@@ -37,6 +37,7 @@
import org.onlab.packet.VlanId;
import org.onlab.packet.ndp.NeighborAdvertisement;
import org.onlab.packet.ndp.NeighborSolicitation;
+import org.onosproject.cfg.ComponentConfigService;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
import org.onosproject.net.ConnectPoint;
@@ -93,6 +94,9 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected DeviceService deviceService;
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected ComponentConfigService cfgService;
+
private HostProviderService providerService;
private final InternalHostProvider processor = new InternalHostProvider();
@@ -118,8 +122,8 @@
@Activate
public void activate(ComponentContext context) {
- appId =
- coreService.registerApplication("org.onosproject.provider.host");
+ cfgService.registerProperties(getClass());
+ appId = coreService.registerApplication("org.onosproject.provider.host");
readComponentConfiguration(context);
providerService = providerRegistry.register(this);
@@ -155,6 +159,7 @@
@Deactivate
public void deactivate() {
+ cfgService.unregisterProperties(getClass(), false);
providerRegistry.unregister(this);
packetService.removeProcessor(processor);
deviceService.removeListener(deviceListener);
diff --git a/providers/host/src/main/resources/org/onosproject/provider/host/impl/HostLocationProvider.cfgdef b/providers/host/src/main/resources/org/onosproject/provider/host/impl/HostLocationProvider.cfgdef
new file mode 100644
index 0000000..0412408
--- /dev/null
+++ b/providers/host/src/main/resources/org/onosproject/provider/host/impl/HostLocationProvider.cfgdef
@@ -0,0 +1,3 @@
+# Temporary: to be auto-generated in near future
+hostRemovalEnabled|BOOLEAN|true|Enable host removal on port/device down events
+ipv6NeighborDiscovery|BOOLEAN|false|Enable using IPv6 Neighbor Discovery by the Host Location Provider; default is false
diff --git a/providers/host/src/test/java/org/onosproject/provider/host/impl/HostLocationProviderTest.java b/providers/host/src/test/java/org/onosproject/provider/host/impl/HostLocationProviderTest.java
index 86c9c4c..2a5f03c 100644
--- a/providers/host/src/test/java/org/onosproject/provider/host/impl/HostLocationProviderTest.java
+++ b/providers/host/src/test/java/org/onosproject/provider/host/impl/HostLocationProviderTest.java
@@ -46,6 +46,7 @@
import org.onlab.packet.IpAddress;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
+import org.onosproject.cfg.ComponentConfigAdapter;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
import org.onosproject.core.DefaultApplicationId;
@@ -145,6 +146,7 @@
.andReturn(appId).anyTimes();
replay(coreService);
+ provider.cfgService = new ComponentConfigAdapter();
provider.coreService = coreService;
provider.providerRegistry = hostRegistry;
diff --git a/providers/lldp/src/main/java/org/onosproject/provider/lldp/impl/LLDPLinkProvider.java b/providers/lldp/src/main/java/org/onosproject/provider/lldp/impl/LLDPLinkProvider.java
index c1b8aa1..c3c9ceb 100644
--- a/providers/lldp/src/main/java/org/onosproject/provider/lldp/impl/LLDPLinkProvider.java
+++ b/providers/lldp/src/main/java/org/onosproject/provider/lldp/impl/LLDPLinkProvider.java
@@ -26,6 +26,7 @@
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.onlab.packet.Ethernet;
+import org.onosproject.cfg.ComponentConfigService;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
import org.onosproject.mastership.MastershipEvent;
@@ -61,10 +62,10 @@
import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor;
import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.onlab.util.Tools.get;
import static org.onlab.util.Tools.groupedThreads;
import static org.slf4j.LoggerFactory.getLogger;
-
/**
* Provider which uses an OpenFlow controller to detect network
* infrastructure links.
@@ -95,22 +96,27 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected MastershipService masterService;
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected ComponentConfigService cfgService;
+
private LinkProviderService providerService;
private ScheduledExecutorService executor;
- @Property(name = PROP_USE_BDDP, label = "use BDDP for link discovery")
+ @Property(name = PROP_USE_BDDP, boolValue = true,
+ label = "Use BDDP for link discovery")
private boolean useBDDP = true;
- @Property(name = PROP_DISABLE_LD, label = "permanently disable link discovery")
- private boolean disableLD = false;
+ @Property(name = PROP_DISABLE_LD, boolValue = false,
+ label = "Permanently disable link discovery")
+ private boolean disableLinkDiscovery = false;
private static final long INIT_DELAY = 5;
private static final long DELAY = 5;
- @Property(name = PROP_LLDP_SUPPRESSION,
+ @Property(name = PROP_LLDP_SUPPRESSION, value = DEFAULT_LLDP_SUPPRESSION_CONFIG,
label = "Path to LLDP suppression configuration file")
- private String filePath = DEFAULT_LLDP_SUPPRESSION_CONFIG;
+ private String lldpSuppression = DEFAULT_LLDP_SUPPRESSION_CONFIG;
private final InternalLinkProvider listener = new InternalLinkProvider();
@@ -131,12 +137,12 @@
@Activate
public void activate(ComponentContext context) {
- appId =
- coreService.registerApplication("org.onosproject.provider.lldp");
+ cfgService.registerProperties(getClass());
+ appId = coreService.registerApplication("org.onosproject.provider.lldp");
// to load configuration at startup
modified(context);
- if (disableLD) {
+ if (disableLinkDiscovery) {
log.info("Link Discovery has been permanently disabled by configuration");
return;
}
@@ -153,7 +159,7 @@
continue;
}
ld = new LinkDiscovery(device, packetService, masterService,
- providerService, useBDDP);
+ providerService, useBDDP);
discoverers.put(device.id(), ld);
for (Port p : deviceService.getPorts(device.id())) {
if (rules.isSuppressed(p)) {
@@ -177,7 +183,8 @@
@Deactivate
public void deactivate() {
- if (disableLD) {
+ cfgService.unregisterProperties(getClass(), false);
+ if (disableLinkDiscovery) {
return;
}
executor.shutdownNow();
@@ -202,29 +209,29 @@
@SuppressWarnings("rawtypes")
Dictionary properties = context.getProperties();
- String s = (String) properties.get(PROP_DISABLE_LD);
+ String s = get(properties, PROP_DISABLE_LD);
if (!Strings.isNullOrEmpty(s)) {
- disableLD = Boolean.valueOf(s);
+ disableLinkDiscovery = Boolean.valueOf(s);
}
- s = (String) properties.get(PROP_USE_BDDP);
+ s = get(properties, PROP_USE_BDDP);
if (!Strings.isNullOrEmpty(s)) {
useBDDP = Boolean.valueOf(s);
}
- s = (String) properties.get(PROP_LLDP_SUPPRESSION);
+ s = get(properties, PROP_LLDP_SUPPRESSION);
if (!Strings.isNullOrEmpty(s)) {
- filePath = s;
+ lldpSuppression = s;
}
loadSuppressionRules();
}
private void loadSuppressionRules() {
- SuppressionRulesStore store = new SuppressionRulesStore(filePath);
+ SuppressionRulesStore store = new SuppressionRulesStore(lldpSuppression);
try {
- log.info("Reading suppression rules from {}", filePath);
+ log.info("Reading suppression rules from {}", lldpSuppression);
rules = store.read();
} catch (IOException e) {
- log.info("Failed to load {}, using built-in rules", filePath);
+ log.info("Failed to load {}, using built-in rules", lldpSuppression);
// default rule to suppress ROADM to maintain compatibility
rules = new SuppressionRules(ImmutableSet.of(),
EnumSet.of(Device.Type.ROADM),
@@ -238,13 +245,13 @@
TrafficSelector.Builder lldpSelector = DefaultTrafficSelector.builder();
lldpSelector.matchEthType(Ethernet.TYPE_LLDP);
packetService.requestPackets(lldpSelector.build(),
- PacketPriority.CONTROL, appId);
+ PacketPriority.CONTROL, appId);
if (useBDDP) {
TrafficSelector.Builder bddpSelector = DefaultTrafficSelector.builder();
bddpSelector.matchEthType(Ethernet.TYPE_BSN);
packetService.requestPackets(bddpSelector.build(),
- PacketPriority.CONTROL, appId);
+ PacketPriority.CONTROL, appId);
}
}
@@ -271,10 +278,10 @@
if (!discoverers.containsKey(deviceId)) {
// ideally, should never reach here
log.debug("Device mastership changed ({}) {}",
- event.type(), deviceId);
+ event.type(), deviceId);
discoverers.put(deviceId, new LinkDiscovery(device,
- packetService, masterService, providerService,
- useBDDP));
+ packetService, masterService, providerService,
+ useBDDP));
}
}
}
@@ -307,7 +314,8 @@
log.debug("Device added ({}) {}", event.type(),
deviceId);
discoverers.put(deviceId, new LinkDiscovery(device,
- packetService, masterService, providerService, useBDDP));
+ packetService, masterService,
+ providerService, useBDDP));
} else {
if (ld.isStopped()) {
log.debug("Device restarted ({}) {}", event.type(),
@@ -412,7 +420,7 @@
synchronized (discoverers) {
if (!discoverers.containsKey(did)) {
ld = new LinkDiscovery(dev, packetService,
- masterService, providerService, useBDDP);
+ masterService, providerService, useBDDP);
discoverers.put(did, ld);
for (Port p : deviceService.getPorts(did)) {
if (rules.isSuppressed(p)) {
diff --git a/providers/lldp/src/main/resource/org/onosproject/provider/lldp/impl/LLDPLinkProvider.cfgdef b/providers/lldp/src/main/resource/org/onosproject/provider/lldp/impl/LLDPLinkProvider.cfgdef
new file mode 100644
index 0000000..588e4f3
--- /dev/null
+++ b/providers/lldp/src/main/resource/org/onosproject/provider/lldp/impl/LLDPLinkProvider.cfgdef
@@ -0,0 +1,4 @@
+# Temporary: to be auto-generated in near future
+useBDDP|BOOLEAN|true|Use BDDP for link discovery
+disableLinkDiscovery|BOOLEAN|false|Permanently disable link discovery
+lldpSuppression|STRING|../config/lldp_suppression.json|Path to LLDP suppression configuration file
diff --git a/providers/lldp/src/main/resources/org/onosproject/provider/lldp/impl/LLDPLinkProvider.cfgdef b/providers/lldp/src/main/resources/org/onosproject/provider/lldp/impl/LLDPLinkProvider.cfgdef
new file mode 100644
index 0000000..588e4f3
--- /dev/null
+++ b/providers/lldp/src/main/resources/org/onosproject/provider/lldp/impl/LLDPLinkProvider.cfgdef
@@ -0,0 +1,4 @@
+# Temporary: to be auto-generated in near future
+useBDDP|BOOLEAN|true|Use BDDP for link discovery
+disableLinkDiscovery|BOOLEAN|false|Permanently disable link discovery
+lldpSuppression|STRING|../config/lldp_suppression.json|Path to LLDP suppression configuration file
diff --git a/providers/lldp/src/test/java/org/onosproject/provider/lldp/impl/LLDPLinkProviderTest.java b/providers/lldp/src/test/java/org/onosproject/provider/lldp/impl/LLDPLinkProviderTest.java
index a601b23..d1d0f9c 100644
--- a/providers/lldp/src/test/java/org/onosproject/provider/lldp/impl/LLDPLinkProviderTest.java
+++ b/providers/lldp/src/test/java/org/onosproject/provider/lldp/impl/LLDPLinkProviderTest.java
@@ -37,6 +37,7 @@
import org.onlab.packet.ChassisId;
import org.onlab.packet.Ethernet;
import org.onlab.packet.ONOSLLDP;
+import org.onosproject.cfg.ComponentConfigAdapter;
import org.onosproject.cluster.NodeId;
import org.onosproject.cluster.RoleInfo;
import org.onosproject.core.ApplicationId;
@@ -103,12 +104,12 @@
@Before
public void setUp() {
-
coreService = createMock(CoreService.class);
expect(coreService.registerApplication(appId.name()))
.andReturn(appId).anyTimes();
replay(coreService);
+ provider.cfgService = new ComponentConfigAdapter();
provider.coreService = coreService;
provider.deviceService = deviceService;
diff --git a/providers/null/host/src/main/java/org/onosproject/provider/nil/host/impl/NullHostProvider.java b/providers/null/host/src/main/java/org/onosproject/provider/nil/host/impl/NullHostProvider.java
index 3cddb9a..d5ee60e 100644
--- a/providers/null/host/src/main/java/org/onosproject/provider/nil/host/impl/NullHostProvider.java
+++ b/providers/null/host/src/main/java/org/onosproject/provider/nil/host/impl/NullHostProvider.java
@@ -22,6 +22,7 @@
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
+import org.onosproject.cfg.ComponentConfigService;
import org.onosproject.cluster.ClusterService;
import org.onosproject.mastership.MastershipService;
import org.onosproject.net.Device;
@@ -65,6 +66,9 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected HostProviderRegistry providerRegistry;
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected ComponentConfigService cfgService;
+
private HostProviderService providerService;
//make sure the device has enough ports to accomodate all of them.
@@ -90,6 +94,7 @@
@Activate
public void activate() {
+ cfgService.registerProperties(getClass());
providerService = providerRegistry.register(this);
for (Device dev : deviceService.getDevices()) {
addHosts(dev);
@@ -101,6 +106,7 @@
@Deactivate
public void deactivate() {
+ cfgService.unregisterProperties(getClass(), false);
providerRegistry.unregister(this);
deviceService.removeListener(hostProvider);
providerService = null;
diff --git a/providers/null/link/src/main/java/org/onosproject/provider/nil/link/impl/NullLinkProvider.java b/providers/null/link/src/main/java/org/onosproject/provider/nil/link/impl/NullLinkProvider.java
index 37cbfca..b819eb7 100644
--- a/providers/null/link/src/main/java/org/onosproject/provider/nil/link/impl/NullLinkProvider.java
+++ b/providers/null/link/src/main/java/org/onosproject/provider/nil/link/impl/NullLinkProvider.java
@@ -27,6 +27,7 @@
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.onosproject.cfg.ComponentConfigService;
import org.onosproject.cluster.ClusterService;
import org.onosproject.cluster.NodeId;
import org.onosproject.mastership.MastershipService;
@@ -101,6 +102,9 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected LinkProviderRegistry providerRegistry;
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected ComponentConfigService cfgService;
+
private LinkProviderService providerService;
private final InternalLinkProvider linkProvider = new InternalLinkProvider();
@@ -119,7 +123,7 @@
Executors.newScheduledThreadPool(THREADS, groupedThreads("onos/null", "link-driver-%d"));
// For flicker = true, duration between events in msec.
- @Property(name = "eventRate", value = "0", label = "Duration between Link Event")
+ @Property(name = "eventRate", intValue = 0, label = "Duration between Link Event")
private int eventRate = DEFAULT_RATE;
// topology configuration file
@@ -137,6 +141,7 @@
@Activate
public void activate(ComponentContext context) {
+ cfgService.registerProperties(getClass());
providerService = providerRegistry.register(this);
modified(context);
@@ -166,6 +171,7 @@
@Deactivate
public void deactivate(ComponentContext context) {
+ cfgService.unregisterProperties(getClass(), false);
linkDriver.shutdown();
try {
linkDriver.awaitTermination(1000, TimeUnit.MILLISECONDS);
diff --git a/providers/null/link/src/main/resource/org/onosproject/provider/nil/link/impl/NullLinkProvider.cfgdef b/providers/null/link/src/main/resource/org/onosproject/provider/nil/link/impl/NullLinkProvider.cfgdef
new file mode 100644
index 0000000..f1dda76
--- /dev/null
+++ b/providers/null/link/src/main/resource/org/onosproject/provider/nil/link/impl/NullLinkProvider.cfgdef
@@ -0,0 +1,3 @@
+# Temporary: to be auto-generated in near future
+ "eventRate"|INTEGER|0|Duration between Link Event
+ "cfgFile"|STRING|"/opt/onos/apache-karaf-3.0.2/etc/linkGraph.cfg"|Topology file location
diff --git a/providers/null/packet/src/main/java/org/onosproject/provider/nil/packet/impl/NullPacketProvider.java b/providers/null/packet/src/main/java/org/onosproject/provider/nil/packet/impl/NullPacketProvider.java
index 82f6ace..15bd671 100644
--- a/providers/null/packet/src/main/java/org/onosproject/provider/nil/packet/impl/NullPacketProvider.java
+++ b/providers/null/packet/src/main/java/org/onosproject/provider/nil/packet/impl/NullPacketProvider.java
@@ -24,6 +24,7 @@
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.onlab.packet.Ethernet;
import org.onlab.packet.ICMP;
+import org.onosproject.cfg.ComponentConfigService;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.Device;
import org.onosproject.net.PortNumber;
@@ -77,6 +78,9 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected DeviceService deviceService;
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected ComponentConfigService cfgService;
+
// Rate to generate PacketEvents, per second
@Property(name = "pktRate", intValue = DEFAULT_RATE,
label = "Rate of PacketEvent generation")
@@ -91,6 +95,7 @@
@Activate
public void activate(ComponentContext context) {
+ cfgService.registerProperties(getClass());
providerService = providerRegistry.register(this);
if (!modified(context)) {
packetDriver.submit(new PacketDriver());
@@ -100,6 +105,7 @@
@Deactivate
public void deactivate(ComponentContext context) {
+ cfgService.unregisterProperties(getClass(), false);
try {
packetDriver.awaitTermination(1000, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
diff --git a/providers/null/packet/src/main/resource/org/onosproject/provider/nil/packet/impl/NullPacketProvider.cfgdef b/providers/null/packet/src/main/resource/org/onosproject/provider/nil/packet/impl/NullPacketProvider.cfgdef
new file mode 100644
index 0000000..b71929c
--- /dev/null
+++ b/providers/null/packet/src/main/resource/org/onosproject/provider/nil/packet/impl/NullPacketProvider.cfgdef
@@ -0,0 +1,2 @@
+# Temporary: to be auto-generated in near future
+ "pktRate"|INTEGER|5|Rate of PacketEvent generation
diff --git a/utils/misc/src/main/java/org/onlab/util/Tools.java b/utils/misc/src/main/java/org/onlab/util/Tools.java
index e3a3a41..b788038 100644
--- a/utils/misc/src/main/java/org/onlab/util/Tools.java
+++ b/utils/misc/src/main/java/org/onlab/util/Tools.java
@@ -35,6 +35,7 @@
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Dictionary;
import java.util.List;
import java.util.concurrent.ThreadFactory;
@@ -142,6 +143,20 @@
}
/**
+ * Get property as a string value.
+ *
+ * @param properties properties to be looked up
+ * @param propertyName the name of the property to look up
+ * @return value when the propertyName is defined or return null
+ */
+ public static String get(Dictionary<?, ?> properties, String propertyName) {
+ Object v = properties.get(propertyName);
+ String s = (v instanceof String) ? (String) v :
+ v != null ? v.toString() : null;
+ return Strings.isNullOrEmpty(s) ? null : s.trim();
+ }
+
+ /**
* Suspends the current thread for a specified number of millis.
*
* @param ms number of millis