cloning labs with drbl and clonezillase

33
Cloning labs with multicasting using DRBL and Clonezilla Server Table of Contents Prologue...........................................................................................................................................3 Apologies.........................................................................................................................................3 DRBL y Clonezilla Server...............................................................................................................4 Operation.........................................................................................................................................5 Performed Tasks..............................................................................................................................5 Form work........................................................................................................................................6 ANNEX I ........................................................................................................................................8 INSTALLATION OF DRBL-Clonezilla SE .............................................................................8 INSTALLATION WITHOUT DHCP........................................................................................9 ANNEX II .....................................................................................................................................10 Imaging and Cloning W7 and Linux.........................................................................................10 ANNEX III ...................................................................................................................................12 Build Rules Script.....................................................................................................................12 ANNEX IV....................................................................................................................................17 Running Scripts after Clone......................................................................................................17 Parsing scripts for Sysprep .......................................................................................................18 ANNEX V......................................................................................................................................20 Tasks Scripts.............................................................................................................................20 Autor: David Fuertes [email protected] 1

Upload: davidter

Post on 06-Apr-2015

1.754 views

Category:

Documents


7 download

DESCRIPTION

Cloning Labs With DRBL and ClonezillaSE

TRANSCRIPT

Cloning labs with multicasting using DRBL and Clonezilla Server

Table of ContentsPrologue...........................................................................................................................................3Apologies.........................................................................................................................................3DRBL y Clonezilla Server...............................................................................................................4Operation.........................................................................................................................................5Performed Tasks..............................................................................................................................5Form work........................................................................................................................................6ANNEX I ........................................................................................................................................8

INSTALLATION OF DRBL-Clonezilla SE .............................................................................8INSTALLATION WITHOUT DHCP........................................................................................9

ANNEX II .....................................................................................................................................10Imaging and Cloning W7 and Linux.........................................................................................10

ANNEX III ...................................................................................................................................12Build Rules Script.....................................................................................................................12

ANNEX IV....................................................................................................................................17Running Scripts after Clone......................................................................................................17Parsing scripts for Sysprep .......................................................................................................18

ANNEX V......................................................................................................................................20Tasks Scripts.............................................................................................................................20

Autor: David Fuertes [email protected] 1

Copyright © 2010 David Fuertes Ortiz

Some rights reserved.

Permission is granted to copy, distribute and / or modify this document under the terms of the Attribution-ShareAlike 3.0 or, at its option, any later version published by Creative Commons.

You can view a copy of the license

http://creativecommons.org/licenses/by-sa/3.0//legalcode

Autor: David Fuertes [email protected] 2

Prologue

This document tries to explain how to use DRBL/Clonezilla as a maintenance and deployment tool for computer labs.

The idea is to use DHCP server's configuration file, which contains data of our already running network, so that the DRBL/Clonezilla server works with it.

Clonezilla allows working with IP lists. Perl scripts are been created to work with names of labs directly, without typing all IP's.

You can see the details of how the cloning is made in the scripts attached at the end of this document.

I hope that this work helps to setup DRBL/Clonezilla SE according to your our needs.

At last, this document (and the perl scripts attached) surely could be improved. Please be free to do it.

Apologies

