Commit 3b352486 authored by Leigh Stoller's avatar Leigh Stoller

Do not default XEN guest images to "packages". Lets make the default

a single slice image, since we can now pull the kernel (ramdisk) out
from the guest filesystem (using pygrub for linux, or just mounting
BSD filesystems). This is a lot faster and easier to deal with. I
added an option to the newimage page so that people can set this, but
in general we need a better way to guess that we need it. Always set
for EC2 images.
parent 12140615
#!/usr/bin/perl -w
#
# Copyright (c) 2000-2012 University of Utah and the Flux Group.
# Copyright (c) 2000-2013 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -35,15 +35,17 @@ my $TAR = "/bin/tar";
#
# Client-side to create a disk image. Caller must have sudo permission!
# This is the OpenVZ specific version.
# This is the XEN specific version.
#
sub usage()
{
print STDOUT "Usage: create-image [-S image-server] [-F imageid] ".
print STDOUT "Usage: create-image [-p] [-r] [-S image-server] [-F imageid] ".
"<vnodeid> <filename>\n";
exit(-1);
}
my $optlist = "F:S:";
my $optlist = "F:S:pr";
my $aspack = 0;
my $norestart = 0;
#
# Turn off line buffering on output
......@@ -52,6 +54,7 @@ $| = 1;
# Need this for predicates.
use libsetup;
use libvnode_xen;
#
# No configure vars.
......@@ -61,6 +64,7 @@ my $zipper = "/usr/local/bin/imagezip";
my $uploader = "/usr/local/etc/emulab/frisupload";
my $vnodeid;
my $filename;
my $cmd;
my $error = 0;
for my $path (qw#/usr/local/bin /usr/bin#) {
......@@ -86,6 +90,9 @@ if (@ARGV != 2) {
usage();
}
if (defined($options{"p"})) {
$aspack = 1;
}
if (defined($options{"S"})) {
$iserver = $options{"S"};
if ($iserver =~ /^([-\w\.]+)$/) {
......@@ -161,27 +168,50 @@ if ($status ne "") {
}
}
#
# Use capture.pl; there are potentially multiple disks, the kernel,
# and a config file. All of this goes into a directory which we then
# tar up and upload.
#
system("$sudo $CAPTURE $vnodeid");
if ($?) {
print STDERR "Failed to capture the container!\n";
$error = 1;
goto cleanup;
if ($aspack) {
#
# Use capture.pl; there are potentially multiple disks, the kernel,
# and a config file. All of this goes into a directory which we then
# tar up and upload.
#
system("$sudo $CAPTURE $vnodeid");
if ($?) {
print STDERR "Failed to capture the container!\n";
$error = 1;
goto cleanup;
}
if (! -e "$EXTRAFS/$vnodeid" || ! -e "$EXTRAFS/$vnodeid/xm.conf") {
print STDERR "$EXTRAFS/$vnodeid appears to be missing or incomplete\n";
$error = 1;
goto cleanup;
}
$cmd = "$TAR zcf - -C $EXTRAFS/$vnodeid . | $zipper -f - $filename";
}
if (! -e "$EXTRAFS/$vnodeid" || ! -e "$EXTRAFS/$vnodeid/xm.conf") {
print STDERR "$EXTRAFS/$vnodeid appears to be missing or incomplete\n";
$error = 1;
goto cleanup;
else {
my $device = libvnode_xen::lvmVolumePath($vnodeid);
my $opt = "";
#
# Hacky way to determine what kind of filesystem, since there
# is nothing in the MBR to tell us.
#
if (system("$zipper -i -b $device >/dev/null 2>&1") == 0) {
$opt = "-b";
}
elsif (system("$zipper -i -l $device >/dev/null 2>&1") == 0) {
$opt = "-l";
}
else {
print STDERR "Cannot determine imagezip FS type of $device\n";
$error = 1;
goto cleanup;
}
$cmd = "$zipper $opt $device $filename";
}
#
# If imageid is defined, we use the frisbee uploader.
#
my $cmd = "$TAR zcf - -C $EXTRAFS/$vnodeid . | $zipper -f - $filename";
if (defined($imageid)) {
$cmd .= " | $uploader -S $iserver -F $imageid";
if (SHAREDHOST()) {
......@@ -203,14 +233,17 @@ if (system("$sudo $cmd")) {
cleanup:
# Clean up the directory.
system("$sudo /bin/rm -rf $EXTRAFS/$vnodeid");
system("$sudo /bin/rm -rf $EXTRAFS/$vnodeid")
if ($aspack);
#
# Reboot the vnode.
#
system("$sudo $VNODESETUP -jbVt $vnodeid");
if ($?) {
die("Could not restart container!\n");
if (! $norestart) {
system("$sudo $VNODESETUP -jbVt $vnodeid");
if ($?) {
die("Could not restart container!\n");
}
}
exit($error);
......@@ -272,7 +272,7 @@ if ($isvirtnode) {
$parentosinfo->pid() . "," . $parentosinfo->osname();
# And this is just plain bogus.
$xmlfields{"mbr_version"} = 99;
#$xmlfields{"mbr_version"} = 99;
}
#
......
......@@ -501,6 +501,12 @@ if ($isec2node) {
$command = "$EC2SNAP ";
}
elsif ($isvirtnode) {
#
# XXX Need to add XEN package flag to descriptor.
#
if ($image->mbr_version() == 99) {
$command .= " -p";
}
$command .= " $node_id";
}
else {
......
......@@ -738,6 +738,14 @@ class Image
<td class=left>$mbr_version</td>
</tr>\n";
# Until I change the schema.
if ($mbr_version == 99) {
echo "<tr>
<td>XEN Package: </td>
<td class=left>Yes</td>
</tr>\n";
}
if ($hash) {
echo "<tr>
<td>SHA1 Hash: </td>
......
......@@ -769,6 +769,22 @@ function SPITFORM($formfields, $errors)
value=\"" . $formfields["def_parentosid"] . "\">
<td class=left><a href='$url'>$osname</a></td>
</tr>\n";
echo "<tr>
<td>Package:</td>
<td class=left>
<input type=checkbox
name=\"formfields[package]\"
value=Yep";
if (isset($formfields["package"]) &&
strcmp($formfields["package"], "Yep") == 0)
echo " checked";
echo " > Yes (XEN only, and only if you know what this means!)
</td>
</tr>\n";
}
echo "<tr>
......@@ -935,9 +951,6 @@ if (!isset($submit)) {
# mtype_all is a "fake" variable which makes all
# mtypes checked in the virgin form.
$defaults["mtype_all"] = "Yep";
# Bogus. This tells the client that the ndz file is a package.
$defaults["mbr_version"] = "99";
}
elseif (isset($nodetype) && $nodetype == "mote") {
# Defaults for mote-type nodes
......@@ -979,6 +992,7 @@ if (!isset($submit)) {
$defaults["reboot_waittime"] = "240";
$defaults["os_feature_ping"] = "checked";
$defaults["os_feature_ssh"] = "checked";
$defaults["package"] = "No";
if ($ec2) {
#
......@@ -986,6 +1000,8 @@ if (!isset($submit)) {
#
$def_parentosinfo =
OSinfo::LookupByName("emulab-ops", "XEN41-64-STD");
$defaults["package"] = "Yep";
}
else {
#
......@@ -1228,7 +1244,12 @@ if (isset($formfields["max_concurrent"]) &&
$args["max_concurrent"] = $formfields["max_concurrent"];
}
if (isset($formfields["mbr_version"]) &&
if ($ec2 ||
(isset($formfields["package"]) && $formfields["package"] == "Yep")) {
# Bogus. This tells the client that the ndz file is a package.
$args["mbr_version"] = "99";
}
elseif (isset($formfields["mbr_version"]) &&
$formfields["mbr_version"] != "") {
$args["mbr_version"] = $formfields["mbr_version"];
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment