Module: sems Branch: master Commit: 4338e3cf7d1cf49eb914c3cf6583aa0db588218e URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=4338e3cf7d1cf49eb914c3cf6583aa0db588218e
Author: Stefan Sayer <[email protected]> Committer: Stefan Sayer <[email protected]> Date: Tue Jul 6 23:47:28 2010 +0200 DSM: createSystemDSM action; DI cmd renamed --- apps/dsm/DSM.cpp | 4 ++-- apps/dsm/DSM.h | 4 ++-- apps/dsm/DSMCoreModule.cpp | 23 +++++++++++++++++++++++ apps/dsm/DSMCoreModule.h | 2 ++ doc/dsm/Readme.dsm.txt | 4 ++-- 5 files changed, 31 insertions(+), 6 deletions(-) diff --git a/apps/dsm/DSM.cpp b/apps/dsm/DSM.cpp index ae1f2d9..80c8576 100644 --- a/apps/dsm/DSM.cpp +++ b/apps/dsm/DSM.cpp @@ -1093,7 +1093,7 @@ void DSMFactory::invoke(const string& method, const AmArg& args, } else if (method == "loadConfig"){ args.assertArrayFmt("ss"); loadConfig(args,ret); - } else if (method == "runSystemDSM"){ + } else if (method == "createSystemDSM"){ args.assertArrayFmt("ss"); string status; if (createSystemDSM(args.get(0).asCStr(), args.get(1).asCStr(), false, status)) { @@ -1114,7 +1114,7 @@ void DSMFactory::invoke(const string& method, const AmArg& args, ret.push(AmArg("hasDSM")); ret.push(AmArg("listDSMs")); ret.push(AmArg("registerApplication")); - ret.push(AmArg("runSystemDSM")); + ret.push(AmArg("createSystemDSM")); } else throw AmDynInvoke::NotImplemented(method); } diff --git a/apps/dsm/DSM.h b/apps/dsm/DSM.h index 1815c74..8d0e017 100644 --- a/apps/dsm/DSM.h +++ b/apps/dsm/DSM.h @@ -111,8 +111,6 @@ class DSMFactory DSMChartReader preload_reader; - bool createSystemDSM(const string& config_name, const string& start_diag, bool reload, string& status); - void listDSMs(const AmArg& args, AmArg& ret); void hasDSM(const AmArg& args, AmArg& ret); void reloadDSMs(const AmArg& args, AmArg& ret); @@ -145,6 +143,8 @@ public: void postEvent(AmEvent* e); + bool createSystemDSM(const string& config_name, const string& start_diag, bool reload, string& status); + }; #endif diff --git a/apps/dsm/DSMCoreModule.cpp b/apps/dsm/DSMCoreModule.cpp index b322c55..be35bfd 100644 --- a/apps/dsm/DSMCoreModule.cpp +++ b/apps/dsm/DSMCoreModule.cpp @@ -32,6 +32,7 @@ #include "AmSessionContainer.h" #include "AmUtils.h" #include "AmEventDispatcher.h" +#include "DSM.h" #include "jsonArg.h" @@ -97,6 +98,7 @@ DSMAction* DSMCoreModule::getAction(const string& from_str) { DEF_CMD("registerEventQueue", SCRegisterEventQueueAction); DEF_CMD("unregisterEventQueue", SCUnregisterEventQueueAction); + DEF_CMD("createSystemDSM", SCCreateSystemDSMAction); if (cmd == "DI") { SCDIAction * a = new SCDIAction(params, false); @@ -1219,3 +1221,24 @@ EXEC_ACTION_START(SCUnregisterEventQueueAction) { } AmEventDispatcher::instance()->delEventQueue(q_name); } EXEC_ACTION_END; + +CONST_ACTION_2P(SCCreateSystemDSMAction,',', false); +EXEC_ACTION_START(SCCreateSystemDSMAction) { + string conf_name = resolveVars(par1, sess, sc_sess, event_params); + string script_name = resolveVars(par2, sess, sc_sess, event_params); + + if (conf_name.empty() || script_name.empty()) { + throw DSMException("core", "cause", "parameters missing - " + "need both conf_name and script_name for createSystemDSM"); + } + + DBG("creating system DSM conf_name %s, script_name %s\n", + conf_name.c_str(), script_name.c_str()); + string status; + if (!DSMFactory::instance()->createSystemDSM(conf_name, script_name, false, status)) { + ERROR("creating system DSM: %s\n", status.c_str()); + throw DSMException("core", "cause", status); + } + +} EXEC_ACTION_END; + diff --git a/apps/dsm/DSMCoreModule.h b/apps/dsm/DSMCoreModule.h index 28c18d0..c0e0cf6 100644 --- a/apps/dsm/DSMCoreModule.h +++ b/apps/dsm/DSMCoreModule.h @@ -107,6 +107,8 @@ DEF_ACTION_2P(SCB2BSetHeadersAction); DEF_ACTION_1P(SCRegisterEventQueueAction); DEF_ACTION_1P(SCUnregisterEventQueueAction); +DEF_ACTION_2P(SCCreateSystemDSMAction); + class SCDIAction : public DSMAction { vector<string> params; diff --git a/doc/dsm/Readme.dsm.txt b/doc/dsm/Readme.dsm.txt index 412d51b..13d0816 100644 --- a/doc/dsm/Readme.dsm.txt +++ b/doc/dsm/Readme.dsm.txt @@ -65,7 +65,7 @@ call and media related functionality is not available (and will throw exceptions with type 'core'). A system DSM receives the "startup" event on start of the server, or if -it is created via runSystemDSM DI call. It gets a "reload" event if the +it is created via createSystemDSM DI call. It gets a "reload" event if the system DSM is created by a live config reload. On server shutdown, a system DSM receives a "system" event with @@ -124,7 +124,7 @@ loadConfig(string conf_file_name, string conf_name) (re)load application configuration and script like a file in conf_dir -runSystemDSM(string conf_name, string start_diag) +createSystemDSM(string conf_name, string start_diag) run a system DSM (i.e. a DSM thread not connected to a session) using scripts/configuration from conf_name. conf_name=='main' for main scripts/main config (from dsm.conf) _______________________________________________ Semsdev mailing list [email protected] http://lists.iptel.org/mailman/listinfo/semsdev