This text is originally written in Spanish (I'm and Spanish). I try to do the translation the better possible. Sorry for my terrible English. I promise to improve it soon.

Autor: David Fuertes [email protected] 3

DRBL y Clonezilla Server

We opted for the use of DRBL-Clonezilla Server because it is free and GPL. Implements multicasting and allows you to clone partitions separately. Which tools do not allow, as FOG.

The minimum requirements on the client, according to tests carried out, is 512MB of RAM.

DRBL (Diskless Remote Boot in Linux) Ver. 1.9.6-35:

Project developed by NCHC Free Software Lab's (National Center for High-Performance Computing located in Hsinchu, Taiwan).

DRBL is an open source solution for deployment and management of operating systems GNU / Linux on multiple computers.

DRBL will provide the necessary services, to clients computers, for network boot using the PXE protocol. With this protocol a bootloader is passed to the client from the server DRBL.

This bootloader is created by automated DRBL depending on the tasks that get executed on clients.

Basically, the bootloader will release a minimal Linux system that mount NFS file systems: /tftpboot/node_root, /usr, /opt, /home and /var/spool/mail from DRBL server (see Annex III).

Clonezilla Server Ver. 2.3.7-41:

Open Source utility for cloning and disk partitioning (included in the DRBL project). It will be the tool used for cloning.

Autor: David Fuertes [email protected] 4

Scenario

You need to clone up to 27 equal computers per labs. Each computer will have installed Windows7 and Linux.

To date, the tool used is rembo toolkit, but to become deprecated and does not support Windows7 and the ext3 file system (yes the ext2 with journaling enabled).

It intends to use the DHCP server already running (with the IP-MAC mapping).

Operation

It will have a DRBL server that will allow clients, using PXE boot, launch a minimal Linux system that will use Clonezilla to clone partitions.

The client will mount a part of their filesystem via NFS from the DRBL server. Thus, the client will have access to the images and the scripts we want to run the client (see Annex IV).

Performed Tasks

In order to use DRBL for our purposes, we have performed the following tasks:

1. Install DRBL / Clonezilla and setup Clonezilla BOX mode.

2. Uninstall DHCP server.

3. It creates an executable file (scripts_sh) that will call our future scripts of postcloning (in order to parse sysprep.xml).

4. IP_HOST_TABLE is created from dhcpd.conf. This file is use for Clonezilla and the created scripts.

5. Clients from DHCP server are entered in the configuration files of DRBL server, NIS and NAS.

6. Put all the scripts and sysprep.xml response file in the directory /home/partimag/ accessible by clients via NFS.

Autor: David Fuertes [email protected] 5

Form work

Exist the following components:

DRBL server: Debian lenny with DRBL/Clonezilla installed (see Annex I).

DHCP server: Debian lenny with dhcp3.

Clients: PC's with network boot and PXE protocol enabled.

The usual way of working is to introduce the tasks on the server and start the client DRBL.

The server tasks are introduced through a perl script created (see Annex V) for working with labs (by groups of IP's) and individual computer (by matching IP).

These tasks are:

High or low of equipment in labs.

Creating new images from the client computer.

Restoring images on damaged equipment.

Restoring images in labs.

Normal boot from disk.

High or low of equipment in labs.

Copy dhcpd.conf from DHCP server to DRBL server.

Run:

./BuildRules.pl

Creating new images from the client computer:

./NewDiskImage.pl IP_computer Lab

Restoring images in damaged equipment:

./RestoreDiskIP.pl IP_computer Lab

./RestoreW7IP.pl IP_computer Lab

./RestoreLinuxIP.pl IP_computer Lab

Autor: David Fuertes [email protected] 6

Restoring images in labs:

./RestoreDiskLab.pl Lab

./RestoreW7Lab.pl Lab

./RestoreLinuxLab.pl Lab

Normal boot from disk of equipment:

It is possible to boot in interactive mode clonezilla and tell everyone is to start from local disk.

../dcs -i

Autor: David Fuertes [email protected] 7

ANNEX I

INSTALLATION OF DRBL-Clonezilla SE

1. Add to the sources.list:

deb http://drbl.sourceforge.net/drbl-core stable DRBL

2. Install with /opt/drb/sbin/drblsrv -i with the following options:

a) Do Not install init images.

b) Do not use the console output.

c) Use the same level of CPU as the server CPU.

Note: In our case we have previously installed a kernel (from debian backports) with support for network cards of our client computers. Now, it is possible to select during the installation process.

d) Do not update SO.

3. Copy the scripts (scripts_sh, see Annex IV) that is run after cloning in /opt/DRBL/share /ocs/ postrun . It is done in this step because the set DRBL enter this script in the boot images of the clients.

4. DRBL/Clonezilla is configured by /opt/drbl/sbin/drblpush -i , with the following options:

a) DNS: foo.

b) Dominio NIS: foo.

c) Hostname client code: is irrelevant because we will not use. d) Ethernet port for access to INET: ethX.

e) No recompile MAC.

f) You want the DHCP service offers .... same IP ..... : No

g) Initial number to use IP's: 1 (does not matter because we will not use)

h) Number of clients DRBL: 1 (not use it)

i) Disless linux service: 2 == NO

j) Clonezilla mode: 1 == Clonezilla BOX

k) Default image directory: /home/partimag

l) Set Password pxelinux: NO

m) boot prompt: YES

n) 10 ms

o) Text mode

p) DO NOT use NAT

Autor: David Fuertes [email protected] 8

5. dhcpd.conf is modified by changing it exists in our DHCP server.

6. Are deleted /etc/exports, /etc/drbl/IP_HOST_TABLE. It removes the client added in /etc/ypserv.securenets.

7. Clients from dhcpd.conf, are introduced in /etc/exports, /etc/drbl/IP_HOST_TABLE y /etc/ypserv.securenets.

8. Restarted NFS, NIS and DHCP.

Steps 6, 7 and 8 can be performed by parsing dhcpd.conf with the script we have called /BuildRules.pl (see Annex III).

INSTALLATION WITHOUT DHCP

In the server DRBL:

1. DRBL-Clonezilla is installed as in the previous steps 1 to 6.

2. Uninstall the dhcp: apt-get remove dhcp3-server.

Note: Do not delete the file /etc/dhcp3/dhcpd.conf . Clonezilla uses that information to generate IP-MAC PXE boot files from the client.

3. PXE bootmanagers of clients are configured to not use the parameter name-server on dhcp server (useful to avoid having to touch the settings dhcp):

/opt/drbl/sbin/mknic-nbi -c n

In the dhcp server:

Set parameters:

next-server IP-DRBLServer

filename pxelinux.0

Note: If not execute step 3 ( mknic-nbi -c n) you must enter the parameter:

server-name NameOfDRBL

The dhcp server should have the option:

option host-name ClientName

This gives Linux client the computer name from dhcp.

Autor: David Fuertes [email protected] 9

ANNEX II

Imaging and Cloning W7 and Linux.

1. Preparing your computer for our work environment:

In our labs are computers with Windows7 and Linux systems.

The dual boot will take charge by grub (particularly grub2).

Although not the only possibility, install W7 and then Linux, to perform the installation of grub automatically.

2. Creating disk image:

We will have to create an image of the entire disk (selecting all partitions) on the server.

Windows7:

W7 creates a partition of 100 MB approx. hidden and the system partition, then in our case W7 will be in the /dev/sda1 (hidden) and /dev/sda2 ( c: \ ).

Once installed the system or the desired apps run the sysprep to act on the response file sysprep.xml (which will be parsed with information from dhcp after cloning).

sysprep.exe /generalize /oobe /shutdown /quiet /unattend:sysprep.xml

Then the generated image is ready to run sysprep on the first start, using the sysprep.xml parsed, after cloning.

Note: Students user must delete before creating the image server. Since the first boot, up a user (compulsory process) with that name.

Linux:

Desired distribution was installed on the source system. In our case we use the /dev/sda3 (for the root system) and /dev/sda4 (to swap).

Will need to modify /boot/grub/grub.cfg to boot by default W7 and remove rescue mode for Linux.

The Linux system will be configure to get the network parameters IP and hostname from dhcp.

/etc/network/interfaces => for dhcp

/etc/hostname => emty

Autor: David Fuertes [email protected] 10

Attention must be given to whether the kernel of the client appoints the drives as hda or sda, since by default Clonezilla use hda.

Autor: David Fuertes [email protected] 11

ANNEX III

Build Rules Script

