diff --git a/agent/conf/environment.properties.in b/agent/conf/environment.properties.in index c38e2b8137b..7fcf570538f 100644 --- a/agent/conf/environment.properties.in +++ b/agent/conf/environment.properties.in @@ -18,3 +18,4 @@ # management server compile-time environment parameters paths.pid=@PIDDIR@ +paths.scripts=@AGENTLIBDIR@ diff --git a/agent/distro/centos/SYSCONFDIR/rc.d/init.d/cloud-agent.in b/agent/distro/centos/SYSCONFDIR/rc.d/init.d/cloud-agent.in index d98d6e23bc4..488ced2fa90 100755 --- a/agent/distro/centos/SYSCONFDIR/rc.d/init.d/cloud-agent.in +++ b/agent/distro/centos/SYSCONFDIR/rc.d/init.d/cloud-agent.in @@ -33,17 +33,34 @@ PIDFILE=@PIDDIR@/"$whatami".pid LOCKFILE=@LOCKDIR@/"$SHORTNAME" LOGFILE=@AGENTLOG@ PROGNAME="Cloud Agent" +CLASS="com.cloud.agent.AgentShell" unset OPTIONS [ -r @SYSCONFDIR@/sysconfig/"$SHORTNAME" ] && source @SYSCONFDIR@/sysconfig/"$SHORTNAME" -DAEMONIZE=@BINDIR@/@PACKAGE@-daemonize -PROG=@LIBEXECDIR@/agent-runner + +# 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/java-1.5.0-sun /usr/lib/j2sdk1.5-sun /usr/lib/j2sdk1.5-ibm" + +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="@SYSTEMCLASSPATH@" +DCP="@DEPSCLASSPATH@" +ACP="@AGENTCLASSPATH@" +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:$ACP:$JCP:@AGENTSYSCONFDIR@" start() { echo -n $"Starting $PROGNAME: " if hostname --fqdn >/dev/null 2>&1 ; then - daemon --check=$SHORTNAME --pidfile=${PIDFILE} "$DAEMONIZE" \ - -n "$SHORTNAME" -p "$PIDFILE" -l "$LOGFILE" "$PROG" $OPTIONS + jsvc -cp "$CLASSPATH" -pidfile "$PIDFILE" $CLASS RETVAL=$? echo else @@ -58,7 +75,7 @@ start() { stop() { echo -n $"Stopping $PROGNAME: " - killproc -p ${PIDFILE} $SHORTNAME # -d 10 $SHORTNAME + jsvc -pidfile "$PIDFILE" -stop $CLASS RETVAL=$? echo [ $RETVAL = 0 ] && rm -f ${LOCKFILE} ${PIDFILE} diff --git a/agent/distro/fedora/SYSCONFDIR/rc.d/init.d/cloud-agent.in b/agent/distro/fedora/SYSCONFDIR/rc.d/init.d/cloud-agent.in index d98d6e23bc4..488ced2fa90 100755 --- a/agent/distro/fedora/SYSCONFDIR/rc.d/init.d/cloud-agent.in +++ b/agent/distro/fedora/SYSCONFDIR/rc.d/init.d/cloud-agent.in @@ -33,17 +33,34 @@ PIDFILE=@PIDDIR@/"$whatami".pid LOCKFILE=@LOCKDIR@/"$SHORTNAME" LOGFILE=@AGENTLOG@ PROGNAME="Cloud Agent" +CLASS="com.cloud.agent.AgentShell" unset OPTIONS [ -r @SYSCONFDIR@/sysconfig/"$SHORTNAME" ] && source @SYSCONFDIR@/sysconfig/"$SHORTNAME" -DAEMONIZE=@BINDIR@/@PACKAGE@-daemonize -PROG=@LIBEXECDIR@/agent-runner + +# 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/java-1.5.0-sun /usr/lib/j2sdk1.5-sun /usr/lib/j2sdk1.5-ibm" + +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="@SYSTEMCLASSPATH@" +DCP="@DEPSCLASSPATH@" +ACP="@AGENTCLASSPATH@" +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:$ACP:$JCP:@AGENTSYSCONFDIR@" start() { echo -n $"Starting $PROGNAME: " if hostname --fqdn >/dev/null 2>&1 ; then - daemon --check=$SHORTNAME --pidfile=${PIDFILE} "$DAEMONIZE" \ - -n "$SHORTNAME" -p "$PIDFILE" -l "$LOGFILE" "$PROG" $OPTIONS + jsvc -cp "$CLASSPATH" -pidfile "$PIDFILE" $CLASS RETVAL=$? echo else @@ -58,7 +75,7 @@ start() { stop() { echo -n $"Stopping $PROGNAME: " - killproc -p ${PIDFILE} $SHORTNAME # -d 10 $SHORTNAME + jsvc -pidfile "$PIDFILE" -stop $CLASS RETVAL=$? echo [ $RETVAL = 0 ] && rm -f ${LOCKFILE} ${PIDFILE} diff --git a/agent/distro/opensuse/sles/SYSCONFDIR/init.d/cloud-agent.in b/agent/distro/opensuse/sles/SYSCONFDIR/init.d/cloud-agent.in index 4046d225258..01606c72a0d 100644 --- a/agent/distro/opensuse/sles/SYSCONFDIR/init.d/cloud-agent.in +++ b/agent/distro/opensuse/sles/SYSCONFDIR/init.d/cloud-agent.in @@ -1,8 +1,8 @@ #!/bin/bash ### BEGIN INIT INFO # Provides: cloud agent -# Required-Start: $network -# Required-Stop: $network +# Required-Start: $network +# Required-Stop: $network # Default-Start: 3 4 5 # Default-Stop: 0 1 2 6 # X-Interactive: true @@ -40,17 +40,37 @@ PIDFILE=@PIDDIR@/"$whatami".pid LOCKFILE=@LOCKDIR@/"$SHORTNAME" LOGFILE=@AGENTLOG@ PROGNAME="Cloud Agent" +CLASS="com.cloud.agent.AgentShell" unset OPTIONS [ -r @SYSCONFDIR@/default/"$SHORTNAME" ] && source @SYSCONFDIR@/default/"$SHORTNAME" -DAEMONIZE=@BINDIR@/@PACKAGE@-daemonize -PROG=@LIBEXECDIR@/agent-runner + +# 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/java-1.5.0-sun /usr/lib/j2sdk1.5-sun /usr/lib/j2sdk1.5-ibm" + +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="@SYSTEMCLASSPATH@" +DCP="@DEPSCLASSPATH@" +ACP="@AGENTCLASSPATH@" +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:$ACP:$JCP:@AGENTSYSCONFDIR@" wait_for_network() { i=1 while [ $i -lt 10 ] do - if ip addr show cloudbr0 |grep -w inet > /dev/null 2>&1; then + # Under Ubuntu and Debian libvirt by default creates a bridge called virbr0. + # That's why we want more then 3 lines back from brctl, so that there is a manually created bridge + if [ "$(brctl show|wc -l)" -gt 2 ]; then break else sleep 1 @@ -75,12 +95,9 @@ start() { exit 1 fi - #FIXME: wait for network - wait_for_network + wait_for_network - if start-stop-daemon --start --quiet \ - --pidfile "$PIDFILE" \ - --exec "$DAEMONIZE" -- -n "$SHORTNAME" -p "$PIDFILE" -l "$LOGFILE" "$PROG" $OPTIONS + if jsvc -cp "$CLASSPATH" -pidfile "$PIDFILE" $CLASS RETVAL=$? then rc=0 @@ -106,11 +123,11 @@ stop() { count="0" echo -n $"Stopping $PROGNAME" "$SHORTNAME" - start-stop-daemon --stop --quiet --oknodo --pidfile "$PIDFILE" + jsvc -pidfile "$PIDFILE" -stop $CLASS until [ "$count" -gt "$SHUTDOWN_WAIT" ] do - agentPid=`ps aux|grep [j]ava|grep cloud-agent` + agentPid=`ps aux|grep [j]svc|grep cloud-agent` if [ "$?" -gt "0" ];then break fi @@ -118,16 +135,16 @@ stop() { let count="${count}+1" done - agentPid=`ps aux|grep [j]ava|grep cloud-agent` + agentPid=`ps aux|grep [j]svc|grep cloud-agent` if [ "$?" -eq "0" ]; then - agentPid=`ps aux|grep [j]ava|awk '{print $2}'` + agentPid=`ps aux|grep [j]svc|awk '{print $2}'` if [ "$agentPid" != "" ]; then kill -9 $agentPid fi fi - log_end_msg $? - rm -f "$PIDFILE" + log_end_msg $? + rm -f "$PIDFILE" } diff --git a/agent/distro/rhel/SYSCONFDIR/rc.d/init.d/cloud-agent.in b/agent/distro/rhel/SYSCONFDIR/rc.d/init.d/cloud-agent.in index d98d6e23bc4..488ced2fa90 100644 --- a/agent/distro/rhel/SYSCONFDIR/rc.d/init.d/cloud-agent.in +++ b/agent/distro/rhel/SYSCONFDIR/rc.d/init.d/cloud-agent.in @@ -33,17 +33,34 @@ PIDFILE=@PIDDIR@/"$whatami".pid LOCKFILE=@LOCKDIR@/"$SHORTNAME" LOGFILE=@AGENTLOG@ PROGNAME="Cloud Agent" +CLASS="com.cloud.agent.AgentShell" unset OPTIONS [ -r @SYSCONFDIR@/sysconfig/"$SHORTNAME" ] && source @SYSCONFDIR@/sysconfig/"$SHORTNAME" -DAEMONIZE=@BINDIR@/@PACKAGE@-daemonize -PROG=@LIBEXECDIR@/agent-runner + +# 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/java-1.5.0-sun /usr/lib/j2sdk1.5-sun /usr/lib/j2sdk1.5-ibm" + +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="@SYSTEMCLASSPATH@" +DCP="@DEPSCLASSPATH@" +ACP="@AGENTCLASSPATH@" +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:$ACP:$JCP:@AGENTSYSCONFDIR@" start() { echo -n $"Starting $PROGNAME: " if hostname --fqdn >/dev/null 2>&1 ; then - daemon --check=$SHORTNAME --pidfile=${PIDFILE} "$DAEMONIZE" \ - -n "$SHORTNAME" -p "$PIDFILE" -l "$LOGFILE" "$PROG" $OPTIONS + jsvc -cp "$CLASSPATH" -pidfile "$PIDFILE" $CLASS RETVAL=$? echo else @@ -58,7 +75,7 @@ start() { stop() { echo -n $"Stopping $PROGNAME: " - killproc -p ${PIDFILE} $SHORTNAME # -d 10 $SHORTNAME + jsvc -pidfile "$PIDFILE" -stop $CLASS RETVAL=$? echo [ $RETVAL = 0 ] && rm -f ${LOCKFILE} ${PIDFILE} diff --git a/agent/distro/sles/SYSCONFDIR/init.d/cloud-agent.in b/agent/distro/sles/SYSCONFDIR/init.d/cloud-agent.in index 4046d225258..01606c72a0d 100644 --- a/agent/distro/sles/SYSCONFDIR/init.d/cloud-agent.in +++ b/agent/distro/sles/SYSCONFDIR/init.d/cloud-agent.in @@ -1,8 +1,8 @@ #!/bin/bash ### BEGIN INIT INFO # Provides: cloud agent -# Required-Start: $network -# Required-Stop: $network +# Required-Start: $network +# Required-Stop: $network # Default-Start: 3 4 5 # Default-Stop: 0 1 2 6 # X-Interactive: true @@ -40,17 +40,37 @@ PIDFILE=@PIDDIR@/"$whatami".pid LOCKFILE=@LOCKDIR@/"$SHORTNAME" LOGFILE=@AGENTLOG@ PROGNAME="Cloud Agent" +CLASS="com.cloud.agent.AgentShell" unset OPTIONS [ -r @SYSCONFDIR@/default/"$SHORTNAME" ] && source @SYSCONFDIR@/default/"$SHORTNAME" -DAEMONIZE=@BINDIR@/@PACKAGE@-daemonize -PROG=@LIBEXECDIR@/agent-runner + +# 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/java-1.5.0-sun /usr/lib/j2sdk1.5-sun /usr/lib/j2sdk1.5-ibm" + +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="@SYSTEMCLASSPATH@" +DCP="@DEPSCLASSPATH@" +ACP="@AGENTCLASSPATH@" +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:$ACP:$JCP:@AGENTSYSCONFDIR@" wait_for_network() { i=1 while [ $i -lt 10 ] do - if ip addr show cloudbr0 |grep -w inet > /dev/null 2>&1; then + # Under Ubuntu and Debian libvirt by default creates a bridge called virbr0. + # That's why we want more then 3 lines back from brctl, so that there is a manually created bridge + if [ "$(brctl show|wc -l)" -gt 2 ]; then break else sleep 1 @@ -75,12 +95,9 @@ start() { exit 1 fi - #FIXME: wait for network - wait_for_network + wait_for_network - if start-stop-daemon --start --quiet \ - --pidfile "$PIDFILE" \ - --exec "$DAEMONIZE" -- -n "$SHORTNAME" -p "$PIDFILE" -l "$LOGFILE" "$PROG" $OPTIONS + if jsvc -cp "$CLASSPATH" -pidfile "$PIDFILE" $CLASS RETVAL=$? then rc=0 @@ -106,11 +123,11 @@ stop() { count="0" echo -n $"Stopping $PROGNAME" "$SHORTNAME" - start-stop-daemon --stop --quiet --oknodo --pidfile "$PIDFILE" + jsvc -pidfile "$PIDFILE" -stop $CLASS until [ "$count" -gt "$SHUTDOWN_WAIT" ] do - agentPid=`ps aux|grep [j]ava|grep cloud-agent` + agentPid=`ps aux|grep [j]svc|grep cloud-agent` if [ "$?" -gt "0" ];then break fi @@ -118,16 +135,16 @@ stop() { let count="${count}+1" done - agentPid=`ps aux|grep [j]ava|grep cloud-agent` + agentPid=`ps aux|grep [j]svc|grep cloud-agent` if [ "$?" -eq "0" ]; then - agentPid=`ps aux|grep [j]ava|awk '{print $2}'` + agentPid=`ps aux|grep [j]svc|awk '{print $2}'` if [ "$agentPid" != "" ]; then kill -9 $agentPid fi fi - log_end_msg $? - rm -f "$PIDFILE" + log_end_msg $? + rm -f "$PIDFILE" } diff --git a/agent/distro/ubuntu/SYSCONFDIR/init.d/cloud-agent.in b/agent/distro/ubuntu/SYSCONFDIR/init.d/cloud-agent.in index c4607cbb799..4f6f04dd4d7 100755 --- a/agent/distro/ubuntu/SYSCONFDIR/init.d/cloud-agent.in +++ b/agent/distro/ubuntu/SYSCONFDIR/init.d/cloud-agent.in @@ -40,11 +40,29 @@ PIDFILE=@PIDDIR@/"$whatami".pid LOCKFILE=@LOCKDIR@/"$SHORTNAME" LOGFILE=@AGENTLOG@ PROGNAME="Cloud Agent" +CLASS="com.cloud.agent.AgentShell" unset OPTIONS [ -r @SYSCONFDIR@/default/"$SHORTNAME" ] && source @SYSCONFDIR@/default/"$SHORTNAME" -DAEMONIZE=@BINDIR@/@PACKAGE@-daemonize -PROG=@LIBEXECDIR@/agent-runner + +# 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/java-1.5.0-sun /usr/lib/j2sdk1.5-sun /usr/lib/j2sdk1.5-ibm" + +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="@SYSTEMCLASSPATH@" +DCP="@DEPSCLASSPATH@" +ACP="@AGENTCLASSPATH@" +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:$ACP:$JCP:@AGENTSYSCONFDIR@" wait_for_network() { i=1 @@ -79,9 +97,7 @@ start() { wait_for_network - if start-stop-daemon --start --quiet \ - --pidfile "$PIDFILE" \ - --exec "$DAEMONIZE" -- -n "$SHORTNAME" -p "$PIDFILE" -l "$LOGFILE" "$PROG" $OPTIONS + if jsvc -cp "$CLASSPATH" -pidfile "$PIDFILE" $CLASS RETVAL=$? then rc=0 @@ -107,11 +123,11 @@ stop() { count="0" echo -n $"Stopping $PROGNAME" "$SHORTNAME" - start-stop-daemon --stop --quiet --oknodo --pidfile "$PIDFILE" + jsvc -pidfile "$PIDFILE" -stop $CLASS until [ "$count" -gt "$SHUTDOWN_WAIT" ] do - agentPid=`ps aux|grep [j]ava|grep cloud-agent` + agentPid=`ps aux|grep [j]svc|grep cloud-agent` if [ "$?" -gt "0" ];then break fi @@ -119,16 +135,16 @@ stop() { let count="${count}+1" done - agentPid=`ps aux|grep [j]ava|grep cloud-agent` + agentPid=`ps aux|grep [j]svc|grep cloud-agent` if [ "$?" -eq "0" ]; then - agentPid=`ps aux|grep [j]ava|awk '{print $2}'` + agentPid=`ps aux|grep [j]svc|awk '{print $2}'` if [ "$agentPid" != "" ]; then kill -9 $agentPid fi fi - log_end_msg $? - rm -f "$PIDFILE" + log_end_msg $? + rm -f "$PIDFILE" } diff --git a/agent/libexec/agent-runner.in b/agent/libexec/agent-runner.in deleted file mode 100755 index 8e548ae78b3..00000000000 --- a/agent/libexec/agent-runner.in +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env bash -# 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. - -#run.sh runs the agent client. - -cd `dirname "$0"` - -SYSTEMJARS="@SYSTEMJARS@" -SCP=$(build-classpath $SYSTEMJARS) ; if [ $? != 0 ] ; then SCP="@SYSTEMCLASSPATH@" ; fi -DCP="@DEPSCLASSPATH@" -ACP="@AGENTCLASSPATH@" -export CLASSPATH=$SCP:$DCP:$ACP:@AGENTSYSCONFDIR@ -for jarfile in "@PREMIUMJAVADIR@"/* ; do - if [ ! -e "$jarfile" ] ; then continue ; fi - CLASSPATH=$jarfile:$CLASSPATH -done -for plugin in "@PLUGINJAVADIR@"/* ; do - if [ ! -e "$plugin" ] ; then continue ; fi - CLASSPATH=$plugin:$CLASSPATH -done -export CLASSPATH - -set -e -cd "@AGENTLIBDIR@" -echo Current directory is "$PWD" -echo CLASSPATH to run the agent: "$CLASSPATH" - -export PATH=/sbin:/usr/sbin:"$PATH" -SERVICEARGS= -for x in private public ; do - configuration=`grep "^$x.network.device" "@AGENTSYSCONFDIR@"/agent.properties||true` - if [ -n "$configuration" ] ; then - echo "Using manually-configured network device $CONFIGURATION" - else - defaultroute=`ip route | grep ^default | cut -d ' ' -f 5` - test -n "$defaultroute" - echo "Using auto-discovered network device $defaultroute which is the default route" - SERVICEARGS="$SERVICEARGS $x.network.device="$defaultroute - fi -done - -function termagent() { - if [ "$agentpid" != "" ] ; then - echo Killing VMOps Agent "(PID $agentpid)" with SIGTERM >&2 - kill -TERM $agentpid - echo Waiting for agent to exit >&2 - wait $agentpid - ex=$? - echo Agent exited with return code $ex >&2 - else - echo Agent PID is unknown >&2 - fi -} - -trap termagent TERM -while true ; do - java -Xms128M -Xmx384M -cp "$CLASSPATH" "$@" com.cloud.agent.AgentShell $SERVICEARGS & - agentpid=$! - echo "Agent started. PID: $!" >&2 - wait $agentpid - ex=$? - if [ $ex -gt 128 ]; then - echo "wait on agent process interrupted by SIGTERM" >&2 - exit $ex - fi - echo "Agent exited with return code $ex" >&2 - if [ $ex -eq 0 ] || [ $ex -eq 1 ] || [ $ex -eq 66 ] || [ $ex -gt 128 ]; then - echo "Exiting..." > /dev/stderr - exit $ex - fi - echo "Restarting agent..." > /dev/stderr - sleep 1 -done diff --git a/agent/src/com/cloud/agent/AgentShell.java b/agent/src/com/cloud/agent/AgentShell.java index 941f09498b4..ca3f7de02f4 100644 --- a/agent/src/com/cloud/agent/AgentShell.java +++ b/agent/src/com/cloud/agent/AgentShell.java @@ -27,6 +27,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.HttpURLConnection; import java.util.ArrayList; +import java.util.Collections; import java.util.Date; import java.util.Enumeration; import java.util.HashMap; @@ -371,7 +372,7 @@ public class AgentShell implements IAgentShell { return true; } - private void init(String[] args) throws ConfigurationException { + public void init(String[] args) throws ConfigurationException { final ComponentLocator locator = ComponentLocator.getLocator("agent"); @@ -383,8 +384,14 @@ public class AgentShell implements IAgentShell { } s_logger.info("Implementation Version is " + _version); + loadProperties(); parseCommand(args); + List properties = Collections.list((Enumeration)_properties.propertyNames()); + for (String property:properties){ + s_logger.debug("Found property: " + property); + } + _storage = locator.getManager(StorageComponent.class); if (_storage == null) { s_logger.info("Defaulting to using properties file for storage"); @@ -558,13 +565,10 @@ public class AgentShell implements IAgentShell { return _nextAgentId++; } - private void run(String[] args) { + public void start() { try { System.setProperty("java.net.preferIPv4Stack", "true"); - loadProperties(); - init(args); - String instance = getProperty(null, "instance"); if (instance == null) { if (Boolean.parseBoolean(getProperty(null, "developer"))) { @@ -579,7 +583,7 @@ public class AgentShell implements IAgentShell { String pidDir = getProperty(null, "piddir"); final String run = "agent." + instance + "pid"; - s_logger.debug("Checking to see if " + run + "exists."); + s_logger.debug("Checking to see if " + run + " exists."); ProcessUtil.pidCheck(pidDir, run); launchAgent(); @@ -616,22 +620,17 @@ public class AgentShell implements IAgentShell { } } - public static void main(String[] args) { - AgentShell shell = new AgentShell(); - Runtime.getRuntime().addShutdownHook(new ShutdownThread(shell)); - shell.run(args); + public void destroy() { + } - private static class ShutdownThread extends Thread { - AgentShell _shell; - - public ShutdownThread(AgentShell shell) { - this._shell = shell; - } - - @Override - public void run() { - _shell.stop(); + public static void main(String[] args) { + try { + AgentShell shell = new AgentShell(); + shell.init(args); + shell.start(); + } catch (ConfigurationException e) { + System.out.println(e.getMessage()); } } } diff --git a/build/deploy/production/server/conf/log4j-cloud.xml b/build/deploy/production/server/conf/log4j-cloud.xml index 1b5639641e8..83692bbbbd6 100755 --- a/build/deploy/production/server/conf/log4j-cloud.xml +++ b/build/deploy/production/server/conf/log4j-cloud.xml @@ -24,19 +24,41 @@ - - + + - - - - - + + + + + + + - - - - + + + + + + + + + + + + + + + + + + + + + @@ -101,7 +123,9 @@ - + + + diff --git a/build/package.xml b/build/package.xml index d61c6983609..30dde943acc 100755 --- a/build/package.xml +++ b/build/package.xml @@ -82,7 +82,7 @@ - + diff --git a/client/WEB-INF/classes/resources/messages.properties b/client/WEB-INF/classes/resources/messages.properties index 35fe56849d9..0ce3d4442c4 100644 --- a/client/WEB-INF/classes/resources/messages.properties +++ b/client/WEB-INF/classes/resources/messages.properties @@ -320,7 +320,7 @@ state.Ready=Ready label.vm.display.name=VM display name label.select-view=Select view label.local.storage=Local Storage -label.direct.ips=Direct IPs +label.direct.ips=Shared Network IPs label.view.all=View all label.zone.details=Zone details message.alert.state.detected=Alert state detected diff --git a/client/tomcatconf/components.xml.in b/client/tomcatconf/components.xml.in index e9c481923be..6893fe02343 100755 --- a/client/tomcatconf/components.xml.in +++ b/client/tomcatconf/components.xml.in @@ -168,7 +168,7 @@ - + diff --git a/cloud-cli/cloudapis/cloud.py b/cloud-cli/cloudapis/cloud.py index 856d81177d3..34b3413ce5e 100644 --- a/cloud-cli/cloudapis/cloud.py +++ b/cloud-cli/cloudapis/cloud.py @@ -167,7 +167,7 @@ def load_dynamic_methods(): code = """ def %s(%s): %s - parms = locals() + parms = dict(locals()) del parms["self"] for arg in %r: if locals()[arg] is None: diff --git a/cloud.spec b/cloud.spec index 7233f0150e2..63a7e8aae71 100644 --- a/cloud.spec +++ b/cloud.spec @@ -201,6 +201,7 @@ Requires: /sbin/service Requires: /sbin/chkconfig Requires: jna Requires: ebtables +Requires: jsvc Group: System Environment/Libraries Requires: kvm @@ -255,6 +256,7 @@ Requires: java >= 1.6.0 Requires: %{name}-utils = %{version}, %{name}-core = %{version}, %{name}-deps = %{version}, %{name}-server = %{version} Requires: %{name}-setup = %{version} Requires: %{name}-client = %{version} +Requires: jsvc License: GPLv3+ Group: System Environment/Libraries %description usage diff --git a/daemonize/daemonize.c b/daemonize/daemonize.c deleted file mode 100644 index 0d3e392fd0f..00000000000 --- a/daemonize/daemonize.c +++ /dev/null @@ -1,351 +0,0 @@ -/* -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. -*/ - -/* -UNIX daemonizer. Daemonizes any non-interactive console program and watches over it. -Whenever a signal is sent to this process, it halts the daemonized process as well. - -To compile: cc -o daemonize daemonize.c -Usage: ./daemonize -? -Users of this: catalina initscript -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define RUNNING_DIR "/" -#define PIDFILE "/var/run/daemonize.pid" -#define VARLOGFILE "/var/log/daemon.log" -#define PROGNAME "daemonized" -#define DEFAULTUSER "root" - -char * pidfile = PIDFILE; -char * varlogfile = VARLOGFILE; -char * progname = PROGNAME; -char * user = PROGNAME; - -void initialize_syslog(const char*pn) { - openlog(pn,LOG_PID,LOG_DAEMON); - syslog(LOG_INFO, "syslog connection opened"); -} - -void cleanup_syslog() { - syslog(LOG_INFO, "syslog connection closed"); - closelog(); -} - -int killed = 0; -int killsignal = 0; -int pidfile_fd; -int varlogfile_fd; -int uid = 0; int gid = 0; -struct passwd *creds; - -void signal_handler(sig) -int sig; -{ - killsignal = sig; - switch(sig) { - case SIGCHLD: - syslog(LOG_INFO,"sigchild signal caught"); - break; - case SIGHUP: - syslog(LOG_INFO,"hangup signal caught"); - killed = 1; - break; - case SIGTERM: - syslog(LOG_INFO,"terminate signal caught"); - killed = 1; - break; - case SIGINT: - syslog(LOG_INFO,"keyboard interrupt signal caught"); - killed = 1; - break; - } -} - -int daemonize(const char*prog_name) -{ - - char str[10]; - int i; - int bufsize=1024; char *buf = malloc(1024); - - umask( S_IWGRP | S_IROTH | S_IWOTH ); /* set newly created file permissions */ - - /* test logfile */ - varlogfile_fd=open(varlogfile,O_RDWR|O_CREAT|O_APPEND,0666); - if (varlogfile_fd == -1) { - snprintf(buf,bufsize,"Could not open output file %s -- exiting",varlogfile); perror(buf); - return 1; /* exitvalue */ - } - if (uid != 0) { - chown(varlogfile,uid,gid); - } - close(varlogfile_fd); - pidfile_fd=open(pidfile,O_RDWR|O_CREAT,0666); - if (pidfile_fd<0) { - snprintf(buf,bufsize,"The PID file %s cannot be opened -- exiting",pidfile); perror(buf); - return 2; /* exitvalue */ - } - if (lockf(pidfile_fd,F_TEST,0)==1) { - snprintf(buf,bufsize,"A daemon is already running (cannot lock PID file %s) -- exiting",pidfile); perror(buf); - return 3; /* exitvalue */ - } - close(pidfile_fd); - - if(getppid()==1) return 0; /* already a daemon */ - i=fork(); - if (i < 0) return 4; /* exitvalue */ /* fork error */ - if (i > 0) exit(0); /* parent exits */ - - /* child (daemon) continues */ - setsid(); /* obtain a new process group */ - - chdir(RUNNING_DIR); /* change running directory */ - - /* close FDs and reopen to logfile */ - for (i=getdtablesize();i>=0;--i) close(i); /* close all descriptors */ - varlogfile_fd=open(varlogfile,O_RDWR|O_APPEND,0666); dup(varlogfile_fd); dup(varlogfile_fd); /* handle standart I/O */ - initialize_syslog(prog_name); /* set up syslog */ - - /* PID file */ - pidfile_fd=open(pidfile,O_RDWR|O_CREAT,0666); - if (pidfile_fd<0) { - syslog(LOG_ERR,"The PID file %s cannot be opened (%m) -- exiting",pidfile); - return 2; /* exitvalue */ - } - if (lockf(pidfile_fd,F_TLOCK,0)<0) { - syslog(LOG_ERR,"A daemon is already running -- cannot lock PID file %s (%m) -- exiting",pidfile); - return 3; /* exitvalue */ - } - - /* first instance continues */ - - /* record pid to pidfile */ - sprintf(str,"%d\n",getpid()); - if (write(pidfile_fd,str,strlen(str)) < strlen(str)) { - syslog(LOG_ERR,"Could not write PID into PID file %s (%m) -- exiting",pidfile); - return 5; /* exitvalue */ - } - signal(SIGTSTP,SIG_IGN); /* ignore tty signals */ - signal(SIGTTOU,SIG_IGN); - signal(SIGTTIN,SIG_IGN); - signal(SIGHUP,signal_handler); /* catch hangup signal */ - signal(SIGTERM,signal_handler); /* catch kill signal */ - signal(SIGINT,signal_handler); /* catch keyboard interrupt signal */ - - return 0; -} - -void cleanup() { - cleanup_syslog(); - unlink(pidfile); - close(pidfile_fd); - close(varlogfile_fd); -} - -void usage(char * cmdname) { - fprintf (stderr, - "Usage: %s [options...] -- [command-specific arguments...]\n" - "Daemonize any program.\n" - "\n" - "Options:\n" - "\n" - " -l : log stdout/stderr to this *absolute* path (default "VARLOGFILE")\n" - " -u : setuid() to this user name before starting the program (default "DEFAULTUSER")\n" - " -p : lock and write the PID to this *absolute* path (default "PIDFILE")\n" - " -n : name the daemon assumes (default "PROGNAME")\n" - " -h: show this usage guide\n" - "\n" - "Exit status:\n" - " 0 if daemonized correctly\n" - " other if an error took place\n" - "", cmdname); - exit(0); -} - -int parse_args(int argc,char ** argv) { - int index; - int c; - -// pidfile = PIDFILE; -// varlogfile = VARLOGFILE; -// progname = PROGNAME; - - opterr = 0; - - while ((c = getopt (argc, argv, "l:p:n:u:")) != -1) - switch (c) - { - case 'l': - varlogfile = optarg; - break; - case 'p': - pidfile = optarg; - break; - case 'n': - progname = optarg; - break; - case 'u': - if (getuid() != 0) { - fprintf (stderr, "-u can only be used by root.\nSee help with -h\n", user); - exit(64); - } - user = optarg; - creds = getpwnam(user); - if (creds == NULL) { - fprintf (stderr, "User %s was not found in the user database.\nSee help with -h\n", user); - exit(63); - } - uid = creds->pw_uid; gid = creds->pw_gid; - break; -// case 'h': -// break; -// usage(argv[0]); /* halts after this */ - case '?': - if (optopt == '?' || optopt == 'h') - usage(argv[0]); /* halts after this */ - if (optopt == 'l' || optopt == 'p' || optopt == 'n') - fprintf (stderr, "Option -%c requires an argument.\nSee help with -h\n", optopt); - else if (isprint (optopt)) - fprintf (stderr, "Unknown option `-%c'.\nSee help with -h\n", optopt); - else - fprintf (stderr, "Unknown option character `\\x%x'.\nSee help with -h\n", optopt); - exit(64); /* exitvalue */ - default: - abort (); - } - - for (index = optind; index < argc; index++); - - if (index == optind) { - fprintf (stderr, "You need to specify a command to run.\nSee help with -h\n", optopt); - exit(64); /* exitvalue */ - } - - return optind; -} - -int main(int argc, char** argv) -{ - /* parse command line arguments, we will use the first non-option one as the starting point */ - int i; - char ** newargv = calloc(argc+1, sizeof(char**)); - int startat = parse_args(argc,argv); - int newargc = argc - startat; - for (i = startat; i < argc; i++) { newargv[i-startat] = argv[i]; } - - /* try and daemonize */ - int daemonret = daemonize(progname); - if (daemonret) exit(daemonret); - syslog(LOG_INFO,"successfully daemonized"); - - /* fork */ - int pid, wpid, status, execret; - syslog(LOG_INFO,"starting %s in subprocess",newargv[0]); - pid = fork(); - if (pid < 0) { - /* failed to fork, damnit! */ - syslog(LOG_ERR,"could not fork to run %s as a child process (%m)",newargv[0]); - exit(4); /* exitvalue */ - } - else if (pid == 0) { - /* child */ - if (uid != 0) { - execret = setgid(gid); - if (execret == -1) { - syslog(LOG_ERR,"could not setgid() to gid %d",gid); - exit(8); /* exitvalue */ - } - execret = setuid(uid); - if (execret == -1) { - syslog(LOG_ERR,"could not setuid() to uid %d",uid); - exit(8); /* exitvalue */ - } - } - execret = execvp(newargv[0],newargv); - if (errno == 2) { - syslog(LOG_ERR,"could not run program: no such file or directory"); - exit(127); - } - if (errno == 13) { - syslog(LOG_ERR,"could not run program: permission denied"); - exit(126); - } - syslog(LOG_ERR,"could not run program: unknown reason"); - exit(255); - } - - /* parent continues here */ - syslog(LOG_INFO,"successfully started subprocess -- PID %d",pid); - int finalexit = 0; - int waitret = 0; - while (1) { - if (killed) { - kill(pid,killsignal); - killed = 0; - } - waitret = waitpid(pid,&status,WNOHANG); - if (waitret == pid) break; - usleep(250000); - } - - - if WIFEXITED(status) { - switch (WEXITSTATUS(status)) { - case 0: - syslog(LOG_INFO,"%s exited normally",newargv[0]); - break; - case 126: - syslog(LOG_ERR,"%s: permission denied",newargv[0]); - finalexit = 126; /* exitvalue */ - break; - case 127: - syslog(LOG_ERR,"%s: command not found",newargv[0]); - finalexit = 127; /* exitvalue */ - break; - default: - syslog(LOG_INFO,"%s exited abnormally with status %d",newargv[0],WEXITSTATUS(status)); - finalexit = 6; /* exitvalue */ - } - } - if WIFSIGNALED(status) { - syslog(LOG_INFO,"%s was killed with signal %d",newargv[0],WTERMSIG(status)); - finalexit = 7; /* exitvalue */ - } - - syslog(LOG_INFO,"shutting down"); - cleanup(); - exit(finalexit); -} - -/* EOF */ - diff --git a/debian/cloud-agent-deps.install b/debian/cloud-agent-deps.install index 57122ac8ffc..13c444ec96d 100644 --- a/debian/cloud-agent-deps.install +++ b/debian/cloud-agent-deps.install @@ -1,3 +1,3 @@ /usr/share/java/cloud-google-gson-1.7.1.jar -/usr/share/java/cloud-libvirt-0.4.5.jar +/usr/share/java/libvirt-0.4.8.jar /usr/share/java/cloud-log4j-extras.jar diff --git a/debian/control b/debian/control index db717a48114..56696108448 100644 --- a/debian/control +++ b/debian/control @@ -123,7 +123,7 @@ Provides: vmops-agent Conflicts: vmops-agent Replaces: vmops-agent Architecture: any -Depends: openjdk-6-jre, cloud-utils (= ${source:Version}), cloud-core (= ${source:Version}), cloud-agent-deps (= ${source:Version}), python, cloud-python (= ${source:Version}), cloud-agent-libs (= ${source:Version}), cloud-agent-scripts (= ${source:Version}), libcommons-httpclient-java, libcommons-collections-java, libcommons-dbcp-java, libcommons-pool-java, libcommons-logging-java, libvirt0, sysvinit-utils, chkconfig, qemu-kvm, libvirt-bin, uuid-runtime, rsync, grep, iproute, ebtables, vlan, libcglib-java, libcommons-httpclient-java, libservlet2.5-java, liblog4j1.2-java, libjna-java, wget +Depends: openjdk-6-jre, cloud-utils (= ${source:Version}), cloud-core (= ${source:Version}), cloud-agent-deps (= ${source:Version}), python, cloud-python (= ${source:Version}), cloud-agent-libs (= ${source:Version}), cloud-agent-scripts (= ${source:Version}), libcommons-httpclient-java, libcommons-collections-java, libcommons-dbcp-java, libcommons-pool-java, libcommons-logging-java, libvirt0, sysvinit-utils, chkconfig, qemu-kvm, libvirt-bin, uuid-runtime, rsync, grep, iproute, ebtables, vlan, libcglib-java, libcommons-httpclient-java, libservlet2.5-java, liblog4j1.2-java, libjna-java, wget, jsvc Description: CloudStack agent The CloudStack agent is in charge of managing shared computing resources in a CloudStack Cloud Stack-powered cloud. Install this package if this computer @@ -141,7 +141,7 @@ Provides: vmops-usage Conflicts: vmops-usage Replaces: vmops-usage Architecture: any -Depends: openjdk-6-jre, cloud-utils (= ${source:Version}), cloud-core (= ${source:Version}), cloud-deps (= ${source:Version}), cloud-server (= ${source:Version}), cloud-setup (= ${source:Version}), cloud-client (= ${source:Version}) +Depends: openjdk-6-jre, cloud-utils (= ${source:Version}), cloud-core (= ${source:Version}), cloud-deps (= ${source:Version}), cloud-server (= ${source:Version}), cloud-setup (= ${source:Version}), cloud-client (= ${source:Version}), jsvc Description: CloudStack usage monitor The CloudStack usage monitor provides usage accounting across the entire cloud for cloud operators to charge based on usage parameters. diff --git a/deps/.classpath b/deps/.classpath index b9eb504b959..0ae345797a1 100755 --- a/deps/.classpath +++ b/deps/.classpath @@ -15,7 +15,7 @@ - + diff --git a/deps/cloud-libvirt-0.4.5.jar b/deps/libvirt-0.4.8.jar similarity index 63% rename from deps/cloud-libvirt-0.4.5.jar rename to deps/libvirt-0.4.8.jar index 9d0a1dfbe60..3a30a1ae551 100644 Binary files a/deps/cloud-libvirt-0.4.5.jar and b/deps/libvirt-0.4.8.jar differ diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java index 8d7b37c9a95..4a398cfa418 100755 --- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java +++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java @@ -2465,7 +2465,11 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa if (cmd.isAttach()) { vmMo.mountToolsInstaller(); } else { + try{ vmMo.unmountToolsInstaller(); + }catch(Throwable e){ + vmMo.detachIso(null); + } } return new Answer(cmd); diff --git a/plugins/network-elements/f5/src/com/cloud/api/commands/AddExternalLoadBalancerCmd.java b/plugins/network-elements/f5/src/com/cloud/api/commands/AddExternalLoadBalancerCmd.java index a8208ae1e8b..3fa61167efa 100644 --- a/plugins/network-elements/f5/src/com/cloud/api/commands/AddExternalLoadBalancerCmd.java +++ b/plugins/network-elements/f5/src/com/cloud/api/commands/AddExternalLoadBalancerCmd.java @@ -1,15 +1,20 @@ -// Copyright 2012 Citrix Systems, Inc. Licensed under the -// Apache License, Version 2.0 (the "License"); you may not use this -// file except in compliance with the License. Citrix Systems, Inc. -// reserves all rights not expressly granted by 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. -// -// Automatically generated by addcopyright.py at 04/03/2012 +// 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. + package com.cloud.api.commands; import org.apache.log4j.Logger; @@ -102,4 +107,4 @@ public class AddExternalLoadBalancerCmd extends BaseCmd { throw new ServerApiException(BaseCmd.INTERNAL_ERROR, cre.getMessage()); } } -} \ No newline at end of file +} diff --git a/plugins/network-elements/f5/src/com/cloud/api/commands/AddF5LoadBalancerCmd.java b/plugins/network-elements/f5/src/com/cloud/api/commands/AddF5LoadBalancerCmd.java index bec09989abd..13c443e7cf0 100644 --- a/plugins/network-elements/f5/src/com/cloud/api/commands/AddF5LoadBalancerCmd.java +++ b/plugins/network-elements/f5/src/com/cloud/api/commands/AddF5LoadBalancerCmd.java @@ -1,15 +1,20 @@ -// Copyright 2012 Citrix Systems, Inc. Licensed under the -// Apache License, Version 2.0 (the "License"); you may not use this -// file except in compliance with the License. Citrix Systems, Inc. -// reserves all rights not expressly granted by 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. -// -// Automatically generated by addcopyright.py at 04/03/2012 +// 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. + package com.cloud.api.commands; import org.apache.log4j.Logger; @@ -127,4 +132,4 @@ public class AddF5LoadBalancerCmd extends BaseAsyncCmd { public long getEntityOwnerId() { return UserContext.current().getCaller().getId(); } -} \ No newline at end of file +} diff --git a/plugins/network-elements/f5/src/com/cloud/api/commands/ConfigureF5LoadBalancerCmd.java b/plugins/network-elements/f5/src/com/cloud/api/commands/ConfigureF5LoadBalancerCmd.java index 20b2e5a3b8c..9f5217c3280 100644 --- a/plugins/network-elements/f5/src/com/cloud/api/commands/ConfigureF5LoadBalancerCmd.java +++ b/plugins/network-elements/f5/src/com/cloud/api/commands/ConfigureF5LoadBalancerCmd.java @@ -1,15 +1,20 @@ -// Copyright 2012 Citrix Systems, Inc. Licensed under the -// Apache License, Version 2.0 (the "License"); you may not use this -// file except in compliance with the License. Citrix Systems, Inc. -// reserves all rights not expressly granted by 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. -// -// Automatically generated by addcopyright.py at 04/03/2012 +// 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. + package com.cloud.api.commands; import org.apache.log4j.Logger; diff --git a/plugins/network-elements/f5/src/com/cloud/api/commands/DeleteExternalLoadBalancerCmd.java b/plugins/network-elements/f5/src/com/cloud/api/commands/DeleteExternalLoadBalancerCmd.java index c4b903a5c81..2c89a4a6a9d 100644 --- a/plugins/network-elements/f5/src/com/cloud/api/commands/DeleteExternalLoadBalancerCmd.java +++ b/plugins/network-elements/f5/src/com/cloud/api/commands/DeleteExternalLoadBalancerCmd.java @@ -1,15 +1,20 @@ -// Copyright 2012 Citrix Systems, Inc. Licensed under the -// Apache License, Version 2.0 (the "License"); you may not use this -// file except in compliance with the License. Citrix Systems, Inc. -// reserves all rights not expressly granted by 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. -// -// Automatically generated by addcopyright.py at 04/03/2012 +// 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. + package com.cloud.api.commands; import org.apache.log4j.Logger; diff --git a/plugins/network-elements/f5/src/com/cloud/api/commands/DeleteF5LoadBalancerCmd.java b/plugins/network-elements/f5/src/com/cloud/api/commands/DeleteF5LoadBalancerCmd.java index 4fcd734a05f..959819b1588 100644 --- a/plugins/network-elements/f5/src/com/cloud/api/commands/DeleteF5LoadBalancerCmd.java +++ b/plugins/network-elements/f5/src/com/cloud/api/commands/DeleteF5LoadBalancerCmd.java @@ -1,15 +1,20 @@ -// Copyright 2012 Citrix Systems, Inc. Licensed under the -// Apache License, Version 2.0 (the "License"); you may not use this -// file except in compliance with the License. Citrix Systems, Inc. -// reserves all rights not expressly granted by 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. -// -// Automatically generated by addcopyright.py at 04/03/2012 +// 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. + package com.cloud.api.commands; import org.apache.log4j.Logger; diff --git a/plugins/network-elements/f5/src/com/cloud/api/commands/ListExternalLoadBalancersCmd.java b/plugins/network-elements/f5/src/com/cloud/api/commands/ListExternalLoadBalancersCmd.java index 6551985363a..acb71b06c0a 100644 --- a/plugins/network-elements/f5/src/com/cloud/api/commands/ListExternalLoadBalancersCmd.java +++ b/plugins/network-elements/f5/src/com/cloud/api/commands/ListExternalLoadBalancersCmd.java @@ -1,15 +1,20 @@ -// Copyright 2012 Citrix Systems, Inc. Licensed under the -// Apache License, Version 2.0 (the "License"); you may not use this -// file except in compliance with the License. Citrix Systems, Inc. -// reserves all rights not expressly granted by 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. -// -// Automatically generated by addcopyright.py at 04/03/2012 +// 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. + package com.cloud.api.commands; import java.util.ArrayList; diff --git a/plugins/network-elements/f5/src/com/cloud/api/commands/ListF5LoadBalancerNetworksCmd.java b/plugins/network-elements/f5/src/com/cloud/api/commands/ListF5LoadBalancerNetworksCmd.java index efa71b554eb..f2fa071b53e 100644 --- a/plugins/network-elements/f5/src/com/cloud/api/commands/ListF5LoadBalancerNetworksCmd.java +++ b/plugins/network-elements/f5/src/com/cloud/api/commands/ListF5LoadBalancerNetworksCmd.java @@ -1,15 +1,20 @@ -// Copyright 2012 Citrix Systems, Inc. Licensed under the -// Apache License, Version 2.0 (the "License"); you may not use this -// file except in compliance with the License. Citrix Systems, Inc. -// reserves all rights not expressly granted by 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. -// -// Automatically generated by addcopyright.py at 04/03/2012 +// 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. + package com.cloud.api.commands; import java.util.ArrayList; diff --git a/plugins/network-elements/f5/src/com/cloud/api/commands/ListF5LoadBalancersCmd.java b/plugins/network-elements/f5/src/com/cloud/api/commands/ListF5LoadBalancersCmd.java index 228bab5623a..fe4cb67bd01 100644 --- a/plugins/network-elements/f5/src/com/cloud/api/commands/ListF5LoadBalancersCmd.java +++ b/plugins/network-elements/f5/src/com/cloud/api/commands/ListF5LoadBalancersCmd.java @@ -1,15 +1,20 @@ -// Copyright 2012 Citrix Systems, Inc. Licensed under the -// Apache License, Version 2.0 (the "License"); you may not use this -// file except in compliance with the License. Citrix Systems, Inc. -// reserves all rights not expressly granted by 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. -// -// Automatically generated by addcopyright.py at 04/03/2012 +// 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. + package com.cloud.api.commands; import java.util.ArrayList; diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index f0e8afaec99..95fc0de4231 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -227,7 +227,6 @@ import com.cloud.utils.db.JoinBuilder; import com.cloud.utils.db.JoinBuilder.JoinType; import com.cloud.utils.db.SearchBuilder; import com.cloud.utils.db.SearchCriteria; -import com.cloud.utils.db.SearchCriteria.Op; import com.cloud.utils.db.Transaction; import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.net.MacAddress; @@ -1789,21 +1788,6 @@ public class ManagementServerImpl implements ManagementServer { vlanType = VlanType.VirtualNetwork; } - // don't show SSVM/CPVM ips - boolean omitSystemVmIps = false; - if (vlanType == VlanType.VirtualNetwork && (allocatedOnly) && vpcId == null) { - - SearchBuilder nonSystemVmSearch = _nicDao.createSearchBuilder(); - nonSystemVmSearch.and().op("vmTypeNnull", nonSystemVmSearch.entity().getVmType(), Op.NULL); - nonSystemVmSearch.or("vmType", nonSystemVmSearch.entity().getVmType(), Op.NOTIN); - nonSystemVmSearch.cp(); - sb.join("nonSystemVms", nonSystemVmSearch, sb.entity().getAddress(), - nonSystemVmSearch.entity().getIp4Address(), JoinType.LEFTOUTER); -// sb.and().join("nonSystemVms", nonSystemVmSearch, sb.entity().getSourceNetworkId(), -// nonSystemVmSearch.entity().getNetworkId(), JoinType.INNER); - omitSystemVmIps = true; - } - SearchCriteria sc = sb.create(); if (isAllocated) { _accountMgr.buildACLSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria); @@ -1820,10 +1804,6 @@ public class ManagementServerImpl implements ManagementServer { count++; } } - - if (omitSystemVmIps) { - sc.setJoinParameters("nonSystemVms", "vmType", VirtualMachine.Type.ConsoleProxy, VirtualMachine.Type.SecondaryStorageVm); - } if (zone != null) { sc.setParameters("dataCenterId", zone); diff --git a/server/test/com/cloud/user/MockAccountManagerImpl.java b/server/test/com/cloud/user/MockAccountManagerImpl.java index f4342a3146c..8f6d4fa21a5 100644 --- a/server/test/com/cloud/user/MockAccountManagerImpl.java +++ b/server/test/com/cloud/user/MockAccountManagerImpl.java @@ -336,4 +336,13 @@ public class MockAccountManagerImpl implements Manager, AccountManager { // TODO Auto-generated method stub } + /* (non-Javadoc) + * @see com.cloud.user.AccountService#getUserByApiKey(java.lang.String) + */ + @Override + public UserAccount getUserByApiKey(String apiKey) { + // TODO Auto-generated method stub + return null; + } + } diff --git a/usage/distro/ubuntu/SYSCONFDIR/init.d/cloud-usage.in b/usage/distro/ubuntu/SYSCONFDIR/init.d/cloud-usage.in index e59fc2acecb..13876b94407 100755 --- a/usage/distro/ubuntu/SYSCONFDIR/init.d/cloud-usage.in +++ b/usage/distro/ubuntu/SYSCONFDIR/init.d/cloud-usage.in @@ -18,11 +18,29 @@ LOCKFILE=@LOCKDIR@/"$SHORTNAME" LOGFILE=@USAGELOG@ PROGNAME="CloudStack Usage Monitor" USER=@MSUSER@ +CLASS="com.cloud.usage.UsageServer" unset OPTIONS [ -r @SYSCONFDIR@/default/"$SHORTNAME" ] && source @SYSCONFDIR@/default/"$SHORTNAME" -DAEMONIZE=@BINDIR@/@PACKAGE@-daemonize -PROG=@LIBEXECDIR@/usage-runner + +# 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/java-1.5.0-sun /usr/lib/j2sdk1.5-sun /usr/lib/j2sdk1.5-ibm" + +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="@SYSTEMCLASSPATH@" +DCP="@DEPSCLASSPATH@" +UCP="@USAGECLASSPATH@" +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:@USAGESYSCONFDIR@" start() { log_daemon_msg $"Starting $PROGNAME" "$SHORTNAME" @@ -39,9 +57,7 @@ start() { exit 1 fi - if start-stop-daemon --start --quiet \ - --pidfile "$PIDFILE" \ - --exec "$DAEMONIZE" -- -n "$SHORTNAME" -p "$PIDFILE" -l "$LOGFILE" -u "$USER" "$PROG" $OPTIONS + if jsvc -cp "$CLASSPATH" -pidfile "$PIDFILE" -user "$USER" $CLASS RETVAL=$? then rc=0 @@ -64,7 +80,7 @@ start() { stop() { echo -n $"Stopping $PROGNAME" "$SHORTNAME" - start-stop-daemon --stop --quiet --oknodo --pidfile "$PIDFILE" + jsvc -pidfile "$PIDFILE" -stop $CLASS log_end_msg $? rm -f "$PIDFILE" } diff --git a/usage/libexec/usage-runner.in b/usage/libexec/usage-runner.in deleted file mode 100755 index a5d57efc9e3..00000000000 --- a/usage/libexec/usage-runner.in +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash -# 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 -# 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. - -SYSTEMJARS="@SYSTEMJARS@" -SCP=$(build-classpath $SYSTEMJARS) ; if [ $? != 0 ] ; then SCP="@SYSTEMCLASSPATH@" ; fi -DCP="@DEPSCLASSPATH@" -ACP="@USAGECLASSPATH@" -export CLASSPATH=$SCP:$DCP:$ACP:@USAGESYSCONFDIR@ -for jarfile in "@PREMIUMJAVADIR@"/* ; do - if [ ! -e "$jarfile" ] ; then continue ; fi - CLASSPATH=$jarfile:$CLASSPATH -done -for plugin in "@PLUGINJAVADIR@"/* ; do - if [ ! -e "$plugin" ] ; then continue ; fi - CLASSPATH=$plugin:$CLASSPATH -done -export CLASSPATH - -set -e -echo Current directory is "$PWD" -echo CLASSPATH to run the usage server: "$CLASSPATH" -exec java -cp "$CLASSPATH" -Dpid=$$ -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=@USAGELOGDIR@ "$@" com.cloud.usage.UsageServer diff --git a/usage/src/com/cloud/usage/UsageServer.java b/usage/src/com/cloud/usage/UsageServer.java index c03f7f0efa1..4cdca7986c2 100644 --- a/usage/src/com/cloud/usage/UsageServer.java +++ b/usage/src/com/cloud/usage/UsageServer.java @@ -28,7 +28,16 @@ public class UsageServer { * @param args */ public static void main(String[] args) { - // TODO: do we need to communicate with mgmt server? + UsageServer usage = new UsageServer(); + usage.init(args); + usage.start(); + } + + public void init(String[] args) { + + } + + public void start() { final ComponentLocator _locator = ComponentLocator.getLocator(UsageServer.Name, "usage-components.xml", "log4j-cloud_usage"); UsageManager mgr = _locator.getManager(UsageManager.class); if (mgr != null) { @@ -37,4 +46,12 @@ public class UsageServer { } } } + + public void stop() { + + } + + public void destroy() { + + } }