#!/usr/bin/python import re import os dev = re.compile('^Host:\s+scsi0*(\d+)\s+Channel:\s+0*(\d+)\s+Id:\s+0*(\d+)\s+Lun:\s+0*(\d+)') type = re.compile('^\s+Type:\s+Direct-Access') block = re.compile('^block:(\S+)') hdreg = re.compile('^(hd\w+)$') diskreg = re.compile('^disk$') hddevices = [] sddevices = [] try: SCSI=open("/proc/scsi/scsi", "r") for line in SCSI: if dev.match(line): s = dev.match(line).group(1) c = dev.match(line).group(2) i = dev.match(line).group(3) l = dev.match(line).group(4) if type.match(line): sddir = "/sys/bus/scsi/drivers/sd/%s:%s:%s:%s" % (s, c, i, l) for file in os.listdir(sddir): if block.match(file): sddevices = sddevices + [ block.match(file).group(1) ] if len(sddevices) > 1: sddevices.sort() SCSI.close() except: pass try: for file in os.listdir("/proc/ide"): if hdreg.match(file): HD = open("/proc/ide/%s/media" % (file) ) media = HD.readline(); if diskreg.match(media): hddevices = hddevices + [ hdreg.match(file).group(1) ] if len(hddevices) > 1: hddevices.sort() except: pass devices = sddevices + hddevices if len(devices) > 0: print "# Found disks %s" % (devices) print "" print "clearpart --all"; print ""; print "part /boot --size=100 --ondisk=%s --fstype ext3" % (devices[0]) print "part pv.11 --size=1 --ondisk=%s --grow" % (devices[0]) if len(devices) > 1: print "part pv.21 --size=1 --ondisk=%s --grow" % (devices[1]) print "" print "volgroup vga pv.11" if len(devices) > 1: print "volgroup vgb pv.21" print ""; print "logvol swap --fstype swap --name=iGlassOpt --vgname=vga --size=256" print "logvol swap --fstype swap --name=swapVol01 --vgname=vga --size=4096" if len(devices) > 1: print "logvol / --fstype ext3 --name=rootVol --vgname=vga --size=1 --grow"; print "logvol swap --fstype swap --name=swapVol02 --vgname=vgb --size=4096" print "logvol /export --fstype ext3 --name=localVol --vgname=vgb --size=1 --grow" else: print "logvol / --fstype ext3 --name=rootVol --vgname=vga --size=5120"; print "logvol /export --fstype ext3 --name=localVol --vgname=vga --size=1 --grow" # print "logvol /var --fstype ext3 --name=rootVol --vgname=vga --size=5120"; # Not really sure how this got here print ""; else: print "# No disks found"