images 2.38 KB
Newer Older
1 2 3 4 5 6 7
#
# 
#
use strict;
use libinstall;
use installvars;

8 9
my $UTAHURL       = "http://www.emulab.net/downloads";
my $DESCRIPTORS   = "$TOP_SRCDIR/install/descriptors-v3.xml";
10
my @STDIMAGES     = ("FBSD82-STD", "FEDORA15-STD");
11 12
my @MBRS          = ("emulab-mbr.dd", "emulab-mbr2.dd");
my $STDIMAGESURL  = "$UTAHURL/images-STD";
13 14 15 16 17 18 19 20 21

sub Install($$$)
{
    my ($server, $isupdate, $impotent) = @_;

    # Replace if this script does an update for ip/domain.
    return 0
	if ($isupdate);

22
    Phase "IDs", "Setting up Images and OSs", sub {
23
	if ($PROTOGENI_GENIRACK) {
24 25
	    require NodeType;
	    
26 27 28 29 30 31 32
	    #
	    # Load up the nodetype. It will be the same on every machine,
	    # and if we do it before loading the descriptors, then we
	    # do not have to go back and change the type mappings.
	    #
	    my $NODETYPE     = "dl360";
	    my $CREATETYPE   = "$PREFIX/bin/editnodetype";
33
	    my $NODETYPEXML  = "$TOP_SRCDIR/install/genirack-nodetype.xml";
34 35 36 37 38 39
	    
	    Phase "nodetype", "Creating Protogeni nodetype", sub {
		my $nodetype = NodeType->Lookup($NODETYPE);
		PhaseSkip("already created")
		    if (defined($NODETYPE));
		ExecQuietFatal("$SUDO -u $PROTOUSER ".
40
			       "         $WAP $CREATETYPE $NODETYPEXML");
41 42 43
	    };
	}
	
44
	#
45 46
	# Load up the initial descriptors. 
	# Load up the images from boss.
47 48 49 50
	#
	Phase "descriptors", "Loading the Image and OS IDS", sub {
	    ExecQuietFatal("cd $TOP_OBJDIR/install; ".
			   "   $SUDO -u $PROTOUSER $WAP ".
51
			   "   perl load-descriptors -a $DESCRIPTORS");
52
	};
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
	foreach my $imagename (@STDIMAGES) {
	    my $localfile = "$PREFIX/images/${imagename}.ndz";
	    my $url       = "$STDIMAGESURL/${imagename}.ndz";
	    
	    Phase "$imagename", "Fetching $imagename. Patience!", sub {
		DoneIfExists($localfile);
		FetchFileFatal($url, $localfile);
	    };
	}
	foreach my $mbr (@MBRS) {
	    my $localfile = "$PREFIX/images/$mbr";
	    my $url       = "$UTAHURL/$mbr";
	    
	    Phase "$mbr", "Fetching $mbr.", sub {
		DoneIfExists($localfile);
		FetchFileFatal($url, $localfile);
	    };
	}
	#
	# The sitevar is how the reload daemon knows what to reload nodes
	# with, by default. Now a comma separated list.
	#
	my $idlist = join(",", @STDIMAGES);
	
	Phase "sitevar", "Setting sitevar $DEFAULTIMAGESITEVAR", sub {
	    ExecQuietFatal("$PREFIX/sbin/setsitevar ".
			   "'$DEFAULTIMAGESITEVAR' '$idlist'");
	};
	PhaseSucceed("done")
82 83 84 85 86 87 88
    };
    return 0;
}

# Local Variables:
# mode:perl
# End: