diff --git a/fetch_images.sh b/fetch_images.sh index 01482aa..c6c4c57 100755 --- a/fetch_images.sh +++ b/fetch_images.sh @@ -4,12 +4,19 @@ # and initrds from somewhere # I should also be made into a manage.py command +OLDPWD="$PWD" +cd "$(dirname $0)" -wget http://c752981.r81.cf2.rackcdn.com/syslinux-needful.tar.gz -qO- | - tar xzC local/tftproot +echo "Downloading syslinux 6.01" +wget https://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-6.01.tar.bz2 -qO- | tar xj -mkdir local/tftproot/ubuntu -cd local/tftproot/ubuntu +cd local/tftproot +ln -s ../../syslinux-6.01/bios/core/pxelinux.0 +ln -s ../../syslinux-6.01/bios/com32/menu/menu.c32 +ln -s ../../syslinux-6.01/bios/com32/mboot/mboot.c32 +ln -s ../../syslinux-6.01/bios/com32/chain/chain.c32 +mkdir ubuntu +cd ubuntu images=( maverick natty oneiric precise) for image in ${images[@]}; do @@ -21,3 +28,4 @@ for image in ${images[@]}; do wget "http://archive.ubuntu.com/ubuntu/dists/${image}/main/installer-amd64/current/images/netboot/ubuntu-installer/amd64/${file}" -q -P ${image}-amd64; done; done; +cd $OLDPWD diff --git a/rolemapper/remote.py b/rolemapper/remote.py index 6fcf62c..b275095 100644 --- a/rolemapper/remote.py +++ b/rolemapper/remote.py @@ -1,14 +1,18 @@ import logging import subprocess - +from views import _get_site_config from django.conf import settings def _build_ipmi_command(host, *args): + config = _get_site_config(host) + user = config.get('ipmi_user', settings.IPMI_USER) + password = config.get('ipmi_password', settings.IPMI_PASSWORD) + return ['/usr/bin/ipmitool', '-H', host.ipmi_ip, - '-U', settings.IPMI_USER, - '-P', settings.IPMI_PASSWORD] + list(args) + '-U', user, + '-P', password] + list(args) def reboot(host): @@ -16,6 +20,8 @@ def reboot(host): # 'cycle' was not sufficient command = _build_ipmi_command(host, 'power', 'reset') logging.info('Rebooting: %s', host.hostname) + logging.debug("Using command %s" % command) + try: subprocess.check_call(command) except Exception: @@ -25,6 +31,7 @@ def reboot(host): def pxe_reboot(host): command = _build_ipmi_command(host, 'chassis', 'bootdev', 'pxe') logging.info('Setting PXE Boot for: %s', host.hostname) + logging.debug("Using command %s" % command) try: subprocess.check_call(command) except Exception: