You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ah...@apache.org on 2013/01/09 14:26:48 UTC

[2/50] [abbrv] git commit: Summary: Get started with packaging cloud-agent

Summary: Get started with packaging cloud-agent

Modify the spec file to package the agent files and the scripts

Some changes to the poms to put the java dependencies in the right place.

Move the agent script to the dedicated os dir in packaging.


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

Branch: refs/heads/javelin
Commit: 91673b10b82178fea03f267f0f41655b2faac757
Parents: d616dcd
Author: Hugo Trippaers <ht...@schubergphilis.com>
Authored: Mon Jan 7 22:17:14 2013 +0100
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Mon Jan 7 22:18:01 2013 +0100

----------------------------------------------------------------------
 agent/pom.xml                     |   51 +++++++++++++
 packaging/centos63/cloud-agent.rc |  121 ++++++++++++++++++++++++++++++++
 packaging/centos63/cloud.spec     |   36 +++++++++-
 plugins/hypervisors/kvm/pom.xml   |   18 +++++
 4 files changed, 225 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/91673b10/agent/pom.xml
----------------------------------------------------------------------
diff --git a/agent/pom.xml b/agent/pom.xml
index 8aab8de..810f33f 100644
--- a/agent/pom.xml
+++ b/agent/pom.xml
@@ -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>

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/91673b10/packaging/centos63/cloud-agent.rc
----------------------------------------------------------------------
diff --git a/packaging/centos63/cloud-agent.rc b/packaging/centos63/cloud-agent.rc
new file mode 100755
index 0000000..084b715
--- /dev/null
+++ b/packaging/centos63/cloud-agent.rc
@@ -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

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/91673b10/packaging/centos63/cloud.spec
----------------------------------------------------------------------
diff --git a/packaging/centos63/cloud.spec b/packaging/centos63/cloud.spec
index e6f2ae2..d828e67 100644
--- a/packaging/centos63/cloud.spec
+++ b/packaging/centos63/cloud.spec
@@ -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 <hu...@apache.org> 4.1.0

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/91673b10/plugins/hypervisors/kvm/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/pom.xml b/plugins/hypervisors/kvm/pom.xml
index d3eca91..8fc8f73 100644
--- a/plugins/hypervisors/kvm/pom.xml
+++ b/plugins/hypervisors/kvm/pom.xml
@@ -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>