BuildRules.pl

#!/usr/bin/perl

###########################################################################

# Script to run after setting Clonezilla by drblpush -i, ###################

# to create rules NIS, NFS, for DHCP clients of laboratories. ###################

# Also creates IP_HOST_TABLE ###################

###########################################################################

###### Files to modify

$dhcpFile = "/etc/dhcp3/dhcpd.conf";

$IP_HOST_TABLE = "/etc/drbl/IP_HOST_TABLE";

$IP_HOST_TABLE_CP = "/home/partimag/scripts/IP_HOST_TABLE";

$exports = "/etc/exports";

$ypservsecurenets = "/etc/ypserv\.securenets";

#### Check input parameters

if ( $ARGV[0] eq "--help " || $#ARGV == -1 )

{

print "Creating NFS, NIS rules and IP_HOST_TABLE file from dhcpd.conf\n";

exit;

}

Autor: David Fuertes [email protected] 12

sub CreateIP_HOST_TABLE

{

$ip = "@_[0]";

$host = "@_[1]";

print IP_HOST "$ip\t$host\n";

}

sub CreateExports

{

$ip = "@_[0]";

print exports"/tftpboot/node_root $ip(ro,async,no_root_squash,no_subtree_check)\n";

print exports"/usr $ip(ro,async,no_root_squash,no_subtree_check)\n";

print exports"/opt $ip(ro,async,no_root_squash,no_subtree_check)\n";

print exports"/home $ip(rw,sync,no_root_squash,no_subtree_check)\n";

print exports"/var/spool/mail $ip(rw,sync,root_squash,no_subtree_check)\n\n";

}

sub CreateYPSecurenets

{

$ip = "@_[0]";

print yp "255.255.255.255 $ip\n";

}

### Main Program

# In order to create rules for the first time we opened the files created by DRBL to overwrite.

Autor: David Fuertes [email protected] 13

open (dhcp,"<$dhcpFile");

open (IP_HOST, ">$IP_HOST_TABLE");

print IP_HOST "\#File create parsing dhcp.conf\n\n";

open (exports, ">$exports");

print exports "\#Clients add from dhcp\n\n";

open (yp, ">$ypservsecurenets");

print yp "\#Data from DRBL Server\n";

print yp "255.0.0.0 127.0.0.0\n";

@ifconfig= `ifconfig`;

$EvalNext="no";

foreach $line(@ifconfig)

{

@fields = split(/\s+/,$line);

if ( $EvalNext eq "si" )

{

@addr=split(/:/,@fields[2]);

# print "IP: @addr[1]\n";

$EvalNext="no";

print yp "255.255.255@addr[1]\n";

}

if ( @fields[0] =~ eth )

{

$EvalNext="si";

# print "Dev: @fields[0]\n";

}

}

Autor: David Fuertes [email protected] 14

print yp "\#Clientes adds from dhcp\n\n";

$next="no";

while (<dhcp>)

{

if ($next eq "si" && !/^#/ && /(\d+\.\d+\.\d+\.\d+)/ )

{

$next="no";

$ip = $&;

&CreateIP_HOST_TABLE("$ip","$host");

&CreateExports("$ip");

&CreateYPSecurenets("$ip");

}

if (/.*host\s.*/) {

$next="si";

@line = split(/ /,$&);

$host = @line[1];

}

}

close(yp);

close(exports);

close(IP_HOST);

close(dhcp);

# Remove templates for client who not were used.

system("rm -fr /tftpboot/nodes/*");

Autor: David Fuertes [email protected] 15

# I do a copy of IP table for parse sysprep.xml

system("cp $IP_HOST_TABLE $IP_HOST_TABLE_CP");

# Restart NAS y NIS

system("/etc/init.d/nfs-kernel-server restart");

system("/etc/init.d/nfs-common restart");

system("/etc/init.d/nis restart");

Autor: David Fuertes [email protected] 16

ANNEX IV

Running Scripts after Clone

You may tell the Clonezilla server that runs a script when you have finished clone (parameter-o1 in command line).

The run scripts are in the directory /opt/drbl/share/ocs/postrun/ .

The server will run all executable scripts that are in that directory, using the command run-parts of Linux.

Note: run-parts only run scripts whose names contain uppercase and lowercase letters, digits, underscores and dashes.

In our case, we have created an executable script called scripts_sh to call another script found in /home/partimag/scripts / , called scripts.sh.

scripts_sh

____________________________________

#!/bin/bash

/home/partimag/scripts/scripts.sh

____________________________________

scripts.sh

____________________________________

#/bin/bash

echo “Parsing DHCP”

/home/partimag/scripts/ParseSysprep.sh

echo “Done”

____________________________________

The idea is to modify the tasks to be performed after cloning without having to reconfigure the Clonezilla server. With this system enough to modify the contents of the script scripts.sh.

Autor: David Fuertes [email protected] 17

Parsing scripts for Sysprep

With those scripts, the template of sysprep.xml (in /home/partimag/sysprep/) file is copied from the server to the Windows7 partition of client and parsed with the information for the client who is being cloned.

ParseSysprep.sh

____________________________________

#!/bin/sh

ntfs-3g /dev/sda2 /mnt/ &&

perl /home/partimag/scripts/ParseSysprep.pl &&

umount /mnt

____________________________________

ParseSysprep.pl

____________________________________

#!/usr/bin/perl

$IP_HOST_TABLE = "/home/partimag/scripts/IP_HOST_TABLE";

$SYSPREP = "/home/partimag/sysprep/sysprep.xml";

$SYSPREP_PARCH = "/mnt/Windows/System32/sysprep/sysprep.xml";

$HOST_IP = `hostname`;

$HOST_IP =~ s/-/./g;

$HOST_IP =~ s/\n//g;

open(table_ip, "<$IP_HOST_TABLE");

while (<table_ip>) {

if (/$HOST_IP/) {

$line=$_;

$line =~ s/\s+/ /g;

Autor: David Fuertes [email protected] 18

@line = split(/ /,$line);

$hostname = @line[1];

}

}

close(table_ip);

open(source,"<$SYSPREP");

open(destiny,">$SYSPREP_PARCH");

while(<source>)

{

s/labX-XX/$hostname/g;

print destiny $_;

}

close(source);

close(destiny);

Autor: David Fuertes [email protected] 19

ANNEX V

Tasks Scripts

NewDiskImage.pl

_____________________________________________________________________

#!/usr/bin/perl

# Script to generate a new image to the given host on the server

$IP_HOST_TABLE = "/etc/drbl/IP_HOST_TABLE";

if ( $ARGV[0] eq "--help " || $#ARGV == -1 )

{

print "Usage: $0 IP_source Lab\n";

print "Create a new image, called lab-img, from the source IP on the server DRBL\n";

exit;

}

$host=$ARGV[0];

$lab=$ARGV[1];

open (IP_HOST, "<$IP_HOST_TABLE");

$exist="no";

while (<IP_HOST>)

{

if (/$host\s/) {

$exist="si";

}

}

Autor: David Fuertes [email protected] 20

close(IP_HOST);

if ( $exist eq "no" ) {

print "The specified computer is not a client of DRBL\n";

exit;

} else {

system("/opt/drbl/sbin/drbl-ocs -b -q2 -j2 -nogui -p poweroff -z1 -i 1000000 -h \"$host\" -l es_ES.UTF-8 startparts save $lab-img sda1 sda2 sda3");

}

Autor: David Fuertes [email protected] 21

RestoreDiskIP.pl

_____________________________________________________________________

#!/usr/bin/perl

# Script to clone an entire disk image on a computer.

$IP_HOST_TABLE = "/etc/drbl/IP_HOST_TABLE";

$Dir_Img="/home/partimag/";

if ( $ARGV[0] eq "--help " || $#ARGV == -1 )

{

print "Usage: $0 IP_Host Lab\n";

print "Make a full reload of the disc, creating the necessary partitions on the specified equipment.\n";

exit;

}

$host=$ARGV[0];

$lab=$ARGV[1];

open (IP_HOST, "<$IP_HOST_TABLE");

$exist="no";

while (<IP_HOST>)

{

if (/$host\s/) {

$exist="si";

}

}

Autor: David Fuertes [email protected] 22

close(IP_HOST);

if ( $exist eq "no" ) {

print "The specified computer is not a client of DRBL\n";

exit;

} else {

if (-d "$Dir_Img$lab-img" ) {

system("/opt/drbl/sbin/drbl-ocs -b -g auto -e1 auto -e2 -x -nogui -r -j2 -o1 -p reboot --clients-to-wait 1 --max-time-to-wait 300 -h \"$host\" -l es_ES.UTF-8 startparts multicast_restore $lab-img sda1 sda2 sda3");

} else {

print "No exist image $Dir_Img$lab-img\n";

exit;

}

}

Autor: David Fuertes [email protected] 23

RestoreDiskLab.pl

#!/usr/bin/perl

# Script to clone a new disk image in a lab

$IP_HOST_TABLE = "/etc/drbl/IP_HOST_TABLE";

if ( $ARGV[0] eq "--help " || $#ARGV == -1 )

{

print "Usage: $0 Lab\n";

print "Make a full reload of the disc. Creating the partitions needed in the lab indicated.\n";

exit;

}

$lab=$ARGV[0];

# Let's create a list of IP `S of the lab

open (IP_HOST, "<$IP_HOST_TABLE");

while (<IP_HOST>)

{

if (/\s$lab/) {

@line = split(/\t/,$_);

$IP = @line[0];

# print "$IP\n";

push(@ListIPs,$IP);

}

}

close(IP_HOST);

Autor: David Fuertes [email protected] 24

if ( $#ListaIPs != -1 )

{

system("/opt/drbl/sbin/drbl-ocs -b -g auto -e1 auto -e2 -x -nogui -r -j2 -o1 -p reboot --clients-to-wait $#ListIPs --max-time-to-wait 300 -h \"@ListIPs\" -l es_ES.UTF-8 startparts multicast_restore $lab-img sda1 sda2 sda3");

} else {

print "The $lab does not belong to this server DRBL\n";

exit;

}

Autor: David Fuertes [email protected] 25

RestoreLinuxIP.pl

#!/usr/bin/perl

# Script to clone a Linux image on a client

$IP_HOST_TABLE = "/etc/drbl/IP_HOST_TABLE";

$Dir_Img="/home/partimag/";

if ( $ARGV[0] eq "--help " || $#ARGV == -1 )

{

print "Usage: $0 IP_Host Lab\n";

print "Make a reload of the Linux partition in the specified equipment.\n";

exit;

}

$host=$ARGV[0];

$lab=$ARGV[1];

open (IP_HOST, "<$IP_HOST_TABLE");

$exist="no";

while (<IP_HOST>)

{

if (/$host\s/) {

$exist="si";

}

}

close(IP_HOST);

Autor: David Fuertes [email protected] 26

if ( $exist eq "no" ) {

print "The specified computer $host is not a client of DRBL\n";

exit;

} else {

if (-d "$Dir_Img$aula-img" ) {

system("/opt/drbl/sbin/drbl-ocs -b -g auto -e1 auto -e2 -x -nogui -r -j2 -k -p reboot --clients-to-wait 1 --max-time-to-wait 300 -h \"$host\" -l es_ES.UTF-8 startparts multicast_restore $lab-img sda3");

} else {

print "No exit image $Dir_Img$lab-img\n";

exit;

}

}

Autor: David Fuertes [email protected] 27

RestoreLinuxLab.pl

#!/usr/bin/perl

# Script to clone a Linux image in a Lab

$IP_HOST_TABLE = "/etc/drbl/IP_HOST_TABLE";

if ( $ARGV[0] eq "--help " || $#ARGV == -1 )

{

print "Usage: $0 Lab\n";

print "Make a reload of the Linux partition in the lab indicated.\n";

exit;

}

$lab=$ARGV[0];

# Let's create a list of IP `S of the lab

open (IP_HOST, "<$IP_HOST_TABLE");

while (<IP_HOST>)

{

if (/\s$lab/) {

@line = split(/\t/,$_);

$IP = @line[0];

# print "$IP\n";

push(@ListIPs,$IP);

}

}

close(IP_HOST);

Autor: David Fuertes [email protected] 28

if ( $#ListIPs != -1 )

{

system("/opt/drbl/sbin/drbl-ocs -b -g auto -e1 auto -e2 -x -nogui -r -j2 -k -p reboot --clients-to-wait $#ListIPs --max-time-to-wait 300 -h \"@ListIPs\" -l es_ES.UTF-8 startparts multicast_restore $lab-img sda3");

} else {

print "The class $lab does not belong to this server DRBL\n";

exit;

}

Autor: David Fuertes [email protected] 29

RestoreW7IP.pl

#!/usr/bin/perl

# Script to clone an image of Windows7 on a computer.

$IP_HOST_TABLE = "/etc/drbl/IP_HOST_TABLE";

$Dir_Img="/home/partimag/";

if ( $ARGV[0] eq "--help " || $#ARGV == -1 )

{

print "Usage: $0 IP_Host Lab\n";

print "Make a reload of the Windows7 partition to the specified equipment.\n";

exit;

}

$host=$ARGV[0];

$lab=$ARGV[1];

open (IP_HOST, "<$IP_HOST_TABLE");

$exist="no";

while (<IP_HOST>)

{

if (/$host\s/) {

$exist="si";

Autor: David Fuertes [email protected] 30

}

}

close(IP_HOST);

if ( $exist eq "no" ) {

print "The specified computer $host is not a client of DRBL\n";

exit;

} else {

if (-d "$Dir_Img$aula-img" ) {

system("/opt/drbl/sbin/drbl-ocs -b -g auto -e1 auto -e2 -x -nogui -r -j2 -o1 -k -p reboot --clients-to-wait 1 --max-time-to-wait 300 -h \"$host\" -l es_ES.UTF-8 startparts multicast_restore $lab-img sda1 sda2");

} else {

print "No exist image $Dir_Img$lab-img\n";

exit;

}

}

Autor: David Fuertes [email protected] 31

RestoreW7Lab.pl

#!/usr/bin/perl

# Script to clone an image of Windows7 in a Lab

$IP_HOST_TABLE = "/etc/drbl/IP_HOST_TABLE";

if ( $ARGV[0] eq "--help " || $#ARGV == -1 )

{

print "Usage: $0 Lab\n";

print "Make a full reload of the disk in the Lab indicated.\n";

exit;

}

$lab=$ARGV[0];

# Let's create a list of IP `S of the lab

open (IP_HOST, "<$IP_HOST_TABLE");

while (<IP_HOST>)

{

if (/\s$lab/) {

@line = split(/\t/,$_);

$IP = @line[0];

# print "$IP\n";

push(@ListIPs,$IP);

}

}

close(IP_HOST);

Autor: David Fuertes [email protected] 32

if ( $#ListIPs != -1 )

{

system("/opt/drbl/sbin/drbl-ocs -b -g auto -e1 auto -e2 -x -nogui -r -j2 -o1 -k -p reboot --clients-to-wait $#ListIPs --max-time-to-wait 300 -h \"@ListIPs\" -l es_ES.UTF-8 startparts multicast_restore $lab-img sda1 sda2");

} else {

print "The lab $lab, does not belong to this server DRBL\n";

exit;

}

Autor: David Fuertes [email protected] 33