Revision: 170
Author:
sma...@gmail.com
Date: Thu Jan 3 16:44:35 2013
Log: Added a skeleton management interface for omapd, with
configuration options in omapd.conf. Currently only one management command
is supported (mapdump), which dumps the contents of the map database to the
configured log location(s).
http://code.google.com/p/omapd/source/detail?r=170
Modified:
/trunk/main.cpp
/trunk/omapd.conf
/trunk/
omapd.pro
/trunk/omapdconfig.cpp
/trunk/omapdconfig.h
=======================================
--- /trunk/main.cpp Tue Nov 6 14:54:00 2012
+++ /trunk/main.cpp Thu Jan 3 16:44:35 2013
@@ -26,6 +26,7 @@
#include "server.h"
#include "omapdconfig.h"
#include "mapgraphinterface.h"
+#include "managementserver.h"
#if defined(Q_OS_WIN)
#define _MAPGRAPH_PLUGIN_FILENAME "RAMHashTables.dll"
@@ -211,5 +212,14 @@
}
qDebug() << "Started server:" << server;
+ if (omapdConfig->valueFor("management_configuration").toBool()) {
+ ManagementServer *mgmtServer = new ManagementServer(mapGraph);
+ if (!mgmtServer->startListening()) {
+ qDebug() << __PRETTY_FUNCTION__ << ":" << "Could not start
management server";
+ exit(3);
+ }
+ qDebug() << "Started management server:" << mgmtServer;
+ }
+
return a.exec();
}
=======================================
--- /trunk/omapd.conf Wed Dec 26 15:50:26 2012
+++ /trunk/omapd.conf Thu Jan 3 16:44:35 2013
@@ -28,13 +28,34 @@
ShowXMLFilterStatements = 0x0040,
ShowMAPGraphAfterChange = 0x0080,
ShowRawSocketData = 0x0100,
- ShowSearchAlgorithm = 0x200,
- ShowPluginOperations = 0x400
+ ShowSearchAlgorithm = 0x0200,
+ ShowPluginOperations = 0x0400,
+ ShowManagementRequests = 0x0800
-->
<!-- debug_level is a OR combination of the above hex flags. Do the
math! -->
<!-- <debug_level> default is 0x0000 (no debugging) -->
<debug_level>0000</debug_level>
+ <!-- Management interface configuration for omapd. -->
+ <!-- default is enable="yes" -->
+ <management_configuration enable="yes">
+ <!-- You are advised against using anything besides localhost for the
+ management address, since it is an unauthenticated interface. -->
+ <!-- <address> default is QHostAddress::LocalHost -->
+ <address>127.0.0.1</address>
+ <!-- <port> default is 8097 -->
+ <port>8097</port>
+
+ <!-- Management Interface Documentation -->
+ <!-- For now, output is sent to the configured log location(s). -->
+ <!-- Supported commands
+ mapdump : dump contents of map graph database
+ -->
+ <!-- Example usage:
+ echo "mapdump" | nc localhost 8097
+ -->
+ </management_configuration>
+
<service_configuration>
<!--
SupportIfmapV10 = 0x01,
=======================================
--- /trunk/
omapd.pro Mon Apr 23 16:41:36 2012
+++ /trunk/
omapd.pro Thu Jan 3 16:44:35 2013
@@ -18,7 +18,8 @@
clienthandler.cpp \
clientparser.cpp \
mapclient.cpp \
- clientconfiguration.cpp
+ clientconfiguration.cpp \
+ managementserver.cpp
HEADERS += server.h \
identifier.h \
metadata.h \
@@ -32,5 +33,6 @@
clienthandler.h \
clientparser.h \
mapclient.h \
- clientconfiguration.h
+ clientconfiguration.h \
+ managementserver.h
INCLUDEPATH += $$[QT_INSTALL_PREFIX]/src/3rdparty/zlib
=======================================
--- /trunk/omapdconfig.cpp Thu Jan 3 15:52:47 2013
+++ /trunk/omapdconfig.cpp Thu Jan 3 16:44:35 2013
@@ -48,6 +48,7 @@
if (dbgValue & OmapdConfig::ShowRawSocketData) debug |=
OmapdConfig::ShowRawSocketData;
if (dbgValue & OmapdConfig::ShowSearchAlgorithm) debug |=
OmapdConfig::ShowSearchAlgorithm;
if (dbgValue & OmapdConfig::ShowPluginOperations) debug |=
OmapdConfig::ShowPluginOperations;
+ if (dbgValue & OmapdConfig::ShowManagementRequests) debug |=
OmapdConfig::ShowManagementRequests;
return debug;
}
@@ -67,6 +68,7 @@
if (debug.testFlag(OmapdConfig::ShowRawSocketData)) str
+= "ShowRawSocketData | ";
if (debug.testFlag(OmapdConfig::ShowSearchAlgorithm)) str
+= "ShowSearchAlgorithm | ";
if (debug.testFlag(OmapdConfig::ShowPluginOperations)) str
+= "ShowPluginOperations | ";
+ if (debug.testFlag(OmapdConfig::ShowManagementRequests)) str
+= "ShowManagementRequests | ";
if (! str.isEmpty()) {
str = str.left(str.size()-3);
@@ -174,6 +176,9 @@
_omapdConfig.insert("allow_arc_on_ssrc", false);
_omapdConfig.insert("session_metadata_timeout", 180);
_omapdConfig.insert("send_tcp_keepalives", false);
+ _omapdConfig.insert("management_configuration", true);
+ _omapdConfig.insert("mgmt_address", "127.0.0.1");
+ _omapdConfig.insert("mgmt_port", 8097);
// Default authorization is DenyAll
var.setValue(OmapdConfig::authzOptions(0));
@@ -271,6 +276,26 @@
xmlReader.raiseError(QObject::tr("ifmap_metadata_v20_schema_path file not
found"));
addConfigItem(xmlReader.name().toString(),
ifmap20SchemaFile);
+ } else if (xmlReader.name() == "management_configuration")
{
+ bool enable = false;
+ if (xmlReader.attributes().value("enable") == "yes")
+ enable = true;
+ addConfigItem(xmlReader.name().toString(), enable);
+
+ while (xmlReader.readNextStartElement()) {
+ if (xmlReader.name() == "address") {
+ addConfigItem("mgmt_" +
xmlReader.name().toString(), xmlReader.readElementText());
+
+ } else if (xmlReader.name() == "port") {
+ QString value = xmlReader.readElementText();
+ addConfigItem("mgmt_" +
xmlReader.name().toString(), QVariant(value.toUInt()));
+
+ } else {
+ xmlReader.skipCurrentElement();
+ }
+ xmlReader.readNext();
+ }
+
} else if (xmlReader.name() == "service_configuration") {
while (xmlReader.readNextStartElement()) {
=======================================
--- /trunk/omapdconfig.h Tue Nov 6 14:54:00 2012
+++ /trunk/omapdconfig.h Thu Jan 3 16:44:35 2013
@@ -42,7 +42,8 @@
ShowMAPGraphAfterChange = 0x0080,
ShowRawSocketData = 0x0100,
ShowSearchAlgorithm = 0x0200,
- ShowPluginOperations = 0x0400
+ ShowPluginOperations = 0x0400,
+ ShowManagementRequests = 0x0800
};
Q_DECLARE_FLAGS(IfmapDebugOptions, IfmapDebug);
static IfmapDebugOptions debugOptions(unsigned int dbgValue);