You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by al...@apache.org on 2012/07/06 21:03:38 UTC

[12/30] git commit: add script to setup devcloud image

add script to setup devcloud image


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

Branch: refs/heads/vpc
Commit: 57ab39937c24e2a6af7ab4f49ee9fa0b5c08a0d4
Parents: 81afcab
Author: Edison Su <su...@gmail.com>
Authored: Thu Jul 5 20:35:56 2012 -0700
Committer: Edison Su <su...@gmail.com>
Committed: Thu Jul 5 20:36:43 2012 -0700

----------------------------------------------------------------------
 build/build-devcloud.xml        |    8 +-
 tools/devcloud/devcloudsetup.sh |  136 ++++++++++++++++++++++++++++++++++
 2 files changed, 140 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/57ab3993/build/build-devcloud.xml
----------------------------------------------------------------------
diff --git a/build/build-devcloud.xml b/build/build-devcloud.xml
index 5b7bcdb..b65e9e4 100644
--- a/build/build-devcloud.xml
+++ b/build/build-devcloud.xml
@@ -30,12 +30,12 @@
 
   <target name="deploydbIfSet" if="deploydb.is.set">
     <echo message="ant deploydb"/>
-    <sshexec host="${host}" port="${port}" username="root" password="password" command="echo $CATALINA_HOME; export CATALINA_HOME=/opt/cloudstack/apache-tomcat-6.0.32;killall java;cd /opt/cloudstack/incubator-cloudstack;ant deploycddb"/>
+    <sshexec host="${host}" port="${port}" username="root" password="password" command="echo $CATALINA_HOME; export CATALINA_HOME=/opt/cloudstack/apache-tomcat-6.0.32;killall java; service cloud-management stop;cd /opt/cloudstack/incubator-cloudstack;ant deploycddb"/>
   </target>
 
   <target name="rdeploydb">
     <echo message="ant rdeploydb"/>
-    <sshexec host="${host}" port="${port}" username="root" password="password" command="echo $CATALINA_HOME; export CATALINA_HOME=/opt/cloudstack/apache-tomcat-6.0.32;killall java;cd /opt/cloudstack/incubator-cloudstack;ant deploycddb -Drhost=${host}"/>
+    <sshexec host="${host}" port="${port}" username="root" password="password" command="echo $CATALINA_HOME; export CATALINA_HOME=/opt/cloudstack/apache-tomcat-6.0.32;killall java;service cloud-management stop;cd /opt/cloudstack/incubator-cloudstack;ant deploycddb -Drhost=${host}"/>
   </target>
 
   <target name="deploycddb" description="deploy specific db configuration for clouddev" depends="deploydb">
@@ -48,12 +48,12 @@
 
   <target name="rdebug-suspend" >
     <echo message="ant debug-suspend"/>
-    <sshexec host="${host}" port="${port}" username="root" password="password" command="killall java;sleep 1;echo $CATALINA_HOME; export CATALINA_HOME=/opt/cloudstack/apache-tomcat-6.0.32;cd /opt/cloudstack/incubator-cloudstack;ant deploy-server;ant debug-suspend"/>
+    <sshexec host="${host}" port="${port}" username="root" password="password" command="killall java;service cloud-management stop;sleep 1;echo $CATALINA_HOME; export CATALINA_HOME=/opt/cloudstack/apache-tomcat-6.0.32;cd /opt/cloudstack/incubator-cloudstack;ant deploy-server;ant debug-suspend"/>
   </target>
   
   <target name="rdebug">
     <echo message="ant debug"/>
-    <sshexec host="${host}" port="${port}" username="root" password="password" command="killall java;sleep 1;export CATALINA_HOME=/opt/cloudstack/apache-tomcat-6.0.32;cd /opt/cloudstack/incubator-cloudstack;ant deploy-server; ant debug "/>
+    <sshexec host="${host}" port="${port}" username="root" password="password" command="killall java;service cloud-management stop;sleep 1;export CATALINA_HOME=/opt/cloudstack/apache-tomcat-6.0.32;cd /opt/cloudstack/incubator-cloudstack;ant deploy-server; ant debug "/>
   </target>
 
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/57ab3993/tools/devcloud/devcloudsetup.sh
----------------------------------------------------------------------
diff --git a/tools/devcloud/devcloudsetup.sh b/tools/devcloud/devcloudsetup.sh
new file mode 100644
index 0000000..8ae3908
--- /dev/null
+++ b/tools/devcloud/devcloudsetup.sh
@@ -0,0 +1,136 @@
+#!/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
+# 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.
+
+fileSvr="http://nfs1.lab.vmops.com/templates/devcloud/"
+install_xen() {
+    aptitude update
+    echo "install xen"
+    aptitude -y install linux-headers-3.2.0-23-generic-pae
+    aptitude -y install xen-hypervisor-4.1 xcp-xapi 
+    echo "configure xen"
+
+    sed -i -e 's/xend_start$/#xend_start/' -e 's/xend_stop$/#xend_stop/' /etc/init.d/xend
+    update-rc.d xendomains disable
+
+    sed -i 's/GRUB_DEFAULT=.\+/GRUB_DEFAULT="Xen 4.1-amd64"/' /etc/default/grub
+    update-grub
+
+    mkdir /usr/share/qemu
+    ln -s /usr/share/qemu-linaro/keymaps /usr/share/qemu/keymaps
+
+cat > /etc/network/interfaces << EOF
+# The loopback network interface
+auto lo
+iface lo inet loopback
+
+# The primary network interface
+auto xenbr0
+iface xenbr0 inet dhcp
+    gateway 10.0.2.2
+    bridge_ports eth0
+
+
+auto eth0
+iface eth0 inet dhcp
+EOF
+
+    echo TOOLSTACK=xapi > /etc/default/xen
+    echo bridge > /etc/xcp/network.conf
+
+    echo "reboot"
+    reboot
+}
+
+postsetup() {
+    #check xen dom0 is working
+    xe host-list > /dev/null
+    if [ $? -gt 0 ]; then
+        print "xen dom0 is not running, make sure dom0 is installed"
+        exit 1
+    fi
+
+    echo "configure NFS server"
+    aptitude -y install nfs-server
+    if [ ! -d /opt/storage/secondary ];then
+        mkdir -p /opt/storage/secondary
+        mkdir -p /opt/storage/secondary/template/tmpl/1/1
+        mkdir -p /opt/storage/secondary/template/tmpl/1/5
+
+        echo "/opt/storage/secondary *(rw,no_subtree_check,no_root_squash,fsid=0)" > /etc/exports
+        wget $fileSvr/vmtemplates/1/dc68eb4c-228c-4a78-84fa-b80ae178fbfd.vhd  -P /opt/storage/secondary/template/tmpl/1/1/
+        wget $fileSvr/vmtemplates/1/template.properties  -P /opt/storage/secondary/template/tmpl/1/1/
+        wget $fileSvr/vmtemplates/5/ce5b212e-215a-3461-94fb-814a635b2215.vhd  -P /opt/storage/secondary/template/tmpl/1/5/
+        wget $fileSvr/vmtemplates/5/template.properties  -P /opt/storage/secondary/template/tmpl/1/5/
+        /etc/init.d/nfs-kernel-server restart
+    fi
+
+    echo "configure local storage"
+    if [ ! -d /opt/storage/primary ]; then
+        mkdir -p /opt/storage/primary
+        hostuuid=`xe host-list |grep uuid|awk '{print $5}'`
+        xe sr-create host-uuid=$hostuuid name-label=local-storage shared=false type=file device-config:location=/opt/storage/primary
+    fi
+
+    echo "generate ssh key"
+    ssh-keygen -A -q 
+
+    echo "configure xcp"
+    wget $fileSvr/echo -P /usr/lib/xcp/plugins/
+    chmod -R 777 /usr/lib/xcp
+
+    sed -i 's/VNCTERM_LISTEN=.\+/VNCTERM_LISTEN="-v 0.0.0.0:1"/' /usr/lib/xcp/lib/vncterm-wrapper
+    
+    echo "install cloudstack "
+
+    if [ ! -d /opt/cloudstack ];then
+        aptitude -y install git unzip openjdk-6-jdk mysql-server ant
+        mkdir /opt/cloudstack
+        cd /opt/cloudstack
+        git clone https://git-wip-us.apache.org/repos/asf/incubator-cloudstack.git
+        mkdir incubator-cloudstack/target
+        mkdir incubator-cloudstack/dist
+        wget http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.32/bin/apache-tomcat-6.0.32.zip -P /opt/cloudstack/
+        unzip apache-tomcat-6.0.32.zip
+        echo "exportCATALINA_HOME=/opt/cloudstack/apache-tomcat-6.0.32" >> /root/.bashrc
+        cd ~
+    fi
+
+    echo "devCloud is ready to use"
+}
+usage() {
+    print "$0 -p: presetup enviroment, e.g. install xen, configure xcp etc" 
+    print "$0 -P: postsetup, install cloudstack, prepare template etc"
+}
+
+while getopts "pP" OPTION
+do
+    case $OPTION in
+        p)
+        install_xen
+        exit 0
+        ;;
+        P)
+        postsetup
+        exit 0
+        ;;
+        ?)
+        usage
+        exit
+        ;;
+    esac
+done