Skip to content

Commit 0a25884

Browse files
committed
Merge branch 'master' into api_refactoring
2 parents 0894822 + 91673b1 commit 0a25884

5 files changed

Lines changed: 231 additions & 2 deletions

File tree

agent/pom.xml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,57 @@
5555
</execution>
5656
</executions>
5757
</plugin>
58+
<plugin>
59+
<artifactId>maven-antrun-plugin</artifactId>
60+
<version>1.7</version>
61+
<executions>
62+
<execution>
63+
<id>generate-resource</id>
64+
<phase>generate-resources</phase>
65+
<goals>
66+
<goal>run</goal>
67+
</goals>
68+
<configuration>
69+
<target>
70+
<copy
71+
todir="${basedir}/target/transformed">
72+
<fileset dir="${basedir}/conf">
73+
<include name="agent.properties" />
74+
</fileset>
75+
</copy>
76+
<copy overwrite="true"
77+
todir="${basedir}/target/transformed">
78+
<fileset dir="${basedir}/conf">
79+
<include name="*.in" />
80+
</fileset>
81+
<globmapper from="*.in" to="*" />
82+
<filterchain>
83+
<filterreader
84+
classname="org.apache.tools.ant.filters.ReplaceTokens">
85+
<param type="propertiesfile"
86+
value="${basedir}/../build/replace.properties" />
87+
</filterreader>
88+
</filterchain>
89+
</copy>
90+
<copy overwrite="true"
91+
todir="${basedir}/target/transformed">
92+
<fileset dir="${basedir}/bindir">
93+
<include name="*.in" />
94+
</fileset>
95+
<globmapper from="*.in" to="*" />
96+
<filterchain>
97+
<filterreader
98+
classname="org.apache.tools.ant.filters.ReplaceTokens">
99+
<param type="propertiesfile"
100+
value="${basedir}/../build/replace.properties" />
101+
</filterreader>
102+
</filterchain>
103+
</copy>
104+
</target>
105+
</configuration>
106+
</execution>
107+
</executions>
108+
</plugin>
58109
</plugins>
59110
</build>
60111
</project>

packaging/centos63/cloud-agent.rc

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
#!/bin/bash
2+
3+
# chkconfig: 35 99 10
4+
# description: Cloud Agent
5+
6+
# Licensed to the Apache Software Foundation (ASF) under one
7+
# or more contributor license agreements. See the NOTICE file
8+
# distributed with this work for additional information
9+
# regarding copyright ownership. The ASF licenses this file
10+
# to you under the Apache License, Version 2.0 (the
11+
# "License"); you may not use this file except in compliance
12+
# with the License. You may obtain a copy of the License at
13+
#
14+
# http://www.apache.org/licenses/LICENSE-2.0
15+
#
16+
# Unless required by applicable law or agreed to in writing,
17+
# software distributed under the License is distributed on an
18+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19+
# KIND, either express or implied. See the License for the
20+
# specific language governing permissions and limitations
21+
# under the License.
22+
23+
# WARNING: if this script is changed, then all other initscripts MUST BE changed to match it as well
24+
25+
. /etc/rc.d/init.d/functions
26+
27+
whatami=cloud-agent
28+
29+
# set environment variables
30+
31+
SHORTNAME="$whatami"
32+
PIDFILE=/var/run/"$whatami".pid
33+
LOCKFILE=/var/lock/subsys/"$SHORTNAME"
34+
LOGFILE=/var/log/cloud/agent/agent.log
35+
PROGNAME="Cloud Agent"
36+
CLASS="com.cloud.agent.AgentShell"
37+
JSVC=`which jsvc 2>/dev/null`;
38+
39+
# exit if we don't find jsvc
40+
if [ -z "$JSVC" ]; then
41+
echo no jsvc found in path;
42+
exit 1;
43+
fi
44+
45+
unset OPTIONS
46+
[ -r /etc/sysconfig/"$SHORTNAME" ] && source /etc/sysconfig/"$SHORTNAME"
47+
48+
# The first existing directory is used for JAVA_HOME (if JAVA_HOME is not defined in $DEFAULT)
49+
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"
50+
51+
for jdir in $JDK_DIRS; do
52+
if [ -r "$jdir/bin/java" -a -z "${JAVA_HOME}" ]; then
53+
JAVA_HOME="$jdir"
54+
fi
55+
done
56+
export JAVA_HOME
57+
58+
SCP=""
59+
DCP=""
60+
ACP=`ls /usr/share/cloud/java/* | tr '\n' ':'`
61+
JCP="/usr/share/java/commons-daemon.jar"
62+
63+
# We need to append the JSVC daemon JAR to the classpath
64+
# AgentShell implements the JSVC daemon methods
65+
export CLASSPATH="$SCP:$DCP:$ACP:$JCP:/etc/cloud/agent:/usr/lib64/cloud/agent"
66+
67+
start() {
68+
echo -n $"Starting $PROGNAME: "
69+
if hostname --fqdn >/dev/null 2>&1 ; then
70+
$JSVC -cp "$CLASSPATH" -pidfile "$PIDFILE" $CLASS
71+
RETVAL=$?
72+
echo
73+
else
74+
failure
75+
echo
76+
echo The host name does not resolve properly to an IP address. Cannot start "$PROGNAME". > /dev/stderr
77+
RETVAL=9
78+
fi
79+
[ $RETVAL = 0 ] && touch ${LOCKFILE}
80+
return $RETVAL
81+
}
82+
83+
stop() {
84+
echo -n $"Stopping $PROGNAME: "
85+
$JSVC -pidfile "$PIDFILE" -stop $CLASS
86+
RETVAL=$?
87+
echo
88+
[ $RETVAL = 0 ] && rm -f ${LOCKFILE} ${PIDFILE}
89+
}
90+
91+
92+
# See how we were called.
93+
case "$1" in
94+
start)
95+
start
96+
;;
97+
stop)
98+
stop
99+
;;
100+
status)
101+
status -p ${PIDFILE} $SHORTNAME
102+
RETVAL=$?
103+
;;
104+
restart)
105+
stop
106+
sleep 3
107+
start
108+
;;
109+
condrestart)
110+
if status -p ${PIDFILE} $SHORTNAME >&/dev/null; then
111+
stop
112+
sleep 3
113+
start
114+
fi
115+
;;
116+
*)
117+
echo $"Usage: $whatami {start|stop|restart|condrestart|status|help}"
118+
RETVAL=3
119+
esac
120+
121+
exit $RETVAL

packaging/centos63/cloud.spec

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,18 @@ Group: System Environment/Libraries
103103
The CloudStack Python library contains a few Python modules that the
104104
CloudStack uses.
105105

106+
%package agent
107+
Summary: CloudStack Agent for KVM hypervisors
108+
Requires: java >= 1.6.0
109+
Requires: %{name}-python = %{_ver}
110+
Requires: libvirt
111+
Requires: bridge-utils
112+
Requires: ebtables
113+
Requires: jsvc
114+
Requires: jna
115+
Group: System Environment/Libraries
116+
%description agent
117+
The CloudStack agent for KVM hypervisors
106118

107119
%prep
108120
echo Doing CloudStack build
@@ -183,8 +195,22 @@ chmod 770 ${RPM_BUILD_ROOT}%{_localstatedir}/cache/%{name}/management/temp
183195
chmod 770 ${RPM_BUILD_ROOT}%{_localstatedir}/log/%{name}/management
184196
chmod 770 ${RPM_BUILD_ROOT}%{_localstatedir}/log/%{name}/agent
185197
chmod -R ugo+x ${RPM_BUILD_ROOT}/usr/share/%{name}/management/webapps/client/WEB-INF/classes/scripts
186-
%clean
187198

199+
mkdir -p ${RPM_BUILD_ROOT}/etc/cloud/agent
200+
mkdir -p ${RPM_BUILD_ROOT}/var/log/cloud/agent
201+
install -D packaging/centos63/cloud-agent.rc ${RPM_BUILD_ROOT}/etc/init.d/%{name}-agent
202+
install -D agent/target/transformed/agent.properties ${RPM_BUILD_ROOT}/etc/cloud/agent/agent.properties
203+
install -D agent/target/transformed/environment.properties ${RPM_BUILD_ROOT}/etc/cloud/agent/environment.properties
204+
install -D agent/target/transformed/log4j-cloud.xml ${RPM_BUILD_ROOT}/etc/cloud/agent/log4j-cloud.xml
205+
install -D agent/target/transformed/cloud-setup-agent ${RPM_BUILD_ROOT}/usr/bin/cloud-setup-agent
206+
install -D agent/target/transformed/cloud-ssh ${RPM_BUILD_ROOT}/usr/bin/cloud-ssh
207+
208+
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
209+
cp plugins/hypervisors/kvm/target/dependencies/* ${RPM_BUILD_ROOT}/usr/share/cloud/java
210+
mkdir -p ${RPM_BUILD_ROOT}/usr/share/cloud/scripts
211+
cp -r scripts/* ${RPM_BUILD_ROOT}/usr/share/cloud/scripts
212+
213+
%clean
188214
[ ${RPM_BUILD_ROOT} != "/" ] && rm -rf ${RPM_BUILD_ROOT}
189215

190216

@@ -271,6 +297,14 @@ fi
271297
%doc LICENSE
272298
%doc NOTICE
273299

300+
%files agent
301+
%attr(0755,root,root) %{_bindir}/%{name}-setup-agent
302+
%attr(0755,root,root) %{_bindir}/%{name}-ssh
303+
%attr(0755,root,root) %{_sysconfdir}/init.d/cloud-agent
304+
%config(noreplace) %{_sysconfdir}/cloud/agent
305+
%dir /var/log/cloud/agent
306+
%attr(0644,root,root) /usr/share/cloud/java/*.jar
307+
%attr(0755,root,root) /usr/share/cloud/scripts
274308

275309
%changelog
276310
* Fri Oct 03 2012 Hugo Trippaers <hugo@apache.org> 4.1.0

plugins/hypervisors/kvm/pom.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,24 @@
9494
</execution>
9595
</executions>
9696
</plugin>
97+
<plugin>
98+
<groupId>org.apache.maven.plugins</groupId>
99+
<artifactId>maven-dependency-plugin</artifactId>
100+
<version>2.5.1</version>
101+
<executions>
102+
<execution>
103+
<id>copy-dependencies</id>
104+
<phase>package</phase>
105+
<goals>
106+
<goal>copy-dependencies</goal>
107+
</goals>
108+
<configuration>
109+
<outputDirectory>target/dependencies</outputDirectory>
110+
<includeScope>runtime</includeScope>
111+
</configuration>
112+
</execution>
113+
</executions>
114+
</plugin>
97115
</plugins>
98116
</build>
99117
</project>

utils/src/com/cloud/utils/script/Script.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,12 @@ public static String findScript(String path, String script) {
350350
* Look in WEB-INF/classes of the webapp
351351
* URI workaround the URL encoding of url.getFile
352352
*/
353-
url = Script.class.getClassLoader().getResource(path + script);
353+
if (path.endsWith(File.separator)) {
354+
url = Script.class.getClassLoader().getResource(path + script);
355+
}
356+
else {
357+
url = Script.class.getClassLoader().getResource(path + File.separator + script);
358+
}
354359
s_logger.debug("Classpath resource: " + url);
355360
if (url != null) {
356361
try {

0 commit comments

Comments
 (0)