showosid_list.php3 4.42 KB
Newer Older
1
<?php
Leigh Stoller's avatar
Leigh Stoller committed
2
#
3
# Copyright (c) 2000-2017 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 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 36 37

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

40 41 42 43 44
#
# Standard Testbed Header
#
PAGEHEADER("OS Descriptor List");

45 46 47 48
#
# Allow for creator restriction
#
$extraclause = "";
49 50 51
if (isset($creator)) {
    $creator_idx = $creator->uid_idx();

52
    $extraclause = "and v.creator_idx='$creator_idx' ";
53 54
}

55 56 57 58
#
# Get the project list.
#
if ($isadmin) {
Leigh Stoller's avatar
Leigh Stoller committed
59
    $query_result =
60
	DBQueryFatal("SELECT distinct v.*,o.osname FROM os_info as o ".
61 62 63
		     "left join os_info_versions as v on ".
		     "     v.osid=o.osid and v.vers=o.version ".
		     "where 1 $extraclause ".
64
		     "order by o.osname");
65 66
}
else {
67
    $uid_idx = $this_user->uid_idx();
68

Leigh Stoller's avatar
Leigh Stoller committed
69
    $query_result =
70
	DBQueryFatal("select distinct v.*,o.osname from os_info as o ".
71 72
		     "left join os_info_versions as v on ".
		     "     v.osid=o.osid and v.vers=o.version ".
73 74 75 76 77 78 79
		     "left join image_permissions as p1 on ".
		     "     p1.imageid=o.osid and p1.permission_type='group' ".
		     "left join image_permissions as p2 on ".
		     "     p2.imageid=o.osid and p2.permission_type='user' ".
		     "left join group_membership as g on ".
		     "     g.pid_idx=o.pid_idx or ".
		     "     g.gid_idx=p1.permission_idx ".
80
		     "where (g.uid_idx='$uid_idx' or v.shared=1 or".
81
		     "       p2.permission_idx='$uid_idx') ".
82
		     "$extraclause ".
83
		     "order by o.osname");
84 85
}

86 87
SUBPAGESTART();
SUBMENUSTART("More Options");
88
if ($isadmin) {
89 90
    WRITESUBMENUBUTTON("Create an Image Descriptor",
		       "newimageid_ez.php3");
91
    WRITESUBMENUBUTTON("Create an OS Descriptor",
92
		       "newosid.php3");
93
}
Leigh Stoller's avatar
Leigh Stoller committed
94
WRITESUBMENUBUTTON("Image Descriptor list",
95 96
		   "showimageid_list.php3");
SUBMENUEND();
97

98
echo "Listed below are the OS Descriptors that you may use in your NS file
99
      with the <a href='$WIKIDOCURL/nscommands#OS'>
100 101 102 103
      <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
Timothy Stack's avatar
Timothy Stack committed
104
      to start your experiment when selecting an OS that is not
105
      already resident. Please be patient.
106 107
      <br>
      More information on how to create your own Images is in the
108 109
      <a href='$WIKIDOCURL/Tutorial#CustomOS'>Custom OS</a> section of
      the <a href='$WIKIDOCURL/Tutorial'>Emulab Tutorial.</a>
110
      <br>\n";
111

112 113
SUBPAGEEND();

114 115
if (mysql_num_rows($query_result)) {
    echo "<br>
116 117
          <table border=2 cellpadding=0 cellspacing=2
                 align='center' id='showosidlist'>\n";
118
    
119 120 121 122 123 124 125
    echo "<thead class='sort'>
           <tr>
              <th>Name</th>
              <th>PID</th>
              <th>Description</th>
           </tr>
          </thead>\n";
126 127
    
    while ($row = mysql_fetch_array($query_result)) {
128 129 130 131
        $osname  = $row["osname"];
        $osid    = $row["osid"];
        $descrip = $row["description"];
        $pid     = $row["pid"];
Leigh Stoller's avatar
Leigh Stoller committed
132
	$url     = CreateURL("showosinfo", URLARG_OSID, $osid);
133 134
    
        echo "<tr>
135
                  <td><A href='$url'>$osname</A></td>
136 137 138 139 140
                  <td>$pid</td>
                  <td>$descrip</td>\n";
        echo "</tr>\n";
    }
    echo "</table>\n";
141
}
142 143 144
echo "<script type='text/javascript' language='javascript'>
	sorttable.makeSortable(getObjbyName('showosidlist'));
      </script>\n";
145 146 147 148 149 150

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