Baud 115200
- Tftp /tftpboot/pxe
-
DebianNonfreeFirmware firmware-bnx2
);
my $whoami = `whoami` or die $!;
chomp($whoami) or die;
+ my $nodename = `uname -n` or die $!;
+ chomp($nodename) or die;
+ my $myfqdn = "$nodename.$c{DnsDomain}";
+
+ $c{TftpPath} ||= "/tftpboot/";
+ $c{TftpHost} ||= $myfqdn;
+ $c{TftpPxeDir} ||= "pxelinux.cfg/";
+ $c{TftpPxeTemplates} ||= '%ipaddrhex% 01-%etherhyph%';
+ $c{TftpPlayDir} ||= "$whoami/osstest/";
+ $c{TftpTmpDir} ||= "$c{TftpPlayDir}tmp/";
+
+ $c{TftpDiBase} ||= "$c{TftpPlayDir}debian-installer";
+ $c{TftpDiVersion} ||= 'current';
+
$c{WebspaceFile} ||= "$ENV{'HOME'}/public_html/";
- if (!$c{WebspaceUrl}) {
- my $nodename = `uname -n` or die $!;
- chomp($nodename) or die;
- $c{WebspaceUrl} = "http://$nodename.$c{DnsDomain}/~$whoami/";
- }
+ $c{WebspaceUrl} ||= "http://$myfqdn/~$whoami/";
$c{WebspaceCommon} ||= 'osstest/';
$c{WebspaceLog} ||= '/var/log/apache2/access.log';
$c{OverlayLocal} ||= "overlay-local";
$c{GuestDebianSuite} ||= $c{DebianSuite};
-
- $c{PxeDiBase} ||= "$whoami/osstest/debian-installer";
- $c{PxeDiVersion} ||= 'current';
}
sub augmentconfigdefaults {
await_webspace_fetch_byleaf create_webfile
file_link_contents get_timeout
- setup_pxeboot setup_pxeboot_local host_pxedir
+ setup_pxeboot setup_pxeboot_local host_pxefile
);
%EXPORT_TAGS = ( );
my $serialmeth = get_host_property($ho,'serial','noop');
$ho->{SerialMethobj} = get_host_method_object($ho,'Serial',$serialmeth);
- my $ip_packed= gethostbyname($ho->{Fqdn});
- die "$ho->{Fqdn} ?" unless $ip_packed;
- $ho->{Ip}= inet_ntoa($ip_packed);
- die "$ho->{Fqdn} ?" unless defined $ho->{Ip};
+ $ho->{IpStatic} = get_host_property($ho,'ip-addr');
+ if (!defined $ho->{IpStatic}) {
+ my $ip_packed= gethostbyname($ho->{Fqdn});
+ die "$ho->{Fqdn} ?" unless $ip_packed;
+ $ho->{IpStatic}= inet_ntoa($ip_packed);
+ die "$ho->{Fqdn} ?" unless defined $ho->{IpStatic};
+ }
+ $ho->{Ip}= $ho->{IpStatic};
$mjobdb->host_check_allocated($ho);
logm("wrote $fn");
}
-sub host_pxedir ($) {
+sub host_pxefile ($) {
my ($ho) = @_;
- my $dir= $ho->{Ether};
- $dir =~ y/A-Z/a-z/;
- $dir =~ y/0-9a-f//cd;
- length($dir)==12 or die "$dir";
- $dir =~ s/../$&-/g;
- $dir =~ s/\-$//;
- return $dir;
+ my %v = %r;
+ if (defined $ho->{Ether}) {
+ my $eth = $v{'ether'} = $ho->{Ether};
+ $eth =~ y/A-Z/a-z/;
+ $eth =~ y/0-9a-f//cd;
+ length($eth)==12 or die "$eth ?";
+ $eth =~ s/../$&-/g;
+ $eth =~ s/\-$//;
+ $v{'etherhyph'} = $eth;
+ }
+ if (defined $ho->{IpStatic}) {
+ my $ip = $ho->{IpStatic};
+ $ip =~ s/\b0+//g;
+ $v{'ipaddr'} = $ip;
+ $v{'ipaddrhex'} = sprintf "%02X%02X%02X%02X", split /\./, $ip;
+ }
+ foreach my $pat (split /\s+/, $c{TftpPxeTemplates}) {
+ # we skip patterns that contain any references to undefined %var%s
+ $pat =~ s{\%(\w*)\%}{
+ $1 eq '' ? '%' :
+ defined($v{$1}) ? $v{$1} :
+ next;
+ }ge;
+ # and return the first pattern we managed to completely substitute
+ return $pat;
+ }
+ die "no pxe template matched $c{TftpPxeTemplates} ".
+ (join ",", sort keys %v)." ?";
}
sub setup_pxeboot ($$) {
my ($ho, $bootfile) = @_;
- my $dir= host_pxedir($ho);
- file_link_contents($c{Tftp}."/$dir/pxelinux.cfg", $bootfile);
+ my $f= host_pxefile($ho);
+ file_link_contents("$c{TftpPath}$c{TftpPxeDir}$f", $bootfile);
}
sub setup_pxeboot_local ($) {
sqlite3
tcl8.4 tclx8.4 libsqlite3-tcl
libdbi-perl libdbd-sqlite3-perl
+ pax rsync
- Write a config file
~/.xen-osstest/config
DebianPreseed added to existing preseed file
+TftpPxeTemplates
+ List (space-separated) of template filenames for writing
+ The templates contain variable substitutions %var%
+ The variables are the runvars plus
+ ether host/guest mac address
+ etherhyp ... in lowercase hyphen-separated form (for pxelinux)
+ ipaddr host/guest static ip address
+ ipaddrhex ... in uppercase hex form (for pxelinux)
+ Templates containing references to unknown %var%s - particularly,
+ the host mac address when not known, or the guest's dynamic
+ ip address - are skipped. The first template all of whose ingredients
+ are known is used, with TftpPath and TftpPxeDir prepended.
+
========================================
Host-specific config settigs
pfile=$sbase/non-free/binary-$arch/Packages.bz2
files='initrd.gz linux'
-dstroot=`getconfig Tftp`/`getconfig PxeDiBase`/
+dstroot=`getconfig TftpPath`/`getconfig TftpDiBase`/
date=`date +%Y-%m-%d`-$suite
dst=$arch/$date
$macdir =~ s/\:/-/g;
system_checked(<<END);
set -e
- cd $c{Tftp}
+ cd $c{TftpPath}$c{TftpPxeDir}
sudo chown root.$c{TftpPxeGroup} $macdir
sudo chmod 2775 $macdir
sudo rm -f $hn
PlanRogueAllocationDuration= 86400*7
+TftpPath /usr/groups/netboot/
+
TftpPxeGroup osstest
-PxeDiBase osstest/debian-installer
-PxeDiVersion 2012-01-30-squeeze
+TftpDiVersion 2012-01-30-squeeze
# We use the IP address because Citrix can't manage reliable nameservice
#DebianMirrorHost debian.uk.xensource.com
-DnsDomain cam.xci-test.com
+DnsDomain uk.xensource.com
NetNameservers 10.80.248.2 10.80.16.28 10.80.16.67
-TestHost bedbug
-HostProp_bedbug_Ether 00:13:72:14:c0:51
+TestHost calder
+#HostProp_bedbug_Ether 00:13:72:14:c0:51
-HostProp_DhcpWatchMethod leases dhcp3 woking.cam.xci-test.com:5556
-#HostProp_DhcpWatchMethod leases dhcp3 dhcp.uk.xensource.com:5556
+#HostProp_DhcpWatchMethod leases dhcp3 woking.cam.xci-test.com:5556
+HostProp_DhcpWatchMethod leases dhcp3 dhcp.uk.xensource.com:5556
+
+TftpPath /usr/groups/netboot/
DebianMirrorHost debian.uk.xensource.com
#---------- ensuring we can update pxe files and have d-i ----------
-tftp=`getconfig Tftp`
+tftp=`getconfig TftpPath`
if ! test -d "$tftp"; then
echo >&2 \
-'Warning, Tftp variable pointing to tftp server needed to do host installs &c'
+'Warning, TftpPath variable would be needed for host installs &c'
else
- dibase=`getconfig PxeDiBase`
- diver=`getconfig PxeDiVersion`
+ tftptmp=`getconfig TftpTmpDir`
+ ensure_dir "$tftp$tftptmp"
+
+ dibase=`getconfig TftpDiBase`
+ diver=`getconfig TftpDiVersion`
suite=`getconfig DebianSuite`
firmware=`getconfig DebianNonfreeFirmware`
sub setup_pxeboot_firstboot($) {
my ($ps_url) = @_;
- my $d_i= $c{PxeDiBase}.'/'.$r{arch}.'/'.$c{PxeDiVersion};
+ my $d_i= $c{TftpDiBase}.'/'.$r{arch}.'/'.$c{TftpDiVersion};
my @installcmdline= qw(vga=normal);
push @installcmdline, di_installcmdline_core($ho, $ps_url, %xopts);
my $src_initrd= "$d_i/initrd.gz";
- my @initrds= "$c{Tftp}/$src_initrd";
+ my @initrds= "$c{TftpPath}/$src_initrd";
foreach my $fp (keys %{ $ho->{Flags} }) {
$fp =~ s/^need-firmware-deb-// or next;
- my $cpio= "$c{Tftp}/$d_i/$fp.cpio.gz";
+ my $cpio= "$c{TftpPath}/$d_i/$fp.cpio.gz";
if (stat $cpio) {
logm("using firmware from: $cpio");
push @initrds, $cpio;
my $wantphysif= get_host_property($ho,'interface force','auto');
if ($wantphysif ne 'auto') {
+ die "need Ether for $ho->{Name} ($wantphysif)"
+ unless defined $ho->{Ether};
system_checked(qw(mkdir -p --), "$initrd_overlay.d/etc/udev/rules.d");
file_simple_write_contents
("$initrd_overlay.d/etc/udev/rules.d/70-persistent-net.rules",
push @initrds, "$initrd_overlay.cpio.gz";
logm("using initrds: @initrds");
- my $initrd= host_pxedir($ho)."/initrd.gz";
- system_checked("cat -- @initrds >$c{Tftp}/$initrd");
+ my $initrd= "$c{TftpTmpDir}$ho->{Name}--initrd.gz";
+ system_checked("cat -- @initrds >$c{TftpPath}$initrd");
- push @installcmdline, ("initrd=$initrd",
+ push @installcmdline, ("initrd=/$initrd",
"domain=$c{TestHostDomain}",
);
push @installcmdline,
label overwrite
menu label ^Overwrite
menu default
- kernel $d_i/linux
+ kernel /$d_i/linux
append $installcmdline
default overwrite
END