- checkout appliance - make rpms - rpm -ivh ovirt-appliance.rpm - /usr/sbin/ovirt-appliance-ctrl install
The install process will take a while, after which you can access the server by going to http://192.168.50.2/ovirt at which you can boot and manage vms on your host. --- .gitignore | 17 +-- Makefile.am | 56 +++++++ autogen.sh | 66 ++++++++ configure.ac | 11 ++ data/appliance.ks | 82 ++++++++++ data/ifcfg-breth0 | 4 + data/network.xml | 9 + ovirt-appliance.spec.in | 52 +++++++ scripts/ovirt-appliance-ctrl | 56 +++++++ scripts/ovirt-appliance-functions | 297 +++++++++++++++++++++++++++++++++++++ 10 files changed, 639 insertions(+), 11 deletions(-) create mode 100644 Makefile.am create mode 100755 autogen.sh create mode 100644 configure.ac create mode 100644 data/appliance.ks create mode 100644 data/ifcfg-breth0 create mode 100644 data/network.xml create mode 100644 ovirt-appliance.spec.in create mode 100755 scripts/ovirt-appliance-ctrl create mode 100644 scripts/ovirt-appliance-functions diff --git a/.gitignore b/.gitignore index 1221087..5b4f7d7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,22 +1,17 @@ -*~ -INSTALL Makefile Makefile.in aclocal.m4 -autom4te.cache/ +autom4te.cache config.h config.h.in config.log config.status configure +depcomp install-sh missing -ovirt-appliance-manifests*.tar -ovirt-appliance-*-*.tar* -ovirt-appliance-*-*.tar.sha1sum -ovirt-appliance-*.tar.gz -ovirt-appliance.spec -ovirt-authorized_keys -repos.ks stamp-h1 -tmp +ovirt-appliance*.gz +ovirt-appliance.spec +schema.rb +log/ diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..7a104ce --- /dev/null +++ b/Makefile.am @@ -0,0 +1,56 @@ +# Copyright (C) 2008 Red Hat, Inc. +# +# 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. + +OVIRT_CACHE_DIR ?= $(HOME)/ovirt-cache + +EXTRA_DIST = \ + .gitignore \ + ovirt-appliance.spec \ + ovirt-appliance.spec.in \ + scripts \ + data + +DISTCLEANFILES = $(PACKAGE)-$(VERSION).tar.gz + +# For Release: 0..., set _ovirt_dev=1 so that we get extra_release.GIT- +# annotated rpm version strings. +_ovirt_dev = \ + $(shell grep -q '^[[:space:]]*Release:[[:space:]]*0' \ + $(srcdir)/*.spec.in && echo 1 || :) + +git_head = $$(git log -1 --pretty=format:%h) +GIT_RELEASE = $$(date --utc +%Y%m%d%H%M%S)git$(git_head) +RPMDIR = $$(rpm --eval '%{_rpmdir}') +RPM_FLAGS = --define "ovirt_cache_dir $(OVIRT_CACHE_DIR)" +RPM_FLAGS += $(if $(_ovirt_dev),--define "extra_release .$(GIT_RELEASE)") + +rpms: dist + rpmbuild $(RPM_FLAGS) -ta $(distdir).tar.gz + +srpms: dist + rpmbuild $(RPM_FLAGS) -ts $(distdir).tar.gz + +publish: rpms + mkdir -p $(OVIRT_CACHE_DIR) + rsync -aq $(shell rpm --eval '%{_rpmdir}')/ $(OVIRT_CACHE_DIR)/ovirt/ + rsync -aq $(shell rpm --eval '%{_srcrpmdir}')/ $(OVIRT_CACHE_DIR)/ovirt/src + createrepo $(OVIRT_CACHE_DIR)/ovirt + +genlangs: + cd src && rake updatepo && rake makemo + +.PHONY: rpms publish srpms genlangs diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..6b0970f --- /dev/null +++ b/autogen.sh @@ -0,0 +1,66 @@ +#!/bin/sh +# Run this to generate configure and Makefile + +srcdir=`dirname $0` +test -z "$srcdir" && srcdir=. + +THEDIR=`pwd` +( + cd $srcdir + die=0 + + (autoconf --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "You must have autoconf installed." + echo "Download the appropriate package for your distribution," + echo "or see http://www.gnu.org/software/autoconf" + die=1 + } + + # Require libtool only if one of of LT_INIT, + # AC_PROG_LIBTOOL, AM_PROG_LIBTOOL is used in configure.ac. + grep -E '^[[:blank:]]*(LT_INIT|A[CM]_PROG_LIBTOOL)' configure.ac >/dev/null \ + && { + (libtool --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "You must have libtool installed." + echo "Download the appropriate package for your distribution," + echo "or see http://www.gnu.org/software/libtool" + die=1 + } + } + + (automake --version) < /dev/null > /dev/null 2>&1 || { + echo + die=1 + echo "You must have automake installed." + echo "Download the appropriate package for your distribution," + echo "or see http://www.gnu.org/software/automake" + } + + test $die = 1 && exit 1 + + test -f ovirt-appliance.spec.in || { + echo "You must run this script in the top-level directory" + exit 1 + } + + if test -z "$*"; then + echo "I am going to run ./configure with no arguments - if you wish " + echo "to pass any to it, please specify them on the $0 command line." + fi + + aclocal + + # Run autoheader only if needed + grep '^[[:blank:]]*AC_CONFIG_HEADERS' configure.ac >/dev/null && autoheader + + automake --add-missing + autoconf + ./configure "$@" +) + +if test "x$OBJ_DIR" != x; then + mkdir -p "$OBJ_DIR" + cd "$OBJ_DIR" +fi diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..db3bc30 --- /dev/null +++ b/configure.ac @@ -0,0 +1,11 @@ +AC_INIT([ovirt-appliance], [0.101], [[email protected]]) +AM_INIT_AUTOMAKE([-Wall -Werror foreign -Wno-portability tar-pax]) +AC_PROG_CC +AC_CONFIG_HEADERS([config.h]) + +# If using gcc and default CFLAGS, enable some warnings. +test x"$ac_ct_CC:$CFLAGS" = 'xgcc:-g -O2' \ + && CFLAGS="$CFLAGS -Wshadow -Wall -Werror" + +AC_CONFIG_FILES([Makefile ovirt-appliance.spec]) +AC_OUTPUT diff --git a/data/appliance.ks b/data/appliance.ks new file mode 100644 index 0000000..39a821c --- /dev/null +++ b/data/appliance.ks @@ -0,0 +1,82 @@ +install + +lang en_US.UTF-8 +keyboard us + +# setup two nics, one public, one on the private libvirt network we setup +network --device=eth0 --bootproto=static --ip=192.168.50.2 --netmask=255.255.255.0 --onboot=on --nameserver=192.168.50.1 +network --device=eth1 --onboot=on + +# Root password is 'ovirt' +rootpw --iscrypted Xa8QeYfWrtscM + +firewall --disabled +authconfig --enableshadow --enablemd5 +selinux --disabled + +# NOTE: ntp/ntpdate need to stay in this list to ensure that time on the +# appliance is correct prior to the ovirt-server-installer being run. Otherwise you +# get Kerberos errors +services --disabled=libvirtd,postgresql --enabled=network,iptables,ntpdate,acpid,sshd +timezone --utc UTC +text + +bootloader --location=mbr +clearpart --all --drives=sda +part /boot --ondisk=sda --fstype=ext3 --size=100 +part / --ondisk=sda --fstype=ext3 --size=10000 +part swap --ondisk=sda --fstype=swap --size=512 +reboot + +repo --name=f11 --mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-11&arch=x86_64 +repo --name=f11-updates --mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=updates-released-f11&arch=x86_64 +#repo --name=f11-rawhide --mirrorlist=http://mirrors.fedoraproject.org/metalink?repo=rawhide&arch=x86_64 +repo --name=ovirtorg --baseurl=http://ovirt.org/repos/ovirt/11/x86_64/ +repo --name=ovirt --baseurl=file://OVIRT_REPO + +%packages --excludedocs --nobase +%include /usr/share/appliance-os/includes/base-pkgs.ks +ntpdate +openssh-server +openssh-clients +ovirt-server +ovirt-server-installer +ovirt-node-image +ovirt-node-image-pxe +%end + +%post +# setup automatic ssh login +mkdir -p /root/.ssh +chmod 700 /root/.ssh +cat > /root/.ssh/authorized_keys << \EOF +OVIRT_SSH_KEY +EOF +chmod 600 /root/.ssh/authorized_keys + +# setup the ovirt installer answers +cat > /root/ovirt-installer-answers << \EOF +y +eth1 +eth0 +server.ovirt-appliance.com +n +n +192.168.50 +3 +50 +ovirt-appliance.com + +y +n +cobbler +cobbler +cobbler +v23zj59an +v23zj59an +ovirt-appliance.com +ovirt +ovirt +EOF + +%end diff --git a/data/ifcfg-breth0 b/data/ifcfg-breth0 new file mode 100644 index 0000000..02955b2 --- /dev/null +++ b/data/ifcfg-breth0 @@ -0,0 +1,4 @@ +DEVICE=breth0 +ONBOOT=yes +TYPE=Bridge +PEERNTP=yes diff --git a/data/network.xml b/data/network.xml new file mode 100644 index 0000000..8bce0db --- /dev/null +++ b/data/network.xml @@ -0,0 +1,9 @@ +<network> + <name>ovirt-appliance</name> + <uuid>OVIRT_NETWORK_UUID</uuid> + <ip address='192.168.50.1' netmask='255.255.255.0'> + <dhcp> + <host mac='54:52:00:1a:cb:f0' name='server.ovirt-appliance.com' ip='192.168.50.2' /> + </dhcp> + </ip> +</network> diff --git a/ovirt-appliance.spec.in b/ovirt-appliance.spec.in new file mode 100644 index 0000000..61bdc8d --- /dev/null +++ b/ovirt-appliance.spec.in @@ -0,0 +1,52 @@ +%define app_root %{_datadir}/%{name} + +Summary: oVirt Appliance +Name: ovirt-appliance +Version: @VERSION@ +Release: 1%{?dist}%{?extra_release} +Source0: %{name}-%{version}.tar.gz +License: GPLv2+ +Group: Applications/System +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot +BuildArch: noarch +URL: http://ovirt.org/ +#Requires: + +%description +The oVirt Appliance scripts to install on a Fedora Host + +%prep +%setup -q + +%build + +%install +%{__rm} -rf %{buildroot} +mkdir %{buildroot} + +%{__install} -d -m0755 %{buildroot}%{_sbindir} +%{__install} -d -m0755 %{buildroot}%{app_root} +%{__install} -d -m0755 %{buildroot}%{app_root}/backup +%{__cp} -a scripts/* %{buildroot}%{app_root} +%{__cp} -a data/* %{buildroot}%{app_root} +%{__ln_s} %{app_root}/ovirt-appliance-ctrl %{buildroot}%{_sbindir}/ + +%clean +%{__rm} -rf %{buildroot} + +%files +%defattr(-,root,root,0755) +%{app_root} +%{_sbindir}/ovirt-appliance-ctrl + +%changelog +* Wed Sep 02 2009 Mohammed Morsi <[email protected]> 0.100-1 +- Revamped entire appliance project to fix it bring it up + to speed with the current implementation of oVirt +* Wed Nov 05 2008 Perry Myers <[email protected]> 0.96 +- Removed appliance building from rpm. RPM now just contains tools to + download image and install it +* Sun Sep 14 2008 Perry Myers <[email protected]> 0.92-1 +- Added Requires on libvirt/kvm +* Fri Sep 05 2008 Perry Myers <[email protected]> 0.92-1 +- Initial build. diff --git a/scripts/ovirt-appliance-ctrl b/scripts/ovirt-appliance-ctrl new file mode 100755 index 0000000..2ac86c6 --- /dev/null +++ b/scripts/ovirt-appliance-ctrl @@ -0,0 +1,56 @@ +#!/bin/bash +# Control script for the oVirt appliance. +# +# Use this to setup / install a server appliance running in a vm +# and a node configuration on the baremetal host. +# +# This must be run as a super-user to be successful. +# +# Copyright (C) 2008 Red Hat, Inc. +# Written by Mohammed Morsi <[email protected]> +# +# 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. + +. /etc/init.d/functions +. /usr/share/ovirt-appliance/ovirt-appliance-functions + +case "$1" in + install) + bootstrap_setup + build_rpms # would like to make this step optional + setup_network + setup_server_ssh_access + create_server_vm + run_server_installer + setup_server_env + backup_node_env + setup_node_env + ;; + uninstall) + bootstrap_teardown + destroy_server_vm + destroy_network + restore_node_env + echo "reboot to complete the uninstall process" + ;; + *) + echo "Usage: ovirt-appliance-ctrl {install|uninstall}" + exit 1 + ;; +esac + +exit $RETVAL + diff --git a/scripts/ovirt-appliance-functions b/scripts/ovirt-appliance-functions new file mode 100644 index 0000000..3ed77fb --- /dev/null +++ b/scripts/ovirt-appliance-functions @@ -0,0 +1,297 @@ +#!/bin/bash +# Function definitions part of the oVirt appliance setup utility +# +# Copyright (C) 2008 Red Hat, Inc. +# Written by Mohammed Morsi <[email protected]> +# +# 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. + +OVIRT_APPLIANCE_DIR="/usr/share/ovirt-appliance" +OVIRT_APPLIANCE_BACKUP_DIR="$OVIRT_APPLIANCE_DIR/backup" +OVIRT_APPLIANCE_WORKING_DIR="`mktemp -d`" + +# perform any common setup initialization routines +bootstrap_setup() { + unalias cp + + # set selinux to permissive mode + /usr/sbin/setenforce 0 + + # make sure we aren't localhost so the server can lookup our hostname + hostname="`hostname`" + if [ "$hostname" == "localhost" -o "$hostname" == "localhost.localdomain" -o "$hostname" == "" ]; then + echo "hostname cannot be localhost (server needs to be able to resolve it)" + hostname host.ovirt-appliance.com + cp -f /etc/sysconfig/network $OVIRT_APPLIANCE_BACKUP_DIR + sed -i s/HOSTNAME.*$/HOSTNAME\=host\.ovirt-appliance\.com/g /etc/sysconfig/network + hostname host.ovirt-appliance.com + fi + + # install the oVirt release rpm if not present + rpm -q ovirt-release || rpm -ivh http://ovirt.org/repos/ovirt/ovirt-release-LATEST.noarch.rpm + + # update our system to have the latest packages, install base packages + yum install -y yum-fastestmirror libvirt + yum update -y --enablerepo=ovirt + + # copy the files we will be modifying into the working dir + cp -f $OVIRT_APPLIANCE_DIR/appliance.ks $OVIRT_APPLIANCE_WORKING_DIR/ + cp -f $OVIRT_APPLIANCE_DIR/network.xml $OVIRT_APPLIANCE_WORKING_DIR/ + cp -f $OVIRT_APPLIANCE_DIR/ifcfg-breth0 $OVIRT_APPLIANCE_WORKING_DIR/ + + # start up libvirt + service libvirtd start +} + +# perform any common teardown initialization routines +bootstrap_teardown() { + unalias cp + + # restore /etc/sysconfig/network if modified + test -f $OVIRT_APPLIANCE_BACKUP_DIR/network && cp -f $OVIRT_APPLIANCE_BACKUP_DIR/network /etc/sysconfig/ +} + +# build the neccessary oVirt rpms to install the appliance +build_rpms() { + # install dependencies + yum install -y --enablerepo=ovirt \ + git automake autoconf gcc rpm-build \ + ruby ruby-devel rubygem-gettext rubygem-rake \ + libvirt-devel dbus-devel hal-devel hardlink \ + livecd-tools appliance-tools \ + publican publican-ovirt + + ### checkout / build oVirt + + # create a build directory, and cd into it + saved_dir=`pwd` + OVIRT_CHECKOUT_DIR=`mktemp -d` + cd $OVIRT_CHECKOUT_DIR + + # clone the release project + git clone git://ovirt.org/ovirt-release release + + # setup the cache dir and make update and publish + export OVIRT_CACHE_DIR=$(pwd)/cache + OVIRT_REPO=$OVIRT_CACHE_DIR/ovirt + make -f release/ovirt.mk update publish + + # restore working directory + cd $saved_dir + + # swap in the correct local repo in the kickstart + sed -i s~OVIRT_REPO~$OVIRT_REPO~g $OVIRT_APPLIANCE_WORKING_DIR/appliance.ks +} + +# setup a libvirt network to act as the oVirt admin network +setup_network() { + # generate a network id and swap it into the network config + sed -i s/OVIRT_NETWORK_UUID/`uuidgen`/g $OVIRT_APPLIANCE_WORKING_DIR/network.xml + + # write the network config to the appropriate place + cp -f $OVIRT_APPLIANCE_WORKING_DIR/network.xml /etc/libvirt/qemu/networks/ovirt-appliance.xml + + # define and start the network via libvirt, set to autostart + virsh net-define /etc/libvirt/qemu/networks/ovirt-appliance.xml + virsh net-start ovirt-appliance + virsh net-autostart ovirt-appliance + + # setup breth0 as its needed to start vms with a network + # (backing the old config up first) + test -f /etc/sysconfig/network-scripts/ifcfg-breth0 && \ + cp -f /etc/sysconfig/network-scripts/ifcfg-breth0 $OVIRT_APPLIANCE_BACKUP_DIR/ifcfg-breth0.bak + cp -f $OVIRT_APPLIANCE_WORKING_DIR/ifcfg-breth0 /etc/sysconfig/network-scripts/ + ifup breth0 +} + +# destroy / remove the network that was setup +destroy_network() { + # destroy, undefine, and un-autostart the network + virsh net-destroy ovirt-appliance + virsh net-undefine ovirt-appliance + rm -f /etc/libvirt/qemu/networks/ovirt-appliance.xml + + # restore ifcfg-breth0 backup if neccessary + test -f $OVIRT_APPLIANCE_BACKUP_DIR/ifcfg-breth0.bak && \ + cp -f $OVIRT_APPLIANCE_BACKUP_DIR/ifcfg-breth0.bak /etc/sysconfig/network-scripts/ +} + +# setup no-password ssh login for the server +setup_server_ssh_access() { + # create convenience env variables for the ssh params/cmds + SSHKEY=~/.ssh/id_ovirt_appliance + remote_target="[email protected]" + ssh_cmd="ssh -i $SSHKEY -o StrictHostKeyChecking=no \ + -o UserKnownHostsFile=/dev/null $remote_target" + scp_cmd="scp -i $SSHKEY -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" + + # generate new ssh key if not found + if [ ! -r $SSHKEY ]; then + mkdir -p $(dirname "$SSHKEY") + ssh-keygen -q -t rsa -N "" -f $SSHKEY + fi + + # implant ssh key into the server kickstart + sed -i "s~OVIRT_SSH_KEY~`ssh-keygen -y -f $SSHKEY`~g" $OVIRT_APPLIANCE_WORKING_DIR/appliance.ks +} + +# create and start the server vm +create_server_vm() { + # install dependencies + yum install -y --enablerepo=ovirt \ + appliance-os python-virtinst kvm + + + # save the current dir, and enter the working dir + saved_dir=`pwd` + cd $OVIRT_APPLIANCE_WORKING_DIR + + # remove the appliance image if it exists + test -d ovirt-appliance && rm -rf ovirt-appliance + + # create the appliance image + appliance-creator --config appliance.ks --name ovirt-appliance \ + -f raw --vmem=2048 -d -v + + # define / start the vm via libvirt, set to autostart + virt-image --network=network:ovirt-appliance ovirt-appliance/ovirt-appliance.xml + virsh define /etc/libvirt/qemu/ovirt-appliance.xml + virsh autostart ovirt-appliance + + # restore the saved dir + cd $saved_dir + + for i in $(seq 1 60); do + $ssh_cmd exit && break + sleep 10 + done +} + +# destroy the server vm that was setup +destroy_server_vm() { + # at some point, find a way to destroy the oVirt + # managed vms as well + virsh destroy ovirt-appliance + virsh undefine ovirt-appliance +} + +# run the oVirt server installation process on the server vm +run_server_installer() { + # run the actual installer w/ pre-specified answers (see kickstart) + $ssh_cmd "ovirt-installer < /root/ovirt-installer-answers" + + # XXX for whatever reason ovirt-node-image-pxe isn't setting + # up the pxe correctly for the node-image iso, just put this + # here until we figure out why + $ssh_cmd "cd /usr/share/ovirt-node-image/ && \ + rm -rf tftpboot && \ + livecd-iso-to-pxeboot ovirt-node-image.iso" + + # XXX another hack needed here to install the old fedora-ds-base + # instead of the currently broken 389-ds-base + # https://bugzilla.redhat.com/show_bug.cgi?id=518544 + # http://ovirt.org/install-instructions.html#free-ipa-warning + $ssh_cmd "yum install perl-Mozilla-LDAP nss-tools mozldap-tools lm_sensors-devel net-snmp-devel openssl-devel -y" + $ssh_cmd "rpm -ivh http://kojipkgs.fedoraproject.org/packages/fedora-ds-base/1.2.0/4.fc11/x86_64/fedora-ds-base-1.2.0-4.fc11.x86_64.rpm" + + # run the ace portion of the installer, actuall performing the oVirt installation + $ssh_cmd "ace -d install ovirt > /root/install.log" +} + +# perform everything else needed to get the oVirt server +# to work on a single machine install +setup_server_env() { + # set server resolv.conf to avoid an infinite loop. + # set it to the server nameserver, followed by the + # nameservers as defined in the host's resolv.conf + nameservers=`grep nameserver /etc/resolv.conf` + nameservers="nameserver 192.168.50.2 +$nameservers" + $ssh_cmd "echo '$nameservers' > /etc/resolv.conf" + + # prepend this hostname onto server's hosts and restart the dns service, + # required for kerberos and other components that need to lookup the host + $ssh_cmd "echo '192.168.50.1 `hostname`'|cat - /etc/hosts > /tmp/out && mv -f /tmp/out /etc/hosts" + $ssh_cmd "service dnsmasq restart" + + # add priciples to the kerberos server allowing node access + #$ssh_cmd /usr/bin/ovirt-add-host `hostname` /usr/share/ovirt-server/ovirt.keytab + $ssh_cmd "echo 'addprinc -randkey libvirt/`[email protected]' | kadmin.local" + $ssh_cmd "echo 'addprinc -randkey qpidd/`[email protected]' | kadmin.local" + $ssh_cmd "echo 'ktadd -k /usr/share/ipa/html/`hostname`-libvirt.tab libvirt/`[email protected]' | kadmin.local" + $ssh_cmd "echo 'ktadd -k /usr/share/ipa/html/`hostname`-libvirt.tab qpidd/`[email protected]' | kadmin.local" +} + +# backup all config files modified by setup_node_env +backup_node_env() { + test -f /etc/resolv.conf && cp -f /etc/resolv.conf $OVIRT_APPLIANCE_BACKUP_DIR + test -f /etc/krb5.conf && cp -f /etc/krb5.conf $OVIRT_APPLIANCE_BACKUP_DIR + test -f /etc/libvirt/krb5.tab/ && cp -f /etc/libvirt/krb5.tab $OVIRT_APPLIANCE_BACKUP_DIR + test -f /etc/sysconfig/libvirt-qpid && cp -f /etc/sysconfig/libvirt-qpid $OVIRT_APPLIANCE_BACKUP_DIR + test -f /etc/sysconfig/matahari && cp -f /etc/sysconfig/matahari $OVIRT_APPLIANCE_BACKUP_DIR +} + +# perform everything else needed to get the oVirt node/host +# to work on a single machine install +setup_node_env() { + # install dependencies + yum install -y --enablerepo=ovirt \ + wget libvirt-qpid cyrus-sasl-gssapi + # selinux-policy-doc \ + + # sync up our system time w/ the server's ntp server + ntpdate 192.168.50.2 + + # prepend the ovirt server's dns nameserver onto the local resolv.conf, + # so that we can perform the appliance domain lookups + echo "nameserver 192.168.50.2"|cat - /etc/resolv.conf > /tmp/out && mv -f /tmp/out /etc/resolv.conf + + # grab the kerberos config + wget -q --no-check-certificate http://192.168.50.2:80/ipa/config/krb5.ini -O /etc/krb5.conf + + # grab key/ticket off the server, and initialize kerberos w/ it + $scp_cmd $remote_target:/usr/share/ipa/html/`hostname`-libvirt.tab /etc/libvirt/krb5.tab + /usr/kerberos/bin/kinit -k -t /etc/libvirt/krb5.tab qpidd/`hostname` + + # setup the libvirt-qpid / matahari sysconfig + echo "LIBVIRT_QPID_ARGS=\"--broker 192.168.50.2 --port 5672\"" >> /etc/sysconfig/libvirt-qpid + echo "/usr/kerberos/bin/kinit -k -t /etc/libvirt/krb5.tab qpidd/`hostname`" >> /etc/sysconfig/libvirt-qpid + echo "MATAHARI_ARGS=\"--broker 192.168.50.2 --port 5672\"" >> /etc/sysconfig/matahari + echo "/usr/kerberos/bin/kinit -k -t /etc/libvirt/krb5.tab qpidd/`hostname`" >> /etc/sysconfig/matahari + + # restart libvirt and start libvirt-qpid + service libvirtd restart + service libvirt-qpid start + + # install matahari (XXX yum install it when it is availabe in the repos) + rpm -q matahari || rpm -ivh http://kojipkgs.fedoraproject.org/packages/matahari/0.0.4/4.fc11/x86_64/matahari-0.0.4-4.fc11.x86_64.rpm + + # and start it + sudo service matahari start + + # run ovirt awake to register us w/ the server + #bash checkout/node/scripts/ovirt-awake start 192.168.50.2 12120 /etc/libvirt/krb5.tab + + # FIXME on reboot we need to setenforce 0, ifup breth0, resetup resolv.conf (on both server/node), start libvirt-qpid / matahari +} + +restore_node_env(){ + test -f $OVIRT_APPLIANCE_BACKUP_DIR/resolv.conf && cp -f $OVIRT_APPLIANCE_BACKUP_DIR/resolv.conf /etc + test -f $OVIRT_APPLIANCE_BACKUP_DIR/krb5.conf && cp -f $OVIRT_APPLIANCE_BACKUP_DIR/krb5.conf /etc + test -f $OVIRT_APPLIANCE_BACKUP_DIR/libvirt/krb5.tab/ && cp -f $OVIRT_APPLIANCE_BACKUP_DIR/krb5.tab /etc + test -f $OVIRT_APPLIANCE_BACKUP_DIR/libvirt-qpid && cp -f $OVIRT_APPLIANCE_BACKUP_DIR/libvirt-qpid /etc/sysconfig + test -f $OVIRT_APPLIANCE_BACKUP_DIR/matahari && cp -f $OVIRT_APPLIANCE_BACKUP_DIR/matahari /etc/sysconfig +} -- 1.6.0.6 _______________________________________________ Ovirt-devel mailing list [email protected] https://www.redhat.com/mailman/listinfo/ovirt-devel
