Fix for property handling
Change-Id: I78342464568f4d2bc6827ae052cafafbbf8b7dd5
diff --git a/ce-api/src/main/java/org/opencord/ce/api/services/channel/Symbols.java b/ce-api/src/main/java/org/opencord/ce/api/services/channel/Symbols.java
index 47ba220..eb72c48 100644
--- a/ce-api/src/main/java/org/opencord/ce/api/services/channel/Symbols.java
+++ b/ce-api/src/main/java/org/opencord/ce/api/services/channel/Symbols.java
@@ -75,7 +75,6 @@
// ===== Device and Port annotations ==== //
public static final String DEVICE_ID = "deviceId";
- public static final String DOMAIN_ID = "domainId";
public static final String MEF_PORT_TYPE = "mefPortType";
diff --git a/local/bigswitch/pom.xml b/local/bigswitch/pom.xml
index 00baf3c..71f0179 100644
--- a/local/bigswitch/pom.xml
+++ b/local/bigswitch/pom.xml
@@ -44,7 +44,6 @@
<artifactId>onos-core-serializers</artifactId>
<version>${onos.version}</version>
</dependency>
-
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-cli</artifactId>
@@ -56,9 +55,16 @@
<version>3.0.5</version>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.scr.annotations</artifactId>
+ </dependency>
</dependencies>
-
<build>
<plugins>
<plugin>
diff --git a/local/bigswitch/src/main/java/org/opencord/ce/local/bigswitch/BigSwitchManager.java b/local/bigswitch/src/main/java/org/opencord/ce/local/bigswitch/BigSwitchManager.java
index ebe2179..010c54d 100644
--- a/local/bigswitch/src/main/java/org/opencord/ce/local/bigswitch/BigSwitchManager.java
+++ b/local/bigswitch/src/main/java/org/opencord/ce/local/bigswitch/BigSwitchManager.java
@@ -16,6 +16,7 @@
package org.opencord.ce.local.bigswitch;
+import com.google.common.base.Strings;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
@@ -48,9 +49,6 @@
import org.onosproject.net.device.DeviceService;
import org.onosproject.net.device.PortDescription;
import org.onosproject.net.domain.DomainId;
-import org.onosproject.net.edge.EdgePortEvent;
-import org.onosproject.net.edge.EdgePortListener;
-import org.onosproject.net.edge.EdgePortService;
import org.onosproject.store.serializers.KryoNamespaces;
import org.onosproject.store.service.AtomicCounter;
import org.onosproject.store.service.ConsistentMap;
@@ -71,15 +69,13 @@
import java.util.concurrent.Executors;
import java.util.stream.Collectors;
-import static com.google.common.base.Strings.isNullOrEmpty;
import static org.onlab.util.Tools.get;
import static org.onosproject.net.config.basics.SubjectFactories.APP_SUBJECT_FACTORY;
-import static org.opencord.ce.api.services.channel.Symbols.DOMAIN_ID;
import static org.opencord.ce.api.services.channel.Symbols.MEF_PORT_TYPE;
import static org.opencord.ce.local.bigswitch.MefPortsConfig.INTERLINK_ID;
import static org.opencord.ce.local.bigswitch.MefPortsConfig.MEF_PORTS;
-import static org.slf4j.LoggerFactory.getLogger;
import static org.opencord.ce.local.bigswitch.MefPortsConfig.MefPortConfig;
+import static org.slf4j.LoggerFactory.getLogger;
/**
* Listens for edge and port changes in the underlying data path and
@@ -93,7 +89,6 @@
private static final Logger log = getLogger(BigSwitchManager.class);
private static final String APP_NAME = "org.opencord.ce.local.bigswitch";
- public static final String REALIZED_BY = "bigswitch:realizedBy";
public static final String DEFAULT_DOMAIN_ID = "local-domain";
private static final String PORT_MAP = "ecord-port-map";
@@ -103,6 +98,9 @@
private final NetworkConfigListener configListener = new InternalConfigListener();
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected ComponentConfigService componentConfigService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected CoreService coreService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
@@ -112,24 +110,14 @@
protected DeviceService deviceService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected EdgePortService edgePortService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected StorageService storageService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected NetworkConfigService networkConfigService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected ComponentConfigService componentConfigService;
-
- @Property(name = "domainId", value = DEFAULT_DOMAIN_ID, label = "Domain ID where this ONOS is running")
- private String siteId = DEFAULT_DOMAIN_ID;
-
- private static final String PROP_ENABLED = "enabled";
- @Property(name = PROP_ENABLED, boolValue = true,
- label = "If false, DEVICE_CREATED event is never triggered")
- private boolean enabled = true;
+ private static final String DOMAIN_ID = "domainId";
+ @Property(name = DOMAIN_ID, value = DEFAULT_DOMAIN_ID, label = "Domain ID where this ONOS is running")
+ private String domainId = DEFAULT_DOMAIN_ID;
private final ExecutorService executorService =
Executors.newSingleThreadExecutor();
@@ -154,7 +142,6 @@
private LoadingCache<ConnectPoint, Long> p2vMap;
// TODO: Add other listeners once we decide what an edge really is
- private EdgePortListener edgeListener = new InternalEdgeListener();
private DeviceListener deviceListener = new InternalDeviceListener();
private final ConfigFactory<ApplicationId, MefPortsConfig> configFactory =
@@ -172,7 +159,6 @@
componentConfigService.registerProperties(getClass());
configRegistry.registerConfigFactory(configFactory);
networkConfigService.addListener(configListener);
- //deviceService = opticalView(deviceService);
portMap = storageService.<ConnectPoint, Long>consistentMapBuilder()
.withName(PORT_MAP)
.withSerializer(SERIALIZER)
@@ -187,7 +173,6 @@
eventDispatcher.addSink(BigSwitchEvent.class, listenerRegistry);
portCounter.compareAndSet(0, 1);
- // edgePortService.addListener(edgeListener);
deviceService.addListener(deviceListener);
log.info("Started");
}
@@ -196,7 +181,6 @@
public void deactivate() {
networkConfigService.removeListener(configListener);
configRegistry.unregisterConfigFactory(configFactory);
- //edgePortService.removeListener(edgeListener);
deviceService.removeListener(deviceListener);
componentConfigService.unregisterProperties(getClass(), false);
log.info("Stopped");
@@ -206,33 +190,13 @@
public void modified(ComponentContext context) {
Dictionary<?, ?> properties = context != null ? context.getProperties() : new Properties();
- boolean newEnabled;
- String newSiteId;
-
- try {
- String s = get(properties, PROP_ENABLED);
- newEnabled = isNullOrEmpty(s) || Boolean.parseBoolean(s.trim());
-
- s = get(properties, DOMAIN_ID);
- newSiteId = s;
-
- } catch (NumberFormatException e) {
- log.warn("Component configuration had invalid values", e);
-
- newEnabled = enabled;
- newSiteId = siteId;
+ String d = get(properties, DOMAIN_ID);
+ if (!Strings.isNullOrEmpty(d)) {
+ // TODO: signal new domain id to global
+ domainId = d;
}
- if (enabled && !newEnabled) {
- disable();
- } else if (!enabled && newEnabled) {
- enable();
- }
- enabled = newEnabled;
-
- // TODO: manage new site ID
- siteId = newSiteId;
- log.info("siteId {}", siteId);
+ log.info("Domain ID set to {}", domainId());
}
@Override
@@ -245,7 +209,7 @@
@Override
public PortNumber getPort(ConnectPoint port) {
- // XXX error-check and seriously think about a better method definition.
+ // FIXME: error-check and seriously think about a better method definition.
Versioned<Long> portNo = portMap.get(port);
if (Versioned.valueOrNull(portNo) != null) {
return PortNumber.portNumber(portNo.value());
@@ -264,9 +228,8 @@
}
@Override
- public DomainId siteId() {
- log.info("siteId {}", siteId);
- return DomainId.domainId(siteId);
+ public DomainId domainId() {
+ return DomainId.domainId(domainId);
}
/**
@@ -284,7 +247,7 @@
DefaultAnnotations.Builder annot = DefaultAnnotations.builder();
p.annotations().keys()
.forEach(k -> annot.set(k, p.annotations().value(k)));
- annot.set(DOMAIN_ID, siteId);
+ annot.set(DOMAIN_ID, domainId);
// add annotation about underlying physical connect-point
Device device = deviceService.getDevice(cp.deviceId());
if (device.annotations().keys()
@@ -344,7 +307,7 @@
private void readConfig() {
mefPortConfigs = configRegistry.getConfig(appId, MefPortsConfig.class).mefPortConfigs();
- if (enabled && mefPortConfigs != null) {
+ if (mefPortConfigs != null) {
buildPorts();
log.info("Notifying Bigswitch presence..");
if (portMap.size() > 0) {
@@ -353,56 +316,6 @@
}
}
- private void disable() {
- // TODO
- }
-
- private void enable() {
- if (mefPortConfigs != null && portMap.size() > 0) {
- post(new BigSwitchEvent(BigSwitchEvent.Type.DEVICE_CREATED, null, getPorts()));
- }
- }
-
-
- private class InternalEdgeListener implements EdgePortListener {
- @Override
- public boolean isRelevant(EdgePortEvent event) {
- // Only listen for real devices
- Device d = deviceService.getDevice(event.subject().deviceId());
-
- return d != null && !d.type().equals(Device.Type.VIRTUAL) &&
- isPortRelevant(event.subject());
- }
-
- @Override
- public void event(EdgePortEvent event) {
- log.info("Edge event {} {}", event.subject(), event.type());
- BigSwitchEvent.Type bigSwitchEvent;
-
- switch (event.type()) {
- case EDGE_PORT_ADDED:
- portMap.put(event.subject(), getVirtualPortNumber(event.subject()));
- bigSwitchEvent = BigSwitchEvent.Type.PORT_ADDED;
- break;
- case EDGE_PORT_REMOVED:
- portMap.remove(event.subject());
- bigSwitchEvent = BigSwitchEvent.Type.PORT_REMOVED;
- break;
- default:
- return;
- }
-
- if (mefPortConfigs != null) {
- PortDescription descr;
- descr = toVirtualPortDescription(event.subject());
- if (descr != null) {
- post(new BigSwitchEvent(bigSwitchEvent, descr, getPorts()));
- }
- }
- }
- }
-
-
private class InternalDeviceListener implements DeviceListener {
@Override
public boolean isRelevant(DeviceEvent event) {
diff --git a/local/bigswitch/src/main/java/org/opencord/ce/local/bigswitch/BigSwitchService.java b/local/bigswitch/src/main/java/org/opencord/ce/local/bigswitch/BigSwitchService.java
index 47880ff..172f2ee 100644
--- a/local/bigswitch/src/main/java/org/opencord/ce/local/bigswitch/BigSwitchService.java
+++ b/local/bigswitch/src/main/java/org/opencord/ce/local/bigswitch/BigSwitchService.java
@@ -54,10 +54,10 @@
Optional<ConnectPoint> connectPointFromVirtPort(PortNumber portNumber);
/**
- * Returns the local site/domain ID of this biw switch.
+ * Returns the local domain ID of this bigswitch.
*
- * @return domain/site ID
+ * @return domain ID
*/
- DomainId siteId();
+ DomainId domainId();
}
diff --git a/local/ce-central-office/pom.xml b/local/ce-central-office/pom.xml
index d8536e7..108623f 100644
--- a/local/ce-central-office/pom.xml
+++ b/local/ce-central-office/pom.xml
@@ -32,7 +32,7 @@
<properties>
<onos.app.name>org.opencord.ce.local.co</onos.app.name>
- <onos.version>1.10.0</onos.version>
+ <onos.version>1.10.6</onos.version>
<onos.app.title>ECORD Central-Office Fabric config</onos.app.title>
<onos.app.url>http://opencord.org</onos.app.url>
</properties>
@@ -54,6 +54,14 @@
</plugins>
</build>
+ <dependencies>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>2.6.2</version>
+ </dependency>
+ </dependencies>
+
<repositories>
<repository>
<id>snapshots</id>
diff --git a/local/http-channel/src/main/java/org/opencord/ce/local/channel/client/HttpClientComponent.java b/local/http-channel/src/main/java/org/opencord/ce/local/channel/client/HttpClientComponent.java
index 17cfa4e..44227af 100644
--- a/local/http-channel/src/main/java/org/opencord/ce/local/channel/client/HttpClientComponent.java
+++ b/local/http-channel/src/main/java/org/opencord/ce/local/channel/client/HttpClientComponent.java
@@ -135,14 +135,14 @@
switch (event.type()) {
case DEVICE_CREATED:
log.info("DEBUG: DEV_CREATED event");
- HttpClientInstance.INSTANCE.notifyBigSwitch(bigSwitchService.siteId());
+ HttpClientInstance.INSTANCE.notifyBigSwitch(bigSwitchService.domainId());
case PORT_ADDED:
case PORT_UPDATED:
case PORT_REMOVED:
// the subject is port last updated / added port
// but we are not interested in it now
List<PortDescription> ports = event.allPorts();
- HttpClientInstance.INSTANCE.notifyBigSwitchPorts(bigSwitchService.siteId(), ports);
+ HttpClientInstance.INSTANCE.notifyBigSwitchPorts(bigSwitchService.domainId(), ports);
break;
case DEVICE_REMOVED:
// TODO