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

9
10
my $UTAHURL       = "http://www.emulab.net/downloads";
my $DESCRIPTORS   = "$TOP_SRCDIR/install/descriptors-v3.xml";
Leigh B Stoller's avatar
Leigh B Stoller committed
11
my $GENDEV        = "$TOP_SRCDIR/install/descriptors-gendev.xml";
12
my @STDIMAGES     = ("FBSD82-STD", "FEDORA15-STD");
13
my @MBRS          = ("emulab-mbr.dd", "emulab-mbr2.dd", "emulab-mbr3.dd");
14
my $STDIMAGESURL  = "$UTAHURL/images-STD";
15
16
17
18
19
20
21
22
23

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

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

24
    # Others for the rack.
25
    if ($PROTOGENI_GENIRACK) {
Leigh B Stoller's avatar
Leigh B Stoller committed
26
	push(@STDIMAGES, "UBUNTU12-64-STD");
27
28
	push(@STDIMAGES, "UBUNTU11-64-STD");
	push(@STDIMAGES, "FBSD91-STD");
29
    }
30
31
32
33
34
35
36
37
38
39
40
41
    #
    # XXX don't want to risk breaking GENIRACK, so only do this otherwise.
    #
    # XXX we should really download: FBSD83-64-STD, FEDORA15-64-STD,
    # UBUNTU10-STD-FW, and the Linux MFSes that are also part of the
    # default descriptors, but downloading images takes a long time
    # so we keep the number of images to a minimum.
    #
    else {
	@STDIMAGES = ("FBSD83-STD", "FEDORA15-STD");
	$DESCRIPTORS = "$TOP_SRCDIR/install/descriptors-v4.xml";
    }
42

43
    Phase "IDs", "Setting up Images and OSs", sub {
44
	if ($PROTOGENI_GENIRACK) {
45
46
	    require NodeType;
	    
47
48
49
50
51
52
53
	    #
	    # 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";
54
	    my $NODETYPEXML  = "$TOP_SRCDIR/install/genirack/nodetype.xml";
55
56
57
58
	    
	    Phase "nodetype", "Creating Protogeni nodetype", sub {
		my $nodetype = NodeType->Lookup($NODETYPE);
		PhaseSkip("already created")
Leigh B Stoller's avatar
Leigh B Stoller committed
59
		    if (defined($nodetype));
60
		ExecQuietFatal("$SUDO -u $PROTOUSER ".
61
			       "         $WAP $CREATETYPE $NODETYPEXML");
62
63
64
	    };
	}
	
65
	#
66
67
	# Load up the initial descriptors. 
	# Load up the images from boss.
68
	#
69
	Phase "descriptors", "Loading the Image and OS IDs", sub {
70
71
	    ExecQuietFatal("cd $TOP_OBJDIR/install; ".
			   "   $SUDO -u $PROTOUSER $WAP ".
72
			   "   perl load-descriptors -a $DESCRIPTORS");
73
	};
74
	Phase "gendev", "Loading additional OS IDs", sub {
Leigh B Stoller's avatar
Leigh B Stoller committed
75
76
77
78
	    ExecQuietFatal("cd $TOP_OBJDIR/install; ".
			   "   $SUDO -u $PROTOUSER $WAP ".
			   "   perl load-descriptors $GENDEV");
	};
79
80
81
82
83
84
85
86
	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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
	    
	    $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");
	    };
101
102
103
104
105
106
107
108
109
110

	    #
	    # XXX the metadata file may not contain any or all of the newer
	    # DB state. So we update the metadata using imagevalidate.
	    #
	    Phase "${imagename}_validate", "Validating DB info for image.", sub {
		my $iname = TBOPSPID() . "/" . $imagename;
		ExecQuietFatal("$SUDO -u $PROTOUSER ".
			       "$PREFIX/sbin/imagevalidate -uq $iname");
	    };
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
	}
	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'");
	};
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146

	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");
	    };
	}
	
147
	PhaseSucceed("done")
148
149
150
151
152
153
154
    };
    return 0;
}

# Local Variables:
# mode:perl
# End: