showimageid.php3 3.68 KB
Newer Older
1
<?php
Leigh Stoller's avatar
Leigh Stoller committed
2
#
3
# Copyright (c) 2000-2014 University of Utah and the Flux Group.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
# 
# {{{EMULAB-LICENSE
# 
# This file is part of the Emulab network testbed software.
# 
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
# 
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
# License for more details.
# 
# You should have received a copy of the GNU Affero General Public License
# along with this file.  If not, see <http://www.gnu.org/licenses/>.
# 
# }}}
Leigh Stoller's avatar
Leigh Stoller committed
23
#
24
include("defs.php3");
25
include("imageid_defs.php");
26 27

#
28
# Only known and logged in users.
29
#
30 31 32
$this_user = CheckLoginOrDie();
$uid       = $this_user->uid();
$isadmin   = ISADMIN();
33
$showperms = 1;
34

35 36 37
# This will not return if its a sajax request.
include("showlogfile_sup.php3");

38
#
39 40
# Verify page arguments.
#
41 42
$reqargs = RequiredPageArguments("image",   PAGEARG_IMAGE);
$optargs = OptionalPageArguments("showlog", PAGEARG_BOOLEAN);
43

44 45 46 47 48
#
# Standard Testbed Header
#
PAGEHEADER("Image Descriptor");

49 50
# Need these below.
$imageid = $image->imageid();
51
$version = $image->version();
52 53

#
Leigh Stoller's avatar
Leigh Stoller committed
54
# Verify permission.
55
#
56
if (!$image->AccessCheck($this_user, $TB_IMAGEID_READINFO)) {
Leigh Stoller's avatar
Leigh Stoller committed
57
    USERERROR("You do not have permission to access ImageID $imageid.", 1);
58 59
}

60 61 62 63 64 65 66 67 68 69
if (isset($showlog)) {
    $logfile = $image->GetLogfile();
    if ($logfile) {
	echo $image->PageHeader();
	STARTLOG($logfile);
	PAGEFOOTER();
	return;
    }
}

70 71
SUBPAGESTART();
SUBMENUSTART("More Options");
72

73
WRITESUBMENUBUTTON("Edit this Image Descriptor",
74
		   "editimageid.php3?imageid=$imageid&version=$version");
75 76 77 78
if ($image->GetLogfile()) {
    WRITESUBMENUBUTTON("View Log File",
	       "showimageid.php3?imageid=$imageid&version=$version&showlog=1");
}
79 80
if ($image->AccessCheck($this_user, $TB_IMAGEID_MODIFYINFO )) {
    WRITESUBMENUBUTTON("Snapshot Node Disk into Image",
81
		       "loadimage.php3?imageid=$imageid");
82
}
83
WRITESUBMENUBUTTON("Clone this Image Descriptor",
84
		   "newimageid_ez.php3?baseimage=$imageid");
85
WRITESUBMENUBUTTON("Delete this Image Descriptor",
86
		   "deleteimageid.php3?imageid=$imageid");
87 88
WRITESUBMENUBUTTON("Image Descriptor list",
		   "showimageid_list.php3");
89
if ($isadmin) {
90 91
    WRITESUBMENUBUTTON("Create a New Image Descriptor",
		       "newimageid_ez.php3");
92
    WRITESUBMENUBUTTON("Create a new OS Descriptor",
93
		       "newosid.php3");
94 95
    WRITESUBMENUBUTTON("OS Descriptor list",
		       "showosid_list.php3");
96
}
97 98
SUBMENUEND();

99 100 101
#
# Dump record.
# 
102
$image->Show($showperms);
103

104 105 106 107
echo "<br>\n";

#
# Show experiments using this image - we have to handle all four partitions.
108 109 110
# Also we do not put OSIDs directly into the virt_nodes table, so we have to
# get the pid and osname for the image, and use that to look into the 
# virt_nodes table.
111
#
112
function SHOWIT($osid, $vers) {
113 114
    global $this_user;
    
115
    if (! ($osinfo = OSinfo::Lookup($osid, $vers))) {
116
	TBERROR("Could not map osid to its object: $osid", 1);
117
    }
118 119 120
    echo "<h3 align='center'>Experiments using OS ";
    $osinfo->SpitLink();
    echo "</h3>\n";
121

122 123
    $osinfo->ShowExperiments($this_user);
}
124

125
if ($image->part1_osid()) {
126
    SHOWIT($image->part1_osid(), $image->part1_vers());
127 128
}
if ($image->part2_osid()) {
129
    SHOWIT($image->part2_osid(), $image->part2_vers());
130 131
}
if ($image->part3_osid()) {
132
    SHOWIT($image->part3_osid(), $image->part3_vers());
133 134
}
if ($image->part4_osid()) {
135
    SHOWIT($image->part4_osid(), $image->part4_vers());
136
}
137
SUBPAGEEND();
138 139 140 141 142 143

#
# Standard Testbed Footer
# 
PAGEFOOTER();
?>