images 4.57 KB
Newer Older
1
2
3
4
5
6
#
# 
#
use strict;
use libinstall;
use installvars;
7
use EmulabConstants;
8
use OSImage;
9
use OSinfo;
10

11
my $UTAHURL       = "http://www.emulab.net/downloads";
12
my $DESCRIPTORS   = "$TOP_SRCDIR/install/descriptors-v4.xml";
Leigh B Stoller's avatar
Leigh B Stoller committed
13
my $GENDEV        = "$TOP_SRCDIR/install/descriptors-gendev.xml";
14
my @MBRS          = ("emulab-mbr.dd", "emulab-mbr2.dd", "emulab-mbr3.dd");
15
16

my $LINUXSTDIMAGE = "UBUNTU14-64-STD";
17
my $FBSDSTDIMAGE  = "FBSD103-64-STD";
18
my $DEFAULTIMAGE  = $LINUXSTDIMAGE;
19
20
21
22
23

#
# We now use image import.
#
my %STDIMAGES     = (
24
25
    "UBUNTU14-64-STD"  => "https://www.emulab.net/image_metadata.php?uuid=0a29c738-32b3-11e4-b30a-001143e453fe",
    "CENTOS7-64-STD"   => "https://www.emulab.net/image_metadata.php?uuid=6fa68fd6-9163-11e6-ac8c-90e2ba22fee4",
26
    "FBSD103-64-STD"   => "https://www.emulab.net/image_metadata.php?uuid=f3866e90-2464-11e6-bdf0-d1afad303f71",
Leigh B Stoller's avatar
Leigh B Stoller committed
27
    "XEN46-64-STD"     => "https://www.emulab.net/image_metadata.php?uuid=61799d52-4dff-11e6-ac8a-90e2ba22fee4",
28
29
);

30
my %NEWIMAGES     = (
31
    "UBUNTU16-64-STD"  => "https://www.emulab.net/image_metadata.php?uuid=7683ca8e-5e37-11e6-ac8a-90e2ba22fee4"
32
33
);

34
35
36
37
#
# Old style mappings, but probably still in use someplace.
#
my %STDMAPPINGS = (
38
39
    "RHL-STD"   => $LINUXSTDIMAGE,
    "FBSD-STD"  => $FBSDSTDIMAGE,
40
);
41
42
43
44
45
46
47
48
49

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

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

50
    Phase "IDs", "Setting up Images and OSs", sub {
51
	if ($PROTOGENI_GENIRACK) {
52
53
	    require NodeType;
	    
54
55
56
57
58
59
60
	    #
	    # 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";
61
	    my $NODETYPEXML  = "$TOP_SRCDIR/install/genirack/nodetype.xml";
62
63
64
65
	    
	    Phase "nodetype", "Creating Protogeni nodetype", sub {
		my $nodetype = NodeType->Lookup($NODETYPE);
		PhaseSkip("already created")
Leigh B Stoller's avatar
Leigh B Stoller committed
66
		    if (defined($nodetype));
67
		ExecQuietFatal("$SUDO -u $PROTOUSER ".
68
			       "         $WAP $CREATETYPE $NODETYPEXML");
69
70
71
	    };
	}
	
72
	#
73
74
	# Load up the initial descriptors. 
	# Load up the images from boss.
75
	#
76
	Phase "descriptors", "Loading the Image and OS IDs", sub {
77
78
	    ExecQuietFatal("cd $TOP_OBJDIR/install; ".
			   "   $SUDO -u $PROTOUSER $WAP ".
79
			   "   perl load-descriptors -a $DESCRIPTORS");
80
	};
81
	Phase "gendev", "Loading additional OS IDs", sub {
Leigh B Stoller's avatar
Leigh B Stoller committed
82
83
84
85
	    ExecQuietFatal("cd $TOP_OBJDIR/install; ".
			   "   $SUDO -u $PROTOUSER $WAP ".
			   "   perl load-descriptors $GENDEV");
	};
86
87
	foreach my $imagename (keys(%STDIMAGES)) {
	    my $url = $STDIMAGES{$imagename};
88
89
	    
	    Phase "$imagename", "Fetching $imagename. Patience!", sub {
90
		my $image = OSImage->Lookup(TBOPSPID(), $imagename);
91
92
		PhaseSkip("already fetched")
		    if (defined($image));
93
94

		ExecQuietFatal("$SUDO -u $PROTOUSER ".
95
			       "         $WAP $IMAGEIMPORT -g '$url'");
96
	    };
97
98
99
100
101
102
103
104
105
106
	}
	foreach my $mbr (@MBRS) {
	    my $localfile = "$PREFIX/images/$mbr";
	    my $url       = "$UTAHURL/$mbr";
	    
	    Phase "$mbr", "Fetching $mbr.", sub {
		DoneIfExists($localfile);
		FetchFileFatal($url, $localfile);
	    };
	}
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
	foreach my $osname (keys(%STDMAPPINGS)) {
	    my $nextosname = $STDMAPPINGS{$osname};

	    Phase "$osname", "Mapping $osname to $nextosname", sub {
		my $osinfo = OSinfo->LookupByName($osname);
		PhaseFail("Could not look up $osname osid")
		    if (!defined($osinfo));
		PhaseSkip("already set")
		    if (defined($osinfo->nextosid()));
	    
		my $nextosinfo = OSinfo->LookupByName($nextosname);
		PhaseFail("Could not look up $nextosname osid")
		    if (!defined($nextosinfo));
		$osinfo->SetNextOS($nextosinfo) == 0
		    or PhaseFail("Could not set the nextosid");
	    };
	}
	
125
126
	#
	# The sitevar is how the reload daemon knows what to reload nodes
127
	# with, by default.
128
129
130
	#
	Phase "sitevar", "Setting sitevar $DEFAULTIMAGESITEVAR", sub {
	    ExecQuietFatal("$PREFIX/sbin/setsitevar ".
131
			   "'$DEFAULTIMAGESITEVAR' '$DEFAULTIMAGE'");
132
	};
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148

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

# Local Variables:
# mode:perl
# End: