incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mlsoren...@apache.org
Subject [32/50] git commit: Package the usage server
Date Wed, 30 Jan 2013 20:55:08 GMT
Package the usage server


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/ca7b8b0a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/ca7b8b0a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/ca7b8b0a

Branch: refs/heads/add_remove_nics
Commit: ca7b8b0a87e38026b24557bedb2abd57d460d388
Parents: cc9110d
Author: Hugo Trippaers <htrippaers@schubergphilis.com>
Authored: Tue Jan 29 08:44:51 2013 +0100
Committer: Hugo Trippaers <htrippaers@schubergphilis.com>
Committed: Tue Jan 29 16:23:14 2013 +0100

----------------------------------------------------------------------
 packaging/centos63/cloud-usage.rc |  138 ++++++++++++++++++++++++++++++++
 packaging/centos63/cloud.spec     |   24 +++++-
 usage/pom.xml                     |   68 ++++++++++++++++
 3 files changed, 229 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ca7b8b0a/packaging/centos63/cloud-usage.rc
----------------------------------------------------------------------
diff --git a/packaging/centos63/cloud-usage.rc b/packaging/centos63/cloud-usage.rc
new file mode 100755
index 0000000..9aa01ea
--- /dev/null
+++ b/packaging/centos63/cloud-usage.rc
@@ -0,0 +1,138 @@
+#!/bin/bash
+
+### BEGIN INIT INFO
+# Provides:          cloud usage
+# Required-Start:    $network $local_fs
+# Required-Stop:     $network $local_fs
+# Default-Start:     3 4 5
+# Default-Stop:      0 1 2 6
+# Short-Description: Start/stop Apache CloudStack Usage Monitor
+# Description: This scripts Starts/Stops the Apache CloudStack Usage Monitor
+##  The CloudStack Usage Monitor is a part of the Apache CloudStack project and is used
+##  for storing usage statistics from instances.
+## JSVC (Java daemonizing) is used for starting and stopping the usage monitor.
+### END INIT INFO
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+. /etc/rc.d/init.d/functions
+
+SHORTNAME="cloud-usage"
+PIDFILE=/var/run/"$SHORTNAME".pid
+LOCKFILE=/var/lock/subsys/"$SHORTNAME"
+LOGFILE=/var/log/cloud/usage/usage.log
+PROGNAME="CloudStack Usage Monitor"
+CLASS="com.cloud.usage.UsageServer"
+PROG="jsvc"
+DAEMON="/usr/bin/jsvc"
+USER=cloud
+
+unset OPTIONS
+[ -r /etc/sysconfig/default/"$SHORTNAME" ] && source /etc/sysconfig/default/"$SHORTNAME"
+
+# The first existing directory is used for JAVA_HOME (if JAVA_HOME is not defined in $DEFAULT)
+JDK_DIRS="/usr/lib/jvm/java-6-openjdk /usr/lib/jvm/java-6-openjdk-i386 /usr/lib/jvm/java-6-openjdk-amd64
/usr/lib/jvm/java-6-sun /usr/lib/jvm/jre-1.6.0 /usr/lib/j2sdk1.5-sun /usr/lib/jre-openjdk"
+
+for jdir in $JDK_DIRS; do
+    if [ -r "$jdir/bin/java" -a -z "${JAVA_HOME}" ]; then
+        JAVA_HOME="$jdir"
+    fi
+done
+export JAVA_HOME
+
+SCP=""
+DCP=""
+UCP=`ls /usr/share/cloud/usage/java/* | tr '\n' ':'`
+JCP="/usr/share/java/commons-daemon.jar"
+
+# We need to append the JSVC daemon JAR to the classpath
+# AgentShell implements the JSVC daemon methods
+export CLASSPATH="$SCP:$DCP:$UCP:$JCP:/etc/sysconfig
+
+start() {
+    if [ -s "$PIDFILE" ] && kill -0 $(cat "$PIDFILE") >/dev/null 2>&1;
then
+        echo "$PROGNAME apparently already running"
+        exit 0
+    fi
+
+    if hostname --fqdn >/dev/null 2>&1 ; then
+        true
+    else
+        echo "The host name does not resolve properly to an IP address. Cannot start $PROGNAME"
+        exit 1
+    fi
+
+    echo -n "Starting $PROGNAME" "$SHORTNAME"
+
+    if daemon --pidfile $PIDFILE $DAEMON -cp "$CLASSPATH" -pidfile "$PIDFILE" -user "$USER"
-errfile SYSLOG -Dpid=$$ $CLASS
+        RETVAL=$?
+    then
+        rc=0
+        sleep 1
+        if ! kill -0 $(cat "$PIDFILE") >/dev/null 2>&1; then
+            failure
+            rc=1
+        fi
+    else
+        rc=1
+    fi
+
+    if [ $rc -eq 0 ]; then
+        success
+    else
+        failure
+        rm -f "$PIDFILE"
+    fi
+    echo
+}
+
+stop() {
+    echo -n "Stopping $PROGNAME" "$SHORTNAME"
+    killproc -p $PIDFILE $DAEMON
+    if [ "$?" -eq 0 ]; then
+        success
+    else
+        failure
+    fi
+    rm -f "$PIDFILE"
+    echo
+}
+
+case "$1" in
+    start)
+        start
+        ;;
+    stop)
+        stop
+        ;;
+    status)
+        status -p $PIDFILE $SHORTNAME
+        RETVAL=$?
+        ;;
+    restart | force-reload)
+        stop
+        sleep 3
+        start
+        ;;
+    *)
+    echo "Usage: $0 {start|stop|restart|force-reload|status}"
+    RETVAL=3
+esac
+
+exit $RETVAL
+

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ca7b8b0a/packaging/centos63/cloud.spec
----------------------------------------------------------------------
diff --git a/packaging/centos63/cloud.spec b/packaging/centos63/cloud.spec
index d828e67..50e1d11 100644
--- a/packaging/centos63/cloud.spec
+++ b/packaging/centos63/cloud.spec
@@ -112,10 +112,21 @@ Requires: bridge-utils
 Requires: ebtables
 Requires: jsvc
 Requires: jna
+Requires: jakarta-commons-daemon
+Requires: jakarta-commons-daemon-jsvc
 Group: System Environment/Libraries
 %description agent
 The CloudStack agent for KVM hypervisors
 
+%package usage
+Summary: CloudStack Usage calculation server
+Requires: java >= 1.6.0
+Requires: jsvc
+Requires: jakarta-commons-daemon
+Requires: jakarta-commons-daemon-jsvc
+%description usage
+The CloudStack usage calculation service
+
 %prep
 echo Doing CloudStack build
 
@@ -196,6 +207,7 @@ chmod 770 ${RPM_BUILD_ROOT}%{_localstatedir}/log/%{name}/management
 chmod 770 ${RPM_BUILD_ROOT}%{_localstatedir}/log/%{name}/agent
 chmod -R ugo+x ${RPM_BUILD_ROOT}/usr/share/%{name}/management/webapps/client/WEB-INF/classes/scripts
 
+# KVM Agent
 mkdir -p ${RPM_BUILD_ROOT}/etc/cloud/agent
 mkdir -p ${RPM_BUILD_ROOT}/var/log/cloud/agent
 install -D packaging/centos63/cloud-agent.rc ${RPM_BUILD_ROOT}/etc/init.d/%{name}-agent
@@ -204,12 +216,17 @@ install -D agent/target/transformed/environment.properties ${RPM_BUILD_ROOT}/etc
 install -D agent/target/transformed/log4j-cloud.xml ${RPM_BUILD_ROOT}/etc/cloud/agent/log4j-cloud.xml
 install -D agent/target/transformed/cloud-setup-agent ${RPM_BUILD_ROOT}/usr/bin/cloud-setup-agent
 install -D agent/target/transformed/cloud-ssh ${RPM_BUILD_ROOT}/usr/bin/cloud-ssh
-
 install -D plugins/hypervisors/kvm/target/%{name}-plugin-hypervisor-kvm-%{_maventag}.jar
