Commit 3b352486 authored by Leigh B Stoller's avatar Leigh B 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 #!/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 # {{{EMULAB-LICENSE
# #
...@@ -35,15 +35,17 @@ my $TAR = "/bin/tar"; ...@@ -35,15 +35,17 @@ my $TAR = "/bin/tar";
# #
# Client-side to create a disk image. Caller must have sudo permission! # 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() 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"; "<vnodeid> <filename>\n";
exit(-1); exit(-1);
} }
my $optlist = "F:S:"; my $optlist = "F:S:pr";
my $aspack = 0;
my $norestart = 0;
# #
# Turn off line buffering on output # Turn off line buffering on output
...@@ -52,6 +54,7 @@ $| = 1; ...@@ -52,6 +54,7 @@ $| = 1;
# Need this for predicates. # Need this for predicates.
use libsetup; use libsetup;
use libvnode_xen;
# #
# No configure vars. # No configure vars.
...@@ -61,6 +64,7 @@ my $zipper = "/usr/local/bin/imagezip"; ...@@ -61,6 +64,7 @@ my $zipper = "/usr/local/bin/imagezip";
my $uploader = "/usr/local/etc/emulab/frisupload"; my $uploader = "/usr/local/etc/emulab/frisupload";
my $vnodeid; my $vnodeid;
my $filename; my $filename;
my $cmd;
my $error = 0; my $error = 0;
for my $path (qw#/usr/local/bin /usr/bin#) { for my $path (qw#/usr/local/bin /usr/bin#) {
...@@ -86,6 +90,9 @@ if (@ARGV != 2) { ...@@ -86,6 +90,9 @@ if (@ARGV != 2) {
usage(); usage();
} }
if (defined($options{"p"})) {
$aspack = 1;
}
if (defined($options{"S"})) { if (defined($options{"S"})) {
$iserver = $options{"S"}; $iserver = $options{"S"};
if ($iserver =~ /^([-\w\.]+)$/) { if ($iserver =~ /^([-\w\.]+)$/) {
...@@ -161,27 +168,50 @@ if ($status ne "") { ...@@ -161,27 +168,50 @@ if ($status ne "") {
} }
} }
# 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 # Use capture.pl; there are potentially multiple disks, the kernel,
# tar up and upload. # and a config file. All of this goes into a directory which we then
# # tar up and upload.
system("$sudo $CAPTURE $vnodeid"); #
if ($?) { system("$sudo $CAPTURE $vnodeid");
print STDERR "Failed to capture the container!\n"; if ($?) {
$error = 1; print STDERR "Failed to capture the container!\n";
goto cleanup; $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") { else {
print STDERR "$EXTRAFS/$vnodeid appears to be missing or incomplete\n"; my $device = libvnode_xen::lvmVolumePath($vnodeid);
$error = 1; my $opt = "";
goto cleanup;
#
# 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. # If imageid is defined, we use the frisbee uploader.
# #
my $cmd = "$TAR zcf - -C $EXTRAFS/$vnodeid . | $zipper -f - $filename";
if (defined($imageid)) { if (defined($imageid)) {
$cmd .= " | $uploader -S $iserver -F $imageid"; $cmd .= " | $uploader -S $iserver -F $imageid";
if (SHAREDHOST()) { if (SHAREDHOST()) {
...@@ -203,14 +233,17 @@ if (system("$sudo $cmd")) { ...@@ -203,14 +233,17 @@ if (system("$sudo $cmd")) {
cleanup: cleanup:
# Clean up the directory. # Clean up the directory.
system("$sudo /bin/rm -rf $EXTRAFS/$vnodeid"); system("$sudo /bin/rm -rf $EXTRAFS/$vnodeid")
if ($aspack);
# #
# Reboot the vnode. # Reboot the vnode.
# #
system("$sudo $VNODESETUP -jbVt $vnodeid"); if (! $norestart) {
if ($?) { system("$sudo $VNODESETUP -jbVt $vnodeid");
die("Could not restart container!\n"); if ($?) {
die("Could not restart container!\n");
}
} }
exit($error); exit($error);
...@@ -272,7 +272,7 @@ if ($isvirtnode) { ...@@ -272,7 +272,7 @@ if ($isvirtnode) {
$parentosinfo->pid() . "," . $parentosinfo->osname(); $parentosinfo->pid() . "," . $parentosinfo->osname();
# And this is just plain bogus. # And this is just plain bogus.
$xmlfields{"mbr_version"} = 99; #$xmlfields{"mbr_version"} = 99;
} }
# #
......
...@@ -501,6 +501,12 @@ if ($isec2node) { ...@@ -501,6 +501,12 @@ if ($isec2node) {
$command = "$EC2SNAP "; $command = "$EC2SNAP ";
} }
elsif ($isvirtnode) { elsif ($isvirtnode) {
#
# XXX Need to add XEN package flag to descriptor.
#
if ($image->mbr_version() == 99) {
$command .= " -p";
}
$command .= " $node_id"; $command .= " $node_id";
} }
else { else {
......
...@@ -738,6 +738,14 @@ class Image ...@@ -738,6 +738,14 @@ class Image
<td class=left>$mbr_version</td> <td class=left>$mbr_version</td>
</tr>\n"; </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) { if ($hash) {
echo "<tr> echo "<tr>
<td>SHA1 Hash: </td> <td>SHA1 Hash: </td>
......
...@@ -769,6 +769,22 @@ function SPITFORM($formfields, $errors) ...@@ -769,6 +769,22 @@ function SPITFORM($formfields, $errors)
value=\"" . $formfields["def_parentosid"] . "\"> value=\"" . $formfields["def_parentosid"] . "\">
<td class=left><a href='$url'>$osname</a></td> <td class=left><a href='$url'>$osname</a></td>
</tr>\n"; </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> echo "<tr>
...@@ -935,9 +951,6 @@ if (!isset($submit)) { ...@@ -935,9 +951,6 @@ if (!isset($submit)) {
# mtype_all is a "fake" variable which makes all # mtype_all is a "fake" variable which makes all
# mtypes checked in the virgin form. # mtypes checked in the virgin form.
$defaults["mtype_all"] = "Yep"; $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") { elseif (isset($nodetype) && $nodetype == "mote") {
# Defaults for mote-type nodes # Defaults for mote-type nodes
...@@ -979,6 +992,7 @@ if (!isset($submit)) { ...@@ -979,6 +992,7 @@ if (!isset($submit)) {
$defaults["reboot_waittime"] = "240"; $defaults["reboot_waittime"] = "240";
$defaults["os_feature_ping"] = "checked"; $defaults["os_feature_ping"] = "checked";
$defaults["os_feature_ssh"] = "checked"; $defaults["os_feature_ssh"] = "checked";
$defaults["package"] = "No";
if ($ec2) { if ($ec2) {
# #
...@@ -986,6 +1000,8 @@ if (!isset($submit)) { ...@@ -986,6 +1000,8 @@ if (!isset($submit)) {
# #
$def_parentosinfo = $def_parentosinfo =
OSinfo::LookupByName("emulab-ops", "XEN41-64-STD"); OSinfo::LookupByName("emulab-ops", "XEN41-64-STD");
$defaults["package"] = "Yep";
} }
else { else {
# #
...@@ -1228,7 +1244,12 @@ if (isset($formfields["max_concurrent"]) && ...@@ -1228,7 +1244,12 @@ if (isset($formfields["max_concurrent"]) &&
$args["max_concurrent"] = $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"] != "") { $formfields["mbr_version"] != "") {
$args["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