Merge branch 'master' into api_refactoring

This commit is contained in:
Rohit Yadav 2013-01-07 17:28:57 -08:00
commit 0a25884215
5 changed files with 231 additions and 2 deletions

View File

@ -55,6 +55,57 @@
</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
todir="${basedir}/target/transformed">
<fileset dir="${basedir}/conf">
<include name="agent.properties" />
</fileset>
</copy>
<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>
<copy overwrite="true"
todir="${basedir}/target/transformed">
<fileset dir="${basedir}/bindir">
<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>

121
packaging/centos63/cloud-agent.rc Executable file
View File

@ -0,0 +1,121 @@
#!/bin/bash
# chkconfig: 35 99 10
# description: Cloud Agent
# 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.
# WARNING: if this script is changed, then all other initscripts MUST BE changed to match it as well
. /etc/rc.d/init.d/functions
whatami=cloud-agent
# set environment variables
SHORTNAME="$whatami"
PIDFILE=/var/run/"$whatami".pid
LOCKFILE=/var/lock/subsys/"$SHORTNAME"
LOGFILE=/var/log/cloud/agent/agent.log
PROGNAME="Cloud Agent"
CLASS="com.cloud.agent.AgentShell"
JSVC=`which jsvc 2>/dev/null`;
# exit if we don't find jsvc
if [ -z "$JSVC" ]; then
echo no jsvc found in path;
exit 1;
fi
unset OPTIONS
[ -r /etc/sysconfig/"$SHORTNAME" ] && source /etc/sysconfig/"$SHORTNAME"
# The first existing directory is used for JAVA_HOME (if JAVA_HOME is not defined in $DEFAULT)
JDK_DIRS="/usr/lib/jvm/jre /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=""
DCP=""
ACP=`ls /usr/share/cloud/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:$ACP:$JCP:/etc/cloud/agent:/usr/lib64/cloud/agent"
start() {
echo -n $"Starting $PROGNAME: "
if hostname --fqdn >/dev/null 2>&1 ; then
$JSVC -cp "$CLASSPATH" -pidfile "$PIDFILE" $CLASS
RETVAL=$?
echo
else
failure
echo
echo The host name does not resolve properly to an IP address. Cannot start "$PROGNAME". > /dev/stderr
RETVAL=9
fi
[ $RETVAL = 0 ] && touch ${LOCKFILE}
return $RETVAL
}
stop() {
echo -n $"Stopping $PROGNAME: "
$JSVC -pidfile "$PIDFILE" -stop $CLASS
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${LOCKFILE} ${PIDFILE}
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -p ${PIDFILE} $SHORTNAME
RETVAL=$?
;;
restart)
stop
sleep 3
start
;;
condrestart)
if status -p ${PIDFILE} $SHORTNAME >&/dev/null; then
stop
sleep 3
start
fi
;;
*)
echo $"Usage: $whatami {start|stop|restart|condrestart|status|help}"
RETVAL=3
esac
exit $RETVAL

View File

@ -103,6 +103,18 @@ Group: System Environment/Libraries
The CloudStack Python library contains a few Python modules that the
CloudStack uses.
%package agent
Summary: CloudStack Agent for KVM hypervisors
Requires: java >= 1.6.0
Requires: %{name}-python = %{_ver}
Requires: libvirt
Requires: bridge-utils
Requires: ebtables
Requires: jsvc
Requires: jna
Group: System Environment/Libraries
%description agent
The CloudStack agent for KVM hypervisors
%prep
echo Doing CloudStack build
@ -183,8 +195,22 @@ chmod 770 ${RPM_BUILD_ROOT}%{_localstatedir}/cache/%{name}/management/temp
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
%clean
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
install -D agent/target/transformed/agent.properties ${RPM_BUILD_ROOT}/etc/cloud/agent/agent.properties
install -D agent/target/transformed/environment.properties ${RPM_BUILD_ROOT}/etc/cloud/agent/environment.properties
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
%clean
[ ${RPM_BUILD_ROOT} != "/" ] && rm -rf ${RPM_BUILD_ROOT}
@ -271,6 +297,14 @@ fi
%doc LICENSE
%doc NOTICE
%files agent
%attr(0755,root,root) %{_bindir}/%{name}-setup-agent
%attr(0755,root,root) %{_bindir}/%{name}-ssh
%attr(0755,root,root) %{_sysconfdir}/init.d/cloud-agent
%config(noreplace) %{_sysconfdir}/cloud/agent
%dir /var/log/cloud/agent
%attr(0644,root,root) /usr/share/cloud/java/*.jar
%attr(0755,root,root) /usr/share/cloud/scripts
%changelog
* Fri Oct 03 2012 Hugo Trippaers <hugo@apache.org> 4.1.0

View File

@ -94,6 +94,24 @@
</execution>
</executions>
</plugin>
<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>
</plugins>
</build>
</project>

View File

@ -350,7 +350,12 @@ public class Script implements Callable<String> {
* Look in WEB-INF/classes of the webapp
* URI workaround the URL encoding of url.getFile
*/
url = Script.class.getClassLoader().getResource(path + script);
if (path.endsWith(File.separator)) {
url = Script.class.getClassLoader().getResource(path + script);
}
else {
url = Script.class.getClassLoader().getResource(path + File.separator + script);
}
s_logger.debug("Classpath resource: " + url);
if (url != null) {
try {