Commit 7f0b35a0 authored by Leigh Stoller's avatar Leigh Stoller

Changes that hopefully make it easier to toggle XEN capable images.

parent cabd612d
......@@ -536,7 +536,7 @@ class Image
$uuid = $this->uuid();
$mbr_version = $this->mbr_version();
$hash = $this->hash();
#
# An imported image has a metadata_url, and at the moment I
# do want to worry about exporting an imported image.
......@@ -746,6 +746,31 @@ class Image
<td class=left>Yes</td>
</tr>\n";
}
if ($this->ezid()) {
$doesxen = 0;
$osinfo = OSinfo::Lookup($imageid);
if ($osinfo && $osinfo->def_parentosid()) {
$parentosinfo = OSinfo::Lookup($osinfo->def_parentosid());
if ($parentosinfo &&
$parentosinfo->FeatureSupported("xen-host")) {
$doesxen = 1;
}
}
$xenval = ($doesxen ? "Yes" : "No");
$xenflip = ($doesxen ? 0 : 1);
echo "<tr>
<td>XEN Capable?:</td>
<td class=left>
$xenval (<a href=toggle.php?imageid=$imageid".
"&type=imagedoesxen&value=$xenflip>Toggle</a>
if you know this image can run
as a XEN guest. More info
<a target=_blank
href='https://wiki.emulab.net/wiki/Emulab/wiki/xen'>here</a>)
</td>
</tr>\n";
}
if ($hash) {
echo "<tr>
......@@ -858,4 +883,33 @@ class Image
return Logfile::Lookup($this->logfileid());
return null;
}
function DoesXen($does) {
$imageid = $this->imageid();
if ($does) {
$parentosinfo = OSinfo::LookupByName("emulab-ops",
"XEN41-64-STD");
if (!$parentosinfo) {
return -1;
}
$parentosid = $parentosinfo->osid();
DBQueryFatal("update os_info set def_parentosid='$parentosid' ".
"where osid='$imageid'");
DBQueryFatal("replace into os_submap set ".
" osid='$imageid', parent_osid='$parentosid'");
DBQueryFatal("replace into osidtoimageid set ".
" osid='$imageid', type='pcvm', imageid='$imageid'");
}
else {
DBQueryFatal("delete from osidtoimageid ".
"where osid='$imageid' and type='pcvm'");
DBQueryFatal("delete from os_submap ".
"where osid='$imageid'");
DBQueryFatal("update os_info set def_parentosid=NULL ".
"where osid='$imageid'");
}
return 0;
}
}
This diff is collapsed.
<?php
#
# Copyright (c) 2000-2012 University of Utah and the Flux Group.
# Copyright (c) 2000-2013 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -59,6 +59,8 @@ WRITESUBMENUBUTTON("Edit this Image Descriptor",
"editimageid.php3?imageid=$fooid");
WRITESUBMENUBUTTON("Snapshot Node Disk into Image",
"loadimage.php3?imageid=$fooid");
WRITESUBMENUBUTTON("Clone this Image Descriptor",
"newimageid_ez.php3?baseimage=$fooid");
WRITESUBMENUBUTTON("Delete this Image Descriptor",
"deleteimageid.php3?imageid=$fooid");
WRITESUBMENUBUTTON("Create a New Image Descriptor",
......
<?php
#
# Copyright (c) 2000-2012 University of Utah and the Flux Group.
# Copyright (c) 2000-2013 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -57,6 +57,8 @@ SUBMENUSTART("OSID Options");
#
if ($osinfo->ezid()) {
$fooid = rawurlencode($osinfo->osid());
WRITESUBMENUBUTTON("Clone this OS Descriptor",
"newimageid_ez.php3?baseimage=$fooid");
WRITESUBMENUBUTTON("Delete this OS Descriptor",
"deleteimageid.php3?imageid=$fooid");
}
......
<?php
#
# Copyright (c) 2000-2012 University of Utah and the Flux Group.
# Copyright (c) 2000-2013 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -42,7 +42,7 @@ $isadmin = ISADMIN();
# List of valid toggles
$toggles = array("adminon", "webfreeze", "cvsweb", "lockdown", "stud",
"cvsrepo_public", "workbench", "hiderun", "widearearoot",
"imageglobal", "skipvlans", "adminflag");
"imageglobal", "skipvlans", "adminflag", "imagedoesxen");
# list of valid values for each toggle
$values = array("adminon" => array(0,1),
......@@ -55,6 +55,7 @@ $values = array("adminon" => array(0,1),
"workbench" => array(0,1),
"widearearoot" => array(0,1),
"imageglobal" => array(0,1),
"imagedoesxen" => array(0,1),
"adminflag" => array(0,1),
"hiderun" => array(0,1));
......@@ -69,6 +70,7 @@ $optargs = array("adminon" => array(),
"workbench" => array("pid" => 1),
"widearearoot" => array("user" => 1),
"imageglobal" => array("imageid" => 1),
"imagedoesxen" => array("imageid" => 1),
"adminflag" => array("user" => 1),
"hiderun" => array("instance" => 1, "runidx" => 1));
......@@ -216,7 +218,7 @@ elseif ($type == "skipvlans") {
$zapurl = CreateURL("showexp", $experiment);
$experiment->SetSkipVlans($value);
}
elseif ($type == "imageglobal") {
elseif ($type == "imageglobal" || $type == "imagedoesxen") {
include("imageid_defs.php");
# Must validate since we allow non-admins to do this.
......@@ -231,7 +233,12 @@ elseif ($type == "imageglobal") {
USERERROR("You do not have permission to toggle $type!", 1);
}
$zapurl = CreateURL("showimageid", $image);
$image->SetGlobal($value);
if ($type == "imagedoesxen") {
$image->DoesXen($value);
}
else {
$image->SetGlobal($value);
}
}
elseif ($type == "cvsrepo_public") {
# Must validate the pid since we allow non-admins to do this.
......
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