All new accounts created on Gitlab now require administrator approval. If you invite any collaborators, please let Flux staff know so they can approve the accounts.

images 5.29 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
    "UBUNTU18-64-STD"  => "https://www.emulab.net/image_metadata.php?uuid=24543775-7e30-11e8-b228-90e2ba22fee4",
32 33
    "UBUNTU16-64-STD"  => "https://www.emulab.net/image_metadata.php?uuid=7683ca8e-5e37-11e6-ac8a-90e2ba22fee4",
    "FBSD111-64-STD"   => "https://www.emulab.net/image_metadata.php?uuid=560f4743-795d-11e7-ac90-90e2ba22fee4"
34 35
);

36 37 38 39 40
if ($FBSD_MAJOR > 10) {
    $LINUXSTDIMAGE = "UBUNTU16-64-STD";
    $FBSDSTDIMAGE  = "FBSD111-64-STD";
}

41 42 43 44
#
# Old style mappings, but probably still in use someplace.
#
my %STDMAPPINGS = (
45 46
    "RHL-STD"   => $LINUXSTDIMAGE,
    "FBSD-STD"  => $FBSDSTDIMAGE,
47
);
48 49 50 51 52 53 54 55 56

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

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

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

		ExecQuietFatal("$SUDO -u $PROTOUSER ".
102
			       "         $WAP $IMAGEIMPORT -g '$url'");
103
	    };
104
	}
105 106 107 108 109 110 111 112 113 114 115 116 117 118
	if ($FBSD_MAJOR > 10) {
	    foreach my $imagename (keys(%NEWIMAGES)) {
		my $url = $NEWIMAGES{$imagename};
		
		Phase "$imagename", "Fetching $imagename. Patience!", sub {
		    my $image = OSImage->Lookup(TBOPSPID(), $imagename);
		    PhaseSkip("already fetched")
			if (defined($image));

		    ExecQuietFatal("$SUDO -u $PROTOUSER ".
				   "         $WAP $IMAGEIMPORT -g '$url'");
		};
	    }
	}
119 120 121 122 123 124 125 126 127
	foreach my $mbr (@MBRS) {
	    my $localfile = "$PREFIX/images/$mbr";
	    my $url       = "$UTAHURL/$mbr";
	    
	    Phase "$mbr", "Fetching $mbr.", sub {
		DoneIfExists($localfile);
		FetchFileFatal($url, $localfile);
	    };
	}
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
	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");
	    };
	}
	
146 147
	#
	# The sitevar is how the reload daemon knows what to reload nodes
148
	# with, by default.
149 150 151
	#
	Phase "sitevar", "Setting sitevar $DEFAULTIMAGESITEVAR", sub {
	    ExecQuietFatal("$PREFIX/sbin/setsitevar ".
152
			   "'$DEFAULTIMAGESITEVAR' '$DEFAULTIMAGE'");
153
	};
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169

	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");
	    };
	}
	
170
	PhaseSucceed("done")
171 172 173 174 175 176 177
    };
    return 0;
}

# Local Variables:
# mode:perl
# End: