Perry Myers
2008-Oct-14 02:06 UTC
[Ovirt-devel] [PATCH node] Fix ovirt install/uninstall node scripts so reboot is not necessary
Signed-off-by: Perry Myers <pmyers at redhat.com> --- ovirt-listen-awake/ovirt-install-node | 55 ++++++++++++++++++++++++++----- ovirt-listen-awake/ovirt-uninstall-node | 10 +++++- 2 files changed, 55 insertions(+), 10 deletions(-) diff --git a/ovirt-listen-awake/ovirt-install-node b/ovirt-listen-awake/ovirt-install-node index 1d998f4..4cffd6d 100644 --- a/ovirt-listen-awake/ovirt-install-node +++ b/ovirt-listen-awake/ovirt-install-node @@ -1,16 +1,27 @@ #!/bin/bash +PHYS_HOST=physical.priv.ovirt.org +MGMT_HOST=management.priv.ovirt.org + . /etc/init.d/ovirt-functions PATH=$PATH:/sbin:/usr/sbin +ME=$(basename "$0") +warn() { printf "$ME: $@\n" >&2; } +die() { warn "$@"; exit 1; } usage() { - echo "Usage: ovirt-install-node <stateless|stateful>" - exit 1 + echo "Usage: $ME <stateless|stateful>" } +# first, check to see we are root +if [ $( id -u ) -ne 0 ]; then + die "Must run as root" +fi + if [ $# -ne 1 ]; then usage + exit 1 fi backup_file() { @@ -73,14 +84,27 @@ elif [ "$1" = "stateful" ]; then exit 2 fi + # Always try to uninstall first, that way the original pristine files are + # in place before re-installing, this prevents OVIRT_BACKUP_DIR from + # being overwritten with an older version of the node config files + ovirt-uninstall-node > /dev/null 2>&1 + + # Remove old keytab if it exists in case we have a new appliance to work with + rm -f /etc/libvirt/krb5.tab + mkdir -p $OVIRT_BACKUP_DIR backup_file /etc/sysconfig/network - sed -i -e 's/^HOSTNAME=.*/HOSTNAME=physical.priv.ovirt.org/' /etc/sysconfig/network + if grep "^HOSTNAME=" /etc/sysconfig/network > /dev/null 2>&1 ; then + sed -i -e "s/^HOSTNAME=.*/HOSTNAME=$PHYS_HOST/" /etc/sysconfig/network + else + echo "HOSTNAME=$PHYS_HOST" >> /etc/sysconfig/network + fi + hostname $PHYS_HOST backup_file /etc/hosts - add_if_not_exist "192.168.50.1 physical.priv.ovirt.org" /etc/hosts - add_if_not_exist "192.168.50.2 management.priv.ovirt.org" /etc/hosts + add_if_not_exist "192.168.50.1 $PHYS_HOST" /etc/hosts + add_if_not_exist "192.168.50.2 $MGMT_HOST" /etc/hosts chkconfig ovirt-listen-awake on chkconfig collectd on @@ -93,10 +117,23 @@ elif [ "$1" = "stateful" ]; then ovirt_setup_libvirtd backup_file /etc/sysconfig/iptables - lokkit -n -t ovirtbr0 - - echo "Setup complete. To make the changes take effect, shut down any" - echo "running guests and reboot the host" + lokkit -p 7777:tcp -p 16509:tcp + + service collectd restart + service ovirt-listen-awake restart + + # Check if any domains are active before restarting libvirtd, since it will + # kill them. Header information from virsh list is 2 lines, and 1 line for + # footer. So > 3 lines means domains are running + running_domains=$(( $(virsh -c qemu:///system list 2> /dev/null | wc -l) - 3 )) + if [ $running_domains -gt 0 ]; then + echo "Cannot restart libvirtd because domains are active." + echo "Please shutdown all domains and restart libvirtd with:" + echo "service libvirtd restart" + else + service libvirtd restart + fi else usage + exit 1 fi diff --git a/ovirt-listen-awake/ovirt-uninstall-node b/ovirt-listen-awake/ovirt-uninstall-node index 1f820e4..a40b0ed 100644 --- a/ovirt-listen-awake/ovirt-uninstall-node +++ b/ovirt-listen-awake/ovirt-uninstall-node @@ -3,9 +3,17 @@ . /etc/init.d/ovirt-functions PATH=$PATH:/sbin:/usr/sbin +ME=$(basename "$0") +warn() { printf "$ME: $@\n" >&2; } +die() { warn "$@"; exit 1; } + +# first, check to see we are root +if [ $( id -u ) -ne 0 ]; then + die "Must run as root" +fi if [ $# -ne 0 ]; then - echo "Usage: ovirt-uninstall-node" + echo "Usage: $ME" exit 1 fi -- 1.5.5.1
Perry Myers
2008-Oct-14 02:11 UTC
[Ovirt-devel] Re: [PATCH node] Fix ovirt install/uninstall node scripts so reboot is not necessary
One problem still exists with the 'running vms on the appliance host'... The current procedure is: 1. Install ovirt-appliance, ovirt-node and ovirt-node-selinux rpms 2. ovirt-install-node stateful 3. create-ovirt-appliance 4. virsh start ovirt-appliance When the appliance comes up, it will contact the host and will assign it a keytab. However, since libvirt doesn't pick up the keytab until it is restarted (and you can't restart libvirtd while the appliance is running) you need to: 5. On appliance: shutdown -h now 6. virsh destroy ovirt-appliance 7. service libvirtd restart 8. virsh start ovirt-appliance Now when the appliance is up again, it can contact the physical host and create vms on it since libvirt has the correct keytab loaded. Once we move to using libvirt-qpid and ovirt-qpid this should go away since we won't need libvirt to have a keytab, the qpid interfaces will will handle the security for us. Perry
Perry Myers
2008-Oct-14 14:49 UTC
[Ovirt-devel] [PATCH node] Fix ovirt install/uninstall node scripts so reboot is not necessary
Signed-off-by: Perry Myers <pmyers at redhat.com> --- ovirt-listen-awake/ovirt-install-node | 61 ++++++++++++++++++++++++++----- ovirt-listen-awake/ovirt-uninstall-node | 11 +++++- 2 files changed, 62 insertions(+), 10 deletions(-) diff --git a/ovirt-listen-awake/ovirt-install-node b/ovirt-listen-awake/ovirt-install-node index 1d998f4..7fbf997 100644 --- a/ovirt-listen-awake/ovirt-install-node +++ b/ovirt-listen-awake/ovirt-install-node @@ -1,16 +1,27 @@ #!/bin/bash +PHYS_HOST=physical.priv.ovirt.org +MGMT_HOST=management.priv.ovirt.org + . /etc/init.d/ovirt-functions PATH=$PATH:/sbin:/usr/sbin +ME=$(basename "$0") +warn() { printf "$ME: $@\n" >&2; } +die() { warn "$@"; exit 1; } usage() { - echo "Usage: ovirt-install-node <stateless|stateful>" - exit 1 + echo "Usage: $ME <stateless|stateful>" } +# first, check to see we are root +if [ $( id -u ) -ne 0 ]; then + die "Must run as root" +fi + if [ $# -ne 1 ]; then usage + exit 1 fi backup_file() { @@ -73,14 +84,28 @@ elif [ "$1" = "stateful" ]; then exit 2 fi + # Always try to uninstall first, that way the original pristine files are + # in place before re-installing, this prevents OVIRT_BACKUP_DIR from + # being overwritten with an older version of the node config files + ovirt-uninstall-node > /dev/null 2>&1 + + # Remove old keytab if it exists in case we have a new appliance to work with + rm -f /etc/libvirt/krb5.tab + + rm -Rf $OVIRT_BACKUP_DIR mkdir -p $OVIRT_BACKUP_DIR backup_file /etc/sysconfig/network - sed -i -e 's/^HOSTNAME=.*/HOSTNAME=physical.priv.ovirt.org/' /etc/sysconfig/network + if grep "^HOSTNAME=" /etc/sysconfig/network > /dev/null 2>&1 ; then + sed -i -e "s/^HOSTNAME=.*/HOSTNAME=$PHYS_HOST/" /etc/sysconfig/network + else + echo "HOSTNAME=$PHYS_HOST" >> /etc/sysconfig/network + fi + hostname $PHYS_HOST backup_file /etc/hosts - add_if_not_exist "192.168.50.1 physical.priv.ovirt.org" /etc/hosts - add_if_not_exist "192.168.50.2 management.priv.ovirt.org" /etc/hosts + add_if_not_exist "192.168.50.1 $PHYS_HOST" /etc/hosts + add_if_not_exist "192.168.50.2 $MGMT_HOST" /etc/hosts chkconfig ovirt-listen-awake on chkconfig collectd on @@ -93,10 +118,28 @@ elif [ "$1" = "stateful" ]; then ovirt_setup_libvirtd backup_file /etc/sysconfig/iptables - lokkit -n -t ovirtbr0 - - echo "Setup complete. To make the changes take effect, shut down any" - echo "running guests and reboot the host" + # We open up anything coming from ovirtbr0 to this node, since it + # is only intended for demo purposes. For reference, here are the + # ports that need to be opened: + # 7777:tcp (ovirt-listen-awake), 16509:tcp (libvirtd), 5900-6000:tcp (vnc), + # 49152-49216:tcp (libvirt migration) + lokkit -t ovirtbr0 + + service collectd restart + service ovirt-listen-awake restart + + # Check if any domains are active before restarting libvirtd, since it will + # kill them. Header information from virsh list is 2 lines, and 1 line for + # footer. So > 3 lines means domains are running + running_domains=$(( $(virsh -c qemu:///system list 2> /dev/null | wc -l) - 3 )) + if [ $running_domains -gt 0 ]; then + echo "Cannot restart libvirtd because domains are active." + echo "Please shutdown all domains and restart libvirtd with:" + echo "service libvirtd restart" + else + service libvirtd restart + fi else usage + exit 1 fi diff --git a/ovirt-listen-awake/ovirt-uninstall-node b/ovirt-listen-awake/ovirt-uninstall-node index 1f820e4..3e4d300 100644 --- a/ovirt-listen-awake/ovirt-uninstall-node +++ b/ovirt-listen-awake/ovirt-uninstall-node @@ -3,9 +3,17 @@ . /etc/init.d/ovirt-functions PATH=$PATH:/sbin:/usr/sbin +ME=$(basename "$0") +warn() { printf "$ME: $@\n" >&2; } +die() { warn "$@"; exit 1; } + +# first, check to see we are root +if [ $( id -u ) -ne 0 ]; then + die "Must run as root" +fi if [ $# -ne 0 ]; then - echo "Usage: ovirt-uninstall-node" + echo "Usage: $ME" exit 1 fi @@ -31,3 +39,4 @@ unbackup_file /etc/libvirt/libvirtd.conf unbackup_file /etc/sasl2/libvirt.conf unbackup_file /etc/sysconfig/iptables unbackup_file /etc/krb5.conf +rm -Rf $OVIRT_BACKUP_DIR -- 1.5.5.1