images 3.69 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";
Leigh B Stoller's avatar
Leigh B Stoller committed
10
my $GENDEV        = "$TOP_SRCDIR/install/descriptors-gendev.xml";
11
my @STDIMAGES     = ("FBSD82-STD", "FEDORA15-STD");
12
13
my @MBRS          = ("emulab-mbr.dd", "emulab-mbr2.dd");
my $STDIMAGESURL  = "$UTAHURL/images-STD";
14
15
16
17
18
19
20
21
22

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

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

23
24
    # Another good one for the rack.
    if ($PROTOGENI_GENIRACK) {
Leigh B Stoller's avatar
Leigh B Stoller committed
25
	push(@STDIMAGES, "UBUNTU12-64-STD");
26
27
    }

28
    Phase "IDs", "Setting up Images and OSs", sub {
29
	if ($PROTOGENI_GENIRACK) {
30
31
	    require NodeType;
	    
32
33
34
35
36
37
38
	    #
	    # 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";
39
	    my $NODETYPEXML  = "$TOP_SRCDIR/install/genirack/nodetype.xml";
40
41
42
43
	    
	    Phase "nodetype", "Creating Protogeni nodetype", sub {
		my $nodetype = NodeType->Lookup($NODETYPE);
		PhaseSkip("already created")
Leigh B Stoller's avatar
Leigh B Stoller committed
44
		    if (defined($nodetype));
45
		ExecQuietFatal("$SUDO -u $PROTOUSER ".
46
			       "         $WAP $CREATETYPE $NODETYPEXML");
47
48
49
	    };
	}
	
50
	#
51
52
	# Load up the initial descriptors. 
	# Load up the images from boss.
53
54
55
56
	#
	Phase "descriptors", "Loading the Image and OS IDS", sub {
	    ExecQuietFatal("cd $TOP_OBJDIR/install; ".
			   "   $SUDO -u $PROTOUSER $WAP ".
57
			   "   perl load-descriptors -a $DESCRIPTORS");
58
	};
Leigh B Stoller's avatar
Leigh B Stoller committed
59
60
61
62
63
	Phase "gendev", "Loading additional OS IDS", sub {
	    ExecQuietFatal("cd $TOP_OBJDIR/install; ".
			   "   $SUDO -u $PROTOUSER $WAP ".
			   "   perl load-descriptors $GENDEV");
	};
64
65
66
67
68
69
70
71
	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);
	    };
Leigh B Stoller's avatar
Leigh B Stoller committed
72
73
74
75
76
77
78
79
80
81
82
83
84
85
	    
	    $localfile = "$PREFIX/images/${imagename}.xml";
	    $url       = "$STDIMAGESURL/${imagename}.xml";
	    
	    Phase "${imagename}_xml", "Fetching $imagename metadata", sub {
		DoneIfExists($localfile);
		FetchFileFatal($url, $localfile);
	    };

	    Phase "${imagename}_load", "Loading the image descriptor.", sub {
		ExecQuietFatal("cd $TOP_OBJDIR/install; ".
			       "   $SUDO -u $PROTOUSER $WAP ".
			       "   perl load-descriptors -a $localfile");
	    };
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
	}
	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'");
	};
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121

	if ($PROTOGENI_GENIRACK) {
	    #
	    # Load up second half of the nodetype, which defines the osids
	    # and images it needs, which has to be done after the above.
	    #
	    my $NODETYPE     = "dl360";
	    my $CREATETYPE   = "$PREFIX/bin/editnodetype";
	    my $NODETYPEXML  = "$TOP_SRCDIR/install/genirack/nodetypeB.xml";
	    
	    Phase "nodetype", "Creating Protogeni nodetype", sub {
		ExecQuietFatal("$SUDO -u $PROTOUSER ".
			       "         $WAP $CREATETYPE $NODETYPEXML");
	    };
	}
	
122
	PhaseSucceed("done")
123
124
125
126
127
128
129
    };
    return 0;
}

# Local Variables:
# mode:perl
# End: