summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevron Rees <kevron.m.rees@intel.com>2015-01-09 14:07:55 -0800
committerKevron Rees <kevron.m.rees@intel.com>2015-01-09 14:07:55 -0800
commita4390c9b7f9677dde98fe101a16dce975b1f7565 (patch)
tree831f112981701bbf23801d71d481a84cff52b532
parentebc6d4db9a0f2f522124b62a68d39923d05a8cc2 (diff)
downloadautomotive-message-broker-a4390c9b7f9677dde98fe101a16dce975b1f7565.tar.gz
[ambctl] - enablePlugin command
-rw-r--r--CMakeLists.txt1
-rw-r--r--ambd/CMakeLists.txt2
-rw-r--r--ambd/config.in19
-rw-r--r--ambd/config.in.json6
-rw-r--r--plugins/CMakeLists.txt5
-rw-r--r--plugins/dbus/CMakeLists.txt4
-rw-r--r--plugins/dbus/dbus.in.json6
-rw-r--r--plugins/examplesink.in.json6
-rw-r--r--plugins/examplesource.in.json6
-rw-r--r--tools/ambctl.py52
10 files changed, 84 insertions, 23 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 43d79db7..1aeb7170 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -22,6 +22,7 @@ set (LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/${CMAKE_LIBRARY_A
set (PLUGIN_INSTALL_PATH "${LIB_INSTALL_DIR}/${PROJECT_NAME}")
set (INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include")
set (DOC_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/doc/packages/${PROJECT_NAME}")
+set (PLUGIN_SEGMENT_INSTALL_PATH "/etc/ambd/plugins.d")
option(qtmainloop "Use QCoreApplication mainloop " OFF)
option(websocket_plugin "websocket source and sink plugins" OFF)
diff --git a/ambd/CMakeLists.txt b/ambd/CMakeLists.txt
index d1af5653..3ca9edaa 100644
--- a/ambd/CMakeLists.txt
+++ b/ambd/CMakeLists.txt
@@ -34,7 +34,7 @@ add_executable(ambd ${ambd_sources})
include_directories(${include_dirs} )
target_link_libraries(ambd ${link_libraries} dl amb)
-configure_file (${CMAKE_CURRENT_SOURCE_DIR}/config.in ${CMAKE_CURRENT_BINARY_DIR}/config @ONLY)
+configure_file (${CMAKE_CURRENT_SOURCE_DIR}/config.in.json ${CMAKE_CURRENT_BINARY_DIR}/config @ONLY)
install (TARGETS ambd RUNTIME DESTINATION bin)
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/config DESTINATION /etc/ambd)
diff --git a/ambd/config.in b/ambd/config.in
deleted file mode 100644
index 850ec786..00000000
--- a/ambd/config.in
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "sources" : [
- {
- "name" : "ExampleSouce",
- "path" : "@PLUGIN_INSTALL_PATH@/examplesourceplugin.so"
- }
- ],
- "sinks": [
- {
- "name" : "ExampleSink",
- "path" : "@PLUGIN_INSTALL_PATH@/examplesinkplugin.so"
- },
- {
- "name" : "DBusSink",
- "path" : "@PLUGIN_INSTALL_PATH@/dbussinkplugin.so"
- }
- ]
-}
-
diff --git a/ambd/config.in.json b/ambd/config.in.json
new file mode 100644
index 00000000..1e17508a
--- /dev/null
+++ b/ambd/config.in.json
@@ -0,0 +1,6 @@
+{
+ "plugins" : "@PLUGIN_SEGMENT_INSTALL_PATH@",
+ "sources" : [ ],
+ "sinks": [ ]
+}
+
diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt
index 45802660..32a41be6 100644
--- a/plugins/CMakeLists.txt
+++ b/plugins/CMakeLists.txt
@@ -21,7 +21,12 @@ install(TARGETS examplesourceplugin LIBRARY DESTINATION ${PLUGIN_INSTALL_PATH})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/exampleplugins.README.txt ${CMAKE_CURRENT_BINARY_DIR}/exampleplugins.README @ONLY)
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/examplesource.in.json ${CMAKE_CURRENT_BINARY_DIR}/examplesource @ONLY)
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/examplesink.in.json ${CMAKE_CURRENT_BINARY_DIR}/examplesink @ONLY)
+
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/exampleplugins.README DESTINATION ${DOC_INSTALL_DIR}/plugins)
+install (FILES ${CMAKE_CURRENT_BINARY_DIR}/examplesource DESTINATION ${PLUGIN_SEGMENT_INSTALL_PATH})
+install (FILES ${CMAKE_CURRENT_BINARY_DIR}/examplesink DESTINATION ${PLUGIN_SEGMENT_INSTALL_PATH})
add_subdirectory(common)
diff --git a/plugins/dbus/CMakeLists.txt b/plugins/dbus/CMakeLists.txt
index 67d6ba65..c4e6fef1 100644
--- a/plugins/dbus/CMakeLists.txt
+++ b/plugins/dbus/CMakeLists.txt
@@ -25,8 +25,10 @@ set(dbus_mapping_headers ${dbus_mapping_headers} ${CMAKE_CURRENT_SOURCE_DIR}/par
set(dbus_mapping_headers ${dbus_mapping_headers} ${CMAKE_CURRENT_SOURCE_DIR}/drivingsafety.h CACHE INTERNAL "dbus mapping headers")
set(dbus_mapping_headers ${dbus_mapping_headers} ${CMAKE_CURRENT_SOURCE_DIR}/personalization.h CACHE INTERNAL "dbus mapping headers")
-
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/README ${CMAKE_CURRENT_BINARY_DIR}/dbus.README @ONLY)
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/dbus.README DESTINATION ${DOC_INSTALL_DIR}/plugins)
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dbus.in.json ${CMAKE_CURRENT_BINARY_DIR}/dbus @ONLY)
+install (FILES ${CMAKE_CURRENT_BINARY_DIR}/dbus DESTINATION ${PLUGIN_SEGMENT_INSTALL_PATH})
+
add_subdirectory(amb-qt)
diff --git a/plugins/dbus/dbus.in.json b/plugins/dbus/dbus.in.json
new file mode 100644
index 00000000..c924d6c9
--- /dev/null
+++ b/plugins/dbus/dbus.in.json
@@ -0,0 +1,6 @@
+{
+ "name" : "DBusSink",
+ "path" : "@PLUGIN_INSTALL_PATH@/dbussinkplugin.so",
+ "frequency" : "30",
+ "enabled" : true
+}
diff --git a/plugins/examplesink.in.json b/plugins/examplesink.in.json
new file mode 100644
index 00000000..254ce541
--- /dev/null
+++ b/plugins/examplesink.in.json
@@ -0,0 +1,6 @@
+{
+ "name" : "ExampleSink",
+ "path" : "@PLUGIN_INSTALL_PATH@/examplesinkplugin.so",
+ "frequency" : "30",
+ "enabled" : true
+}
diff --git a/plugins/examplesource.in.json b/plugins/examplesource.in.json
new file mode 100644
index 00000000..5a9680ae
--- /dev/null
+++ b/plugins/examplesource.in.json
@@ -0,0 +1,6 @@
+{
+ "name" : "ExampleSouce",
+ "path" : "@PLUGIN_INSTALL_PATH@/examplesourceplugin.so",
+ "delay" : "6",
+ "enabled" : true
+}
diff --git a/tools/ambctl.py b/tools/ambctl.py
index 581f1062..0de96a17 100644
--- a/tools/ambctl.py
+++ b/tools/ambctl.py
@@ -41,6 +41,7 @@ class Autocomplete:
self.commands.append(Autocomplete.Cmd('listen', 'Listen for changes on an ObjectName'))
self.commands.append(Autocomplete.Cmd('set', 'Set a property for an ObjectName'))
self.commands.append(Autocomplete.Cmd('getHistory', 'Get logged data within a time range'))
+ self.commands.append(Autocomplete.Cmd('enablePlugin', 'Get logged data within a time range'))
self.commands.append(Autocomplete.Cmd('quit', 'Exit ambctl'))
bus = dbus.SystemBus()
@@ -89,6 +90,38 @@ def help():
def changed(interface, properties, invalidated):
print json.dumps(properties, indent=2)
+def listPlugins():
+ list = {}
+ for root, dirs, files in os.walk('@PLUGIN_SEGMENT_INSTALL_PATH@'):
+ for file in files:
+ fullpath = root + "/" + file;
+ pluginFile = open(fullpath)
+ data = json.load(pluginFile)
+ pluginFile.close()
+ list.update({data["name"]:fullpath})
+
+ return list
+
+def enablePlugin(pluginName, enabled):
+ list = listPlugins()
+ if pluginName not in list:
+ return false
+
+ path = list[pluginName]
+ try :
+ file = open(path, 'rw+')
+ data = json.load(file)
+ data["enabled"] = enabled;
+ fixedData = json.JSONEncoder().encode(data)
+ file.truncate(0)
+ file.write(fixedData)
+ file.close()
+ except IOError, error:
+ print error
+ except:
+ print "Unknown error"
+
+
def processCommand(command, commandArgs, noMain=True):
if command == 'help':
@@ -189,6 +222,22 @@ def processCommand(command, commandArgs, noMain=True):
object = managerInterface.FindObjectForZone(objectName, zone);
propertiesInterface = dbus.Interface(bus.get_object("org.automotive.message.broker", object),"org.automotive."+objectName)
print json.dumps(propertiesInterface.GetHistory(start, end), indent=2)
+ elif command == "enablePlugin":
+ if len(commandArgs) == 0:
+ commandArgs = ['help']
+ if commandArgs[0] == 'help':
+ print "[list] [pluginName] [on/off]"
+ return 1
+ elif commandArgs[0] == 'list':
+ for name, path in listPlugins():
+ print name
+ return 1
+ else:
+ if len(commandArgs) < 2:
+ return 1
+ enablePlugin(commandArgs[0], commandArgs[1] == "on")
+ return 1
+
else:
print "Invalid command"
return 1
@@ -404,8 +453,7 @@ if args.command == "stdin":
row = ""
endRow = -1
if len(results) >= i+3:
- endRow = 3
- print "endRow: ", endRow
+ endRow = 2
for col in results[i : endRow]:
row += col
for i in range((longestLen + 5) - len(col)):