openvz 3.09 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#
# Install openvz support.
#
use strict;
use libinstall;
use installvars;
use NodeType;
use OSinfo;
use Image;
use EmulabConstants;

my $UTAHURL       = "http://www.emulab.net/downloads";
my $DESCRIPTORS   = "$TOP_SRCDIR/install/descriptors-sh.xml";
my $OPENVZIMAGE   = "FEDORA15-OPENVZ-STD";
my $STDIMAGESURL  = "$UTAHURL/images-STD";

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

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

    Phase "openvz", "Adding OPENVZ Support", sub {
	#
	# Load up the initial descriptors. 
	# Load up the images from boss.
	#
	Phase "descriptors", "Loading the Image and OS IDS", sub {
	    ExecQuietFatal("cd $TOP_OBJDIR/install; ".
			   "   $SUDO -u $PROTOUSER $WAP ".
			   "   perl load-descriptors -a $DESCRIPTORS");
	};
	foreach my $imagename ($OPENVZIMAGE) {
	    my $localfile = "$PREFIX/images/${imagename}.ndz";
	    my $url       = "$STDIMAGESURL/${imagename}.ndz";
	    
	    Phase "$imagename", "Fetching $imagename. Patience!", sub {
		DoneIfExists($localfile);
		FetchFileFatal($url, $localfile);
	    };
43
44
45
46
47
48
49
50
51
52
53
54
	    $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");
	    };
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
	}

	#
	# Now that OPENVZ-STD is loaded, need to find the nodetype for
	# PCVM and link them via the default_osid. We could avoid this by
	# creating an xml file for the pcvm nodetype and loading it that
	# way instead of as sql in database-fill-supplement.
	#
	my $pcvm = NodeType->Lookup("pcvm");
	PhaseFail("Could not look up PCVM node type")
	    if (!defined($pcvm));

	my $osinfo = OSinfo->LookupByName("OPENVZ-STD");
	PhaseFail("Could not look up OPENVZ-STD osid")
	    if (!defined($osinfo));

	my $nextosinfo = OSinfo->LookupByName($OPENVZIMAGE);
	PhaseFail("Could not look up $OPENVZIMAGE osid")
	    if (!defined($nextosinfo));

75
76
77
78
	my $diskload_osinfo = OSinfo->LookupByName("FRISBEE-MFS-PCVM");
	PhaseFail("Could not look up FRISBEE-MFS-PCVM osid")
	    if (!defined($diskload_osinfo));

79
80
81
	Phase "pcvm", "Updating the PCVM node type", sub {
	    $pcvm->SetAttribute("default_osid", $osinfo->osid()) == 0
		or PhaseFail("Could not update the pcvm node type");
82
83
84
	    $pcvm->SetAttribute("diskloadmfs_osid",
				$diskload_osinfo->osid()) == 0
		or PhaseFail("Could not update the pcvm node type");
85
86
87
88
	};
	Phase "openvz", "Updating the OPENVZ-STD osid", sub {
	    $osinfo->SetNextOS($nextosinfo) == 0
		or PhaseFail("Could not set the nextosid for OPENVZ-STD");
89
90
	    $osinfo->SetParentOS($nextosinfo) == 0
		or PhaseFail("Could not set the parent osid for OPENVZ-STD");
Leigh B Stoller's avatar
Leigh B Stoller committed
91
92
	    $osinfo->SetRunsOnParent($nextosinfo) == 0
		or PhaseFail("Could not add os_submap entry for OPENVZ-STD");
93
94
95
96
97
98
99
100
101
102
	};
	
	PhaseSucceed("done")
    };
    return 0;
}

# Local Variables:
# mode:perl
# End: