[PATCH v2] Core: Start daemons through systemd if possible
by Zane Bitter
* Read the broker and port options from the environment as well as from the
CLI. This makes it easier to configure agents through systemd, which is
replacing SysV init in Fedora.
* Also set up the .service files to correctly launch daemons with the correct
configuration.
* Turn matahari-brokerd into a wrapper script which can interpret the
matahari-broker sysconfig file for qpidd.
* Pass only the correct args for the daemon type. Agents get
MATAHARI_AGENT_ARGS; consoles get MATAHARI_CONSOLE_ARGS instead.
Signed-off-by: Zane Bitter <zbitter(a)redhat.com>
---
CMakeLists.txt | 18 +++++++
matahari-broker.init.in | 25 +++++-----
matahari-broker.service | 19 ++++++++
matahari-brokerd.in | 8 +++
matahari.init.in | 41 +++++++----------
matahari.service.in | 10 ++--
matahari.spec.in | 9 +++-
src/CMakeLists.txt | 2 +
src/cmake/modules/MatahariMacros.cmake | 2 -
src/lib/mh_agent.cpp | 78 +++++++++++++++++++++++---------
src/sysconfig/CMakeLists.txt | 10 ++--
11 files changed, 148 insertions(+), 74 deletions(-)
create mode 100644 matahari-broker.service
create mode 100644 matahari-brokerd.in
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a3d34b2..815c73c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -109,6 +109,9 @@ else(WIN32)
set (CPACK_GENERATOR "TGZ")
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/matahari-brokerd.in
+ ${CMAKE_CURRENT_BINARY_DIR}/matahari-brokerd)
+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/matahari.init.in
${CMAKE_CURRENT_BINARY_DIR}/matahari.init)
@@ -118,6 +121,13 @@ else(WIN32)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/matahari-broker.sysconf.in
${CMAKE_CURRENT_BINARY_DIR}/matahari-broker.sysconf)
+ install(DIRECTORY DESTINATION ${localstatedir}/lib/matahari
+ DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
+ GROUP_READ GROUP_WRITE GROUP_EXECUTE)
+ install(CODE "execute_process(COMMAND chown root:qpidd ${localstatedir}/lib/matahari)")
+
+ install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/matahari-brokerd DESTINATION sbin)
+
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/matahari-broker DESTINATION ${initdir})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/matahari.sysconf DESTINATION ${sysconfdir}/sysconfig RENAME matahari)
@@ -126,6 +136,14 @@ else(WIN32)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/matahari-broker.conf DESTINATION ${sysconfdir})
+ # Check for systemd
+ include(FindPkgConfig)
+ pkg_check_modules(systemd systemd)
+
+ if(systemd_FOUND)
+ set(systemdunitdir "/lib/systemd/system")
+ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/matahari-broker.service DESTINATION ${systemdunitdir})
+ endif(systemd_FOUND)
endif(WIN32)
INCLUDE(InstallRequiredSystemLibraries)
diff --git a/matahari-broker.init.in b/matahari-broker.init.in
index aee1d6d..e74926c 100755
--- a/matahari-broker.init.in
+++ b/matahari-broker.init.in
@@ -35,27 +35,23 @@
# description: Matahari Broker is an AMQP broker. It receives, stores, routes and forwards messages using the AMQP protcol.
# processname: qpidd
-prog=matahari-brokerd
+prog="matahari-brokerd --pid-dir @localstatedir@/run/matahari"
+proc=qpidd
lockfile=@localstatedir@/lock/subsys/matahari-broker
pidfile=@localstatedir(a)/run/matahari-broker.pid
# Turn off automatic systemd redirects
-SYSTEMCTL_SKIP_REDIRECT=1
+#SYSTEMCTL_SKIP_REDIRECT=1
# Source function library.
. @sysconfdir(a)/rc.d/init.d/functions
-if [ -f @sysconfdir@/sysconfig/matahari-broker ] ; then
- . @sysconfdir@/sysconfig/matahari-broker
-fi
-
RETVAL=0
start() {
echo -n $"Starting Matahari broker daemon: "
- install -o root -g qpidd -m 770 -d @localstatedir@/lib/matahari
install -o root -g qpidd -m 775 -d @localstatedir@/run/matahari
- daemon --pidfile $pidfile --check $prog --user qpidd /usr/sbin/$prog --daemon --pid-dir @localstatedir@/run/matahari --data-dir @localstatedir@/lib/matahari $QPIDD_OPTIONS
+ daemon --pidfile $pidfile --check $proc --user qpidd /usr/sbin/$prog --daemon
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch $lockfile
@@ -63,14 +59,14 @@ start() {
touch $pidfile
chown qpidd.qpidd $pidfile
[ -x /sbin/restorecon ] && /sbin/restorecon $pidfile
- runuser -s /bin/sh qpidd -c "/usr/sbin/$prog --check --pid-dir @localstatedir@/run/matahari $QPIDD_OPTIONS > $pidfile"
+ runuser -s /bin/sh qpidd -c "/usr/sbin/$prog --check > $pidfile"
fi
return $RETVAL
}
stop() {
echo -n $"Stopping Matahari broker daemon: "
- killproc -p $pidfile $prog
+ killproc -p $pidfile $proc
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f $lockfile $pidfile
@@ -88,11 +84,14 @@ restart() {
# See how we were called.
case "$1" in
- start|stop|restart|reload)
- $1
+ start)
+ status -p $pidfile -l $lockfile $proc >/dev/null || $1
+ ;;
+ stop|restart|reload)
+ $1
;;
status)
- status -p $pidfile -l $lockfile $prog
+ status -p $pidfile -l $lockfile $proc
RETVAL=$?
;;
force-reload)
diff --git a/matahari-broker.service b/matahari-broker.service
new file mode 100644
index 0000000..7e6e9f7
--- /dev/null
+++ b/matahari-broker.service
@@ -0,0 +1,19 @@
+[Unit]
+Description=Matahari Broker is an AMQP broker. It receives, stores, routes and forwards messages using the AMQP protcol.
+After=syslog.target network.target
+Requires=syslog.target network.target
+
+[Install]
+WantedBy=multi-user.target
+
+[Service]
+Type=simple
+NotifyAccess=all
+SysVStartPriority=85
+User=qpidd
+Group=qpidd
+
+ExecStart=/usr/sbin/matahari-brokerd
+
+# Restart options include: no, on-success, on-failure, on-abort or always
+Restart=on-failure
diff --git a/matahari-brokerd.in b/matahari-brokerd.in
new file mode 100644
index 0000000..0bab652
--- /dev/null
+++ b/matahari-brokerd.in
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+if [ -f @sysconfdir@/sysconfig/matahari-broker ]; then
+ . @sysconfdir@/sysconfig/matahari-broker
+fi
+
+/usr/sbin/qpidd --data-dir @localstatedir@/lib/matahari $QPIDD_OPTIONS $*
+
diff --git a/matahari.init.in b/matahari.init.in
index ea51d2d..75f9739 100644
--- a/matahari.init.in
+++ b/matahari.init.in
@@ -1,25 +1,25 @@
#!/bin/sh
# the following is chkconfig init header
-# matahari-@BASE@: QMF agent for @BASE@
+# matahari-@BASE@@BASE_SUB@: Matahari QMF @BASE@@BASE_SUB@ daemon
### BEGIN INIT INFO
# Provides:
# Required-Start: $local_fs matahari-broker
# Required-Stop: $local_fs matahari-broker
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
-# Short-Description: Starts and stops the @BASE@ matahari agent
-# Description: Matahari agent providing a @BASE@-related API using the AMQP protocol.
+# Short-Description: Starts and stops the @BASE@@BASE_SUB@ matahari daemon
+# Description: Matahari @BASE@@BASE_SUB@ daemon using the AMQP protocol.
### END INIT INFO
# chkconfig: - 99 01
-# description: Matahari agent providing a @BASE@-related API using the AMQP protocol.
-# processname: matahari-@BASE@d
-# pidfile: @localstatedir@/run/matahari-@BASE@.pid
+# description: Matahari @BASE@@BASE_SUB@ daemon using the AMQP protocol.
+# processname: matahari-@BASE@@BASE_SUB@d
+# pidfile: @localstatedir@/run/matahari-@BASE@@BASE_SUB@.pid
#
# Turn off automatic systemd redirects
-# SYSTEMCTL_SKIP_REDIRECT=1
+#SYSTEMCTL_SKIP_REDIRECT=1
# Source function library.
. @sysconfdir(a)/rc.d/init.d/functions
@@ -33,21 +33,16 @@ test -f @sysconfdir@/sysconfig/matahari && . @sysconfdir@/sysconfig/matahari
start() {
echo -n $"Starting the $SERVICE daemon: "
- if [ ! -z "$MATAHARI_BROKER" ]; then
- MATAHARI_AGENT_ARGS="$MATAHARI_AGENT_ARGS --broker $MATAHARI_BROKER"
- fi
- if [ ! -z "$MATAHARI_PORT" ]; then
- MATAHARI_AGENT_ARGS="$MATAHARI_AGENT_ARGS --port $MATAHARI_PORT"
- fi
- if [ ! -z "$@BASE@_AGENT_ARGS" ]; then
- MATAHARI_AGENT_ARGS="$MATAHARI_AGENT_ARGS $@BASE@_AGENT_ARGS"
- fi
- if [ ! -z "$@BASE@_CONSOLE_ARGS" ]; then
- MATAHARI_AGENT_ARGS="$MATAHARI_AGENT_ARGS $MATAHARI_CONSOLE_ARGS $@BASE@_CONSOLE_ARGS"
+ MATAHARI_ARGS="$MATAHARI_@DAEMON_TYPE@_ARGS $@BASE@_@DAEMON_TYPE@_ARGS"
+ if [ -n "$MATAHARI_PORT" ]; then
+ MATAHARI_ARGS="--port $MATAHARI_PORT $MATAHARI_ARGS"
+ fi
+ if [ -n "$MATAHARI_BROKER" ]; then
+ MATAHARI_ARGS="--broker $MATAHARI_BROKER $MATAHARI_ARGS"
fi
- daemon $PROCESS $MATAHARI_AGENT_ARGS --daemon
+ daemon $PROCESS $MATAHARI_ARGS --daemon
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch @localstatedir@/lock/subsys/$SERVICE
@@ -82,12 +77,8 @@ reload() {
# See how we were called.
case "$1" in
start)
- if
- ! status $PROCESS
- then
- $1
- fi
- ;;
+ status $PROCESS >/dev/null || $1
+ ;;
stop|restart|reload)
$1
;;
diff --git a/matahari.service.in b/matahari.service.in
index 2db4f9b..2a7a741 100644
--- a/matahari.service.in
+++ b/matahari.service.in
@@ -1,6 +1,6 @@
[Unit]
-Description=Matahari agent providing a @BASE@-related API using the AMQP protocol.
-After=syslog.target network.target
+Description=Matahari @BASE@@BASE_SUB@ daemon using the AMQP protocol.
+After=syslog.target network.target matahari-broker.service
Requires=syslog.target network.target
[Install]
@@ -8,13 +8,11 @@ WantedBy=multi-user.target
[Service]
Type=simple
-KillMode=main
NotifyAccess=main
SysVStartPriority=99
-GuessMainPID=forking
-EnvironmentFile=@sysconfdir@/sysconfig/matahari
-ExecStart=matahari-qmf-@BASE@d
+EnvironmentFile=-@sysconfdir@/sysconfig/matahari
+ExecStart=/usr/sbin/matahari-qmf-@BASE@@BASE_SUB@d $MATAHARI_@DAEMON_TYPE@_ARGS $@BASE@_@DAEMON_TYPE@_ARGS
# Restart options include: no, on-success, on-failure, on-abort or always
Restart=on-failure
diff --git a/matahari.spec.in b/matahari.spec.in
index 9671f3b..5031789 100644
--- a/matahari.spec.in
+++ b/matahari.spec.in
@@ -189,7 +189,6 @@ make DESTDIR=%{buildroot} install
%{__install} matahari-broker $RPM_BUILD_ROOT/%{_sysconfdir}/rc.d/init.d/matahari-broker
%{__install} matahari-broker.sysconf $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/matahari-broker
-%{__ln_s} qpidd $RPM_BUILD_ROOT/%{_sbindir}/matahari-brokerd
%{__install} -d -m0770 $RPM_BUILD_ROOT/%{_localstatedir}/lib/%{name}
%{__install} -d -m0775 $RPM_BUILD_ROOT/%{_localstatedir}/run/%{name}
@@ -409,6 +408,10 @@ test "x%{buildroot}" != "x" && rm -rf %{buildroot}
%if %{with qmf}
%attr(755, root, root) %{_initddir}/matahari-sysconfig-console
%attr(755, root, root) %{_sbindir}/matahari-qmf-sysconfig-consoled
+
+%if %{defined _unitdir}
+%{_unitdir}/matahari-sysconfig-console.service
+%endif
%endif
%if %{with qmf}
@@ -420,6 +423,10 @@ test "x%{buildroot}" != "x" && rm -rf %{buildroot}
%{_sbindir}/matahari-brokerd
%doc AUTHORS COPYING
+%if %{defined _unitdir}
+%{_unitdir}/matahari-broker.service
+%endif
+
%else
%exclude %{_sysconfdir}/matahari-broker.conf
%endif
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 323c5e4..cb47956 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -31,6 +31,8 @@ set(AGENT_MAN_DESC "Part of the Matahari suite of remote agents")
set(CONSOLE_MAN_SECTION "8")
set(CONSOLE_MAN_DESC "Console for the Matahari suite of remote agents")
+set(DAEMON_TYPE "AGENT")
+
include(FindPkgConfig)
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
diff --git a/src/cmake/modules/MatahariMacros.cmake b/src/cmake/modules/MatahariMacros.cmake
index 9f04d4d..65e489b 100644
--- a/src/cmake/modules/MatahariMacros.cmake
+++ b/src/cmake/modules/MatahariMacros.cmake
@@ -120,6 +120,6 @@ macro(create_service_scripts BASE)
if(systemd_FOUND)
configure_file(${CMAKE_SOURCE_DIR}/matahari.service.in ${CMAKE_CURRENT_BINARY_DIR}/matahari-${BASE}.service)
- install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/matahari-${BASE}.service DESTINATION ${systemdunitdir})
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/matahari-${BASE}.service DESTINATION ${systemdunitdir})
endif(systemd_FOUND)
endmacro(create_service_scripts)
diff --git a/src/lib/mh_agent.cpp b/src/lib/mh_agent.cpp
index d2b9ee6..0b8fe7d 100644
--- a/src/lib/mh_agent.cpp
+++ b/src/lib/mh_agent.cpp
@@ -56,6 +56,8 @@ using namespace qpid::management;
using namespace qpid::client;
using namespace std;
+typedef qpid::types::Variant::Map OptionsMap;
+
struct MatahariAgentImpl {
GMainLoop *_mainloop;
@@ -152,28 +154,14 @@ static mh_option matahari_options[MAX_CHAR];
static int
map_option(int code, const char *name, const char *arg, void *userdata)
{
- qpid::types::Variant::Map *options = static_cast<qpid::types::Variant::Map*>(userdata);
+ OptionsMap *options = (OptionsMap*)userdata;
if(strcmp(name, "verbose") == 0) {
mh_log_level++;
mh_enable_stderr(1);
} else if(strcmp(name, "broker") == 0) {
-#ifdef WIN32
(*options)["servername"] = arg;
-#else
- int rc;
- struct addrinfo hints, *res;
-
- memset(&hints, 0, sizeof(struct addrinfo));
- hints.ai_family = AF_UNSPEC;
- rc = getaddrinfo(arg, NULL, &hints, &res);
- if (rc == 0) {
- (*options)["servername"] = arg;
- } else {
- mh_err("Broker '%s' is not resolvable - ignoring", arg);
- }
-#endif
} else if(strcmp(name, "port") == 0) {
(*options)["serverport"] = atoi(arg);
@@ -219,7 +207,7 @@ ssl_option(int code, const char *name, const char *arg, void *userdata)
static int
connection_option(int code, const char *name, const char *arg, void *userdata)
{
- qpid::types::Variant::Map *options = static_cast<qpid::types::Variant::Map*>(userdata);
+ OptionsMap *options = (OptionsMap*)userdata;
if(strcmp(name, "service") == 0) {
(*options)["sasl-service"] = arg;
@@ -252,7 +240,7 @@ int print_help(int code, const char *name, const char *arg, void *userdata)
}
qpid::messaging::Connection
-mh_connect(qpid::types::Variant::Map mh_options, qpid::types::Variant::Map amqp_options, int retry)
+mh_connect(OptionsMap mh_options, OptionsMap amqp_options, int retry)
{
int retries = 0;
int backoff = 0;
@@ -326,11 +314,51 @@ mh_connect(qpid::types::Variant::Map mh_options, qpid::types::Variant::Map amqp_
return NULL;
}
-qpid::types::Variant::Map
-mh_parse_options(const char *proc_name, int argc, char **argv, qpid::types::Variant::Map &options)
+#ifndef WIN32
+static void
+read_environment(OptionsMap& options)
+{
+ const char *data;
+
+ data = getenv("MATAHARI_BROKER");
+ if (data && strlen(data)) {
+ options["servername"] = data;
+ }
+
+ data = getenv("MATAHARI_PORT");
+ if (data && strlen(data)) {
+ options["serverport"] = data;
+ }
+}
+
+static void
+verify_broker_option(OptionsMap& options)
+{
+ if (!options.count("servername")) {
+ return;
+ }
+
+ struct addrinfo hints, *res;
+ std::string broker = options["servername"];
+
+ memset(&hints, 0, sizeof(struct addrinfo));
+ hints.ai_family = AF_UNSPEC;
+
+ if (getaddrinfo(broker.c_str(), NULL, &hints, &res) == 0) {
+ freeaddrinfo(res);
+ } else {
+ OptionsMap::iterator iter = options.find("servername");
+ options.erase(iter);
+ mh_err("Broker '%s' is not resolvable - ignoring", broker.c_str());
+ }
+}
+#endif
+
+OptionsMap
+mh_parse_options(const char *proc_name, int argc, char **argv, OptionsMap &options)
{
std::stringstream url;
- qpid::types::Variant::Map amqp_options;
+ OptionsMap amqp_options;
int lpc = 0;
@@ -409,6 +437,8 @@ mh_parse_options(const char *proc_name, int argc, char **argv, qpid::types::Vari
}
}
+ read_environment(options);
+
while ((arg = getopt_long(argc, argv, opt_string, long_opts, &idx)) != -1) {
if(arg == 'h') {
print_help('h', NULL, NULL, (void*)proc_name);
@@ -425,6 +455,10 @@ mh_parse_options(const char *proc_name, int argc, char **argv, qpid::types::Vari
}
}
free(long_opts);
+
+ if (!options.count("dns-srv")) {
+ verify_broker_option(options);
+ }
#endif
#ifdef MH_SSL
@@ -491,7 +525,7 @@ qmf::AgentSession& MatahariAgent::getSession(void)
int
MatahariAgent::init(int argc, char **argv, const char* proc_name)
{
- qpid::types::Variant::Map options;
+ OptionsMap options;
int res = 0;
std::stringstream logname;
logname << "matahari-" << proc_name;
@@ -500,7 +534,7 @@ MatahariAgent::init(int argc, char **argv, const char* proc_name)
mh_log_init(proc_name, mh_log_level, FALSE);
mh_add_option('d', no_argument, "daemon", "run as a daemon", NULL, mh_should_daemonize);
- qpid::types::Variant::Map amqp_options = mh_parse_options(proc_name, argc, argv, options);
+ OptionsMap amqp_options = mh_parse_options(proc_name, argc, argv, options);
/* Re-initialize logging now that we've completed option processing */
diff --git a/src/sysconfig/CMakeLists.txt b/src/sysconfig/CMakeLists.txt
index 0f988e6..e8eda56 100644
--- a/src/sysconfig/CMakeLists.txt
+++ b/src/sysconfig/CMakeLists.txt
@@ -18,12 +18,10 @@ if(WITH-QMF)
create_manpage(${QMF_AGENT} ${AGENT_MAN_SECTION} ${AGENT_MAN_DESC})
create_service_scripts(${BASE})
- if(NOT WIN32)
- set(BASE_SUB "-console")
- configure_file(${CMAKE_SOURCE_DIR}/matahari.init.in ${CMAKE_CURRENT_BINARY_DIR}/matahari-${BASE}${BASE_SUB})
- install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/matahari-${BASE}${BASE_SUB} DESTINATION ${initdir})
- endif(NOT WIN32)
-
+ set(BASE_SUB "-console")
+ set(DAEMON_TYPE "CONSOLE")
+ create_service_scripts(${BASE}${BASE_SUB})
+
install(TARGETS ${QMF_AGENT} DESTINATION sbin)
install(TARGETS ${QMF_CONSOLE} DESTINATION sbin)
endif(WITH-QMF)
12 years, 8 months
Re: [Matahari] matahari and gofer
by Zane Bitter
[Adding this thread to the mailing list, as someone else may have a
better answer, and it may be useful to other people writing agents in
the future.]
On 26/08/11 23:42, Jeff Ortel wrote:
> Zane,
>
> I wrote a (test) agent named "package" which defines a class named
> "Package" with a method named: install(const char* name).
>
> After launching the agent, I'm seeing the following:
>
> [jortel@pulp package]$ qmf-tool localhost:49000
> Management Tool for QMF
> qmf: list agents
> QMF Agents:
> Id Vendor Product Instance Epoch
> ==================================================================================
>
> * 1 apache.org qpidd abd86426-651a-4cad-9fbc-bda2733b892c 2
> 2 matahariproject.org host c9161f88-293f-48af-90c2-c1f018ee8bf5 1
> 3 matahariproject.org package 08e69a0d-b69b-44e0-86d0-d85f743d92d2 1
> qmf: set default 3
> Default Agent:
> matahariproject.org:package:08e69a0d-b69b-44e0-86d0-d85f743d92d2
> qmf: list classes
> Classes:
> qmf:
>
> Can you think of any reason the package/class isn't showing up? How can
> I debug this? Are there log files I can look at? Suggestions?
>
> Thanks,
>
> Jeff
Good question. I would have guessed that it should show up as soon as
you register the schema (i.e. the following code from the
https://github.com/matahari/matahari/wiki/How-to-create-agent page):
int
TestAgent::setup(qmf::AgentSession session)
{
_package.configure(session);
(configure(session) calls session.registerSchema(), assuming you use the
code that matahari autogenerates from the XML schema file.) Another
possibility is that _package is not set up as an instance variable; I
imagine that the schema gets de-registered if it goes out of scope and
gets deleted.
As far as debugging goes, you can turn on the --trace option in the
broker by adding it to the QPIDD_OPTIONS string in
/etc/sysconfig/matahari-broker. You can increase the log level for the
agents by adding the -v option to MATAHARI_AGENT_ARGS in
/etc/sysconfig/matahari (this option can be added multiple times to
increase the log level by several steps). Everything is logged to syslog.
cheers,
Zane.
12 years, 8 months
[PATCH] Build: Pass full binary path to help2man
by Zane Bitter
Previously the binary was being picked up from the current $PATH.
Signed-off-by: Zane Bitter <zbitter(a)redhat.com>
---
src/cmake/modules/MatahariMacros.cmake | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/cmake/modules/MatahariMacros.cmake b/src/cmake/modules/MatahariMacros.cmake
index 65e489b..720d03c 100644
--- a/src/cmake/modules/MatahariMacros.cmake
+++ b/src/cmake/modules/MatahariMacros.cmake
@@ -105,7 +105,7 @@ macro(create_manpage BINARY SECTION DESC)
add_custom_command(
TARGET ${BINARY}
POST_BUILD
- COMMAND ${HELP2MAN} --output ${BINARY}.${SECTION} --no-info --section ${SECTION} --name ${DESC} ${BINARY}
+ COMMAND ${HELP2MAN} --output ${BINARY}.${SECTION} --no-info --section ${SECTION} --name ${DESC} ${CMAKE_CURRENT_BINARY_DIR}/${BINARY}
COMMENT "Generating ${BINARY} man page"
VERBATIM
)
12 years, 8 months
Release Management
by Russell Bryant
Greetings,
We currently only use one branch in our git repo: master. Now that
Matahari is making its way into some Linux distributions, such as Fedora
16 [1], I think it's time to create and maintain a release branch.
--- Create a release branch.
The first thing that needs to be done is to create a new branch, which I
propose be called "release-0.4".
--- Maintain the release branch
There are a few different models that we could follow for maintaining
the release branch. I propose that committers share the responsibility
of maintaining the branch. If the commit you are making is a bug fix,
push it into release-0.4 and then "git cherry-pick -x" it to master.
Otherwise, just push your changes to the branch they are applicable for
as usual.
--- Release tarballs
Once we have the release branch up and going, we should regularly make
release tarballs (matahari-0.4.X). We can plan for doing so roughly
monthly, but the frequency could differ based on the quantity and
severity of bugs that have been fixed.
--- Release maintenance commitment
Given that Matahari is still in heavy development, I would rather not
make any promises about how long a given release series will be
maintained. In the case of the 0.4 release series, which is is in
Fedora 16, it will at least be maintained as long as Fedora 16 is supported.
Let me know what you think. We need to get this settled before we make
any more feature additions to master.
Thanks,
[1] http://fedoraproject.org/wiki/Features/Matahari
--
Russell Bryant
12 years, 8 months
[PATCH] - Raise Exception on NULL in sysconfig agent (rev2)
by Adam Stokes
- qmf/qpid doesn't allow null as an acceptable return argument
so raising an exception to alert end user of possible status
conflicts
resolves rhbz 733384, 733451
Signed-off-by: Adam Stokes <astokes(a)fedoraproject.org>
---
src/sysconfig/sysconfig-qmf.cpp | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/sysconfig/sysconfig-qmf.cpp b/src/sysconfig/sysconfig-qmf.cpp
index 442d27a..94415e5 100644
--- a/src/sysconfig/sysconfig-qmf.cpp
+++ b/src/sysconfig/sysconfig-qmf.cpp
@@ -93,24 +93,24 @@ ConfigAgent::invoke(qmf::AgentSession session, qmf::AgentEvent event, gpointer u
args["scheme"].asString().c_str(),
args["key"].asString().c_str());
status = mh_sysconfig_is_configured(args["key"].asString().c_str());
- event.addReturnArgument("status", status);
+ event.addReturnArgument("status", status ? status : "unknown");
} else if (methodName == "run_string") {
mh_sysconfig_run_string(args["data"].asString().c_str(),
args["flags"].asUint32(),
args["scheme"].asString().c_str(),
args["key"].asString().c_str());
status = mh_sysconfig_is_configured(args["key"].asString().c_str());
- event.addReturnArgument("status", status);
+ event.addReturnArgument("status", status ? status : "unknown");
} else if (methodName == "query") {
const char *data = NULL;
data = mh_sysconfig_query(args["query"].asString().c_str(),
args["flags"].asUint32(),
args["scheme"].asString().c_str());
- event.addReturnArgument("query", data);
+ event.addReturnArgument("data", data ? data : "unknown");
} else if (methodName == "is_configured") {
status = mh_sysconfig_is_configured(args["key"].asString().c_str());
_instance.setProperty("is_postboot_configured", status);
- event.addReturnArgument("status", status);
+ event.addReturnArgument("status", status ? status : "unknown");
} else {
session.raiseException(event, MH_NOT_IMPLEMENTED);
goto bail;
--
1.7.6
12 years, 8 months
[IANA #483358] Application for port-number: matahari
by Pearl Liang via RT
The Port Experts Team has review your application (included below).
The team has the following questions with respect to your request:
-----
I'd like to summarize what I understand of the application, and then ask
a question or two:
This application is for an additional TCP port 49000 for a service
called "matahari", to be used for configuration management of QMF/QPid
implementations. Justification for this port assignment seems to be
that privileged communications must be separated from normal operations,
and that QMF will run atop Matahari. Given this, aren't we really
talking about a newer version of AMQP? Could not the AMQP version be
bumped? We seek more information as to why precisely different ports
should be used.
Also, there is an inconsistency in the application:
The applicant has stated that multicast may be used, and yet the
application is only for TCP. This is generally inadvisable and
impracticable, given the state machine that TCP uses.
-----
Please resolve the above questions. If we do not receive the information
from you within 30 days, your request will be closed without prejudice, as
a matter of administrative procedure.
Thank you,
Pearl Liang
IANA
On Wed Aug 24 09:22:44 2011, zbitter(a)redhat.com wrote:
> On 24/08/11 18:04, Pearl Liang via RT wrote:
> > Thank you for the reply.
> >
> >> Assignee Name (REQUIRED): Matahari Project
> >> Assignee E-mail (REQUIRED): matahari(a)lists.fedorahosted.org
> >
> > Please confirm if http://matahariproject.org/ is the organization's
> > website.
>
> Yes, that is correct.
>
> > On Wed Aug 24 06:07:57 2011, zbitter(a)redhat.com wrote:
> >> Assignee Name (REQUIRED): Matahari Project
> >> Assignee E-mail (REQUIRED): matahari(a)lists.fedorahosted.org
> >> (The Assignee is the organization, company or individual person
> >> responsible
> >> for the initial assignment. )
> >> Contact Name (REQUIRED): Zane Bitter
> >> Contact E-mail (REQUIRED): zbitter(a)redhat.com
> >>
> >> Transport Protocol(s) (REQUIRED): (Please indicate which protocols
> are
> >> currently required.)
> >> [ X ] TCP [ ] UDP [ ] SCTP [ ] DCCP
> >>
> >> Service Code (REQUIRED for DCCP only)
> >>
> >> A: ____________________________
> >>
> >> Service Name (REQUIRED, 15 character maximum):
> >>
> >> A: matahari
> >>
> >> Desired Port Number (OPTIONAL, for Port Number only)
> >>
> >> A: 49000
> >> NOTE: It is *inappropriate* to use a port number until your
> >> application has
> >> been approved for assignment. Leave it blank if no number
> preference.
> >>
> >> Description (REQUIRED) (For example: Super User Messaging)
> >>
> >> A: Matahari Broker
> >>
> >> Reference (REQUIRED): Please provide a brief and basic technical
> >> description
> >> of the protocol that will use the service name or port number,
> >> including
> >> message
> >> formats, types, sequences, functionalities, of your protocol. In
> >> addition,
> >> please address the specific questions included below to the extent
> >> possible.
> >>
> >> A: The Matahari server is an implementation of an Advanced Message
> >> Queuing Protocol (AMQP) broker. Matahari uses a subset of the Qpid
> >> Management Framework (QMF), which sits on top of AMQP (Apache Qpid
> is
> >> an
> >> implementation of AMQP). AMQP is an open standard which is
> documented
> >> here:
> >> http://www.amqp.org/confluence/download/attachments/720900/amqp.0-
> >> 10.pdf
> >>
> >> In short, AMQP is a generic protocol for handling message queues.
> >> Client
> >> applications can create and subscribe to queues and publish
> messages
> >> to
> >> them.
> >>
> >> Matahari (http://www.matahariproject.org/) is a service to provide
> >> remote access to system management APIs over QMF. Existing APIs
> >> support
> >> system configuration and querying of system parameters for virtual
> >> servers, however the protocol is extensible so users can add their
> own
> >> custom APIs.
> >>
> >> Q: If broadcast/multicast is used, how and what for?
> >>
> >> A: Multicast may optionally be used to efficiently combine multiple
> >> brokers into a high-availability cluster.
> >>
> >> Q: If UDP is requested, please explain how traffic is limited, and
> >> whether the protocol reacts to congestion.
> >>
> >> A:
> >>
> ___________________________________________________________________________
> >>
> >> Q: If UDP is requested, please indicate whether the service is
> solely
> >> for the discovery of hosts supporting this protocol.
> >>
> >> A:
> >>
> ___________________________________________________________________________
> >>
> >> Q: Please explain how your protocol supports versioning.
> >>
> >> A: All AMQP messages begin with a version field, and AMQP defines a
> >> method for the client and server to negotiate a mutually compatible
> >> protocol version. QMF objects have a schema which can be queried
> over
> >> the protocol.
> >>
> >> Q: If your request is for more than one transport, please explain
> in
> >> detail how the protocol differs over each transport.
> >>
> >> A:
> >>
> __________________________________________________________________________
> >>
> >> Q: Please describe how your protocol supports security. Please note
> >> that
> >> there is current debate as to whether additional future ports will
> be
> >> allocated for newly assigned services that lack security, e.g.,
> solely
> >> for the addition of a secure variant. Applicants are strongly
> advised
> >> to
> >> address this issue as early as possible in the design of their
> >> protocols.
> >>
> >>
> >> A: The protocol may optionally be tunnelled over SSL.
> >>
> >>
> >> Q: Please explain the state of development of your protocol.
> >>
> >> A: AMQP is a published open standard with four published versions
> >> since
> >> 2006 and multiple available implementations. QMF has undergone a
> major
> >> revision and is now considered stable.
> >>
> >> Q: If SCTP is requested, please describe the following: Is there an
> >> existing TCP and/or UDP service name or port number assignment?
> >> If so, please indicate the details below:
> >>
> >> Service Name: _______________; Port number: _______________
> >>
> >> What specific SCTP capability is used by the application such that
> a
> >> user who has the choice of both TCP (and/or UDP) and SCTP ports for
> >> this application would choose SCTP? See [RFC4960 section 7.1]
> >> (http://tools.ietf.org/html/rfc4960#section-7.1)
> >>
> >> A:
> >>
> _____________________________________________________________________________
> >>
> >>
> ________________________________________________________________________________
> >>
> >>
> >> Please provide any other information that would be helpful in
> >> understanding how this protocol differs from existing assigned
> >> services.
> >>
> >> A: Matahari differs from a generic AMQP broker in that it requires
> the
> >> QMF protocol running on top, so only the Apache Qpid implementation
> of
> >> AMQP can be used. Since Matahari is designed for system
> configuration,
> >> for security reasons it places a tighter than usual set of
> >> restrictions
> >> on how the connection can be used, and thus must be segregated from
> >> regular applications' AMQP traffic.
> >>
> >
>
> On Wed Aug 24 06:07:57 2011, zbitter(a)redhat.com wrote:
> Application for User Registered Port Number
>
> Name :
> Zane Bitter
>
> E-mail :
> zbitter(a)redhat.com
>
> Protocol Number :
> TCP
>
> Message Formats :
> Protocol version, type, channel, size, payload
>
> Message Types :
> Method, Header, Body, Heartbeat
>
> Message opcodes :
> Channel: Open, Open-Ok, Close, Close-Ok
> Exchange: Declare, Delete
> Queue: Declare, Declare-Ok, Bind, Bind-Ok
> Basic: Publish, Consume, Cancel, Deliver, Return, Ack, Reject, Get
> Transaction: Select, Publish, Ack, Commit, Roll-back
>
> Message Sequences :
> See: https://www.amqp.org/confluence/download/attachments/720900/amqp0-9-1.pdf
>
> Protocol functions :
> Queuing and routing of messages for applications.
>
> Broadcast or Multicast used ?
> yes
>
> How and what for Broadcast and Multicast is used (if used):
> Multicast may optionally be used to efficiently combine multiple brokers into a high-availability cluster.
>
> Description :
> Matahari (http://www.matahariproject.org/) is a service to provide remote access to system management APIs. Existing APIs
> support system configuration and querying of system parameters for virtual servers, however the protocol is extensible so users
> can add their own custom APIs.
>
> The server is an implementation of an Advanced Message Queuing Protocol (AMQP) broker. AMQP is an existing open standard
> (http://www.ampq.org/). On a Matahari server, communication occurs through the Qpid Management Framework which sits on
> top of AMQP. (Apache Qpid is an implementation of AMQP.)
>
> Name of the port :
> Matahari Broker
>
> Short name of the port :
> matahari
>
>
12 years, 8 months
[PATCH] - Raise Exception on NULL in sysconfig agent
by Adam Stokes
- qmf/qpid doesn't allow null as an acceptable return argument
so raising an exception to alert end user of possible status
conflicts
resolves rhbz 733384, 733451
Signed-off-by: Adam Stokes <astokes(a)fedoraproject.org>
---
src/sysconfig/sysconfig-qmf.cpp | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/src/sysconfig/sysconfig-qmf.cpp b/src/sysconfig/sysconfig-qmf.cpp
index 442d27a..2966135 100644
--- a/src/sysconfig/sysconfig-qmf.cpp
+++ b/src/sysconfig/sysconfig-qmf.cpp
@@ -93,6 +93,9 @@ ConfigAgent::invoke(qmf::AgentSession session, qmf::AgentEvent event, gpointer u
args["scheme"].asString().c_str(),
args["key"].asString().c_str());
status = mh_sysconfig_is_configured(args["key"].asString().c_str());
+ if (!status) {
+ goto bail;
+ }
event.addReturnArgument("status", status);
} else if (methodName == "run_string") {
mh_sysconfig_run_string(args["data"].asString().c_str(),
@@ -100,15 +103,24 @@ ConfigAgent::invoke(qmf::AgentSession session, qmf::AgentEvent event, gpointer u
args["scheme"].asString().c_str(),
args["key"].asString().c_str());
status = mh_sysconfig_is_configured(args["key"].asString().c_str());
+ if (!status) {
+ goto bail;
+ }
event.addReturnArgument("status", status);
} else if (methodName == "query") {
const char *data = NULL;
data = mh_sysconfig_query(args["query"].asString().c_str(),
args["flags"].asUint32(),
args["scheme"].asString().c_str());
+ if (!data) {
+ goto bail;
+ }
event.addReturnArgument("query", data);
} else if (methodName == "is_configured") {
status = mh_sysconfig_is_configured(args["key"].asString().c_str());
+ if (!status) {
+ goto bail;
+ }
_instance.setProperty("is_postboot_configured", status);
event.addReturnArgument("status", status);
} else {
@@ -120,5 +132,6 @@ ConfigAgent::invoke(qmf::AgentSession session, qmf::AgentEvent event, gpointer u
session.methodSuccess(event);
bail:
+ session.raiseException(event, "Error in return arguments");
return TRUE;
}
--
1.7.6
12 years, 8 months
[PATCH] core: Fix --daemon option. Add --srv option.
by Russell Bryant
In a recent patch, I added a --domain option related to DNS SRV support.
Unfortunately, that overwrote the --daemon option. This patch removes
the --domain option and adds a new --srv option which I actually like
more than the previous --domain option anyway. So, now you have:
1) matahari-qmf-<agent>d
Determine the local domain. If found, do a DNS SRV lookup on it. If
results are found, connect to that. When all else fails, connect to
localhost.
2) matahari-qmf-<agent>d --broker russellbryant.net
Do a DNS A/AAAA lookup on russellbryant.net and connect to that.
3) matahari-qmf-<agent>d --broker russellbryant.net --srv
Do a DNS SRV lookup on russellbryant.net. If a result is found, use
that. If not, do an A/AAAA lookup on russellbryant.net and use that.
Signed-off-by: Russell Bryant <rbryant(a)redhat.com>
---
src/lib/mh_agent.cpp | 38 ++++++++++++++++++++++----------------
1 files changed, 22 insertions(+), 16 deletions(-)
diff --git a/src/lib/mh_agent.cpp b/src/lib/mh_agent.cpp
index 27d7aa1..ef2d305 100644
--- a/src/lib/mh_agent.cpp
+++ b/src/lib/mh_agent.cpp
@@ -174,9 +174,7 @@ int print_help(int code, const char *name, const char *arg, void *userdata)
printf("\t-h | --help print this help message.\n");
printf("\t-b | --broker value specify broker host name..\n");
printf("\t-p | --port value specify broker port.\n");
- printf("\t-d | --domain value Specify domain to connect to (Use DNS SRV to determine host).\n"
- "\t For this option to take effect, the broker option must not\n"
- "\t be provided.\n");
+ printf("\t-S | --srv Enable DNS SRV lookup for the specified broker.\n");
printf("\t-u | --username value username to use for authentication purposes.\n");
printf("\t-P | --password value password to use for authentication purposes.\n");
printf("\t-s | --service value service name to use for authentication purposes.\n");
@@ -205,12 +203,18 @@ mh_connect(qpid::types::Variant::Map mh_options, qpid::types::Variant::Map amqp_
int backoff = 0;
char *target = NULL;
- if(mh_options.count("servername") == 0) {
+ if (!mh_options.count("servername") || mh_options.count("srv")) {
+ /*
+ * Do an SRV lookup either because no broker was specified at all,
+ * or because a broker domain was given and the --srv option was
+ * used specifically requesting an SRV lookup.
+ */
+
/* Is _ssl valid here as a protocol? _udp? */
std::stringstream fqdn;
- if (mh_options.count("domain")) {
- fqdn << "_matahari._tcp." << mh_options["domain"];
+ if (mh_options.count("servername")) {
+ fqdn << "_matahari._tcp." << mh_options["servername"];
} else {
fqdn << "_matahari._tcp." << mh_domainname();
}
@@ -226,13 +230,15 @@ mh_connect(qpid::types::Variant::Map mh_options, qpid::types::Variant::Map amqp_
while (true) {
std::stringstream url;
- if(mh_options.count("servername") > 0) {
- url << "amqp:" << mh_options["protocol"] << ":" << mh_options["servername"] << ":" << mh_options["serverport"] ;
- } else if (target) {
- /* Try DNS */
+
+ if (target) {
+ /* Use the result of a DNS SRV lookup. */
url << "amqp:" << mh_options["protocol"] << ":" << target << ":" << mh_options["serverport"] ;
+ } else if (mh_options.count("servername")) {
+ /* Use the explicitly specified broker hostname or IP address. */
+ url << "amqp:" << mh_options["protocol"] << ":" << mh_options["servername"] << ":" << mh_options["serverport"] ;
} else {
- /* Try localhost */
+ /* If nothing else, try localhost */
url << "amqp:" << mh_options["protocol"] << ":localhost:" << mh_options["serverport"] ;
}
@@ -281,7 +287,7 @@ mh_parse_options(const char *proc_name, int argc, char **argv, qpid::types::Vari
/* Force local-only handling */
mh_add_option('b', required_argument, "broker", NULL, NULL, NULL);
- mh_add_option('d', required_argument, "domain", NULL, NULL, NULL);
+ mh_add_option('S', no_argument, "srv", NULL, NULL, NULL);
mh_add_option('p', required_argument, "port", NULL, NULL, NULL);
#ifdef MH_SSL
mh_add_option('N', required_argument, "ssl-cert-name", NULL, NULL, NULL);
@@ -306,8 +312,8 @@ mh_parse_options(const char *proc_name, int argc, char **argv, qpid::types::Vari
if (RegistryRead(HKEY_LOCAL_MACHINE,
L"SYSTEM\\CurrentControlSet\\services\\Matahari",
- L"domain", &value) == 0) {
- options["domain"] = value;
+ L"srv", &value) == 0) {
+ options["srv"] = value;
value = NULL;
}
@@ -395,8 +401,8 @@ mh_parse_options(const char *proc_name, int argc, char **argv, qpid::types::Vari
mh_err("Broker '%s' is not resolvable - ignoring", optarg);
}
break;
- case 'd':
- options["domain"] = optarg;
+ case 'S':
+ options["srv"] = 1;
break;
#ifdef MH_SSL
case 'N':
--
1.7.6
12 years, 8 months
[PATCH] systemd initialisation
by Zane Bitter
The following patch is still a work in progress (I have to look into the
creation of the /var/run directory and the possible bug I mentioned in the
previous message). However, I'd like to give everyone the chance to take a
look over this and comment now.
cheers,
Zane.
---
Zane Bitter (1):
Core: Start daemons through systemd if possible
CMakeLists.txt | 15 ++++++
matahari-broker.init.in | 22 +++++----
matahari-broker.service | 20 ++++++++
matahari-brokerd.in | 8 +++
matahari.init.in | 41 +++++++----------
matahari.service.in | 9 ++--
matahari.spec.in | 9 +++-
src/CMakeLists.txt | 2 +
src/cmake/modules/MatahariMacros.cmake | 2 -
src/lib/mh_agent.cpp | 76 +++++++++++++++++++++++---------
src/sysconfig/CMakeLists.txt | 10 ++--
11 files changed, 143 insertions(+), 71 deletions(-)
create mode 100644 matahari-broker.service
create mode 100644 matahari-brokerd.in
12 years, 8 months