Skip to content

Commit

Permalink
Merge pull request #24 from willkelly/master
Browse files Browse the repository at this point in the history
Bug fixes (fixes issue 20, fixes issue 22)
  • Loading branch information
willkelly committed Jul 12, 2013
2 parents 0595197 + 37a0050 commit 91a066b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
16 changes: 12 additions & 4 deletions fetch_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
13 changes: 10 additions & 3 deletions rolemapper/remote.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
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):
# 'reset' performs a cold reboot, which is necessary for pxe booting to work
# '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:
Expand All @@ -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:
Expand Down

0 comments on commit 91a066b

Please sign in to comment.