showosid_list.php3 2.77 KB
Newer Older
1 2 3 4 5 6
<?php
include("defs.php3");

#
# Standard Testbed Header
#
7
PAGEHEADER("OS Descriptor List");
8 9 10 11 12 13 14 15 16 17 18 19 20 21

#
#
# Only known and logged in users allowed.
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);

#
# Admin users can see all OSIDs, while normal users can only see
# ones in their projects or ones that are globally available.
#
$isadmin = ISADMIN($uid);

22 23 24 25 26 27 28 29 30 31 32 33 34
if (! isset($sortby))
    $sortby = "normal";

if (! strcmp($sortby, "normal") ||
    ! strcmp($sortby, "name"))
    $order = "o.osname";
elseif (! strcmp($sortby, "pid"))
    $order = "o.pid";
elseif (! strcmp($sortby, "desc"))
    $order = "o.description";
else 
    $order = "o.osname";

35 36 37 38
#
# Get the project list.
#
if ($isadmin) {
Leigh B. Stoller's avatar
Leigh B. Stoller committed
39
    $query_result =
40
	DBQueryFatal("SELECT * FROM os_info as o order by $order");
41 42
}
else {
Leigh B. Stoller's avatar
Leigh B. Stoller committed
43 44
    $query_result =
	DBQueryFatal("select distinct o.* from os_info as o ".
45 46
		     "left join group_membership as g on g.pid=o.pid ".
		     "where g.uid='$uid' or o.shared=1 ".
47
		     "order by $order");
48 49 50 51 52 53 54 55 56 57 58
}

if (mysql_num_rows($query_result) == 0) {
	if ($isadmin) {
	    USERERROR("There are no OSIDs!", 1);
	}
	else {
	    USERERROR("There are no OSIDs in any of your projects!", 1);
	}
}

59 60 61 62 63 64 65 66 67
SUBPAGESTART();
SUBMENUSTART("More Options");
WRITESUBMENUBUTTON("Create an Image Descriptor",
		   "newimageid_explain.php3");
WRITESUBMENUBUTTON("Create an OS Descriptor",
		   "newosid_form.php3");
WRITESUBMENUBUTTON("Back to Image Descriptor list",
		   "showimageid_list.php3");
SUBMENUEND();
68 69 70 71 72 73 74 75 76 77 78 79

echo "<p><br>
      Listed below are the OS Descriptors that you may use in your NS file
      with the <a href='tutorial/docwrapper.php3?docname=nscommands.html#OS'>
      <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
      to start start your experiment when selecting an OS that is not
      already resident. Please be patient.
      <br>\n";

80 81
SUBPAGEEND();

82 83
echo "<br>
      <table border=2 cellpadding=0 cellspacing=2 align='center'>\n";
84 85

echo "<tr>
86 87 88 89 90 91
          <td><a href='showosid_list.php3?&sortby=name'>
              Name</td>
          <td><a href='showosid_list.php3?&sortby=pid'>
              PID</td>
          <td><a href='showosid_list.php3?&sortby=desc'>
              Description</td>
92 93 94
      </tr>\n";

while ($row = mysql_fetch_array($query_result)) {
95
    $osname  = $row[osname];
96 97 98 99 100
    $osid    = $row[osid];
    $descrip = $row[description];
    $pid     = $row[pid];

    echo "<tr>
101
              <td><A href='showosinfo.php3?osid=$osid'>$osname</A></td>
102 103 104 105 106 107 108 109 110 111 112
              <td>$pid</td>
              <td>$descrip</td>\n";
    echo "</tr>\n";
}
echo "</table>\n";

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