openstack and routing app OSGi property migration
Change-Id: I855020959456f059911284bb7d8ade376cbc20c5
diff --git a/apps/openstacknetworking/api/src/main/java/org/onosproject/openstacknetworking/api/Constants.java b/apps/openstacknetworking/api/src/main/java/org/onosproject/openstacknetworking/api/Constants.java
index ead7234..1be5b35 100644
--- a/apps/openstacknetworking/api/src/main/java/org/onosproject/openstacknetworking/api/Constants.java
+++ b/apps/openstacknetworking/api/src/main/java/org/onosproject/openstacknetworking/api/Constants.java
@@ -45,7 +45,6 @@
public static final String ARP_PROXY_MODE = "proxy";
public static final String DEFAULT_GATEWAY_MAC_STR = "fe:00:00:00:00:02";
- public static final String DEFAULT_ARP_MODE_STR = ARP_PROXY_MODE;
public static final MacAddress DEFAULT_GATEWAY_MAC = MacAddress.valueOf(DEFAULT_GATEWAY_MAC_STR);
public static final MacAddress DEFAULT_EXTERNAL_ROUTER_MAC = MacAddress.valueOf("fe:00:00:00:00:01");
diff --git a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenstackRoutingArpHandler.java b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenstackRoutingArpHandler.java
index 7f34ad7..51990d1 100644
--- a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenstackRoutingArpHandler.java
+++ b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenstackRoutingArpHandler.java
@@ -88,13 +88,14 @@
import static org.onlab.util.Tools.groupedThreads;
import static org.onosproject.openstacknetworking.api.Constants.ARP_BROADCAST_MODE;
import static org.onosproject.openstacknetworking.api.Constants.ARP_PROXY_MODE;
-import static org.onosproject.openstacknetworking.api.Constants.DEFAULT_ARP_MODE_STR;
-import static org.onosproject.openstacknetworking.api.Constants.DEFAULT_GATEWAY_MAC_STR;
import static org.onosproject.openstacknetworking.api.Constants.GW_COMMON_TABLE;
import static org.onosproject.openstacknetworking.api.Constants.OPENSTACK_NETWORKING_APP_ID;
import static org.onosproject.openstacknetworking.api.Constants.PRIORITY_ARP_CONTROL_RULE;
import static org.onosproject.openstacknetworking.api.Constants.PRIORITY_ARP_GATEWAY_RULE;
import static org.onosproject.openstacknetworking.api.OpenstackNetworkEvent.Type.OPENSTACK_PORT_PRE_REMOVE;
+import static org.onosproject.openstacknetworking.impl.OsgiPropertyConstants.ARP_MODE;
+import static org.onosproject.openstacknetworking.impl.OsgiPropertyConstants.ARP_MODE_DEFAULT;
+import static org.onosproject.openstacknetworking.impl.OsgiPropertyConstants.GATEWAY_MAC_DEFAULT;
import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.associatedFloatingIp;
import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.getGwByComputeDevId;
import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.getGwByInstancePort;
@@ -109,7 +110,12 @@
/**
* Handle ARP requests from gateway nodes.
*/
-@Component(immediate = true)
+@Component(
+ immediate = true,
+ property = {
+ ARP_MODE + "=" + ARP_MODE_DEFAULT
+ }
+)
public class OpenstackRoutingArpHandler {
private final Logger log = getLogger(getClass());
@@ -154,11 +160,10 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY)
protected PreCommitPortService preCommitPortService;
- //@Property(name = ARP_MODE, value = DEFAULT_ARP_MODE_STR,
- // label = "ARP processing mode, broadcast | proxy (default)")
- protected String arpMode = DEFAULT_ARP_MODE_STR;
+ /** ARP processing mode, broadcast | proxy (default). **/
+ protected String arpMode = ARP_MODE_DEFAULT;
- protected String gatewayMac = DEFAULT_GATEWAY_MAC_STR;
+ protected String gatewayMac = GATEWAY_MAC_DEFAULT;
private final OpenstackRouterListener osRouterListener = new InternalRouterEventListener();
private final OpenstackNodeListener osNodeListener = new InternalNodeEventListener();
diff --git a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenstackRoutingHandler.java b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenstackRoutingHandler.java
index c7b0ac1..1a9de18 100644
--- a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenstackRoutingHandler.java
+++ b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenstackRoutingHandler.java
@@ -97,6 +97,8 @@
import static org.onosproject.openstacknetworking.api.Constants.ROUTING_TABLE;
import static org.onosproject.openstacknetworking.api.Constants.STAT_OUTBOUND_TABLE;
import static org.onosproject.openstacknetworking.api.InstancePort.State.ACTIVE;
+import static org.onosproject.openstacknetworking.impl.OsgiPropertyConstants.USE_STATEFUL_SNAT;
+import static org.onosproject.openstacknetworking.impl.OsgiPropertyConstants.USE_STATEFUL_SNAT_DEFAULT;
import static org.onosproject.openstacknetworking.util.RulePopulatorUtil.buildExtension;
import static org.onosproject.openstacknode.api.OpenstackNode.NodeType.COMPUTE;
import static org.onosproject.openstacknode.api.OpenstackNode.NodeType.GATEWAY;
@@ -104,7 +106,12 @@
/**
* Handles OpenStack router events.
*/
-@Component(immediate = true)
+@Component(
+ immediate = true,
+ property = {
+ USE_STATEFUL_SNAT + ":Boolean=" + USE_STATEFUL_SNAT_DEFAULT
+ }
+)
public class OpenstackRoutingHandler {
private final Logger log = LoggerFactory.getLogger(getClass());
@@ -112,11 +119,9 @@
private static final String MSG_ENABLED = "Enabled ";
private static final String MSG_DISABLED = "Disabled ";
private static final String ERR_UNSUPPORTED_NET_TYPE = "Unsupported network type";
- private static final boolean USE_STATEFUL_SNAT = false;
- //@Property(name = "useStatefulSnat", boolValue = USE_STATEFUL_SNAT,
- // label = "Use Stateful SNAT for source NATing")
- private boolean useStatefulSnat = USE_STATEFUL_SNAT;
+ /** Use Stateful SNAT for source NATing. */
+ private boolean useStatefulSnat = USE_STATEFUL_SNAT_DEFAULT;
@Reference(cardinality = ReferenceCardinality.MANDATORY)
protected CoreService coreService;
@@ -193,7 +198,7 @@
Dictionary<?, ?> properties = context.getProperties();
Boolean flag;
- flag = Tools.isPropertyEnabled(properties, "useStatefulSnat");
+ flag = Tools.isPropertyEnabled(properties, USE_STATEFUL_SNAT);
if (flag == null) {
log.info("useStatefulSnat is not configured, " +
"using current value of {}", useStatefulSnat);
diff --git a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenstackSecurityGroupHandler.java b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenstackSecurityGroupHandler.java
index 4701d9c..e9577bf 100644
--- a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenstackSecurityGroupHandler.java
+++ b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenstackSecurityGroupHandler.java
@@ -101,6 +101,8 @@
import static org.onosproject.openstacknetworking.api.Constants.PRIORITY_CT_DROP_RULE;
import static org.onosproject.openstacknetworking.api.Constants.PRIORITY_CT_HOOK_RULE;
import static org.onosproject.openstacknetworking.api.Constants.PRIORITY_CT_RULE;
+import static org.onosproject.openstacknetworking.impl.OsgiPropertyConstants.USE_SECURITY_GROUP;
+import static org.onosproject.openstacknetworking.impl.OsgiPropertyConstants.USE_SECURITY_GROUP_DEFAULT;
import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.swapStaleLocation;
import static org.onosproject.openstacknetworking.util.RulePopulatorUtil.computeCtMaskFlag;
import static org.onosproject.openstacknetworking.util.RulePopulatorUtil.computeCtStateFlag;
@@ -111,16 +113,18 @@
/**
* Populates flow rules to handle OpenStack SecurityGroups.
*/
-@Component(immediate = true)
+@Component(
+ immediate = true,
+ property = {
+ USE_SECURITY_GROUP + ":Boolean=" + USE_SECURITY_GROUP_DEFAULT
+ }
+)
public class OpenstackSecurityGroupHandler {
private final Logger log = getLogger(getClass());
- private static final boolean USE_SECURITY_GROUP = false;
-
- //@Property(name = "useSecurityGroup", boolValue = USE_SECURITY_GROUP,
- // label = "Apply OpenStack security group rule for VM traffic")
- private boolean useSecurityGroup = USE_SECURITY_GROUP;
+ /** Apply OpenStack security group rule for VM traffic. */
+ private boolean useSecurityGroup = USE_SECURITY_GROUP_DEFAULT;
@Reference(cardinality = ReferenceCardinality.MANDATORY)
protected CoreService coreService;
@@ -247,7 +251,7 @@
Dictionary<?, ?> properties = context.getProperties();
Boolean flag;
- flag = Tools.isPropertyEnabled(properties, "useSecurityGroup");
+ flag = Tools.isPropertyEnabled(properties, USE_SECURITY_GROUP);
if (flag == null) {
log.info("useSecurityGroup is not configured, " +
"using current value of {}", useSecurityGroup);
diff --git a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenstackSwitchingArpHandler.java b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenstackSwitchingArpHandler.java
index c78134d..e2f8f92 100644
--- a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenstackSwitchingArpHandler.java
+++ b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenstackSwitchingArpHandler.java
@@ -75,8 +75,6 @@
import static org.onosproject.openstacknetworking.api.Constants.ARP_BROADCAST_MODE;
import static org.onosproject.openstacknetworking.api.Constants.ARP_PROXY_MODE;
import static org.onosproject.openstacknetworking.api.Constants.ARP_TABLE;
-import static org.onosproject.openstacknetworking.api.Constants.DEFAULT_ARP_MODE_STR;
-import static org.onosproject.openstacknetworking.api.Constants.DEFAULT_GATEWAY_MAC_STR;
import static org.onosproject.openstacknetworking.api.Constants.OPENSTACK_NETWORKING_APP_ID;
import static org.onosproject.openstacknetworking.api.Constants.PRIORITY_ARP_CONTROL_RULE;
import static org.onosproject.openstacknetworking.api.Constants.PRIORITY_ARP_FLOOD_RULE;
@@ -84,6 +82,10 @@
import static org.onosproject.openstacknetworking.api.Constants.PRIORITY_ARP_REPLY_RULE;
import static org.onosproject.openstacknetworking.api.Constants.PRIORITY_ARP_REQUEST_RULE;
import static org.onosproject.openstacknetworking.api.InstancePort.State.ACTIVE;
+import static org.onosproject.openstacknetworking.impl.OsgiPropertyConstants.ARP_MODE;
+import static org.onosproject.openstacknetworking.impl.OsgiPropertyConstants.ARP_MODE_DEFAULT;
+import static org.onosproject.openstacknetworking.impl.OsgiPropertyConstants.GATEWAY_MAC;
+import static org.onosproject.openstacknetworking.impl.OsgiPropertyConstants.GATEWAY_MAC_DEFAULT;
import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.getPropertyValue;
import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.swapStaleLocation;
import static org.onosproject.openstacknetworking.util.RulePopulatorUtil.buildExtension;
@@ -92,14 +94,17 @@
/**
* Handles ARP packet from VMs.
*/
-@Component(immediate = true)
+@Component(
+ immediate = true,
+ property = {
+ GATEWAY_MAC + "=" + GATEWAY_MAC_DEFAULT,
+ ARP_MODE + "=" + ARP_MODE_DEFAULT,
+ }
+)
public final class OpenstackSwitchingArpHandler {
private final Logger log = LoggerFactory.getLogger(getClass());
- private static final String GATEWAY_MAC = "gatewayMac";
- private static final String ARP_MODE = "arpMode";
-
@Reference(cardinality = ReferenceCardinality.MANDATORY)
CoreService coreService;
@@ -133,13 +138,11 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY)
protected OpenstackNodeService osNodeService;
- //@Property(name = GATEWAY_MAC, value = DEFAULT_GATEWAY_MAC_STR,
- // label = "Fake MAC address for virtual network subnet gateway")
- private String gatewayMac = DEFAULT_GATEWAY_MAC_STR;
+ /** Fake MAC address for virtual network subnet gateway. */
+ private String gatewayMac = GATEWAY_MAC_DEFAULT;
- //@Property(name = ARP_MODE, value = DEFAULT_ARP_MODE_STR,
- // label = "ARP processing mode, broadcast | proxy (default)")
- protected String arpMode = DEFAULT_ARP_MODE_STR;
+ /** ARP processing mode, broadcast | proxy (default). */
+ protected String arpMode = ARP_MODE_DEFAULT;
private final InternalPacketProcessor packetProcessor = new InternalPacketProcessor();
private final InternalOpenstackNetworkListener osNetworkListener =
@@ -519,7 +522,7 @@
Dictionary<?, ?> properties = context.getProperties();
String updatedMac = Tools.get(properties, GATEWAY_MAC);
- gatewayMac = updatedMac != null ? updatedMac : DEFAULT_GATEWAY_MAC_STR;
+ gatewayMac = updatedMac != null ? updatedMac : GATEWAY_MAC_DEFAULT;
log.info("Configured. Gateway MAC is {}", gatewayMac);
}
diff --git a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenstackSwitchingDhcpHandler.java b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenstackSwitchingDhcpHandler.java
index ca322ea..71fa4d1 100644
--- a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenstackSwitchingDhcpHandler.java
+++ b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenstackSwitchingDhcpHandler.java
@@ -84,20 +84,25 @@
import static org.onlab.packet.DHCP.DHCPOptionCode.OptionCode_SubnetMask;
import static org.onlab.packet.DHCP.MsgType.DHCPACK;
import static org.onlab.packet.DHCP.MsgType.DHCPOFFER;
-import static org.onosproject.openstacknetworking.api.Constants.DEFAULT_GATEWAY_MAC_STR;
import static org.onosproject.openstacknetworking.api.Constants.DHCP_TABLE;
import static org.onosproject.openstacknetworking.api.Constants.PRIORITY_DHCP_RULE;
+import static org.onosproject.openstacknetworking.impl.OsgiPropertyConstants.DHCP_SERVER_MAC;
+import static org.onosproject.openstacknetworking.impl.OsgiPropertyConstants.DHCP_SERVER_MAC_DEFAULT;
import static org.onosproject.openstacknode.api.OpenstackNode.NodeType.COMPUTE;
import static org.slf4j.LoggerFactory.getLogger;
/**
* Handles DHCP requests for the virtual instances.
*/
-@Component(immediate = true)
+@Component(
+ immediate = true,
+ property = {
+ DHCP_SERVER_MAC + "=" + DHCP_SERVER_MAC_DEFAULT
+ }
+)
public class OpenstackSwitchingDhcpHandler {
protected final Logger log = getLogger(getClass());
- private static final String DHCP_SERVER_MAC = "dhcpServerMac";
private static final Ip4Address DEFAULT_PRIMARY_DNS = Ip4Address.valueOf("8.8.8.8");
private static final Ip4Address DEFAULT_SECONDARY_DNS = Ip4Address.valueOf("8.8.4.4");
private static final byte PACKET_TTL = (byte) 127;
@@ -140,9 +145,8 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY)
protected LeadershipService leadershipService;
- //@Property(name = DHCP_SERVER_MAC, value = DEFAULT_GATEWAY_MAC_STR,
- // label = "Fake MAC address for virtual network subnet gateway")
- private String dhcpServerMac = DEFAULT_GATEWAY_MAC_STR;
+ /** Fake MAC address for virtual network subnet gateway. */
+ private String dhcpServerMac = DHCP_SERVER_MAC_DEFAULT;
private int dhcpDataMtu = DHCP_DATA_MTU_DEFAULT;
diff --git a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OsgiPropertyConstants.java b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OsgiPropertyConstants.java
new file mode 100644
index 0000000..154fe79
--- /dev/null
+++ b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OsgiPropertyConstants.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * 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.
+ */
+
+package org.onosproject.openstacknetworking.impl;
+
+/**
+ * Name/Value constants for properties.
+ */
+public final class OsgiPropertyConstants {
+ private OsgiPropertyConstants() {
+ }
+
+ static final String GATEWAY_MAC = "gatewayMac";
+ static final String GATEWAY_MAC_DEFAULT = "fe:00:00:00:00:02";
+
+ static final String ARP_MODE = "arpMode";
+ static final String ARP_MODE_DEFAULT = "proxy";
+
+ static final String USE_STATEFUL_SNAT = "useStatefulSnat";
+ static final boolean USE_STATEFUL_SNAT_DEFAULT = false;
+
+ static final String USE_SECURITY_GROUP = "useSecurityGroup";
+ static final boolean USE_SECURITY_GROUP_DEFAULT = false;
+
+ static final String DHCP_SERVER_MAC = "dhcpServerMac";
+ static final String DHCP_SERVER_MAC_DEFAULT = "fe:00:00:00:00:02";
+}
diff --git a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/DefaultOpenstackNodeHandler.java b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/DefaultOpenstackNodeHandler.java
index f3645d7..9f3d220 100644
--- a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/DefaultOpenstackNodeHandler.java
+++ b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/DefaultOpenstackNodeHandler.java
@@ -90,6 +90,10 @@
import static org.onosproject.openstacknode.api.OpenstackNode.NodeType.CONTROLLER;
import static org.onosproject.openstacknode.api.OpenstackNode.NodeType.GATEWAY;
import static org.onosproject.openstacknode.api.OpenstackNodeService.APP_ID;
+import static org.onosproject.openstacknode.impl.OsgiPropertyConstants.AUTO_RECOVERY;
+import static org.onosproject.openstacknode.impl.OsgiPropertyConstants.AUTO_RECOVERY_DEFAULT;
+import static org.onosproject.openstacknode.impl.OsgiPropertyConstants.OVSDB_PORT;
+import static org.onosproject.openstacknode.impl.OsgiPropertyConstants.OVSDB_PORT_NUM_DEFAULT;
import static org.onosproject.openstacknode.util.OpenstackNodeUtil.addOrRemoveDpdkInterface;
import static org.onosproject.openstacknode.util.OpenstackNodeUtil.addOrRemoveSystemInterface;
import static org.onosproject.openstacknode.util.OpenstackNodeUtil.getBooleanProperty;
@@ -101,17 +105,18 @@
/**
* Service bootstraps openstack node based on its type.
*/
-@Component(immediate = true)
+@Component(immediate = true,
+ property = {
+ OVSDB_PORT + ":Integer=" + OVSDB_PORT_NUM_DEFAULT,
+ AUTO_RECOVERY + ":Boolean=" + AUTO_RECOVERY_DEFAULT
+ }
+)
public class DefaultOpenstackNodeHandler implements OpenstackNodeHandler {
private final Logger log = getLogger(getClass());
- private static final String OVSDB_PORT = "ovsdbPortNum";
- private static final String AUTO_RECOVERY = "autoRecovery";
private static final String DEFAULT_OF_PROTO = "tcp";
- private static final int DEFAULT_OVSDB_PORT = 6640;
private static final int DEFAULT_OFPORT = 6653;
- private static final boolean DEFAULT_AUTO_RECOVERY = true;
private static final int DPID_BEGIN = 3;
@Reference(cardinality = ReferenceCardinality.MANDATORY)
@@ -141,14 +146,11 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY)
protected ComponentConfigService componentConfigService;
- //@Property(name = OVSDB_PORT, intValue = DEFAULT_OVSDB_PORT,
- // label = "OVSDB server listen port")
- private int ovsdbPort = DEFAULT_OVSDB_PORT;
+ /** OVSDB server listen port. */
+ private int ovsdbPortNum = OVSDB_PORT_NUM_DEFAULT;
- //@Property(name = AUTO_RECOVERY, boolValue = DEFAULT_AUTO_RECOVERY,
- // label = "A flag which indicates whether auto-recover openstack " +
- // "node status at the receiving of switch reconnecting event.")
- private boolean autoRecovery = DEFAULT_AUTO_RECOVERY;
+ /** A flag which indicates whether auto-recover openstack node status on switch reconnecting event. */
+ private boolean autoRecovery = AUTO_RECOVERY_DEFAULT;
private final ExecutorService eventExecutor = newSingleThreadExecutor(
groupedThreads(this.getClass().getSimpleName(), "event-handler", log));
@@ -195,8 +197,8 @@
@Override
public void processInitState(OpenstackNode osNode) {
- if (!isOvsdbConnected(osNode, ovsdbPort, ovsdbController, deviceService)) {
- ovsdbController.connect(osNode.managementIp(), tpPort(ovsdbPort));
+ if (!isOvsdbConnected(osNode, ovsdbPortNum, ovsdbController, deviceService)) {
+ ovsdbController.connect(osNode.managementIp(), tpPort(ovsdbPortNum));
return;
}
if (!deviceService.isAvailable(osNode.intgBridge())) {
@@ -210,8 +212,8 @@
@Override
public void processDeviceCreatedState(OpenstackNode osNode) {
try {
- if (!isOvsdbConnected(osNode, ovsdbPort, ovsdbController, deviceService)) {
- ovsdbController.connect(osNode.managementIp(), tpPort(ovsdbPort));
+ if (!isOvsdbConnected(osNode, ovsdbPortNum, ovsdbController, deviceService)) {
+ ovsdbController.connect(osNode.managementIp(), tpPort(ovsdbPortNum));
return;
}
@@ -229,12 +231,12 @@
osNode.dpdkConfig().dpdkIntfs().stream()
.filter(dpdkInterface -> dpdkInterface.deviceName().equals(TUNNEL_BRIDGE))
.forEach(dpdkInterface -> addOrRemoveDpdkInterface(
- osNode, dpdkInterface, ovsdbPort, ovsdbController, true));
+ osNode, dpdkInterface, ovsdbPortNum, ovsdbController, true));
osNode.dpdkConfig().dpdkIntfs().stream()
.filter(dpdkInterface -> dpdkInterface.deviceName().equals(INTEGRATION_BRIDGE))
.forEach(dpdkInterface -> addOrRemoveDpdkInterface(
- osNode, dpdkInterface, ovsdbPort, ovsdbController, true));
+ osNode, dpdkInterface, ovsdbPortNum, ovsdbController, true));
}
osNode.phyIntfs().forEach(i -> {
@@ -274,7 +276,7 @@
private boolean dpdkTunnelBridgeCreated(OpenstackNode osNode) {
- OvsdbClientService client = getOvsdbClient(osNode, ovsdbPort, ovsdbController);
+ OvsdbClientService client = getOvsdbClient(osNode, ovsdbPortNum, ovsdbController);
if (client == null) {
log.info("Failed to get ovsdb client");
return false;
@@ -388,7 +390,7 @@
private boolean isCurrentStateDone(OpenstackNode osNode) {
switch (osNode.state()) {
case INIT:
- if (!isOvsdbConnected(osNode, ovsdbPort, ovsdbController, deviceService)) {
+ if (!isOvsdbConnected(osNode, ovsdbPortNum, ovsdbController, deviceService)) {
return false;
}
@@ -434,7 +436,7 @@
}
private boolean isDpdkIntfsCreated(OpenstackNode osNode, Collection<DpdkInterface> dpdkInterfaces) {
- OvsdbClientService client = getOvsdbClient(osNode, ovsdbPort, ovsdbController);
+ OvsdbClientService client = getOvsdbClient(osNode, ovsdbPortNum, ovsdbController);
if (client == null) {
log.info("Failed to get ovsdb client");
return false;
@@ -537,7 +539,7 @@
String intfName,
Optional<DpdkInterface> dpdkInterface) {
if (dpdkInterface.isPresent()) {
- addOrRemoveDpdkInterface(osNode, dpdkInterface.get(), ovsdbPort,
+ addOrRemoveDpdkInterface(osNode, dpdkInterface.get(), ovsdbPortNum,
ovsdbController, false);
} else {
addOrRemoveSystemInterface(osNode, INTEGRATION_BRIDGE, intfName, deviceService,
@@ -546,7 +548,7 @@
}
private void processOpenstackNodeRemoved(OpenstackNode osNode) {
- OvsdbClientService client = getOvsdbClient(osNode, ovsdbPort, ovsdbController);
+ OvsdbClientService client = getOvsdbClient(osNode, ovsdbPortNum, ovsdbController);
if (client == null) {
log.info("Failed to get ovsdb client");
return;
@@ -562,7 +564,7 @@
if (osNode.dpdkConfig() != null) {
osNode.dpdkConfig().dpdkIntfs().forEach(dpdkInterface -> {
if (isDpdkIntfsCreated(osNode, Lists.newArrayList(dpdkInterface))) {
- addOrRemoveDpdkInterface(osNode, dpdkInterface, ovsdbPort, ovsdbController, false);
+ addOrRemoveDpdkInterface(osNode, dpdkInterface, ovsdbPortNum, ovsdbController, false);
}
});
}
@@ -611,17 +613,17 @@
Integer ovsdbPortConfigured = Tools.getIntegerProperty(properties, OVSDB_PORT);
if (ovsdbPortConfigured == null) {
- ovsdbPort = DEFAULT_OVSDB_PORT;
- log.info("OVSDB port is NOT configured, default value is {}", ovsdbPort);
+ ovsdbPortNum = OVSDB_PORT_NUM_DEFAULT;
+ log.info("OVSDB port is NOT configured, default value is {}", ovsdbPortNum);
} else {
- ovsdbPort = ovsdbPortConfigured;
- log.info("Configured. OVSDB port is {}", ovsdbPort);
+ ovsdbPortNum = ovsdbPortConfigured;
+ log.info("Configured. OVSDB port is {}", ovsdbPortNum);
}
Boolean autoRecoveryConfigured =
getBooleanProperty(properties, AUTO_RECOVERY);
if (autoRecoveryConfigured == null) {
- autoRecovery = DEFAULT_AUTO_RECOVERY;
+ autoRecovery = AUTO_RECOVERY_DEFAULT;
log.info("Auto recovery flag is NOT " +
"configured, default value is {}", autoRecovery);
} else {
diff --git a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/OpenstackNodeManager.java b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/OpenstackNodeManager.java
index 846f44e..d990fae 100644
--- a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/OpenstackNodeManager.java
+++ b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/OpenstackNodeManager.java
@@ -61,6 +61,8 @@
import static org.onosproject.openstacknode.api.Constants.INTEGRATION_BRIDGE;
import static org.onosproject.openstacknode.api.NodeState.COMPLETE;
import static org.onosproject.openstacknode.api.OpenstackNode.NodeType.CONTROLLER;
+import static org.onosproject.openstacknode.impl.OsgiPropertyConstants.OVSDB_PORT;
+import static org.onosproject.openstacknode.impl.OsgiPropertyConstants.OVSDB_PORT_NUM_DEFAULT;
import static org.onosproject.openstacknode.util.OpenstackNodeUtil.addOrRemoveSystemInterface;
import static org.onosproject.openstacknode.util.OpenstackNodeUtil.genDpid;
import static org.onosproject.openstacknode.util.OpenstackNodeUtil.isOvsdbConnected;
@@ -69,7 +71,13 @@
/**
* Service administering the inventory of openstack nodes.
*/
-@Component(immediate = true, service = { OpenstackNodeService.class, OpenstackNodeAdminService.class })
+@Component(
+ immediate = true,
+ service = { OpenstackNodeService.class, OpenstackNodeAdminService.class },
+ property = {
+ OVSDB_PORT + ":Integer=" + OVSDB_PORT_NUM_DEFAULT
+ }
+)
public class OpenstackNodeManager extends ListenerRegistry<OpenstackNodeEvent, OpenstackNodeListener>
implements OpenstackNodeService, OpenstackNodeAdminService {
@@ -79,8 +87,6 @@
private static final String MSG_CREATED = "created";
private static final String MSG_UPDATED = "updated";
private static final String MSG_REMOVED = "removed";
- private static final String OVSDB_PORT = "ovsdbPortNum";
- private static final int DEFAULT_OVSDB_PORT = 6640;
private static final String DEVICE_ID_COUNTER_NAME = "device-id-counter";
@@ -111,9 +117,8 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY)
protected DeviceService deviceService;
- //@Property(name = OVSDB_PORT, intValue = DEFAULT_OVSDB_PORT,
- // label = "OVSDB server listen port")
- private int ovsdbPort = DEFAULT_OVSDB_PORT;
+ /** OVSDB server listen port. */
+ private int ovsdbPortNum = OVSDB_PORT_NUM_DEFAULT;
private final ExecutorService eventExecutor = newSingleThreadExecutor(
groupedThreads(this.getClass().getSimpleName(), "event-handler", log));
@@ -150,8 +155,8 @@
protected void modified(ComponentContext context) {
Dictionary<?, ?> properties = context.getProperties();
int updatedOvsdbPort = Tools.getIntegerProperty(properties, OVSDB_PORT);
- if (!Objects.equals(updatedOvsdbPort, ovsdbPort)) {
- ovsdbPort = updatedOvsdbPort;
+ if (!Objects.equals(updatedOvsdbPort, ovsdbPortNum)) {
+ ovsdbPortNum = updatedOvsdbPort;
}
log.info("Modified");
@@ -336,11 +341,11 @@
}
private void connectSwitch(OpenstackNode osNode) {
- if (!isOvsdbConnected(osNode, ovsdbPort, ovsdbController, deviceService)) {
+ if (!isOvsdbConnected(osNode, ovsdbPortNum, ovsdbController, deviceService)) {
log.warn("There's no ovsdb connection with the device {}. Try to connect the device...",
osNode.ovsdb().toString());
try {
- ovsdbController.connect(osNode.managementIp(), tpPort(ovsdbPort));
+ ovsdbController.connect(osNode.managementIp(), tpPort(ovsdbPortNum));
} catch (Exception e) {
log.error("Failed to connect to the openstackNode via ovsdb protocol because of exception {}",
e.toString());
diff --git a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/OsgiPropertyConstants.java b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/OsgiPropertyConstants.java
new file mode 100644
index 0000000..9f22f27
--- /dev/null
+++ b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/OsgiPropertyConstants.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * 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.
+ */
+
+package org.onosproject.openstacknode.impl;
+
+/**
+ * Name/Value constants for properties.
+ */
+public final class OsgiPropertyConstants {
+ private OsgiPropertyConstants() {
+ }
+
+ static final String OVSDB_PORT = "ovsdbPortNum";
+ static final int OVSDB_PORT_NUM_DEFAULT = 6640;
+
+ static final String AUTO_RECOVERY = "autoRecovery";
+ static final boolean AUTO_RECOVERY_DEFAULT = true;
+}
diff --git a/apps/openstacktelemetry/api/src/main/java/org/onosproject/openstacktelemetry/api/Constants.java b/apps/openstacktelemetry/api/src/main/java/org/onosproject/openstacktelemetry/api/Constants.java
index 11b2774..44894db 100644
--- a/apps/openstacktelemetry/api/src/main/java/org/onosproject/openstacktelemetry/api/Constants.java
+++ b/apps/openstacktelemetry/api/src/main/java/org/onosproject/openstacktelemetry/api/Constants.java
@@ -27,48 +27,8 @@
private static final String DEFAULT_SERVER_IP = "localhost";
- // default configuration variables for gRPC
- public static final String DEFAULT_GRPC_SERVER_IP = DEFAULT_SERVER_IP;
- public static final int DEFAULT_GRPC_SERVER_PORT = 50051;
- public static final boolean DEFAULT_GRPC_USE_PLAINTEXT = true;
- public static final int DEFAULT_GRPC_MAX_INBOUND_MSG_SIZE = 4 * 1024 * 1024;
-
// default configuration variables for InfluxDB
- public static final String DEFAULT_INFLUXDB_SERVER_IP = DEFAULT_SERVER_IP;
- public static final int DEFAULT_INFLUXDB_SERVER_PORT = 8086;
- public static final String DEFAULT_INFLUXDB_USERNAME = "onos";
- public static final String DEFAULT_INFLUXDB_PASSWORD = "onos";
- public static final String DEFAULT_INFLUXDB_DATABASE = "onos";
public static final String DEFAULT_INFLUXDB_MEASUREMENT = "sonaflow";
- public static final boolean DEFAULT_INFLUXDB_ENABLE_BATCH = true;
-
- // default configuration variables for Promethetus exporter
- public static final String DEFAULT_PROMETHEUS_EXPORTER_IP = "0.0.0.0";
- public static final int DEFAULT_PROMETHEUS_EXPORTER_PORT = 9501;
-
- // default configuration variables for Kafka
- public static final String DEFAULT_KAFKA_SERVER_IP = DEFAULT_SERVER_IP;
- public static final int DEFAULT_KAFKA_SERVER_PORT = 9092;
- public static final int DEFAULT_KAFKA_RETRIES = 0;
- public static final String DEFAULT_KAFKA_REQUIRED_ACKS = "all";
- public static final int DEFAULT_KAFKA_BATCH_SIZE = 16384;
- public static final int DEFAULT_KAFKA_LINGER_MS = 1;
- public static final int DEFAULT_KAFKA_MEMORY_BUFFER = 33554432;
- public static final String DEFAULT_KAFKA_KEY_SERIALIZER =
- "org.apache.kafka.common.serialization.StringSerializer";
- public static final String DEFAULT_KAFKA_VALUE_SERIALIZER =
- "org.apache.kafka.common.serialization.ByteArraySerializer";
-
- // default configuration variables for REST API
- public static final String DEFAULT_REST_SERVER_IP = DEFAULT_SERVER_IP;
- public static final int DEFAULT_REST_SERVER_PORT = 80;
- public static final String DEFAULT_REST_ENDPOINT = "telemetry";
- public static final String DEFAULT_REST_METHOD = "POST";
- public static final String DEFAULT_REST_REQUEST_MEDIA_TYPE = "application/json";
- public static final String DEFAULT_REST_RESPONSE_MEDIA_TYPE = "application/json";
-
- public static final boolean DEFAULT_DISABLE = false;
- public static final boolean DEFAULT_ENABLE = true;
public static final String VXLAN = "VXLAN";
public static final String VLAN = "VLAN";
diff --git a/apps/openstacktelemetry/app/src/main/java/org/onosproject/openstacktelemetry/impl/GrpcTelemetryConfigManager.java b/apps/openstacktelemetry/app/src/main/java/org/onosproject/openstacktelemetry/impl/GrpcTelemetryConfigManager.java
index 97ddcb1..70b1d70 100644
--- a/apps/openstacktelemetry/app/src/main/java/org/onosproject/openstacktelemetry/impl/GrpcTelemetryConfigManager.java
+++ b/apps/openstacktelemetry/app/src/main/java/org/onosproject/openstacktelemetry/impl/GrpcTelemetryConfigManager.java
@@ -35,53 +35,57 @@
import static org.onlab.util.Tools.get;
import static org.onlab.util.Tools.getIntegerProperty;
-import static org.onosproject.openstacktelemetry.api.Constants.DEFAULT_DISABLE;
-import static org.onosproject.openstacktelemetry.api.Constants.DEFAULT_GRPC_MAX_INBOUND_MSG_SIZE;
-import static org.onosproject.openstacktelemetry.api.Constants.DEFAULT_GRPC_SERVER_IP;
-import static org.onosproject.openstacktelemetry.api.Constants.DEFAULT_GRPC_SERVER_PORT;
-import static org.onosproject.openstacktelemetry.api.Constants.DEFAULT_GRPC_USE_PLAINTEXT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.GRPC_ENABLE_SERVICE_DEFAULT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.GRPC_MAX_INBOUND_MSG_SIZE_DEFAULT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.GRPC_SERVER_ADDRESS_DEFAULT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.GRPC_SERVER_PORT_DEFAULT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.GRPC_USE_PLAINTEXT_DEFAULT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_GRPC_ENABLE_SERVICE;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_GRPC_MAX_INBOUND_MSG_SIZE;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_GRPC_SERVER_ADDRESS;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_GRPC_SERVER_PORT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_GRPC_USE_PLAINTEXT;
import static org.onosproject.openstacktelemetry.util.OpenstackTelemetryUtil.getBooleanProperty;
import static org.onosproject.openstacktelemetry.util.OpenstackTelemetryUtil.initTelemetryService;
/**
* gRPC server configuration manager for publishing openstack telemetry.
*/
-@Component(immediate = true, service = GrpcTelemetryConfigService.class)
+@Component(
+ immediate = true,
+ service = GrpcTelemetryConfigService.class,
+ property = {
+ PROP_GRPC_ENABLE_SERVICE + ":Boolean=" + GRPC_ENABLE_SERVICE_DEFAULT,
+ PROP_GRPC_SERVER_ADDRESS + "=" + GRPC_SERVER_ADDRESS_DEFAULT,
+ PROP_GRPC_SERVER_PORT + ":Integer=" + GRPC_SERVER_PORT_DEFAULT,
+ PROP_GRPC_USE_PLAINTEXT + ":Boolean=" + GRPC_USE_PLAINTEXT_DEFAULT,
+ PROP_GRPC_MAX_INBOUND_MSG_SIZE + ":Integer=" + GRPC_MAX_INBOUND_MSG_SIZE_DEFAULT
+ }
+)
public class GrpcTelemetryConfigManager implements GrpcTelemetryConfigService {
private final Logger log = LoggerFactory.getLogger(getClass());
- private static final String ENABLE_SERVICE = "enableService";
- private static final String ADDRESS = "address";
- private static final String PORT = "port";
- private static final String USE_PLAINTEXT = "usePlaintext";
- private static final String MAX_INBOUND_MSG_SIZE = "maxInboundMsgSize";
-
@Reference(cardinality = ReferenceCardinality.MANDATORY)
protected ComponentConfigService componentConfigService;
@Reference(cardinality = ReferenceCardinality.MANDATORY)
protected GrpcTelemetryAdminService grpcTelemetryAdminService;
- //@Property(name = ADDRESS, value = DEFAULT_GRPC_SERVER_IP,
- // label = "Default IP address to establish initial connection to gRPC server")
- protected String address = DEFAULT_GRPC_SERVER_IP;
+ /** Default IP address to establish initial connection to gRPC server. */
+ protected String address = GRPC_SERVER_ADDRESS_DEFAULT;
- //@Property(name = PORT, intValue = DEFAULT_GRPC_SERVER_PORT,
- // label = "Default port number to establish initial connection to gRPC server")
- protected Integer port = DEFAULT_GRPC_SERVER_PORT;
+ /** Default port number to establish initial connection to gRPC server. */
+ protected Integer port = GRPC_SERVER_PORT_DEFAULT;
- //@Property(name = USE_PLAINTEXT, boolValue = DEFAULT_GRPC_USE_PLAINTEXT,
- // label = "UsePlaintext flag value used for connecting to gRPC server")
- protected Boolean usePlaintext = DEFAULT_GRPC_USE_PLAINTEXT;
+ /** UsePlaintext flag value used for connecting to gRPC server. */
+ protected Boolean usePlaintext = GRPC_USE_PLAINTEXT_DEFAULT;
- //@Property(name = MAX_INBOUND_MSG_SIZE, intValue = DEFAULT_GRPC_MAX_INBOUND_MSG_SIZE,
- // label = "Maximum inbound message size used for communicating with gRPC server")
- protected Integer maxInboundMsgSize = DEFAULT_GRPC_MAX_INBOUND_MSG_SIZE;
+ /** Maximum inbound message size used for communicating with gRPC server. */
+ protected Integer maxInboundMsgSize = GRPC_MAX_INBOUND_MSG_SIZE_DEFAULT;
- //@Property(name = ENABLE_SERVICE, boolValue = DEFAULT_DISABLE,
- // label = "Specify the default behavior of telemetry service")
- protected Boolean enableService = DEFAULT_DISABLE;
+ /** Specify the default behavior of telemetry service. */
+ protected Boolean enableService = GRPC_ENABLE_SERVICE_DEFAULT;
@Activate
protected void activate(ComponentContext context) {
@@ -128,13 +132,13 @@
private void readComponentConfiguration(ComponentContext context) {
Dictionary<?, ?> properties = context.getProperties();
- String addressStr = get(properties, ADDRESS);
- address = addressStr != null ? addressStr : DEFAULT_GRPC_SERVER_IP;
+ String addressStr = get(properties, PROP_GRPC_SERVER_ADDRESS);
+ address = addressStr != null ? addressStr : GRPC_SERVER_ADDRESS_DEFAULT;
log.info("Configured. gRPC server address is {}", address);
- Integer portConfigured = Tools.getIntegerProperty(properties, PORT);
+ Integer portConfigured = Tools.getIntegerProperty(properties, PROP_GRPC_SERVER_PORT);
if (portConfigured == null) {
- port = DEFAULT_GRPC_SERVER_PORT;
+ port = GRPC_SERVER_PORT_DEFAULT;
log.info("gRPC server port is NOT configured, default value is {}", port);
} else {
port = portConfigured;
@@ -142,9 +146,9 @@
}
Boolean usePlaintextConfigured =
- getBooleanProperty(properties, USE_PLAINTEXT);
+ getBooleanProperty(properties, PROP_GRPC_USE_PLAINTEXT);
if (usePlaintextConfigured == null) {
- usePlaintext = DEFAULT_GRPC_USE_PLAINTEXT;
+ usePlaintext = GRPC_USE_PLAINTEXT_DEFAULT;
log.info("gRPC server use plaintext flag is NOT " +
"configured, default value is {}", usePlaintext);
} else {
@@ -153,9 +157,9 @@
}
Integer maxInboundMsgSizeConfigured =
- getIntegerProperty(properties, MAX_INBOUND_MSG_SIZE);
+ getIntegerProperty(properties, PROP_GRPC_MAX_INBOUND_MSG_SIZE);
if (maxInboundMsgSizeConfigured == null) {
- maxInboundMsgSize = DEFAULT_GRPC_MAX_INBOUND_MSG_SIZE;
+ maxInboundMsgSize = GRPC_MAX_INBOUND_MSG_SIZE_DEFAULT;
log.info("gRPC server max inbound message size is NOT " +
"configured, default value is {}", maxInboundMsgSize);
} else {
@@ -164,9 +168,9 @@
}
Boolean enableServiceConfigured =
- getBooleanProperty(properties, ENABLE_SERVICE);
+ getBooleanProperty(properties, PROP_GRPC_ENABLE_SERVICE);
if (enableServiceConfigured == null) {
- enableService = DEFAULT_DISABLE;
+ enableService = GRPC_ENABLE_SERVICE_DEFAULT;
log.info("gRPC service enable flag is NOT " +
"configured, default value is {}", enableService);
} else {
diff --git a/apps/openstacktelemetry/app/src/main/java/org/onosproject/openstacktelemetry/impl/InfluxDbTelemetryConfigManager.java b/apps/openstacktelemetry/app/src/main/java/org/onosproject/openstacktelemetry/impl/InfluxDbTelemetryConfigManager.java
index e3db947..d9107ca 100644
--- a/apps/openstacktelemetry/app/src/main/java/org/onosproject/openstacktelemetry/impl/InfluxDbTelemetryConfigManager.java
+++ b/apps/openstacktelemetry/app/src/main/java/org/onosproject/openstacktelemetry/impl/InfluxDbTelemetryConfigManager.java
@@ -33,71 +33,75 @@
import java.util.Dictionary;
-import static org.onosproject.openstacktelemetry.api.Constants.DEFAULT_DISABLE;
-import static org.onosproject.openstacktelemetry.api.Constants.DEFAULT_INFLUXDB_DATABASE;
-import static org.onosproject.openstacktelemetry.api.Constants.DEFAULT_INFLUXDB_ENABLE_BATCH;
-import static org.onosproject.openstacktelemetry.api.Constants.DEFAULT_INFLUXDB_MEASUREMENT;
-import static org.onosproject.openstacktelemetry.api.Constants.DEFAULT_INFLUXDB_PASSWORD;
-import static org.onosproject.openstacktelemetry.api.Constants.DEFAULT_INFLUXDB_SERVER_IP;
-import static org.onosproject.openstacktelemetry.api.Constants.DEFAULT_INFLUXDB_SERVER_PORT;
-import static org.onosproject.openstacktelemetry.api.Constants.DEFAULT_INFLUXDB_USERNAME;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_INFLUXDB_DATABASE;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_INFLUXDB_DATABASE_DEFAULT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_INFLUXDB_ENABLE_BATCH;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_INFLUXDB_ENABLE_BATCH_DEFAULT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_INFLUXDB_ENABLE_SERVICE;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_INFLUXDB_ENABLE_SERVICE_DEFAULT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_INFLUXDB_MEASUREMENT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_INFLUXDB_MEASUREMENT_DEFAULT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_INFLUXDB_PASSWORD;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_INFLUXDB_PASSWORD_DEFAULT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_INFLUXDB_SERVER_ADDRESS;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_INFLUXDB_SERVER_ADDRESS_DEFAULT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_INFLUXDB_SERVER_PORT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_INFLUXDB_SERVER_PORT_DEFAULT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_INFLUXDB_USERNAME;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_INFLUXDB_USERNAME_DEFAULT;
import static org.onosproject.openstacktelemetry.util.OpenstackTelemetryUtil.getBooleanProperty;
import static org.onosproject.openstacktelemetry.util.OpenstackTelemetryUtil.initTelemetryService;
/**
* InfluxDB server configuration manager for publishing openstack telemetry.
*/
-@Component(immediate = true, service = InfluxDbTelemetryConfigService.class)
+@Component(
+ immediate = true,
+ service = InfluxDbTelemetryConfigService.class,
+ property = {
+ PROP_INFLUXDB_ENABLE_SERVICE + ":Boolean=" + PROP_INFLUXDB_ENABLE_SERVICE_DEFAULT,
+ PROP_INFLUXDB_SERVER_ADDRESS + "=" + PROP_INFLUXDB_SERVER_ADDRESS_DEFAULT,
+ PROP_INFLUXDB_SERVER_PORT + ":Integer=" + PROP_INFLUXDB_SERVER_PORT_DEFAULT,
+ PROP_INFLUXDB_USERNAME + "=" + PROP_INFLUXDB_USERNAME_DEFAULT,
+ PROP_INFLUXDB_PASSWORD + "=" + PROP_INFLUXDB_PASSWORD_DEFAULT,
+ PROP_INFLUXDB_DATABASE + "=" + PROP_INFLUXDB_DATABASE_DEFAULT,
+ PROP_INFLUXDB_MEASUREMENT + "=" + PROP_INFLUXDB_MEASUREMENT_DEFAULT,
+ PROP_INFLUXDB_ENABLE_BATCH + ":Boolean=" + PROP_INFLUXDB_ENABLE_BATCH_DEFAULT
+ }
+)
public class InfluxDbTelemetryConfigManager implements InfluxDbTelemetryConfigService {
private final Logger log = LoggerFactory.getLogger(getClass());
- private static final String ENABLE_SERVICE = "enableService";
- private static final String ADDRESS = "address";
- private static final String PORT = "port";
- private static final String USERNAME = "username";
- private static final String PASSWORD = "password";
- private static final String DATABASE = "database";
- private static final String MEASUREMENT = "measurement";
- private static final String ENABLE_BATCH = "enableBatch";
-
@Reference(cardinality = ReferenceCardinality.MANDATORY)
protected ComponentConfigService componentConfigService;
@Reference(cardinality = ReferenceCardinality.MANDATORY)
protected InfluxDbTelemetryAdminService influxDbTelemetryAdminService;
- //@Property(name = ADDRESS, value = DEFAULT_INFLUXDB_SERVER_IP,
- // label = "Default IP address to establish initial connection to InfluxDB server")
- protected String address = DEFAULT_INFLUXDB_SERVER_IP;
+ /** Default IP address to establish initial connection to InfluxDB server. */
+ protected String address = PROP_INFLUXDB_SERVER_ADDRESS_DEFAULT;
- //@Property(name = PORT, intValue = DEFAULT_INFLUXDB_SERVER_PORT,
- // label = "Default port number to establish initial connection to InfluxDB server")
- protected Integer port = DEFAULT_INFLUXDB_SERVER_PORT;
+ /** Default port number to establish initial connection to InfluxDB server. */
+ protected Integer port = PROP_INFLUXDB_SERVER_PORT_DEFAULT;
- //@Property(name = USERNAME, value = DEFAULT_INFLUXDB_USERNAME,
- // label = "Username used for authenticating against InfluxDB server")
- protected String username = DEFAULT_INFLUXDB_USERNAME;
+ /** Username used for authenticating against InfluxDB server. */
+ protected String username = PROP_INFLUXDB_USERNAME_DEFAULT;
- //@Property(name = PASSWORD, value = DEFAULT_INFLUXDB_PASSWORD,
- // label = "Password used for authenticating against InfluxDB server")
- protected String password = DEFAULT_INFLUXDB_PASSWORD;
+ /** Password used for authenticating against InfluxDB server. */
+ protected String password = PROP_INFLUXDB_PASSWORD_DEFAULT;
- //@Property(name = DATABASE, value = DEFAULT_INFLUXDB_DATABASE,
- // label = "Database of InfluxDB server")
- protected String database = DEFAULT_INFLUXDB_DATABASE;
+ /** Database of InfluxDB server. */
+ protected String database = PROP_INFLUXDB_DATABASE_DEFAULT;
- //@Property(name = MEASUREMENT, value = DEFAULT_INFLUXDB_MEASUREMENT,
- // label = "Measurement of InfluxDB server")
- protected String measurement = DEFAULT_INFLUXDB_MEASUREMENT;
+ /** Measurement of InfluxDB server. */
+ protected String measurement = PROP_INFLUXDB_MEASUREMENT_DEFAULT;
- //@Property(name = ENABLE_BATCH, boolValue = DEFAULT_INFLUXDB_ENABLE_BATCH,
- // label = "Flag value of enabling batch mode of InfluxDB server")
- protected Boolean enableBatch = DEFAULT_INFLUXDB_ENABLE_BATCH;
+ /** Flag value of enabling batch mode of InfluxDB server. */
+ protected Boolean enableBatch = PROP_INFLUXDB_ENABLE_SERVICE_DEFAULT;
- //@Property(name = ENABLE_SERVICE, boolValue = DEFAULT_DISABLE,
- // label = "Specify the default behavior of telemetry service")
- protected Boolean enableService = DEFAULT_DISABLE;
+ /** Specify the default behavior of telemetry service. */
+ protected Boolean enableService = PROP_INFLUXDB_ENABLE_SERVICE_DEFAULT;
@Activate
protected void activate(ComponentContext context) {
@@ -147,38 +151,38 @@
private void readComponentConfiguration(ComponentContext context) {
Dictionary<?, ?> properties = context.getProperties();
- String addressStr = Tools.get(properties, ADDRESS);
- address = addressStr != null ? addressStr : DEFAULT_INFLUXDB_SERVER_IP;
+ String addressStr = Tools.get(properties, PROP_INFLUXDB_SERVER_ADDRESS);
+ address = addressStr != null ? addressStr : PROP_INFLUXDB_SERVER_ADDRESS_DEFAULT;
log.info("Configured. InfluxDB server address is {}", address);
- Integer portConfigured = Tools.getIntegerProperty(properties, PORT);
+ Integer portConfigured = Tools.getIntegerProperty(properties, PROP_INFLUXDB_SERVER_PORT);
if (portConfigured == null) {
- port = DEFAULT_INFLUXDB_SERVER_PORT;
+ port = PROP_INFLUXDB_SERVER_PORT_DEFAULT;
log.info("InfluxDB server port is NOT configured, default value is {}", port);
} else {
port = portConfigured;
log.info("Configured. InfluxDB server port is {}", port);
}
- String usernameStr = Tools.get(properties, USERNAME);
- username = usernameStr != null ? usernameStr : DEFAULT_INFLUXDB_USERNAME;
+ String usernameStr = Tools.get(properties, PROP_INFLUXDB_USERNAME);
+ username = usernameStr != null ? usernameStr : PROP_INFLUXDB_USERNAME_DEFAULT;
log.info("Configured. InfluxDB server username is {}", username);
- String passwordStr = Tools.get(properties, PASSWORD);
- password = passwordStr != null ? passwordStr : DEFAULT_INFLUXDB_PASSWORD;
+ String passwordStr = Tools.get(properties, PROP_INFLUXDB_PASSWORD);
+ password = passwordStr != null ? passwordStr : PROP_INFLUXDB_PASSWORD_DEFAULT;
log.info("Configured. InfluxDB server password is {}", password);
- String databaseStr = Tools.get(properties, DATABASE);
- database = databaseStr != null ? databaseStr : DEFAULT_INFLUXDB_DATABASE;
+ String databaseStr = Tools.get(properties, PROP_INFLUXDB_DATABASE);
+ database = databaseStr != null ? databaseStr : PROP_INFLUXDB_DATABASE_DEFAULT;
log.info("Configured. InfluxDB server database is {}", database);
- String measurementStr = Tools.get(properties, MEASUREMENT);
- measurement = measurementStr != null ? measurementStr : DEFAULT_INFLUXDB_MEASUREMENT;
+ String measurementStr = Tools.get(properties, PROP_INFLUXDB_MEASUREMENT);
+ measurement = measurementStr != null ? measurementStr : PROP_INFLUXDB_MEASUREMENT_DEFAULT;
log.info("Configured. InfluxDB server measurement is {}", measurement);
- Boolean enableBatchConfigured = getBooleanProperty(properties, ENABLE_BATCH);
+ Boolean enableBatchConfigured = getBooleanProperty(properties, PROP_INFLUXDB_ENABLE_BATCH);
if (enableBatchConfigured == null) {
- enableBatch = DEFAULT_INFLUXDB_ENABLE_BATCH;
+ enableBatch = PROP_INFLUXDB_ENABLE_BATCH_DEFAULT;
log.info("InfluxDB server enable batch flag is " +
"NOT configured, default value is {}", enableBatch);
} else {
@@ -187,9 +191,9 @@
}
Boolean enableServiceConfigured =
- getBooleanProperty(properties, ENABLE_SERVICE);
+ getBooleanProperty(properties, PROP_INFLUXDB_ENABLE_SERVICE);
if (enableServiceConfigured == null) {
- enableService = DEFAULT_DISABLE;
+ enableService = PROP_INFLUXDB_ENABLE_SERVICE_DEFAULT;
log.info("InfluxDB service enable flag is NOT " +
"configured, default value is {}", enableService);
} else {
diff --git a/apps/openstacktelemetry/app/src/main/java/org/onosproject/openstacktelemetry/impl/KafkaTelemetryConfigManager.java b/apps/openstacktelemetry/app/src/main/java/org/onosproject/openstacktelemetry/impl/KafkaTelemetryConfigManager.java
index 1212b0b..6621e0b 100644
--- a/apps/openstacktelemetry/app/src/main/java/org/onosproject/openstacktelemetry/impl/KafkaTelemetryConfigManager.java
+++ b/apps/openstacktelemetry/app/src/main/java/org/onosproject/openstacktelemetry/impl/KafkaTelemetryConfigManager.java
@@ -33,84 +33,87 @@
import java.util.Dictionary;
-import static org.onosproject.openstacktelemetry.api.Constants.DEFAULT_DISABLE;
-import static org.onosproject.openstacktelemetry.api.Constants.DEFAULT_KAFKA_BATCH_SIZE;
-import static org.onosproject.openstacktelemetry.api.Constants.DEFAULT_KAFKA_KEY_SERIALIZER;
-import static org.onosproject.openstacktelemetry.api.Constants.DEFAULT_KAFKA_LINGER_MS;
-import static org.onosproject.openstacktelemetry.api.Constants.DEFAULT_KAFKA_MEMORY_BUFFER;
-import static org.onosproject.openstacktelemetry.api.Constants.DEFAULT_KAFKA_REQUIRED_ACKS;
-import static org.onosproject.openstacktelemetry.api.Constants.DEFAULT_KAFKA_RETRIES;
-import static org.onosproject.openstacktelemetry.api.Constants.DEFAULT_KAFKA_SERVER_IP;
-import static org.onosproject.openstacktelemetry.api.Constants.DEFAULT_KAFKA_SERVER_PORT;
-import static org.onosproject.openstacktelemetry.api.Constants.DEFAULT_KAFKA_VALUE_SERIALIZER;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_KAFKA_ADDRESS;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_KAFKA_ADDRESS_DEFAULT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_KAFKA_BATCH_SIZE;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_KAFKA_BATCH_SIZE_DEFAULT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_KAFKA_ENABLE_SERVICE;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_KAFKA_ENABLE_SERVICE_DEFAULT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_KAFKA_KEY_SERIALIZER;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_KAFKA_KEY_SERIALIZER_DEFAULT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_KAFKA_LINGER_MS;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_KAFKA_LINGER_MS_DEFAULT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_KAFKA_MEMORY_BUFFER;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_KAFKA_MEMORY_BUFFER_DEFAULT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_KAFKA_PORT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_KAFKA_PORT_DEFAULT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_KAFKA_REQUIRED_ACKS;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_KAFKA_REQUIRED_ACKS_DEFAULT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_KAFKA_RETRIES;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_KAFKA_RETRIES_DEFAULT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_KAFKA_VALUE_SERIALIZER;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_KAFKA_VALUE_SERIALIZER_DEFAULT;
import static org.onosproject.openstacktelemetry.util.OpenstackTelemetryUtil.getBooleanProperty;
import static org.onosproject.openstacktelemetry.util.OpenstackTelemetryUtil.initTelemetryService;
/**
* Kafka server configuration manager for publishing openstack telemetry.
*/
-@Component(immediate = true, service = KafkaTelemetryConfigService.class)
+@Component(
+ immediate = true,
+ service = KafkaTelemetryConfigService.class,
+ property = {
+ PROP_KAFKA_ADDRESS + "=" + PROP_KAFKA_ADDRESS_DEFAULT,
+ PROP_KAFKA_PORT + ":Integer=" + PROP_KAFKA_PORT_DEFAULT,
+ PROP_KAFKA_RETRIES + ":Integer=" + PROP_KAFKA_RETRIES_DEFAULT,
+ PROP_KAFKA_REQUIRED_ACKS + "=" + PROP_KAFKA_REQUIRED_ACKS_DEFAULT,
+ PROP_KAFKA_BATCH_SIZE + ":Integer=" + PROP_KAFKA_BATCH_SIZE_DEFAULT,
+ PROP_KAFKA_LINGER_MS + ":Integer=" + PROP_KAFKA_LINGER_MS_DEFAULT,
+ PROP_KAFKA_MEMORY_BUFFER + ":Integer=" + PROP_KAFKA_MEMORY_BUFFER_DEFAULT,
+ PROP_KAFKA_KEY_SERIALIZER + "=" + PROP_KAFKA_KEY_SERIALIZER_DEFAULT,
+ PROP_KAFKA_VALUE_SERIALIZER + "=" + PROP_KAFKA_VALUE_SERIALIZER_DEFAULT,
+ PROP_KAFKA_ENABLE_SERVICE + ":Boolean=" + PROP_KAFKA_ENABLE_SERVICE_DEFAULT
+ }
+)
public class KafkaTelemetryConfigManager implements KafkaTelemetryConfigService {
private final Logger log = LoggerFactory.getLogger(getClass());
- private static final String ENABLE_SERVICE = "enableService";
- private static final String ADDRESS = "address";
- private static final String PORT = "port";
- private static final String RETRIES = "retries";
- private static final String REQUIRED_ACKS = "requiredAcks";
- private static final String BATCH_SIZE = "batchSize";
- private static final String LINGER_MS = "lingerMs";
- private static final String MEMORY_BUFFER = "memoryBuffer";
- private static final String KEY_SERIALIZER = "keySerializer";
- private static final String VALUE_SERIALIZER = "valueSerializer";
-
@Reference(cardinality = ReferenceCardinality.MANDATORY)
protected ComponentConfigService componentConfigService;
@Reference(cardinality = ReferenceCardinality.MANDATORY)
protected KafkaTelemetryAdminService kafkaTelemetryAdminService;
- //@Property(name = ADDRESS, value = DEFAULT_KAFKA_SERVER_IP,
- // label = "Default IP address to establish initial connection to Kafka server")
- protected String address = DEFAULT_KAFKA_SERVER_IP;
+ /** Default IP address to establish initial connection to Kafka server. */
+ protected String address = PROP_KAFKA_ADDRESS_DEFAULT;
- //@Property(name = PORT, intValue = DEFAULT_KAFKA_SERVER_PORT,
- // label = "Default port number to establish initial connection to Kafka server")
- protected Integer port = DEFAULT_KAFKA_SERVER_PORT;
+ /** Default port number to establish initial connection to Kafka server. */
+ protected Integer port = PROP_KAFKA_PORT_DEFAULT;
- //@Property(name = RETRIES, intValue = DEFAULT_KAFKA_RETRIES,
- // label = "Number of times the producer can retry to send after first failure")
- protected int retries = DEFAULT_KAFKA_RETRIES;
+ /** Number of times the producer can retry to send after first failure. */
+ protected int retries = PROP_KAFKA_RETRIES_DEFAULT;
- //@Property(name = REQUIRED_ACKS, value = DEFAULT_KAFKA_REQUIRED_ACKS,
- // label = "Producer will get an acknowledgement after the leader has replicated the data")
- protected String requiredAcks = DEFAULT_KAFKA_REQUIRED_ACKS;
+ /** Producer will get an acknowledgement after the leader has replicated the data. */
+ protected String requiredAcks = PROP_KAFKA_REQUIRED_ACKS_DEFAULT;
- //@Property(name = BATCH_SIZE, intValue = DEFAULT_KAFKA_BATCH_SIZE,
- // label = "The largest record batch size allowed by Kafka")
- protected Integer batchSize = DEFAULT_KAFKA_BATCH_SIZE;
+ /** The largest record batch size allowed by Kafka. */
+ protected Integer batchSize = PROP_KAFKA_BATCH_SIZE_DEFAULT;
- //@Property(name = LINGER_MS, intValue = DEFAULT_KAFKA_LINGER_MS,
- // label = "The producer groups together any records that arrive in " +
- // "between request transmissions into a single batched request")
- protected Integer lingerMs = DEFAULT_KAFKA_LINGER_MS;
+ /** The producer groups together any records that arrive between request transmissions into a single batch. */
+ protected Integer lingerMs = PROP_KAFKA_LINGER_MS_DEFAULT;
- //@Property(name = MEMORY_BUFFER, intValue = DEFAULT_KAFKA_MEMORY_BUFFER,
- // label = "The total memory used for log cleaner I/O buffers across all cleaner threads")
- protected Integer memoryBuffer = DEFAULT_KAFKA_MEMORY_BUFFER;
+ /** The total memory used for log cleaner I/O buffers across all cleaner threads. */
+ protected Integer memoryBuffer = PROP_KAFKA_MEMORY_BUFFER_DEFAULT;
- //@Property(name = KEY_SERIALIZER, value = DEFAULT_KAFKA_KEY_SERIALIZER,
- // label = "Serializer class for key that implements the Serializer interface")
- protected String keySerializer = DEFAULT_KAFKA_KEY_SERIALIZER;
+ /** Serializer class for key that implements the Serializer interface. */
+ protected String keySerializer = PROP_KAFKA_KEY_SERIALIZER_DEFAULT;
- //@Property(name = VALUE_SERIALIZER, value = DEFAULT_KAFKA_VALUE_SERIALIZER,
- // label = "Serializer class for value that implements the Serializer interface")
- protected String valueSerializer = DEFAULT_KAFKA_VALUE_SERIALIZER;
+ /** Serializer class for value that implements the Serializer interface. */
+ protected String valueSerializer = PROP_KAFKA_VALUE_SERIALIZER_DEFAULT;
- //@Property(name = ENABLE_SERVICE, boolValue = DEFAULT_DISABLE,
- // label = "Specify the default behavior of telemetry service")
- protected Boolean enableService = DEFAULT_DISABLE;
+ /** Specify the default behavior of telemetry service. */
+ protected Boolean enableService = PROP_KAFKA_ENABLE_SERVICE_DEFAULT;
@Activate
protected void activate(ComponentContext context) {
@@ -162,71 +165,71 @@
private void readComponentConfiguration(ComponentContext context) {
Dictionary<?, ?> properties = context.getProperties();
- String addressStr = Tools.get(properties, ADDRESS);
- address = addressStr != null ? addressStr : DEFAULT_KAFKA_SERVER_IP;
+ String addressStr = Tools.get(properties, PROP_KAFKA_ADDRESS);
+ address = addressStr != null ? addressStr : PROP_KAFKA_ADDRESS_DEFAULT;
log.info("Configured. Kafka server address is {}", address);
- Integer portConfigured = Tools.getIntegerProperty(properties, PORT);
+ Integer portConfigured = Tools.getIntegerProperty(properties, PROP_KAFKA_PORT);
if (portConfigured == null) {
- port = DEFAULT_KAFKA_SERVER_PORT;
+ port = PROP_KAFKA_PORT_DEFAULT;
log.info("Kafka server port is NOT configured, default value is {}", port);
} else {
port = portConfigured;
log.info("Configured. Kafka server port is {}", port);
}
- Integer retriesConfigured = Tools.getIntegerProperty(properties, RETRIES);
+ Integer retriesConfigured = Tools.getIntegerProperty(properties, PROP_KAFKA_RETRIES);
if (retriesConfigured == null) {
- retries = DEFAULT_KAFKA_RETRIES;
+ retries = PROP_KAFKA_RETRIES_DEFAULT;
log.info("Kafka number of retries property is NOT configured, default value is {}", retries);
} else {
retries = retriesConfigured;
log.info("Configured. Kafka number of retries is {}", retries);
}
- String requiredAcksStr = Tools.get(properties, REQUIRED_ACKS);
- requiredAcks = requiredAcksStr != null ? requiredAcksStr : DEFAULT_KAFKA_REQUIRED_ACKS;
+ String requiredAcksStr = Tools.get(properties, PROP_KAFKA_REQUIRED_ACKS);
+ requiredAcks = requiredAcksStr != null ? requiredAcksStr : PROP_KAFKA_REQUIRED_ACKS_DEFAULT;
log.info("Configured, Kafka required acknowledgement is {}", requiredAcks);
- Integer batchSizeConfigured = Tools.getIntegerProperty(properties, BATCH_SIZE);
+ Integer batchSizeConfigured = Tools.getIntegerProperty(properties, PROP_KAFKA_BATCH_SIZE);
if (batchSizeConfigured == null) {
- batchSize = DEFAULT_KAFKA_BATCH_SIZE;
+ batchSize = PROP_KAFKA_BATCH_SIZE_DEFAULT;
log.info("Kafka batch size property is NOT configured, default value is {}", batchSize);
} else {
batchSize = batchSizeConfigured;
log.info("Configured. Kafka batch size is {}", batchSize);
}
- Integer lingerMsConfigured = Tools.getIntegerProperty(properties, LINGER_MS);
+ Integer lingerMsConfigured = Tools.getIntegerProperty(properties, PROP_KAFKA_LINGER_MS);
if (lingerMsConfigured == null) {
- lingerMs = DEFAULT_KAFKA_LINGER_MS;
+ lingerMs = PROP_KAFKA_LINGER_MS_DEFAULT;
log.info("Kafka lingerMs property is NOT configured, default value is {}", lingerMs);
} else {
lingerMs = lingerMsConfigured;
log.info("Configured. Kafka lingerMs is {}", lingerMs);
}
- Integer memoryBufferConfigured = Tools.getIntegerProperty(properties, MEMORY_BUFFER);
+ Integer memoryBufferConfigured = Tools.getIntegerProperty(properties, PROP_KAFKA_MEMORY_BUFFER);
if (memoryBufferConfigured == null) {
- memoryBuffer = DEFAULT_KAFKA_MEMORY_BUFFER;
+ memoryBuffer = PROP_KAFKA_MEMORY_BUFFER_DEFAULT;
log.info("Kafka memory buffer property is NOT configured, default value is {}", memoryBuffer);
} else {
memoryBuffer = memoryBufferConfigured;
log.info("Configured. Kafka memory buffer is {}", memoryBuffer);
}
- String keySerializerStr = Tools.get(properties, KEY_SERIALIZER);
- keySerializer = keySerializerStr != null ? keySerializerStr : DEFAULT_KAFKA_KEY_SERIALIZER;
+ String keySerializerStr = Tools.get(properties, PROP_KAFKA_KEY_SERIALIZER);
+ keySerializer = keySerializerStr != null ? keySerializerStr : PROP_KAFKA_KEY_SERIALIZER_DEFAULT;
log.info("Configured, Kafka key serializer is {}", keySerializer);
- String valueSerializerStr = Tools.get(properties, VALUE_SERIALIZER);
- valueSerializer = valueSerializerStr != null ? valueSerializerStr : DEFAULT_KAFKA_VALUE_SERIALIZER;
+ String valueSerializerStr = Tools.get(properties, PROP_KAFKA_VALUE_SERIALIZER);
+ valueSerializer = valueSerializerStr != null ? valueSerializerStr : PROP_KAFKA_VALUE_SERIALIZER_DEFAULT;
log.info("Configured, Kafka value serializer is {}", valueSerializer);
Boolean enableServiceConfigured =
- getBooleanProperty(properties, ENABLE_SERVICE);
+ getBooleanProperty(properties, PROP_KAFKA_ENABLE_SERVICE);
if (enableServiceConfigured == null) {
- enableService = DEFAULT_DISABLE;
+ enableService = PROP_KAFKA_ENABLE_SERVICE_DEFAULT;
log.info("Kafka service enable flag is NOT " +
"configured, default value is {}", enableService);
} else {
diff --git a/apps/openstacktelemetry/app/src/main/java/org/onosproject/openstacktelemetry/impl/OsgiPropertyConstants.java b/apps/openstacktelemetry/app/src/main/java/org/onosproject/openstacktelemetry/impl/OsgiPropertyConstants.java
new file mode 100644
index 0000000..7be6973
--- /dev/null
+++ b/apps/openstacktelemetry/app/src/main/java/org/onosproject/openstacktelemetry/impl/OsgiPropertyConstants.java
@@ -0,0 +1,151 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * 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.
+ */
+
+package org.onosproject.openstacktelemetry.impl;
+
+/**
+ * Name/Value constants for properties.
+ */
+public final class OsgiPropertyConstants {
+ private OsgiPropertyConstants() {
+ }
+
+ // REST telemetry
+
+ static final String PROP_REST_ENABLE_SERVICE = "enableService";
+ static final boolean PROP_REST_ENABLE_SERVICE_DEFAULT = false;
+
+ static final String PROP_REST_SERVER_ADDRESS = "address";
+ static final String PROP_REST_SERVER_ADDRESS_DEFAULT = "localhost";
+
+ static final String PROP_REST_SERVER_PORT = "port";
+ static final int PROP_REST_SERVER_PORT_DEFAULT = 80;
+
+ static final String PROP_REST_ENDPOINT = "endpoint";
+ static final String PROP_REST_ENDPOINT_DEFAULT = "telemetry";
+
+ static final String PROP_REST_METHOD = "method";
+ static final String PROP_REST_METHOD_DEFAULT = "POST";
+
+ static final String PROP_REST_REQUEST_MEDIA_TYPE = "requestMediaType";
+ static final String PROP_REST_REQUEST_MEDIA_TYPE_DEFAULT = "application/json";
+
+ static final String PROP_REST_RESPONSE_MEDIA_TYPE = "responseMediaType";
+ static final String PROP_REST_RESPONSE_MEDIA_TYPE_DEFAULT = "application/json";
+
+ // Kafka telemetry
+
+ static final String PROP_KAFKA_ENABLE_SERVICE = "enableService";
+ static final boolean PROP_KAFKA_ENABLE_SERVICE_DEFAULT = false;
+
+ static final String PROP_KAFKA_ADDRESS = "address";
+ static final String PROP_KAFKA_ADDRESS_DEFAULT = "localhost";
+
+ static final String PROP_KAFKA_PORT = "port";
+ static final int PROP_KAFKA_PORT_DEFAULT = 9092;
+
+ static final String PROP_KAFKA_RETRIES = "retries";
+ static final int PROP_KAFKA_RETRIES_DEFAULT = 0;
+
+ static final String PROP_KAFKA_REQUIRED_ACKS = "requiredAcks";
+ static final String PROP_KAFKA_REQUIRED_ACKS_DEFAULT = "all";
+
+ static final String PROP_KAFKA_BATCH_SIZE = "batchSize";
+ static final int PROP_KAFKA_BATCH_SIZE_DEFAULT = 16384;
+
+ static final String PROP_KAFKA_LINGER_MS = "lingerMs";
+ static final int PROP_KAFKA_LINGER_MS_DEFAULT = 1;
+
+ static final String PROP_KAFKA_MEMORY_BUFFER = "memoryBuffer";
+ static final int PROP_KAFKA_MEMORY_BUFFER_DEFAULT = 33554432;
+
+ static final String PROP_KAFKA_KEY_SERIALIZER = "keySerializer";
+ static final String PROP_KAFKA_KEY_SERIALIZER_DEFAULT =
+ "org.apache.kafka.common.serialization.StringSerializer";
+
+ static final String PROP_KAFKA_VALUE_SERIALIZER = "valueSerializer";
+ static final String PROP_KAFKA_VALUE_SERIALIZER_DEFAULT =
+ "org.apache.kafka.common.serialization.ByteArraySerializer";
+
+ // Stats flow rule manager
+
+ static final String PROP_REVERSE_PATH_STATS = "reversePathStats";
+ static final boolean PROP_REVERSE_PATH_STATS_DEFAULT = false;
+
+ static final String PROP_EGRESS_STATS = "egressStats";
+ static final boolean PROP_EGRESS_STATS_DEFAULT = false;
+
+ static final String PROP_PORT_STATS = "portStats";
+ static final boolean PROP_PORT_STATS_DEFAULT = true;
+
+ static final String PROP_MONITOR_OVERLAY = "monitorOverlay";
+ static final boolean PROP_MONITOR_OVERLAY_DEFAULT = true;
+
+ static final String PROP_MONITOR_UNDERLAY = "monitorUnderlay";
+ static final boolean PROP_MONITOR_UNDERLAY_DEFAULT = true;
+
+ // Influx DB Telemetry config manager
+
+ static final String PROP_INFLUXDB_ENABLE_SERVICE = "enableService";
+ static final boolean PROP_INFLUXDB_ENABLE_SERVICE_DEFAULT = false;
+
+ static final String PROP_INFLUXDB_SERVER_ADDRESS = "address";
+ static final String PROP_INFLUXDB_SERVER_ADDRESS_DEFAULT = "localhost";
+
+ static final String PROP_INFLUXDB_SERVER_PORT = "port";
+ static final int PROP_INFLUXDB_SERVER_PORT_DEFAULT = 8086;
+
+ static final String PROP_INFLUXDB_USERNAME = "username";
+ static final String PROP_INFLUXDB_USERNAME_DEFAULT = "onos";
+
+ static final String PROP_INFLUXDB_PASSWORD = "password";
+ static final String PROP_INFLUXDB_PASSWORD_DEFAULT = "onos";
+
+ static final String PROP_INFLUXDB_DATABASE = "database";
+ static final String PROP_INFLUXDB_DATABASE_DEFAULT = "onos";
+
+ static final String PROP_INFLUXDB_MEASUREMENT = "measurement";
+ static final String PROP_INFLUXDB_MEASUREMENT_DEFAULT = "sonaflow";
+
+ static final String PROP_INFLUXDB_ENABLE_BATCH = "enableBatch";
+ static final boolean PROP_INFLUXDB_ENABLE_BATCH_DEFAULT = true;
+
+ // GRPC Telemetry config manager
+ static final String PROP_GRPC_ENABLE_SERVICE = "enableService";
+ static final boolean GRPC_ENABLE_SERVICE_DEFAULT = false;
+
+ static final String PROP_GRPC_SERVER_ADDRESS = "address";
+ static final String GRPC_SERVER_ADDRESS_DEFAULT = "localhost";
+
+ static final String PROP_GRPC_SERVER_PORT = "port";
+ static final int GRPC_SERVER_PORT_DEFAULT = 50051;
+
+ static final String PROP_GRPC_USE_PLAINTEXT = "usePlaintext";
+ static final boolean GRPC_USE_PLAINTEXT_DEFAULT = true;
+
+ static final String PROP_GRPC_MAX_INBOUND_MSG_SIZE = "maxInboundMsgSize";
+ static final int GRPC_MAX_INBOUND_MSG_SIZE_DEFAULT = 4194304; //4 * 1024 * 1024;
+
+ // Prometheus Telemetry config manager
+ static final String PROP_PROMETHEUS_ENABLE_SERVICE = "enableService";
+ static final boolean PROMETHEUS_ENABLE_SERVICE_DEFAULT = false;
+
+ static final String PROP_PROMETHEUS_EXPORTER_ADDRESS = "address";
+ public static final String PROMETHEUS_EXPORTER_ADDRESS_DEFAULT = "localhost";
+
+ static final String PROP_PROMETHEUS_EXPORTER_PORT = "port";
+ public static final int PROMETHEUS_EXPORTER_PORT_DEFAULT = 50051;
+}
diff --git a/apps/openstacktelemetry/app/src/main/java/org/onosproject/openstacktelemetry/impl/PrometheusTelemetryConfigManager.java b/apps/openstacktelemetry/app/src/main/java/org/onosproject/openstacktelemetry/impl/PrometheusTelemetryConfigManager.java
index 49a9547..4405b97 100644
--- a/apps/openstacktelemetry/app/src/main/java/org/onosproject/openstacktelemetry/impl/PrometheusTelemetryConfigManager.java
+++ b/apps/openstacktelemetry/app/src/main/java/org/onosproject/openstacktelemetry/impl/PrometheusTelemetryConfigManager.java
@@ -14,12 +14,7 @@
* limitations under the License.
*/
package org.onosproject.openstacktelemetry.impl;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Modified;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
+
import org.onlab.util.Tools;
import org.onosproject.cfg.ComponentConfigService;
import org.onosproject.openstacktelemetry.api.PrometheusTelemetryAdminService;
@@ -27,47 +22,56 @@
import org.onosproject.openstacktelemetry.api.config.TelemetryConfig;
import org.onosproject.openstacktelemetry.config.DefaultPrometheusTelemetryConfig;
import org.osgi.service.component.ComponentContext;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.service.component.annotations.Modified;
+import org.osgi.service.component.annotations.Reference;
+import org.osgi.service.component.annotations.ReferenceCardinality;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Dictionary;
-import static org.onosproject.openstacktelemetry.api.Constants.DEFAULT_DISABLE;
-import static org.onosproject.openstacktelemetry.api.Constants.DEFAULT_ENABLE;
-import static org.onosproject.openstacktelemetry.api.Constants.DEFAULT_PROMETHEUS_EXPORTER_IP;
-import static org.onosproject.openstacktelemetry.api.Constants.DEFAULT_PROMETHEUS_EXPORTER_PORT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROMETHEUS_ENABLE_SERVICE_DEFAULT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROMETHEUS_EXPORTER_ADDRESS_DEFAULT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROMETHEUS_EXPORTER_PORT_DEFAULT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_PROMETHEUS_ENABLE_SERVICE;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_PROMETHEUS_EXPORTER_ADDRESS;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_PROMETHEUS_EXPORTER_PORT;
import static org.onosproject.openstacktelemetry.util.OpenstackTelemetryUtil.getBooleanProperty;
import static org.onosproject.openstacktelemetry.util.OpenstackTelemetryUtil.initTelemetryService;
/**
* Prometheus exporter configuration manager for publishing openstack telemetry.
*/
-@Component(immediate = true, service = PrometheusTelemetryConfigService.class)
+@Component(
+ immediate = true,
+ service = PrometheusTelemetryConfigService.class,
+ property = {
+ PROP_PROMETHEUS_ENABLE_SERVICE + ":Boolean=" + PROMETHEUS_ENABLE_SERVICE_DEFAULT,
+ PROP_PROMETHEUS_EXPORTER_ADDRESS + "=" + PROMETHEUS_EXPORTER_ADDRESS_DEFAULT,
+ PROP_PROMETHEUS_EXPORTER_PORT + ":Integer=" + PROMETHEUS_EXPORTER_PORT_DEFAULT
+ }
+)
public class PrometheusTelemetryConfigManager implements PrometheusTelemetryConfigService {
private final Logger log = LoggerFactory.getLogger(getClass());
- private static final String ENABLE_SERVICE = "enableService";
- private static final String ADDRESS = "address";
- private static final String PORT = "port";
-
@Reference(cardinality = ReferenceCardinality.MANDATORY)
protected ComponentConfigService componentConfigService;
@Reference(cardinality = ReferenceCardinality.MANDATORY)
protected PrometheusTelemetryAdminService prometheusTelemetryAdminService;
- //@Property(name = ADDRESS, value = DEFAULT_PROMETHEUS_EXPORTER_IP,
- // label = "Default IP address of prometheus exporter")
- protected String address = DEFAULT_PROMETHEUS_EXPORTER_IP;
+ /** Default IP address of prometheus exporter. */
+ protected String address = PROMETHEUS_EXPORTER_ADDRESS_DEFAULT;
- //@Property(name = PORT, intValue = DEFAULT_PROMETHEUS_EXPORTER_PORT,
- // label = "Default port number of prometheus exporter")
- protected Integer port = DEFAULT_PROMETHEUS_EXPORTER_PORT;
+ /** Default port number of prometheus exporter. */
+ protected Integer port = PROMETHEUS_EXPORTER_PORT_DEFAULT;
- //@Property(name = ENABLE_SERVICE, boolValue = DEFAULT_ENABLE,
- // label = "Specify the default behavior of telemetry service")
- protected Boolean enableService = DEFAULT_ENABLE;
+ /** Specify the default behavior of telemetry service. */
+ protected Boolean enableService = PROMETHEUS_ENABLE_SERVICE_DEFAULT;
@Activate
protected void activate(ComponentContext context) {
@@ -110,22 +114,22 @@
private void readComponentConfiguration(ComponentContext context) {
Dictionary<?, ?> properties = context.getProperties();
- String addressStr = Tools.get(properties, ADDRESS);
- address = addressStr != null ? addressStr : DEFAULT_PROMETHEUS_EXPORTER_IP;
+ String addressStr = Tools.get(properties, PROP_PROMETHEUS_EXPORTER_ADDRESS);
+ address = addressStr != null ? addressStr : PROMETHEUS_EXPORTER_ADDRESS_DEFAULT;
log.info("Configured. Prometheus exporter address is {}", address);
- Integer portConfigured = Tools.getIntegerProperty(properties, PORT);
+ Integer portConfigured = Tools.getIntegerProperty(properties, PROP_PROMETHEUS_EXPORTER_PORT);
if (portConfigured == null) {
- port = DEFAULT_PROMETHEUS_EXPORTER_PORT;
+ port = PROMETHEUS_EXPORTER_PORT_DEFAULT;
log.info("Prometheus exporter port is NOT configured, default value is {}", port);
} else {
port = portConfigured;
log.info("Configured. Prometheus exporter port is {}", port);
}
- Boolean enableServiceConfigured = getBooleanProperty(properties, ENABLE_SERVICE);
+ Boolean enableServiceConfigured = getBooleanProperty(properties, PROP_PROMETHEUS_ENABLE_SERVICE);
if (enableServiceConfigured == null) {
- enableService = DEFAULT_DISABLE;
+ enableService = PROMETHEUS_ENABLE_SERVICE_DEFAULT;
log.info("Prometheus service enable flag is NOT " +
"configured, default value is {}", enableService);
} else {
diff --git a/apps/openstacktelemetry/app/src/main/java/org/onosproject/openstacktelemetry/impl/RestTelemetryConfigManager.java b/apps/openstacktelemetry/app/src/main/java/org/onosproject/openstacktelemetry/impl/RestTelemetryConfigManager.java
index e3b76b6..16b62cb 100644
--- a/apps/openstacktelemetry/app/src/main/java/org/onosproject/openstacktelemetry/impl/RestTelemetryConfigManager.java
+++ b/apps/openstacktelemetry/app/src/main/java/org/onosproject/openstacktelemetry/impl/RestTelemetryConfigManager.java
@@ -33,65 +33,69 @@
import java.util.Dictionary;
-import static org.onosproject.openstacktelemetry.api.Constants.DEFAULT_DISABLE;
-import static org.onosproject.openstacktelemetry.api.Constants.DEFAULT_REST_ENDPOINT;
-import static org.onosproject.openstacktelemetry.api.Constants.DEFAULT_REST_METHOD;
-import static org.onosproject.openstacktelemetry.api.Constants.DEFAULT_REST_REQUEST_MEDIA_TYPE;
-import static org.onosproject.openstacktelemetry.api.Constants.DEFAULT_REST_RESPONSE_MEDIA_TYPE;
-import static org.onosproject.openstacktelemetry.api.Constants.DEFAULT_REST_SERVER_IP;
-import static org.onosproject.openstacktelemetry.api.Constants.DEFAULT_REST_SERVER_PORT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_REST_SERVER_ADDRESS;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_REST_ENABLE_SERVICE;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_REST_ENABLE_SERVICE_DEFAULT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_REST_ENDPOINT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_REST_METHOD;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_REST_SERVER_PORT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_REST_REQUEST_MEDIA_TYPE;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_REST_RESPONSE_MEDIA_TYPE;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_REST_ENDPOINT_DEFAULT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_REST_METHOD_DEFAULT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_REST_REQUEST_MEDIA_TYPE_DEFAULT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_REST_RESPONSE_MEDIA_TYPE_DEFAULT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_REST_SERVER_ADDRESS_DEFAULT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_REST_SERVER_PORT_DEFAULT;
import static org.onosproject.openstacktelemetry.util.OpenstackTelemetryUtil.getBooleanProperty;
import static org.onosproject.openstacktelemetry.util.OpenstackTelemetryUtil.initTelemetryService;
/**
* REST server configuration manager for publishing openstack telemetry.
*/
-@Component(immediate = true, service = RestTelemetryConfigService.class)
+@Component(
+ immediate = true,
+ service = RestTelemetryConfigService.class,
+ property = {
+ PROP_REST_ENABLE_SERVICE + ":Boolean=" + PROP_REST_ENABLE_SERVICE_DEFAULT,
+ PROP_REST_SERVER_ADDRESS + "=" + PROP_REST_SERVER_ADDRESS_DEFAULT,
+ PROP_REST_SERVER_PORT + ":Integer=" + PROP_REST_SERVER_PORT_DEFAULT,
+ PROP_REST_ENDPOINT + "=" + PROP_REST_ENDPOINT_DEFAULT,
+ PROP_REST_METHOD + "=" + PROP_REST_METHOD_DEFAULT,
+ PROP_REST_REQUEST_MEDIA_TYPE + "=" + PROP_REST_REQUEST_MEDIA_TYPE_DEFAULT,
+ PROP_REST_RESPONSE_MEDIA_TYPE + "=" + PROP_REST_RESPONSE_MEDIA_TYPE_DEFAULT
+ }
+)
public class RestTelemetryConfigManager implements RestTelemetryConfigService {
private final Logger log = LoggerFactory.getLogger(getClass());
- private static final String ENABLE_SERVICE = "enableService";
- private static final String ADDRESS = "address";
- private static final String PORT = "port";
- private static final String ENDPOINT = "endpoint";
- private static final String METHOD = "method";
- private static final String REQUEST_MEDIA_TYPE = "requestMediaType";
- private static final String RESPONSE_MEDIA_TYPE = "responseMediaType";
-
@Reference(cardinality = ReferenceCardinality.MANDATORY)
protected ComponentConfigService componentConfigService;
@Reference(cardinality = ReferenceCardinality.MANDATORY)
protected RestTelemetryAdminService restTelemetryAdminService;
- //@Property(name = ADDRESS, value = DEFAULT_REST_SERVER_IP,
- // label = "Default IP address to establish initial connection to REST server")
- protected String address = DEFAULT_REST_SERVER_IP;
+ /** Default IP address to establish initial connection to REST server. */
+ protected String address = PROP_REST_SERVER_ADDRESS_DEFAULT;
- //@Property(name = PORT, intValue = DEFAULT_REST_SERVER_PORT,
- // label = "Default port number to establish initial connection to REST server")
- protected Integer port = DEFAULT_REST_SERVER_PORT;
+ /** Default port number to establish initial connection to REST server. */
+ protected Integer port = PROP_REST_SERVER_PORT_DEFAULT;
- //@Property(name = ENDPOINT, value = DEFAULT_REST_ENDPOINT,
- // label = "Endpoint of REST server")
- protected String endpoint = DEFAULT_REST_ENDPOINT;
+ /** Endpoint of REST server. */
+ protected String endpoint = PROP_REST_ENDPOINT_DEFAULT;
- //@Property(name = METHOD, value = DEFAULT_REST_METHOD,
- // label = "HTTP method of REST server")
- protected String method = DEFAULT_REST_METHOD;
+ /** HTTP method of REST server. */
+ protected String method = PROP_REST_METHOD_DEFAULT;
- //@Property(name = REQUEST_MEDIA_TYPE, value = DEFAULT_REST_REQUEST_MEDIA_TYPE,
- // label = "Request media type of REST server")
- protected String requestMediaType = DEFAULT_REST_REQUEST_MEDIA_TYPE;
+ /** Request media type of REST server. */
+ protected String requestMediaType = PROP_REST_REQUEST_MEDIA_TYPE_DEFAULT;
- //@Property(name = RESPONSE_MEDIA_TYPE, value = DEFAULT_REST_RESPONSE_MEDIA_TYPE,
- // label = "Response media type of REST server")
- protected String responseMediaType = DEFAULT_REST_RESPONSE_MEDIA_TYPE;
+ /** Response media type of REST server. */
+ protected String responseMediaType = PROP_REST_RESPONSE_MEDIA_TYPE_DEFAULT;
- //@Property(name = ENABLE_SERVICE, boolValue = DEFAULT_DISABLE,
- // label = "Specify the default behavior of telemetry service")
- protected Boolean enableService = DEFAULT_DISABLE;
+ /** Specify the default behavior of telemetry service. */
+ protected Boolean enableService = PROP_REST_ENABLE_SERVICE_DEFAULT;
@Activate
protected void activate(ComponentContext context) {
@@ -140,41 +144,41 @@
private void readComponentConfiguration(ComponentContext context) {
Dictionary<?, ?> properties = context.getProperties();
- String addressStr = Tools.get(properties, ADDRESS);
- address = addressStr != null ? addressStr : DEFAULT_REST_SERVER_IP;
+ String addressStr = Tools.get(properties, PROP_REST_SERVER_ADDRESS);
+ address = addressStr != null ? addressStr : PROP_REST_SERVER_ADDRESS_DEFAULT;
log.info("Configured. REST server address is {}", address);
- Integer portConfigured = Tools.getIntegerProperty(properties, PORT);
+ Integer portConfigured = Tools.getIntegerProperty(properties, PROP_REST_SERVER_PORT);
if (portConfigured == null) {
- port = DEFAULT_REST_SERVER_PORT;
+ port = PROP_REST_SERVER_PORT_DEFAULT;
log.info("REST server port is NOT configured, default value is {}", port);
} else {
port = portConfigured;
log.info("Configured. REST server port is {}", port);
}
- String endpointStr = Tools.get(properties, ENDPOINT);
- endpoint = endpointStr != null ? endpointStr : DEFAULT_REST_ENDPOINT;
+ String endpointStr = Tools.get(properties, PROP_REST_ENDPOINT);
+ endpoint = endpointStr != null ? endpointStr : PROP_REST_ENDPOINT_DEFAULT;
log.info("Configured. REST server endpoint is {}", endpoint);
- String methodStr = Tools.get(properties, METHOD);
- method = methodStr != null ? methodStr : DEFAULT_REST_METHOD;
+ String methodStr = Tools.get(properties, PROP_REST_METHOD);
+ method = methodStr != null ? methodStr : PROP_REST_METHOD_DEFAULT;
log.info("Configured. REST server default HTTP method is {}", method);
- String requestMediaTypeStr = Tools.get(properties, REQUEST_MEDIA_TYPE);
+ String requestMediaTypeStr = Tools.get(properties, PROP_REST_REQUEST_MEDIA_TYPE);
requestMediaType = requestMediaTypeStr != null ?
- requestMediaTypeStr : DEFAULT_REST_REQUEST_MEDIA_TYPE;
+ requestMediaTypeStr : PROP_REST_REQUEST_MEDIA_TYPE_DEFAULT;
log.info("Configured. REST server request media type is {}", requestMediaType);
- String responseMediaTypeStr = Tools.get(properties, RESPONSE_MEDIA_TYPE);
+ String responseMediaTypeStr = Tools.get(properties, PROP_REST_RESPONSE_MEDIA_TYPE);
responseMediaType = responseMediaTypeStr != null ?
- responseMediaTypeStr : DEFAULT_REST_RESPONSE_MEDIA_TYPE;
+ responseMediaTypeStr : PROP_REST_RESPONSE_MEDIA_TYPE_DEFAULT;
log.info("Configured. REST server response media type is {}", responseMediaType);
Boolean enableServiceConfigured =
- getBooleanProperty(properties, ENABLE_SERVICE);
+ getBooleanProperty(properties, PROP_REST_ENABLE_SERVICE);
if (enableServiceConfigured == null) {
- enableService = DEFAULT_DISABLE;
+ enableService = PROP_REST_ENABLE_SERVICE_DEFAULT;
log.info("REST service enable flag is NOT " +
"configured, default value is {}", enableService);
} else {
diff --git a/apps/openstacktelemetry/app/src/main/java/org/onosproject/openstacktelemetry/impl/StatsFlowRuleManager.java b/apps/openstacktelemetry/app/src/main/java/org/onosproject/openstacktelemetry/impl/StatsFlowRuleManager.java
index 5ffd40c..4ddaf40 100644
--- a/apps/openstacktelemetry/app/src/main/java/org/onosproject/openstacktelemetry/impl/StatsFlowRuleManager.java
+++ b/apps/openstacktelemetry/app/src/main/java/org/onosproject/openstacktelemetry/impl/StatsFlowRuleManager.java
@@ -108,12 +108,32 @@
import static org.onosproject.openstacktelemetry.api.Constants.OPENSTACK_TELEMETRY_APP_ID;
import static org.onosproject.openstacktelemetry.api.Constants.VLAN;
import static org.onosproject.openstacktelemetry.api.Constants.VXLAN;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_EGRESS_STATS;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_EGRESS_STATS_DEFAULT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_MONITOR_OVERLAY;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_MONITOR_OVERLAY_DEFAULT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_MONITOR_UNDERLAY;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_MONITOR_UNDERLAY_DEFAULT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_PORT_STATS;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_PORT_STATS_DEFAULT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_REVERSE_PATH_STATS;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_REVERSE_PATH_STATS_DEFAULT;
import static org.onosproject.openstacktelemetry.util.OpenstackTelemetryUtil.getBooleanProperty;
/**
* Flow rule manager for network statistics of a VM.
*/
-@Component(immediate = true, service = StatsFlowRuleAdminService.class)
+@Component(
+ immediate = true,
+ service = StatsFlowRuleAdminService.class,
+ property = {
+ PROP_REVERSE_PATH_STATS + ":Boolean=" + PROP_REVERSE_PATH_STATS_DEFAULT,
+ PROP_EGRESS_STATS + ":Boolean=" + PROP_EGRESS_STATS_DEFAULT,
+ PROP_PORT_STATS + ":Boolean=" + PROP_PORT_STATS_DEFAULT,
+ PROP_MONITOR_OVERLAY + ":Boolean=" + PROP_MONITOR_OVERLAY_DEFAULT,
+ PROP_MONITOR_UNDERLAY + ":Boolean=" + PROP_MONITOR_UNDERLAY_DEFAULT
+ }
+)
public class StatsFlowRuleManager implements StatsFlowRuleAdminService {
private final Logger log = LoggerFactory.getLogger(getClass());
@@ -125,22 +145,8 @@
private static final long REFRESH_INTERVAL = 5L;
private static final TimeUnit TIME_UNIT_SECOND = TimeUnit.SECONDS;
- private static final String REVERSE_PATH_STATS = "reversePathStats";
- private static final String EGRESS_STATS = "egressStats";
- private static final String PORT_STATS = "portStats";
-
- private static final String MONITOR_OVERLAY = "monitorOverlay";
- private static final String MONITOR_UNDERLAY = "monitorUnderlay";
-
private static final String OVS_DRIVER_NAME = "ovs";
- private static final boolean DEFAULT_REVERSE_PATH_STATS = false;
- private static final boolean DEFAULT_EGRESS_STATS = false;
- private static final boolean DEFAULT_PORT_STATS = true;
-
- private static final boolean DEFAULT_MONITOR_OVERLAY = true;
- private static final boolean DEFAULT_MONITOR_UNDERLAY = true;
-
private static final String ARBITRARY_IP = "0.0.0.0/32";
private static final int ARBITRARY_PROTOCOL = 0x0;
private static final int ARBITRARY_LENGTH = 32;
@@ -185,27 +191,20 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY)
protected OpenstackTelemetryService telemetryService;
- //@Property(name = REVERSE_PATH_STATS, boolValue = DEFAULT_REVERSE_PATH_STATS,
- // label = "A flag which indicates whether to install the rules for " +
- // "collecting the flow-based stats for reversed path.")
- private boolean reversePathStats = DEFAULT_REVERSE_PATH_STATS;
+ /** A flag which indicates whether to install the rules for collecting the flow-based stats for reversed path. */
+ private boolean reversePathStats = PROP_REVERSE_PATH_STATS_DEFAULT;
- //@Property(name = EGRESS_STATS, boolValue = DEFAULT_EGRESS_STATS,
- // label = "A flag which indicates whether to install the rules for " +
- // "collecting the flow-based stats for egress port.")
- private boolean egressStats = DEFAULT_EGRESS_STATS;
+ /** A flag which indicates whether to install the rules for collecting the flow-based stats for egress port. */
+ private boolean egressStats = PROP_EGRESS_STATS_DEFAULT;
- //@Property(name = PORT_STATS, boolValue = DEFAULT_PORT_STATS,
- // label = "A flag which indicates whether to collect port TX & RX stats.")
- private boolean portStats = DEFAULT_PORT_STATS;
+ /** A flag which indicates whether to collect port TX & RX stats. */
+ private boolean portStats = PROP_PORT_STATS_DEFAULT;
- //@Property(name = MONITOR_OVERLAY, boolValue = DEFAULT_MONITOR_OVERLAY,
- // label = "A flag which indicates whether to monitor overlay network port stats.")
- private boolean monitorOverlay = DEFAULT_MONITOR_OVERLAY;
+ /** A flag which indicates whether to monitor overlay network port stats. */
+ private boolean monitorOverlay = PROP_MONITOR_OVERLAY_DEFAULT;
- //@Property(name = MONITOR_UNDERLAY, boolValue = DEFAULT_MONITOR_UNDERLAY,
- // label = "A flag which indicates whether to monitor underlay network port stats.")
- private boolean monitorUnderlay = DEFAULT_MONITOR_UNDERLAY;
+ /** A flag which indicates whether to monitor underlay network port stats. */
+ private boolean monitorUnderlay = PROP_MONITOR_UNDERLAY_DEFAULT;
private ApplicationId telemetryAppId;
private TelemetryCollector collector;
@@ -986,9 +985,9 @@
Dictionary<?, ?> properties = context.getProperties();
Boolean reversePathStatsConfigured =
- getBooleanProperty(properties, REVERSE_PATH_STATS);
+ getBooleanProperty(properties, PROP_REVERSE_PATH_STATS);
if (reversePathStatsConfigured == null) {
- reversePathStats = DEFAULT_REVERSE_PATH_STATS;
+ reversePathStats = PROP_REVERSE_PATH_STATS_DEFAULT;
log.info("Reversed path stats flag is NOT " +
"configured, default value is {}", reversePathStats);
} else {
@@ -996,9 +995,9 @@
log.info("Configured. Reversed path stats flag is {}", reversePathStats);
}
- Boolean egressStatsConfigured = getBooleanProperty(properties, EGRESS_STATS);
+ Boolean egressStatsConfigured = getBooleanProperty(properties, PROP_EGRESS_STATS);
if (egressStatsConfigured == null) {
- egressStats = DEFAULT_EGRESS_STATS;
+ egressStats = PROP_EGRESS_STATS_DEFAULT;
log.info("Egress stats flag is NOT " +
"configured, default value is {}", egressStats);
} else {
@@ -1006,9 +1005,9 @@
log.info("Configured. Egress stats flag is {}", egressStats);
}
- Boolean portStatsConfigured = getBooleanProperty(properties, PORT_STATS);
+ Boolean portStatsConfigured = getBooleanProperty(properties, PROP_PORT_STATS);
if (portStatsConfigured == null) {
- portStats = DEFAULT_PORT_STATS;
+ portStats = PROP_PORT_STATS_DEFAULT;
log.info("Port stats flag is NOT " +
"configured, default value is {}", portStats);
} else {
@@ -1016,9 +1015,9 @@
log.info("Configured. Port stats flag is {}", portStats);
}
- Boolean monitorOverlayConfigured = getBooleanProperty(properties, MONITOR_OVERLAY);
+ Boolean monitorOverlayConfigured = getBooleanProperty(properties, PROP_MONITOR_OVERLAY);
if (monitorOverlayConfigured == null) {
- monitorOverlay = DEFAULT_MONITOR_OVERLAY;
+ monitorOverlay = PROP_MONITOR_OVERLAY_DEFAULT;
log.info("Monitor overlay flag is NOT " +
"configured, default value is {}", monitorOverlay);
} else {
@@ -1026,9 +1025,9 @@
log.info("Configured. Monitor overlay flag is {}", monitorOverlay);
}
- Boolean monitorUnderlayConfigured = getBooleanProperty(properties, MONITOR_UNDERLAY);
+ Boolean monitorUnderlayConfigured = getBooleanProperty(properties, PROP_MONITOR_UNDERLAY);
if (monitorUnderlayConfigured == null) {
- monitorUnderlay = DEFAULT_MONITOR_UNDERLAY;
+ monitorUnderlay = PROP_MONITOR_UNDERLAY_DEFAULT;
log.info("Monitor underlay flag is NOT " +
"configured, default value is {}", monitorUnderlay);
} else {
diff --git a/apps/openstacktelemetry/app/src/test/java/org/onosproject/openstacktelemetry/config/DefaultPrometheusTelemetryConfigTest.java b/apps/openstacktelemetry/app/src/test/java/org/onosproject/openstacktelemetry/config/DefaultPrometheusTelemetryConfigTest.java
index 3e291c2..6a0c0b5 100644
--- a/apps/openstacktelemetry/app/src/test/java/org/onosproject/openstacktelemetry/config/DefaultPrometheusTelemetryConfigTest.java
+++ b/apps/openstacktelemetry/app/src/test/java/org/onosproject/openstacktelemetry/config/DefaultPrometheusTelemetryConfigTest.java
@@ -26,19 +26,19 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-import static org.onosproject.openstacktelemetry.api.Constants.DEFAULT_PROMETHEUS_EXPORTER_IP;
-import static org.onosproject.openstacktelemetry.api.Constants.DEFAULT_PROMETHEUS_EXPORTER_PORT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROMETHEUS_EXPORTER_PORT_DEFAULT;
+import static org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROMETHEUS_EXPORTER_ADDRESS_DEFAULT;
/**
* Unit tests for DefaultPrometheusTelemetryConfig class.
*/
public class DefaultPrometheusTelemetryConfigTest {
- private static final String IP_ADDRESS_1 = DEFAULT_PROMETHEUS_EXPORTER_IP;
+ private static final String IP_ADDRESS_1 = PROMETHEUS_EXPORTER_ADDRESS_DEFAULT;
private static final String IP_ADDRESS_2 = "10.10.1.2";
- private static final int PORT_1 = DEFAULT_PROMETHEUS_EXPORTER_PORT;
- private static final int PORT_2 = DEFAULT_PROMETHEUS_EXPORTER_PORT + 1;
+ private static final int PORT_1 = PROMETHEUS_EXPORTER_PORT_DEFAULT;
+ private static final int PORT_2 = PROMETHEUS_EXPORTER_PORT_DEFAULT + 1;
private static final Map<String, Object> CONFIG_MAP_1 =
ImmutableMap.of("key1", "value1");
diff --git a/apps/openstackvtap/app/src/main/java/org/onosproject/openstackvtap/impl/OpenstackVtapManager.java b/apps/openstackvtap/app/src/main/java/org/onosproject/openstackvtap/impl/OpenstackVtapManager.java
index a2c1a0a..439b084 100644
--- a/apps/openstackvtap/app/src/main/java/org/onosproject/openstackvtap/impl/OpenstackVtapManager.java
+++ b/apps/openstackvtap/app/src/main/java/org/onosproject/openstackvtap/impl/OpenstackVtapManager.java
@@ -123,6 +123,8 @@
import static org.onosproject.openstacknode.api.Constants.INTEGRATION_BRIDGE;
import static org.onosproject.openstacknode.api.NodeState.COMPLETE;
import static org.onosproject.openstacknode.api.OpenstackNode.NodeType.COMPUTE;
+import static org.onosproject.openstackvtap.impl.OsgiPropertyConstants.TUNNEL_NICIRA;
+import static org.onosproject.openstackvtap.impl.OsgiPropertyConstants.TUNNEL_NICRA_DEFAULT;
import static org.onosproject.openstackvtap.util.OpenstackVtapUtil.containsIp;
import static org.onosproject.openstackvtap.util.OpenstackVtapUtil.dumpStackTrace;
import static org.onosproject.openstackvtap.util.OpenstackVtapUtil.getGroupKey;
@@ -135,7 +137,13 @@
/**
* Provides implementation of the openstack vtap and openstack vtap network APIs.
*/
-@Component(immediate = true, service = { OpenstackVtapService.class, OpenstackVtapAdminService.class })
+@Component(
+ immediate = true,
+ service = { OpenstackVtapService.class, OpenstackVtapAdminService.class },
+ property = {
+ TUNNEL_NICIRA + ":Boolean=" + TUNNEL_NICRA_DEFAULT
+ }
+)
public class OpenstackVtapManager
extends AbstractListenerManager<OpenstackVtapEvent, OpenstackVtapListener>
implements OpenstackVtapService, OpenstackVtapAdminService {
@@ -173,10 +181,8 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY)
protected ComponentConfigService componentConfigService;
- private static final boolean DEFAULT_TUNNEL_NICRA = false;
- //@Property(name = TUNNEL_NICIRA, boolValue = DEFAULT_TUNNEL_NICRA,
- // label = "Use nicra extension for tunneling")
- private boolean tunnelNicira = DEFAULT_TUNNEL_NICRA;
+ /** Use nicra extension for tunneling. */
+ private boolean tunnelNicira = TUNNEL_NICRA_DEFAULT;
public static final String APP_ID = "org.onosproject.openstackvtap";
public static final String VTAP_DESC_NULL = "vtap field %s cannot be null";
@@ -208,7 +214,6 @@
IpPrefix.valueOf(IpAddress.valueOf("0.0.0.0"), 0);
private static final String TABLE_EXTENSION = "table";
private static final String TUNNEL_DST_EXTENSION = "tunnelDst";
- private static final String TUNNEL_NICIRA = "tunnelNicira";
private static final int VTAP_NETWORK_KEY = 0;
diff --git a/apps/openstackvtap/app/src/main/java/org/onosproject/openstackvtap/impl/OsgiPropertyConstants.java b/apps/openstackvtap/app/src/main/java/org/onosproject/openstackvtap/impl/OsgiPropertyConstants.java
new file mode 100644
index 0000000..bc6f5ed
--- /dev/null
+++ b/apps/openstackvtap/app/src/main/java/org/onosproject/openstackvtap/impl/OsgiPropertyConstants.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * 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.
+ */
+
+package org.onosproject.openstackvtap.impl;
+
+/**
+ * Name/Value constants for properties.
+ */
+public final class OsgiPropertyConstants {
+ private OsgiPropertyConstants() {
+ }
+
+ static final String TUNNEL_NICIRA = "tunnelNicira";
+ static final boolean TUNNEL_NICRA_DEFAULT = false;
+}
diff --git a/apps/routeradvertisement/src/main/java/org/onosproject/ra/OsgiPropertyConstants.java b/apps/routeradvertisement/src/main/java/org/onosproject/ra/OsgiPropertyConstants.java
new file mode 100644
index 0000000..e9784ec
--- /dev/null
+++ b/apps/routeradvertisement/src/main/java/org/onosproject/ra/OsgiPropertyConstants.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * 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.
+ */
+
+package org.onosproject.ra;
+
+/**
+ * Name/Value constants for properties.
+ */
+public final class OsgiPropertyConstants {
+ private OsgiPropertyConstants() {
+ }
+
+ public static final String RA_THREADS_POOL = "raPoolSize";
+ public static final int RA_THREADS_POOL_SIZE_DEFAULT = 10;
+
+ public static final String RA_THREADS_DELAY = "raThreadDelay";
+ public static final int RA_THREADS_DELAY_DEFAULT = 5;
+
+ public static final String RA_FLAG_MBIT_STATUS = "raFlagMbitStatus";
+ public static final boolean RA_FLAG_MBIT_STATUS_DEFAULT = false;
+
+ public static final String RA_FLAG_OBIT_STATUS = "raFlagObitStatus";
+ public static final boolean RA_FLAG_OBIT_STATUS_DEFAULT = false;
+
+ public static final String RA_OPTION_PREFIX_STATUS = "raOptionPrefixStatus";
+ public static final boolean RA_OPTION_PREFIX_STATUS_DEFAULT = false;
+
+ public static final String RA_GLOBAL_PREFIX_CONF_STATUS = "raGlobalPrefixConfStatus";
+ public static final boolean RA_GLOBAL_PREFIX_CONF_STATUS_DEFAULT = true;
+
+}
diff --git a/apps/routeradvertisement/src/main/java/org/onosproject/ra/RouterAdvertisementManager.java b/apps/routeradvertisement/src/main/java/org/onosproject/ra/RouterAdvertisementManager.java
index 8da5065..53d96b1 100644
--- a/apps/routeradvertisement/src/main/java/org/onosproject/ra/RouterAdvertisementManager.java
+++ b/apps/routeradvertisement/src/main/java/org/onosproject/ra/RouterAdvertisementManager.java
@@ -89,26 +89,37 @@
import static com.google.common.base.Strings.isNullOrEmpty;
import static org.onlab.util.Tools.get;
import static org.onlab.util.Tools.groupedThreads;
+import static org.onosproject.ra.OsgiPropertyConstants.RA_FLAG_MBIT_STATUS;
+import static org.onosproject.ra.OsgiPropertyConstants.RA_FLAG_MBIT_STATUS_DEFAULT;
+import static org.onosproject.ra.OsgiPropertyConstants.RA_FLAG_OBIT_STATUS;
+import static org.onosproject.ra.OsgiPropertyConstants.RA_FLAG_OBIT_STATUS_DEFAULT;
+import static org.onosproject.ra.OsgiPropertyConstants.RA_GLOBAL_PREFIX_CONF_STATUS;
+import static org.onosproject.ra.OsgiPropertyConstants.RA_GLOBAL_PREFIX_CONF_STATUS_DEFAULT;
+import static org.onosproject.ra.OsgiPropertyConstants.RA_OPTION_PREFIX_STATUS;
+import static org.onosproject.ra.OsgiPropertyConstants.RA_OPTION_PREFIX_STATUS_DEFAULT;
+import static org.onosproject.ra.OsgiPropertyConstants.RA_THREADS_DELAY;
+import static org.onosproject.ra.OsgiPropertyConstants.RA_THREADS_DELAY_DEFAULT;
+import static org.onosproject.ra.OsgiPropertyConstants.RA_THREADS_POOL;
+import static org.onosproject.ra.OsgiPropertyConstants.RA_THREADS_POOL_SIZE_DEFAULT;
/**
* Manages IPv6 Router Advertisements.
*/
-@Component(immediate = true, service = RoutingAdvertisementService.class)
+@Component(
+ immediate = true,
+ service = RoutingAdvertisementService.class,
+ property = {
+ RA_THREADS_POOL + ":Integer=" + RA_THREADS_POOL_SIZE_DEFAULT,
+ RA_THREADS_DELAY + ":Integer=" + RA_THREADS_DELAY_DEFAULT,
+ RA_FLAG_MBIT_STATUS + ":Boolean=" + RA_FLAG_MBIT_STATUS_DEFAULT,
+ RA_FLAG_OBIT_STATUS + ":Boolean=" + RA_FLAG_OBIT_STATUS_DEFAULT,
+ RA_OPTION_PREFIX_STATUS + ":Boolean=" + RA_OPTION_PREFIX_STATUS_DEFAULT,
+ RA_GLOBAL_PREFIX_CONF_STATUS + ":Boolean=" + RA_GLOBAL_PREFIX_CONF_STATUS_DEFAULT
+ }
+)
public class RouterAdvertisementManager implements RoutingAdvertisementService {
private final Logger log = LoggerFactory.getLogger(getClass());
- private static final String PROP_RA_THREADS_POOL = "raPoolSize";
- private static final int DEFAULT_RA_THREADS_POOL_SIZE = 10;
- private static final String PROP_RA_THREADS_DELAY = "raThreadDelay";
- private static final int DEFAULT_RA_THREADS_DELAY = 5;
- private static final String PROP_RA_FLAG_MBIT_STATUS = "raFlagMbitStatus";
- private static final boolean DEFAULT_RA_FLAG_MBIT_STATUS = false;
- private static final String PROP_RA_FLAG_OBIT_STATUS = "raFlagObitStatus";
- private static final boolean DEFAULT_RA_FLAG_OBIT_STATUS = false;
- private static final String PROP_RA_OPTION_PREFIX_STATUS = "raOptionPrefixStatus";
- private static final boolean DEFAULT_RA_OPTION_PREFIX_STATUS = false;
- private static final String PROP_RA_GLOBAL_PREFIX_CONF_STATUS = "raGlobalPrefixConfStatus";
- private static final boolean DEFAULT_RA_GLOBAL_PREFIX_CONF_STATUS = true;
@Reference(cardinality = ReferenceCardinality.MANDATORY)
protected CoreService coreService;
@@ -131,29 +142,23 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY)
protected DeviceService deviceService;
- //@Property(name = PROP_RA_THREADS_POOL, intValue = DEFAULT_RA_THREADS_POOL_SIZE,
- // label = "Thread pool capacity")
- protected int raPoolSize = DEFAULT_RA_THREADS_POOL_SIZE;
+ /** Thread pool capacity. */
+ protected int raPoolSize = RA_THREADS_POOL_SIZE_DEFAULT;
- //@Property(name = PROP_RA_THREADS_DELAY, intValue = DEFAULT_RA_THREADS_DELAY,
- // label = "Thread delay in seconds")
- protected int raThreadDelay = DEFAULT_RA_THREADS_DELAY;
+ /** Thread delay in seconds. */
+ protected int raThreadDelay = RA_THREADS_DELAY_DEFAULT;
- //@Property(name = PROP_RA_FLAG_MBIT_STATUS, boolValue = DEFAULT_RA_FLAG_MBIT_STATUS,
- // label = "Turn M-bit flag on/off")
- protected boolean raFlagMbitStatus = DEFAULT_RA_FLAG_MBIT_STATUS;
+ /** Turn M-bit flag on/off. */
+ protected boolean raFlagMbitStatus = RA_FLAG_MBIT_STATUS_DEFAULT;
- //@Property(name = PROP_RA_FLAG_OBIT_STATUS, boolValue = DEFAULT_RA_FLAG_OBIT_STATUS,
- // label = "Turn O-bit flag on/off")
- protected boolean raFlagObitStatus = DEFAULT_RA_FLAG_OBIT_STATUS;
+ /** Turn O-bit flag on/off. */
+ protected boolean raFlagObitStatus = RA_FLAG_OBIT_STATUS_DEFAULT;
- //@Property(name = PROP_RA_OPTION_PREFIX_STATUS, boolValue = DEFAULT_RA_OPTION_PREFIX_STATUS,
- // label = "Prefix option support needed or not")
- protected boolean raOptionPrefixStatus = DEFAULT_RA_OPTION_PREFIX_STATUS;
+ /** Prefix option support needed or not. */
+ protected boolean raOptionPrefixStatus = RA_OPTION_PREFIX_STATUS_DEFAULT;
- //@Property(name = PROP_RA_GLOBAL_PREFIX_CONF_STATUS, boolValue = DEFAULT_RA_GLOBAL_PREFIX_CONF_STATUS,
- // label = "Global prefix configuration support on/off")
- protected boolean raGlobalConfigStatus = DEFAULT_RA_GLOBAL_PREFIX_CONF_STATUS;
+ /** Global prefix configuration support on/off. */
+ protected boolean raGlobalPrefixConfStatus = RA_GLOBAL_PREFIX_CONF_STATUS_DEFAULT;
@GuardedBy(value = "this")
private final Map<ConnectPoint, Map.Entry<ScheduledFuture<?>, List<InterfaceIpAddress>>> transmitters =
@@ -173,7 +178,7 @@
private Function<Interface, Map.Entry<ConnectPoint, List<InterfaceIpAddress>>> prefixGenerator =
i -> {
Map.Entry<ConnectPoint, List<InterfaceIpAddress>> prefixEntry;
- if (raGlobalConfigStatus && globalPrefixes.containsKey(i.connectPoint().deviceId())) {
+ if (raGlobalPrefixConfStatus && globalPrefixes.containsKey(i.connectPoint().deviceId())) {
prefixEntry = new AbstractMap.SimpleEntry<>(i.connectPoint(),
globalPrefixes.get(i.connectPoint().deviceId()));
} else {
@@ -427,9 +432,9 @@
Dictionary<?, ?> properties = context.getProperties();
try {
// Handle change in pool size
- String s = get(properties, PROP_RA_THREADS_POOL);
+ String s = get(properties, RA_THREADS_POOL);
newRaPoolSize = isNullOrEmpty(s) ?
- DEFAULT_RA_THREADS_POOL_SIZE : Integer.parseInt(s.trim());
+ RA_THREADS_POOL_SIZE_DEFAULT : Integer.parseInt(s.trim());
if (newRaPoolSize != raPoolSize) {
raPoolSize = newRaPoolSize;
clearPoolAndTxWorkers();
@@ -438,9 +443,9 @@
}
// Handle change in thread delay
- s = get(properties, PROP_RA_THREADS_DELAY);
+ s = get(properties, RA_THREADS_DELAY);
newRaThreadDelay = isNullOrEmpty(s) ?
- DEFAULT_RA_THREADS_DELAY : Integer.parseInt(s.trim());
+ RA_THREADS_DELAY_DEFAULT : Integer.parseInt(s.trim());
if (newRaThreadDelay != raThreadDelay) {
raThreadDelay = newRaThreadDelay;
clearTxWorkers();
@@ -449,30 +454,30 @@
}
// Handle M-flag changes
- s = get(properties, PROP_RA_FLAG_MBIT_STATUS);
+ s = get(properties, RA_FLAG_MBIT_STATUS);
if (!isNullOrEmpty(s)) {
raFlagMbitStatus = Boolean.parseBoolean(s.trim());
log.info("RA M-flag set {}", s);
}
// Handle O-flag changes
- s = get(properties, PROP_RA_FLAG_OBIT_STATUS);
+ s = get(properties, RA_FLAG_OBIT_STATUS);
if (!isNullOrEmpty(s)) {
raFlagObitStatus = Boolean.parseBoolean(s.trim());
log.info("RA O-flag set {}", s);
}
// Handle prefix option configuration
- s = get(properties, PROP_RA_OPTION_PREFIX_STATUS);
+ s = get(properties, RA_OPTION_PREFIX_STATUS);
if (!isNullOrEmpty(s)) {
raOptionPrefixStatus = Boolean.parseBoolean(s.trim());
String status = raOptionPrefixStatus ? "enabled" : "disabled";
log.info("RA prefix option {}", status);
}
- s = get(properties, PROP_RA_GLOBAL_PREFIX_CONF_STATUS);
+ s = get(properties, RA_GLOBAL_PREFIX_CONF_STATUS);
if (!isNullOrEmpty(s)) {
- raGlobalConfigStatus = Boolean.parseBoolean(s.trim());
+ raGlobalPrefixConfStatus = Boolean.parseBoolean(s.trim());
clearTxWorkers();
setupTxWorkers();
String status = raOptionPrefixStatus ? "enabled" : "disabled";
diff --git a/apps/routing/fibinstaller/src/main/java/org/onosproject/routing/fibinstaller/FibInstaller.java b/apps/routing/fibinstaller/src/main/java/org/onosproject/routing/fibinstaller/FibInstaller.java
index 6eb23d4..d12c6d8 100644
--- a/apps/routing/fibinstaller/src/main/java/org/onosproject/routing/fibinstaller/FibInstaller.java
+++ b/apps/routing/fibinstaller/src/main/java/org/onosproject/routing/fibinstaller/FibInstaller.java
@@ -81,10 +81,18 @@
import java.util.Map;
import java.util.Set;
+import static org.onosproject.routing.fibinstaller.OsgiPropertyConstants.ROUTE_TO_NEXT_HOP;
+import static org.onosproject.routing.fibinstaller.OsgiPropertyConstants.ROUTE_TO_NEXT_HOP_DEFAULT;
+
/**
* Programs routes to a single OpenFlow switch.
*/
-@Component(immediate = true)
+@Component(
+ immediate = true,
+ property = {
+ ROUTE_TO_NEXT_HOP + ":Boolean= " + ROUTE_TO_NEXT_HOP_DEFAULT
+ }
+)
public class FibInstaller {
private final Logger log = LoggerFactory.getLogger(getClass());
@@ -124,9 +132,8 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY)
protected ApplicationService applicationService;
- //@Property(name = "routeToNextHop", boolValue = false,
- // label = "Install a /32 or /128 route to each next hop")
- private boolean routeToNextHop = false;
+ /** Install a /32 or /128 route to each next hop. */
+ private boolean routeToNextHop = ROUTE_TO_NEXT_HOP_DEFAULT;
// Device id of data-plane switch - should be learned from config
private DeviceId deviceId;
diff --git a/apps/routing/fibinstaller/src/main/java/org/onosproject/routing/fibinstaller/OsgiPropertyConstants.java b/apps/routing/fibinstaller/src/main/java/org/onosproject/routing/fibinstaller/OsgiPropertyConstants.java
new file mode 100644
index 0000000..731ce4f
--- /dev/null
+++ b/apps/routing/fibinstaller/src/main/java/org/onosproject/routing/fibinstaller/OsgiPropertyConstants.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * 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.
+ */
+
+package org.onosproject.routing.fibinstaller;
+
+/**
+ * Name/Value constants for properties.
+ */
+public final class OsgiPropertyConstants {
+ private OsgiPropertyConstants() {
+ }
+
+ public static final String ROUTE_TO_NEXT_HOP = "routeToNextHop";
+ public static final boolean ROUTE_TO_NEXT_HOP_DEFAULT = false;
+}
diff --git a/apps/routing/fpm/app/src/main/java/org/onosproject/routing/fpm/FpmManager.java b/apps/routing/fpm/app/src/main/java/org/onosproject/routing/fpm/FpmManager.java
index 3973520..294ebe8 100644
--- a/apps/routing/fpm/app/src/main/java/org/onosproject/routing/fpm/FpmManager.java
+++ b/apps/routing/fpm/app/src/main/java/org/onosproject/routing/fpm/FpmManager.java
@@ -95,11 +95,28 @@
import static java.util.concurrent.Executors.newCachedThreadPool;
import static org.onlab.util.Tools.groupedThreads;
+import static org.onosproject.routing.fpm.OsgiPropertyConstants.CLEAR_ROUTES;
+import static org.onosproject.routing.fpm.OsgiPropertyConstants.CLEAR_ROUTES_DEFAULT;
+import static org.onosproject.routing.fpm.OsgiPropertyConstants.PD_PUSH_ENABLED;
+import static org.onosproject.routing.fpm.OsgiPropertyConstants.PD_PUSH_ENABLED_DEFAULT;
+import static org.onosproject.routing.fpm.OsgiPropertyConstants.PD_PUSH_NEXT_HOP_IPV4;
+import static org.onosproject.routing.fpm.OsgiPropertyConstants.PD_PUSH_NEXT_HOP_IPV4_DEFAULT;
+import static org.onosproject.routing.fpm.OsgiPropertyConstants.PD_PUSH_NEXT_HOP_IPV6;
+import static org.onosproject.routing.fpm.OsgiPropertyConstants.PD_PUSH_NEXT_HOP_IPV6_DEFAULT;
/**
* Forwarding Plane Manager (FPM) route source.
*/
-@Component(immediate = true, service = FpmInfoService.class)
+@Component(
+ immediate = true,
+ service = FpmInfoService.class,
+ property = {
+ CLEAR_ROUTES + ":Boolean=" + CLEAR_ROUTES_DEFAULT,
+ PD_PUSH_ENABLED + ":Boolean=" + PD_PUSH_ENABLED_DEFAULT,
+ PD_PUSH_NEXT_HOP_IPV4 + "=" + PD_PUSH_NEXT_HOP_IPV4_DEFAULT,
+ PD_PUSH_NEXT_HOP_IPV6 + "=" + PD_PUSH_NEXT_HOP_IPV6_DEFAULT,
+ }
+)
public class FpmManager implements FpmInfoService {
private final Logger log = LoggerFactory.getLogger(getClass());
@@ -159,20 +176,16 @@
//Local cache for peers to be used in case of cluster partition.
private Map<FpmPeer, Set<FpmConnectionInfo>> localPeers = new ConcurrentHashMap<>();
- //@Property(name = "clearRoutes", boolValue = true,
- // label = "Whether to clear routes when the FPM connection goes down")
- private boolean clearRoutes = true;
+ /** Whether to clear routes when the FPM connection goes down. */
+ private boolean clearRoutes = CLEAR_ROUTES_DEFAULT;
- //@Property(name = "pdPushEnabled", boolValue = false,
- // label = "Whether to push prefixes to Quagga over fpm connection")
- private boolean pdPushEnabled = false;
+ /** Whether to push prefixes to Quagga over fpm connection. */
+ private boolean pdPushEnabled = PD_PUSH_ENABLED_DEFAULT;
- //@Property(name = "pdPushNextHopIPv4", value = "",
- // label = "IPv4 next-hop address for PD Pushing.")
+ /** IPv4 next-hop address for PD Pushing. */
private List<Ip4Address> pdPushNextHopIPv4 = null;
- //@Property(name = "pdPushNextHopIPv6", value = "",
- // label = "IPv6 next-hop address for PD Pushing.")
+ /** IPv6 next-hop address for PD Pushing. */
private List<Ip6Address> pdPushNextHopIPv6 = null;
protected void bindRipStore(FpmPrefixStore store) {
@@ -265,13 +278,13 @@
if (properties == null) {
return;
}
- String strClearRoutes = Tools.get(properties, "clearRoutes");
+ String strClearRoutes = Tools.get(properties, CLEAR_ROUTES);
if (strClearRoutes != null) {
clearRoutes = Boolean.parseBoolean(strClearRoutes);
log.info("clearRoutes is {}", clearRoutes);
}
- String strPdPushEnabled = Tools.get(properties, "pdPushEnabled");
+ String strPdPushEnabled = Tools.get(properties, PD_PUSH_ENABLED);
if (strPdPushEnabled != null) {
boolean oldValue = pdPushEnabled;
pdPushEnabled = Boolean.parseBoolean(strPdPushEnabled);
@@ -280,7 +293,7 @@
pdPushNextHopIPv4 = new ArrayList<Ip4Address>();
pdPushNextHopIPv6 = new ArrayList<Ip6Address>();
- String strPdPushNextHopIPv4 = Tools.get(properties, "pdPushNextHopIPv4");
+ String strPdPushNextHopIPv4 = Tools.get(properties, PD_PUSH_NEXT_HOP_IPV4);
if (strPdPushNextHopIPv4 != null) {
List<String> strPdPushNextHopIPv4List = Arrays.asList(strPdPushNextHopIPv4.split(","));
for (String nextHop : strPdPushNextHopIPv4List) {
@@ -288,7 +301,7 @@
pdPushNextHopIPv4.add(Ip4Address.valueOf(nextHop));
}
}
- String strPdPushNextHopIPv6 = Tools.get(properties, "pdPushNextHopIPv6");
+ String strPdPushNextHopIPv6 = Tools.get(properties, PD_PUSH_NEXT_HOP_IPV6);
if (strPdPushNextHopIPv6 != null) {
List<String> strPdPushNextHopIPv6List = Arrays.asList(strPdPushNextHopIPv6.split(","));
for (String nextHop : strPdPushNextHopIPv6List) {
diff --git a/apps/routing/fpm/app/src/main/java/org/onosproject/routing/fpm/OsgiPropertyConstants.java b/apps/routing/fpm/app/src/main/java/org/onosproject/routing/fpm/OsgiPropertyConstants.java
new file mode 100644
index 0000000..2092657
--- /dev/null
+++ b/apps/routing/fpm/app/src/main/java/org/onosproject/routing/fpm/OsgiPropertyConstants.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * 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.
+ */
+
+package org.onosproject.routing.fpm;
+
+/**
+ * Name/Value constants for properties.
+ */
+public final class OsgiPropertyConstants {
+ private OsgiPropertyConstants() {
+ }
+
+ public static final String CLEAR_ROUTES = "clearRoutes";
+ public static final boolean CLEAR_ROUTES_DEFAULT = true;
+
+ public static final String PD_PUSH_ENABLED = "pdPushEnabled";
+ public static final boolean PD_PUSH_ENABLED_DEFAULT = false;
+
+ public static final String PD_PUSH_NEXT_HOP_IPV4 = "pdPushNextHopIPv4";
+ public static final String PD_PUSH_NEXT_HOP_IPV4_DEFAULT = "";
+
+ public static final String PD_PUSH_NEXT_HOP_IPV6 = "pdPushNextHopIPv6";
+ public static final String PD_PUSH_NEXT_HOP_IPV6_DEFAULT = "";
+}