${RPM_BUILD_ROOT}/usr/share/cloud/java/%{name}-plugin-hypervisor-kvm-%{_maventag}.jar
 cp plugins/hypervisors/kvm/target/dependencies/*  ${RPM_BUILD_ROOT}/usr/share/cloud/java
 mkdir -p ${RPM_BUILD_ROOT}/usr/share/cloud/scripts
 cp -r scripts/* ${RPM_BUILD_ROOT}/usr/share/cloud/scripts
 
+# Usage server
+install -D usage/target/%{name}-usage-%{_maventag}.jar ${RPM_BUILD_ROOT}/usr/share/cloud/usage/java/%{name}-usage-%{_maventag}.jar
+cp usage/target/dependencies/* ${RPM_BUILD_ROOT}/usr/share/cloud/usage/java
+install -D packaging/centos63/cloud-usage.rc ${RPM_BUILD_ROOT}/etc/init.d/%{name}-usage
+mkdir -p ${RPM_BUILD_ROOT}/var/log/cloud/usage/
+
 %clean
 [ ${RPM_BUILD_ROOT} != "/" ] && rm -rf ${RPM_BUILD_ROOT}
 
@@ -306,6 +323,11 @@ fi
 %attr(0644,root,root) /usr/share/cloud/java/*.jar
 %attr(0755,root,root) /usr/share/cloud/scripts
 
+%files usage
+%attr(0755,root,root) %{_sysconfdir}/init.d/cloud-usage
+%attr(0644,root,root) /usr/share/cloud/usage/java/*.jar
+%dir /var/log/cloud/usage
+
 %changelog
 * Fri Oct 03 2012 Hugo Trippaers <hugo@apache.org> 4.1.0
 - new style spec file

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ca7b8b0a/usage/pom.xml
----------------------------------------------------------------------
diff --git a/usage/pom.xml b/usage/pom.xml
index 252e293..9ecd6e1 100644
--- a/usage/pom.xml
+++ b/usage/pom.xml
@@ -36,5 +36,73 @@
     <defaultGoal>install</defaultGoal>
     <sourceDirectory>src</sourceDirectory>
     <testSourceDirectory>test</testSourceDirectory>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-dependency-plugin</artifactId>
+        <version>2.5.1</version>
+        <executions>
+          <execution>
+            <id>copy-dependencies</id>
+            <phase>package</phase>
+            <goals>
+              <goal>copy-dependencies</goal>
+            </goals>
+            <configuration>
+              <outputDirectory>target/dependencies</outputDirectory>
+              <includeScope>runtime</includeScope>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <artifactId>maven-antrun-plugin</artifactId>
+        <version>1.7</version>
+        <executions>
+          <execution>
+            <id>generate-resource</id>
+            <phase>generate-resources</phase>
+            <goals>
+              <goal>run</goal>
+            </goals>
+            <configuration>
+              <target>
+                <copy overwrite="true"
+                  todir="${basedir}/target/transformed">
+                  <fileset dir="${basedir}/../client/tomcatconf">
+                    <include name="**/db.properties.in" />
+                  </fileset>
+                  <globmapper from="*.in" to="*" />
+                  <filterchain>
+                    <filterreader
+                      classname="org.apache.tools.ant.filters.ReplaceTokens">
+                      <param type="propertiesfile"
+                        value="${basedir}/../build/replace.properties" />
+                    </filterreader>
+                  </filterchain>
+                </copy>
+              </target>
+              <target>
+                <copy overwrite="true"
+                  todir="${basedir}/target/transformed">
+                  <fileset dir="${basedir}/conf">
+                    <include name="*.in" />
+                  </fileset>
+                  <globmapper from="*.in" to="*" />
+                  <filterchain>
+                    <filterreader
+                      classname="org.apache.tools.ant.filters.ReplaceTokens">
+                      <param type="propertiesfile"
+                        value="${basedir}/../build/replace.properties" />
+                    </filterreader>
+                  </filterchain>
+                </copy>
+              </target>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+
+    </plugins>
   </build>
 </project>


Mime
View raw message