Permalink
Browse files

XX-10065: Port SAA/BLA to cfengine

  • Loading branch information...
mirceac committed Jun 15, 2012
1 parent 1192b78 commit 9ca0babdcbacbbeec2bde9215b1f08239e8272eb
View
@@ -9,8 +9,6 @@ sf_broken = \
sipXacd \
sipXtunnel \
sipXpreflight \
- sipXrls \
- sipXsaa \
sipXtools \
sipXpark \
sipXpresence \
View
@@ -37,7 +37,8 @@ sipx = \
sipXpark \
sipXpage \
sipXpolycom \
- sipXrls
+ sipXrls \
+ sipXsaa
# re: ruby-postgres, there's a new one we should be using ruby-pgsql i
# think it's called as ruby-postgres is obsoleted.
@@ -1,9 +0,0 @@
-SIP_SAA_LOG_DIR :
-SIP_SAA_LOG_LEVEL : ${saaService.logLevel}
-SIP_SAA_LOG_CONSOLE :
-SIP_SAA_UDP_PORT : ${saaService.udpPort}
-SIP_SAA_TCP_PORT : ${saaService.tcpPort}
-SIP_SAA_BIND_IP : ${location.address}
-SIP_SAA_FILE_NAME : @SIPX_CONFDIR@/appearance-groups.xml
-SIP_SAA_DOMAIN_NAME : ${saaService.domainName}
-SIP_SAA_AUTHENTICATE_REALM : ${saaService.realm}
@@ -0,0 +1,4 @@
+saa-config.label=Shared Appearance Agent and Bridged Line Appearance (SAA/BLA) configuration
+saa-config.SIP_SAA_UDP_PORT.label=UDP Port
+saa-config.SIP_SAA_TCP_PORT.label=TCP Port
+saa-config.SIP_SAA_LOG_LEVEL.label=Logging Level
@@ -33,7 +33,7 @@
<type id="nonRootPort">
<integer min="1025" max="65535"/>
</type>
- <group name="saa-config" hidden="yes">
+ <group name="saa-config">
<setting name="SIP_SAA_UDP_PORT">
<type refid="nonRootPort"/>
<value>5170</value>
@@ -28,6 +28,7 @@
import org.sipfoundry.sipxconfig.cfgmgt.ConfigManager;
import org.sipfoundry.sipxconfig.cfgmgt.ConfigProvider;
import org.sipfoundry.sipxconfig.cfgmgt.ConfigRequest;
+import org.sipfoundry.sipxconfig.cfgmgt.ConfigUtils;
import org.sipfoundry.sipxconfig.cfgmgt.KeyValueConfiguration;
import org.sipfoundry.sipxconfig.common.CoreContext;
import org.sipfoundry.sipxconfig.common.User;
@@ -50,7 +51,13 @@ public void replicate(ConfigManager manager, ConfigRequest request) throws IOExc
List<Location> locations = manager.getFeatureManager().getLocationsForEnabledFeature(SaaManager.FEATURE);
for (Location location : locations) {
File dir = manager.getLocationDataDirectory(location);
- Writer saa = new FileWriter(new File(dir, "sipxsaa.properties.cfdat"));
+ boolean enabled = manager.getFeatureManager().isFeatureEnabled(SaaManager.FEATURE, location);
+ ConfigUtils.enableCfengineClass(dir, "sipxsaa.cfdat", enabled, "sipxsaa");
+ if (!enabled) {
+ continue;
+ }
+
+ Writer saa = new FileWriter(new File(dir, "sipxsaa-config.part"));
try {
writeSaaConfig(saa, settings, location.getAddress(), domainName, realm);
} finally {
@@ -81,9 +88,6 @@ void writeSaaConfig(Writer wtr, SaaSettings settings, String address, String dom
throws IOException {
KeyValueConfiguration config = KeyValueConfiguration.colonSeparated(wtr);
config.writeSettings(settings.getSettings().getSetting("saa-config"));
- config.write("SIP_SAA_BIND_IP", address);
- config.write("SIP_SAA_DOMAIN_NAME", domainName);
- config.write("SIP_SAA_AUTHENTICATE_REALM", realm);
}
public void setVelocityEngine(VelocityEngine velocityEngine) {
@@ -71,6 +71,9 @@
<li jwcid="@If" condition="ognl:isOn('rls')">
<a jwcid="@PageLink" page="rls/EditRls"><span key="menu.rls.featureMenu"/></a>
</li>
+ <li jwcid="@If" condition="ognl:isOn('saa')">
+ <a jwcid="@PageLink" page="saa/EditSaa"><span key="menu.saa.featureMenu"/></a>
+ </li>
<li jwcid="@If" condition="ognl:isOn('mwi')">
<a jwcid="@PageLink" page="mwi/EditMwi"><span key="menu.mwi.featureMenu"/></a>
</li>
@@ -29,7 +29,8 @@ menu.firewall.featureMenu=Firewall
menu.dhcpd.featureMenu=DHCP
menu.tunnel.featureMenu=Communication Encryption
menu.sipxsqa.featureMenu=Network Queue
-menu.rls.featureMenu=RLS
+menu.rls.featureMenu=RLS
+menu.saa.featureMenu=SAA/BLA
menu.logwatcher.featureMenu=Log Watcher
menu.restore=Restore
menu.backup=Backup
@@ -0,0 +1,9 @@
+<div jwcid="@common/Border" useDojo="ognl:true" borderTitle="ognl:borderTitle">
+ <span jwcid="@common/ErrorMsg"/>
+ <form jwcid="form@Form" delegate="bean:validator">
+ <fieldset jwcid="@setting/SettingsFieldset"
+ settings="ognl:settings.settings" />
+ <ul jwcid="formActions@common/FormActions" callback="ognl:callback"
+ listener="listener:apply"/>
+ </form>
+</div>
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE page-specification PUBLIC "-//Apache Software Foundation//Tapestry Specification 4.0//EN"
+ "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">
+<page-specification class="org.sipfoundry.sipxconfig.site.saa.EditSaa" />
@@ -0,0 +1,52 @@
+/**
+ *
+ *
+ * Copyright (c) 2012 eZuce, Inc. All rights reserved.
+ * Contributed to SIPfoundry under a Contributor Agreement
+ *
+ * This software is free software; you can redistribute it and/or modify it under
+ * the terms of the Affero General Public License (AGPL) as published by the
+ * Free Software Foundation; either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
+ * details.
+ */
+package org.sipfoundry.sipxconfig.site.saa;
+
+import org.apache.tapestry.annotations.Bean;
+import org.apache.tapestry.annotations.InjectObject;
+import org.apache.tapestry.event.PageBeginRenderListener;
+import org.apache.tapestry.event.PageEvent;
+import org.sipfoundry.sipxconfig.components.PageWithCallback;
+import org.sipfoundry.sipxconfig.components.SipxValidationDelegate;
+import org.sipfoundry.sipxconfig.saa.SaaManager;
+import org.sipfoundry.sipxconfig.saa.SaaSettings;
+
+public abstract class EditSaa extends PageWithCallback implements PageBeginRenderListener {
+ public static final String PAGE = "saa/EditSaa";
+
+ @Bean
+ public abstract SipxValidationDelegate getValidator();
+
+ @InjectObject("spring:saaManager")
+ public abstract SaaManager getSaaManager();
+
+ public abstract SaaSettings getSettings();
+
+ public abstract void setSettings(SaaSettings settings);
+
+ @Override
+ public void pageBeginRender(PageEvent arg0) {
+ if (getSettings() == null) {
+ setSettings(getSaaManager().getSettings());
+ }
+ }
+
+ public void apply() {
+ getSaaManager().saveSettings(getSettings());
+ }
+}
+
View
@@ -1,13 +1,17 @@
include $(top_srcdir)/config/utility.am
+EXTRA_DIST = \
+ $(bin_SCRIPTS:=.in) \
+ $(initd_SCRIPTS:=.in)
+
bin_SCRIPTS = \
- sipxsaa.sh \
- sipx-snapshot-saa
+ sipx-snapshot-saa
-EXTRA_DIST = \
- $(bin_SCRIPTS:=.in)
+initddir = @SIPX_SERVICEDIR@
+initd_SCRIPTS = \
+ sipxsaa
-$(bin_SCRIPTS) : % : %.in Makefile
+$(initd_SCRIPTS) $(bin_SCRIPTS) : % : %.in Makefile
@$(call SearchAndReplace,$<,$@)
-CLEANFILES = $(bin_SCRIPTS)
+CLEANFILES = $(initd_SCRIPTS)
View
@@ -0,0 +1,71 @@
+#!@BASH@
+#
+# Copyright (C) 2009 Nortel, certain elements licensed under a Contributor Agreement.
+# Contributors retain copyright to elements licensed under a Contributor Agreement.
+# Licensed to the User under the LGPL license.
+
+. /etc/rc.d/init.d/functions || exit 1
+. @SIPX_LIBEXECDIR@/sipx-utils.sh || exit 1
+
+prog=sipxsaa
+exec="@SIPX_BINDIR@/${prog}"
+config="@SIPX_CONFDIR@/sipxsaa-config"
+pidfile="@SIPX_RUNDIR@/sipxsaa.pid"
+
+[ -e @SIPX_CONFDIR@/sysconfig/$prog ] && . @SIPX_CONFDIR@/sysconfig/$prog
+
+start() {
+ [ -x $exec ] || exit 5
+ [ -f $config ] || exit 6
+ if [ -n "${NoFork}" ] ; then
+ runuser - @SIPXPBXUSER@ -c $exec
+ else
+ echo -n $"Starting $prog: "
+ daemon --user @SIPXPBXUSER@ --pidfile $pidfile $exec $pidfile
+ Status=$?
+ echo_success
+ fi
+}
+
+stop() {
+ echo -n $"Stopping sipXsaa: "
+ killproc -p "${pidfile}" "${exec}"
+ Status=$?
+ echo
+ [ $Status -eq 0 ] && rm -f "${pidfile}"
+}
+
+restart() {
+ stop
+ start
+}
+
+case "$1" in
+ nofork)
+ NoFork=1
+ start
+ ;;
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ restart|reload|force-reload)
+ restart
+ ;;
+ condrestart)
+ [ -f ${pidfile} ] && restart || :
+ ;;
+ status)
+ status -p "${pidfile}" "${prog}"
+ Status=$?
+ ;;
+ configtest)
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart|nofork}"
+ Status=1
+esac
+
+exit $Status
View
@@ -1,61 +0,0 @@
-#!@BASH@
-#
-# Copyright (C) 2009 Nortel, certain elements licensed under a Contributor Agreement.
-# Contributors retain copyright to elements licensed under a Contributor Agreement.
-# Licensed to the User under the LGPL license.
-
-Action=RUN
-Status=0
-Args=""
-
-while [ $# -ne 0 ]
-do
- case ${1} in
- --configtest)
- Action=CONFIGTEST
- ;;
-
- --stop)
- Action=STOP
- ;;
-
- *)
- Args="$Args $1"
- ;;
- esac
-
- shift # always consume 1
-done
-
-. @SIPX_LIBEXECDIR@/sipx-utils.sh || exit 1
-
-pidfile=@SIPX_RUNDIR@/sipxsaa.pid
-
-case ${Action} in
- RUN)
- echo $$ > ${pidfile}
- exec @bindir@/sipxsaa $Args
- ;;
-
- STOP)
- sipx_stop sipxsaa ${pidfile}
- ;;
-
- CONFIGTEST)
- Status=0
- ! test -e @SIPX_CONFDIR@/appearance-groups.xml \
- || @bindir@/sipx-validate-xml @SIPX_CONFDIR@/appearance-groups.xml
- Status=$(($Status+$?))
-
- # Check that the log file is writable.
- logfile="@SIPX_LOGDIR@/sipxsaa.log"
- if [ -e $logfile -a ! -w $logfile ]
- then
- echo "Log file '$logfile' exists but is not writable by user '@SIPXPBXUSER@'." >&2
- Status=1
- fi
-
- ;;
-esac
-
-exit $Status
View
@@ -1,15 +1,8 @@
include $(top_srcdir)/config/utility.am
EXTRA_DIST = \
- $(proc_DATA:.xml=.xml.in)
+ sample-appearance-groups.xml
-procdir = \
- $(SIPX_DATADIR)/process.d
-
-proc_DATA = \
- sipxsaa-process.xml
-
-$(proc_DATA) : % : %.in Makefile
- @$(call SearchAndReplace, $<, $@)
-
-CLEANFILES = $(proc_DATA)
+cfinputsdir = $(SIPX_CFINPUTS)/plugin.d
+dist_cfinputs_DATA = \
+ sipxsaa.cf
@@ -1,9 +0,0 @@
-SIP_SAA_LOG_DIR :
-SIP_SAA_LOG_LEVEL : NOTICE
-SIP_SAA_LOG_CONSOLE :
-SIP_SAA_UDP_PORT : ${SAA_SIP_PORT}
-SIP_SAA_TCP_PORT : ${SAA_SIP_PORT}
-SIP_SAA_BIND_IP : ${MY_IP_ADDR}
-SIP_SAA_FILE_NAME : @SIPX_CONFDIR@/appearance-groups.xml
-SIP_SAA_DOMAIN_NAME : ${SIPXCHANGE_DOMAIN_NAME}
-SIP_SAA_AUTHENTICATE_REALM : ${SIPXCHANGE_REALM}
@@ -1,27 +0,0 @@
-<?xml version='1.0' encoding='iso-8859-1' standalone='yes'?>
-<sipXecs-process xmlns='http://www.sipfoundry.org/sipX/schema/xml/sipXecs-process-01-00'>
- <name>SharedAppearanceAgent</name>
- <version>@VERSION@</version>
- <commands>
- <configtest>
- <execute>@SIPX_BINDIR@/sipxsaa.sh</execute>
- <parameter>--configtest</parameter>
- </configtest>
- <start>
- <execute>@SIPX_BINDIR@/sipxsaa.sh</execute>
- </start>
- <stop>
- <execute>@SIPX_BINDIR@/sipxsaa.sh</execute>
- <parameter>--stop</parameter>
- </stop>
- </commands>
- <status>
- <pid>@SIPX_RUNDIR@/sipxsaa.pid</pid>
- <log>@SIPX_LOGDIR@/sipxsaa.log</log>
- </status>
- <resources>
- <osconfig>@SIPX_CONFDIR@/domain-config</osconfig>
- <file>@SIPX_CONFDIR@/appearance-groups.xml</file>
- <file>@SIPX_CONFDIR@/sipxsaa-config</file>
- </resources>
-</sipXecs-process>
Oops, something went wrong.

0 comments on commit 9ca0bab

Please sign in to comment.