showosid_list.php3 4.27 KB
Newer Older
1
<?php
Leigh B. Stoller's avatar
Leigh B. Stoller committed
2
#
3
# Copyright (c) 2000-2011 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 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
    if ($isadmin) 
53
	$extraclause = "where o.creator_idx='$creator_idx' ";
54
    else
55
	$extraclause = "and o.creator_idx='$creator_idx' ";
56 57
}

58 59 60 61
#
# Get the project list.
#
if ($isadmin) {
Leigh B. Stoller's avatar
Leigh B. Stoller committed
62
    $query_result =
63 64
	DBQueryFatal("SELECT * FROM os_info as o ".
		     "$extraclause ".
65
		     "order by o.osname");
66 67
}
else {
68
    $uid_idx = $this_user->uid_idx();
69

Leigh B. Stoller's avatar
Leigh B. Stoller committed
70 71
    $query_result =
	DBQueryFatal("select distinct o.* from os_info as o ".
72 73 74 75 76 77 78 79 80
		     "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 ".
		     "where (g.uid_idx='$uid_idx' or o.shared=1 or".
		     "       p2.permission_idx='$uid_idx') ".
81
		     "$extraclause ".
82
		     "order by o.osname");
83 84
}

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

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

111 112
SUBPAGEEND();

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

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