showimageid_list.php3 4.76 KB
Newer Older
1
<?php
Leigh B. Stoller's avatar
Leigh B. Stoller committed
2
#
3
# Copyright (c) 2000-2012 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 B. Stoller's avatar
Leigh B. Stoller committed
23
#
24
25
26
27
28
29
include("defs.php3");

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

#
35
# Admin users can see all ImageIDs, while normal users can only see
36
37
# ones in their projects or ones that are globally available.
#
38
$optargs = OptionalPageArguments("creator",  PAGEARG_USER);
39
40
$extraclause = "";

41
42
43
44
45
#
# Standard Testbed Header
#
PAGEHEADER("Image List");

46
47
48
#
# Allow for creator restriction
#
49
50
51
52
53
54
55
56
if (isset($creator)) {
    $creator_idx = $creator->uid_idx();
    
    if ($isadmin) {
	$extraclause = "where i.creator_idx='$creator_idx' ";
    }
    elseif ($creator->SameUser($this_user)) {
	$extraclause = "and i.creator_idx='$creator_idx' ";
57
58
    }
}
59

60
#
61
# Get the list.
62
63
#
if ($isadmin) {
64
65
    $query_result = DBQueryFatal("SELECT * FROM images as i ".
				 "$extraclause ".
66
				 "order by i.imagename");
67
68
}
else {
69
70
71
72
73
74
75
    #
    # User is allowed to view the list of all global images, and all images
    # in his project. Include images in the subgroups too, since its okay
    # for the all project members to see the descriptors. They need proper 
    # permission to use/modify the image/descriptor of course, but that is
    # checked in the pages that do that stuff. In other words, ignore the
    # shared flag in the descriptors.
76
77
78
    #
    $uid_idx = $this_user->uid_idx();
    
Leigh B. Stoller's avatar
Leigh B. Stoller committed
79
80
    $query_result =
	DBQueryFatal("select distinct i.* from images as i ".
81
82
83
84
85
86
87
88
89
		     "left join image_permissions as p1 on ".
		     "     p1.imageid=i.imageid and p1.permission_type='group' ".
		     "left join image_permissions as p2 on ".
		     "     p2.imageid=i.imageid and p2.permission_type='user' ".
		     "left join group_membership as g on ".
		     "     g.pid_idx=i.pid_idx or ".
		     "     g.gid_idx=p1.permission_idx ".
		     "where (g.uid_idx='$uid_idx' or i.global or".
		     "       p2.permission_idx='$uid_idx') ".
90
		     "$extraclause ".
91
		     "order by i.imagename");
92
93
}

94
95
96
SUBPAGESTART();
SUBMENUSTART("More Options");
WRITESUBMENUBUTTON("Create an Image Descriptor",
97
		   "newimageid_ez.php3");
98
99
if ($isadmin) {
    WRITESUBMENUBUTTON("Create an OS Descriptor",
100
		       "newosid.php3");
101
102
    WRITESUBMENUBUTTON("OS Descriptor list",
		       "showosid_list.php3");
103
}
104
SUBMENUEND();
105
106

echo "Listed below are the Images that you can load on your nodes with the
107
      <a href='$WIKIDOCURL/nscommands#OS'>
108
109
110
111
      <tt>tb-set-node-os</tt></a> directive. If the OS you have selected for
      a node is not loaded on that node when the experiment is swapped in,
      the Testbed system will automatically reload that node's disk with the
      appropriate image. You might notice that it takes a few minutes longer
112
      to start your experiment when selecting an OS that is not
113
114
115
      already resident. Please be patient.
      <br>
      More information on how to create your own Images is in the
116
117
      <a href='$WIKIDOCURL/Tutorial#CustomOS'>Custom OS</a> section of
      the <a href='$WIKIDOCURL/Tutorial'>Emulab Tutorial.</a>
118
119
      <br>\n";

120
121
SUBPAGEEND();

122
if (mysql_num_rows($query_result)) {
123
    echo "<table border=2 cellpadding=0 cellspacing=2 id='showimagelist'
124
           align='center'>\n";
125

126
127
    echo "<thead class='sort'>
           <tr>
128
129
130
              <th class='sorttable_alpha'>Image</th>
              <th class='sorttable_alpha'>PID</th>
              <th class='sorttable_alpha'>Description</th>
131
132
           </tr>
          </thead>\n";
133

134
    while ($row = mysql_fetch_array($query_result)) {
135
136
137
138
	$imageid    = $row["imageid"];
	$descrip    = $row["description"];
	$imagename  = $row["imagename"];
	$pid        = $row["pid"];
Leigh B. Stoller's avatar
Leigh B. Stoller committed
139
	$url        = CreateURL("showimageid", URLARG_IMAGEID, $imageid);
140

141
	echo "<tr>
142
                  <td><A href='$url'>$imagename</A></td>
143
144
145
146
147
                  <td>$pid</td>
                  <td>$descrip</td>\n";
        echo "</tr>\n";
    }
    echo "</table>\n";
148
}
149
150
151
echo "<script type='text/javascript' language='javascript'>
	sorttable.makeSortable(getObjbyName('showimagelist'));
      </script>\n";
152
153
154
155
156
157

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