[Ovirt-devel] [PATCH] ovirt / autobuild integration

Alan Pevec apevec at redhat.com
Mon Jul 28 18:31:06 UTC 2008


From: Mohammed Morsi <mmorsi at redhat.com>

---
 autobuild.sh                           |   73 +++++++++++++++++++++++++++++--
 wui-appliance/common-pkgs.ks           |    1 +
 wui/src/app/controllers/application.rb |    6 ++-
 3 files changed, 74 insertions(+), 6 deletions(-)

diff --git a/autobuild.sh b/autobuild.sh
index ccae050..4e67200 100755
--- a/autobuild.sh
+++ b/autobuild.sh
@@ -1,6 +1,69 @@
-#oVirt wui autobuild script
+#oVirt autobuild script
+#
+# Copyright (C) 2008 Red Hat, Inc.
+# Written by Mohammed Morsi <mmorsi at redhat.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA  02110-1301, USA.  A copy of the GNU General Public License is
+# also available at http://www.gnu.org/copyleft/gpl.html.
+#
+# NOTE StrictHostKeyChecking must be set to "no" in /etc/ssh/sshd_config for this to work
 
-#run tests
-cd wui/src/
-rake db:migrate
-rake test
+echo "Running oVirt Autobuild"
+
+ssh_cmd="ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root at 192.168.50.2"
+
+# implant local ssh key into appliance for autobuild only
+if [ ! -e ~/.ssh/id_rsa.pub ]; then
+  ssh-keygen -t rsa
+fi
+git checkout wui-appliance/common-post.ks
+cat >> wui-appliance/common-post.ks << \KS
+mkdir -p /root/.ssh/
+chmod 700 /root/.ssh/
+cat > /root/.ssh/authorized_keys << \EOF
+KS
+cat ~/.ssh/id_rsa.pub >> wui-appliance/common-post.ks
+cat >> wui-appliance/common-post.ks << \KS
+EOF
+chmod 600 /root/.ssh/authorized_keys
+KS
+# move sshd to start last
+cat >> wui-appliance/common-post.ks << \KS
+mkdir -p /etc/chkconfig.d/
+cat > /etc/chkconfig.d/sshd << \EOF
+# chkconfig: 2345 99 01
+EOF
+chkconfig --override sshd
+KS
+
+# create appliance
+./build-all.sh -ac
+
+# start appliance
+virsh start ovirt-appliance
+
+# wait until started
+while : ; do
+   $ssh_cmd "exit"
+   if [ $? -eq 0 ]; then
+      break
+   fi
+   sleep 10
+done
+
+echo "Running the wui tests"
+$ssh_cmd \
+    "curl -i --negotiate -u : management.priv.ovirt.org/ovirt/ | grep \"HTTP/1.1 200 OK\" && \
+     cd /usr/share/ovirt-wui/ && rake test"
diff --git a/wui-appliance/common-pkgs.ks b/wui-appliance/common-pkgs.ks
index 7a8866c..5688308 100644
--- a/wui-appliance/common-pkgs.ks
+++ b/wui-appliance/common-pkgs.ks
@@ -25,3 +25,4 @@ cobbler
 bind-utils
 augeas
 /usr/sbin/lokkit
+curl
diff --git a/wui/src/app/controllers/application.rb b/wui/src/app/controllers/application.rb
index aa8fd7c..eacf6f3 100644
--- a/wui/src/app/controllers/application.rb
+++ b/wui/src/app/controllers/application.rb
@@ -34,7 +34,11 @@ class ApplicationController < ActionController::Base
   before_filter :authorize_admin, :only => [:new, :create, :edit, :update, :destroy]
 
   def get_login_user
-    user_from_principal(request.env["HTTP_X_FORWARDED_USER"])
+    if ENV["RAILS_ENV"] != 'test'
+        user_from_principal(request.env["HTTP_X_FORWARDED_USER"])
+    else
+        'ovirtadmin'
+    end
   end
   
   def user_from_principal(principal)
-- 
1.5.5.1




More information about the ovirt-devel mailing list