Hi all,

I think we could allow to decalare the particular devices for the disks as parameters in the autoinstallscript.conf file. I can explain better the advantages with an example. Suppose you have this template:

<config>
  <disk dev="/dev/hda" label_type="msdos" unit_of_measurement="MB">
    <part  num="1"  size="100"  p_type="primary"  p_name="-"  flags="boot" />
    <part  num="2"  size="9990"  p_type="primary"  p_name="-"  flags="-" />
    <part  num="3"  size="*"  p_type="extended"  p_name="-"  flags="-" />
    <part  num="5"  size="512"  p_type="logical"  p_name="-"  flags="-" />
    <part  num="6"  size="1024"  p_type="logical"  p_name="-"  flags="-" />
    <part  num="7"  size="*"  p_type="logical"  p_name="-"  flags="-" />
  </disk>
  <disk dev="/dev/hdc" label_type="msdos" unit_of_measurement="MB">
    <part  num="1"  size="*"  p_type="primary"  p_name="-"  flags="-" />
  </disk>

<fsinfo line="10" real_dev="/dev/hda2" mp="/" fs="ext3" options="noatime" dump="1" pass="2" />
<fsinfo line="20" real_dev="/dev/hda1" mp="/boot" fs="ext3" options="ro,noatime,noexec" dump="1" pass="1" />
<fsinfo line="30" real_dev="/dev/hda6" mp="/tmp" fs="reiserfs" options="rw,user" dump="0" pass="0" />
<fsinfo line="40" real_dev="/dev/hda7" mp="/var" fs="xfs" options="rw,user,noexec" dump="0" pass="0" />
<fsinfo line="50" real_dev="/dev/hdc1" mp="/home" fs="reiserfs" options="rw,user" dump="0" pass="0" />
<fsinfo line="60" real_dev="none" mp="/dev/pts" fs="devpts" options="mode=0620" dump="0" pass="0" format="no" />
<fsinfo line="70" real_dev="/dev/hdb" mp="/mnt/cdrom" fs="iso9660" options="user,ro,exec" dump="0" pass="0" format="no" />
<fsinfo line="80" real_dev="none" mp="/proc" fs="proc" options="defaults" dump="0" pass="0" />
<fsinfo line="90" real_dev="/dev/hda5" mp="swap" fs="swap" options="defaults" dump="0" pass="0" />
</config>


The point is that I'd like to use the same template for a number of hosts without knowing the type of the disk that are installed in each one.

I could have one host with a SCSI disk, another one with a hardware-RAID controller, another with a different IDE disk (i.e. /dev/hdd) and I don't want to care about this.

So I could declare the config file in a form similar to this one:

<config>
  <disk dev="${disk_1}" label_type="msdos" unit_of_measurement="MB">
    <part  num="1"  size="100"  p_type="primary"  p_name="-"  flags="boot" />
    <part  num="2"  size="9990"  p_type="primary"  p_name="-"  flags="-" />
    <part  num="3"  size="*"  p_type="extended"  p_name="-"  flags="-" />
    <part  num="5"  size="512"  p_type="logical"  p_name="-"  flags="-" />
    <part  num="6"  size="1024"  p_type="logical"  p_name="-"  flags="-" />
    <part  num="7"  size="*"  p_type="logical"  p_name="-"  flags="-" />
  </disk>
  <disk dev="${disk_2}" label_type="msdos" unit_of_measurement="MB">
    <part  num="1"  size="*"  p_type="primary"  p_name="-"  flags="-" />
  </disk>

<fsinfo line="10" real_dev="${disk_1}2" mp="/" fs="ext3" options="noatime" dump="1" pass="2" />
<fsinfo line="20" real_dev="${disk_1}1" mp="/boot" fs="ext3" options="ro,noatime,noexec" dump="1" pass="1" />
<fsinfo line="30" real_dev="${disk_1}6" mp="/tmp" fs="reiserfs" options="rw,user" dump="0" pass="0" />
<fsinfo line="40" real_dev="${disk_1}7" mp="/var" fs="xfs" options="rw,user,noexec" dump="0" pass="0" />
<fsinfo line="50" real_dev="${disk_2}1" mp="/home" fs="reiserfs" options="rw,user" dump="0" pass="0" />
<fsinfo line="60" real_dev="none" mp="/dev/pts" fs="devpts" options="mode=0620" dump="0" pass="0" format="no" />
<fsinfo line="70" real_dev="/dev/hdb" mp="/mnt/cdrom" fs="iso9660" options="user,ro,exec" dump="0" pass="0" format="no" />
<fsinfo line="80" real_dev="none" mp="/proc" fs="proc" options="defaults" dump="0" pass="0" />
<fsinfo line="90" real_dev="${disk_1}5" mp="swap" fs="swap" options="defaults" dump="0" pass="0" />
</config>


Then I could determine the real values of ${disk_1}, ${disk_2} parameters at run-time detecting respectively the first HD device installed in the system, the second one and so on... In this way is not mandatatory for the user to know the exact configuration of the machines he wants to install.

From the implementation point of view we could add in the autoinstall script header something like this:

#!/bin/sh

# get_disk
# Usage: get_disk <num>
get_disk() {
        echo $HDLIST | cut -d',' -f $1
}

# remove_disk
# Usage: remove_disk <dev>
remove_disk() {
        dev=`echo $1 | sed s/^\/dev\//`
        HDLIST=`echo $HDLIST | sed s/$1// | sed s/,,/,/ | sed s/^,// | sed 
s/,$//`
        uset dev
}

# Generate a comma separated list of all available disks in the system (HDLIST)
TMP=`cat /proc/diskstats | grep "[hs]d[a-z]* " | sed "s/  */ /g" | cut -d' ' 
-f4; \
cat /proc/diskstats | grep "\/c[0-9]*d[0-9]*" | sed "s/  */ /g" | cut -d' ' 
-f4; \
cat /proc/diskstats | grep "\/ar[0-9]*" | sed "s/  */ /g" | cut -d' ' -f4`
for dev in $TMP; do HDLIST=$HDLIST,$dev; done
HDLIST=`echo $HDLIST | sed -e s/^,// -e s/,$//`
unset TMP

# Update the disks list, removing non-disk devices (i.e. cdroms, USB floppies, 
etc.)
OLD_IFS=$IFS; IFS=,
for dev in $HDLIST; do
    if ! parted -s /dev/$dev > /dev/null 2>&1; then
        remove_disk /dev/$dev
    fi
done
IFS=$OLD_IFS

Then during the autoinstallscript.master script we can replace the ${disk_n} occurrences with the value of the list at position "n".

For example if I want to print the partition table of the 3rd disk installed in the system (without knowing it) I can do something like this:

parted -s /dev/`get_disk 3` print

I think I will be able to make this updates in a relative short time. Do you think this could be useful? And, surely, there is a better way to define the syntax in the xml template... the one I've proposed is only a simple way for an easy parsing... but probably we can find a better one...

Every opinion is appreciate...

Regards,
-Andrea

--
Andrea Righi
System Management Group - CINECA - http://www.cineca.it
Via Magnanelli 6/3
40033 Casalecchio di Reno (BO) - Italy
e-mail: [EMAIL PROTECTED]


------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ Sisuite-devel mailing list Sisuite-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sisuite-devel

Reply via email to