Ejemplo n.º 1
0
 function SliverList($slice)
 {
     $result = array();
     $dblink = GetDBLink("sa");
     $slice_idx = $slice->idx();
     if (!$dblink) {
         return null;
     }
     $query_result = DBQueryFatal("select idx from client_slivers " . "where slice_idx='{$slice_idx}'", $dblink);
     if (!($query_result && mysql_num_rows($query_result))) {
         return null;
     }
     while ($row = mysql_fetch_array($query_result)) {
         $idx = $row["idx"];
         if (!($sliver = ClientSliver::Lookup($idx))) {
             TBERROR("ClientSliver::SliverList: " . "Could not load client sliver {$idx}!", 1);
         }
         $result[] = $sliver;
     }
     return $result;
 }
Ejemplo n.º 2
0
 function Show($flags = 0)
 {
     $node_id = $this->node_id();
     $short = $flags & SHOWNODE_SHORT ? 1 : 0;
     $noperm = $flags & SHOWNODE_NOPERM ? 1 : 0;
     $query_result = DBQueryFatal("select n.*,na.*,r.vname,r.pid,r.eid,i.IP, " . "greatest(last_tty_act,last_net_act,last_cpu_act," . "last_ext_act) as last_act, " . "  t.isvirtnode,t.isremotenode,t.isplabdslice, " . "  r.erole as rsrvrole, pi.IP as phys_IP, loc.*, " . "  util.*,n.uuid as node_uuid, " . "  mi.IP as mngmnt_IP " . " from nodes as n " . "left join reserved as r on n.node_id=r.node_id " . "left join node_activity as na on " . "     n.node_id=na.node_id " . "left join node_types as t on t.type=n.type " . "left join interfaces as i on " . "     i.node_id=n.node_id and " . "     i.role='" . TBDB_IFACEROLE_CONTROL . "' " . "left join interfaces as pi on " . "     pi.node_id=n.phys_nodeid and " . "     pi.role='" . TBDB_IFACEROLE_CONTROL . "' " . "left join interfaces as mi on " . "     mi.node_id=n.node_id and " . "     mi.role='" . TBDB_IFACEROLE_MANAGEMENT . "' " . "left join location_info as loc on " . "     loc.node_id=n.node_id " . "left join node_utilization as util on " . "     util.node_id=n.node_id " . "where n.node_id='{$node_id}'");
     if (mysql_num_rows($query_result) == 0) {
         TBERROR("The node {$node_id} is not a valid nodeid!", 1);
     }
     $row = mysql_fetch_array($query_result);
     $phys_nodeid = $row["phys_nodeid"];
     $type = $row["type"];
     $vname = $row["vname"];
     $pid = $row["pid"];
     $eid = $row["eid"];
     $def_boot_osid = $row["def_boot_osid"];
     $def_boot_cmd_line = $row["def_boot_cmd_line"];
     $next_boot_osid = $row["next_boot_osid"];
     $temp_boot_osid = $row["temp_boot_osid"];
     $next_boot_cmd_line = $row["next_boot_cmd_line"];
     $rpms = $row["rpms"];
     $tarballs = $row["tarballs"];
     $startupcmd = $row["startupcmd"];
     $routertype = $row["routertype"];
     $eventstate = $row["eventstate"];
     $state_timestamp = $row["state_timestamp"];
     $allocstate = $row["allocstate"];
     $allocstate_timestamp = $row["allocstate_timestamp"];
     $op_mode = $row["op_mode"];
     $op_mode_timestamp = $row["op_mode_timestamp"];
     $IP = $row["IP"];
     $isvirtnode = $row["isvirtnode"];
     $isremotenode = $row["isremotenode"];
     $isplabdslice = $row["isplabdslice"];
     $ipport_low = $row["ipport_low"];
     $ipport_next = $row["ipport_next"];
     $ipport_high = $row["ipport_high"];
     $sshdport = $row["sshdport"];
     $last_act = $row["last_act"];
     $last_tty_act = $row["last_tty_act"];
     $last_net_act = $row["last_net_act"];
     $last_cpu_act = $row["last_cpu_act"];
     $last_ext_act = $row["last_ext_act"];
     $last_report = $row["last_report"];
     $rsrvrole = $row["rsrvrole"];
     $phys_IP = $row["phys_IP"];
     $mngmnt_IP = $row["mngmnt_IP"];
     $battery_voltage = $row["battery_voltage"];
     $battery_percentage = $row["battery_percentage"];
     $battery_timestamp = $row["battery_timestamp"];
     $boot_errno = $row["boot_errno"];
     $reserved_pid = $row["reserved_pid"];
     $inception = $row["inception"];
     $alloctime = $row["allocated"];
     $downtime = $row["down"];
     $uuid = $row["node_uuid"];
     if (!$def_boot_cmd_line) {
         $def_boot_cmd_line = " ";
     }
     if (!$next_boot_cmd_line) {
         $next_boot_cmd_line = " ";
     }
     if (!$rpms) {
         $rpms = " ";
     }
     if (!$tarballs) {
         $tarballs = " ";
     }
     if (!$startupcmd) {
         $startupcmd = " ";
     } else {
         $startupcmd = CleanString($startupcmd);
     }
     if ($node_id != $phys_nodeid) {
         if (!($phys_this = Node::Lookup($phys_nodeid))) {
             TBERROR("Cannot map physical node {$phys_nodeid} to object", 1);
         }
     }
     if (!$short) {
         #
         # Location info.
         #
         if (isset($row["loc_x"]) && isset($row["loc_y"]) && isset($row["floor"]) && isset($row["building"])) {
             $floor = $row["floor"];
             $building = $row["building"];
             $room = $row["room"];
             $loc_x = $row["loc_x"];
             $loc_y = $row["loc_y"];
             $orient = $row["orientation"];
             $contact = $row["contact"];
             $email = $row["email"];
             $phone = $row["phone"];
             $query_result = DBQueryFatal("select * from floorimages " . "where scale=1 and " . "      floor='{$floor}' and " . "      building='{$building}'");
             if (mysql_num_rows($query_result)) {
                 $row = mysql_fetch_array($query_result);
                 if (isset($row["pixels_per_meter"]) && ($pixels_per_meter = $row["pixels_per_meter"]) != 0.0) {
                     $meters_x = sprintf("%.3f", $loc_x / $pixels_per_meter);
                     $meters_y = sprintf("%.3f", $loc_y / $pixels_per_meter);
                     if (isset($orient)) {
                         $orientation = sprintf("%.3f", $orient);
                     }
                 }
             }
         }
     }
     echo "<table border=2 cellpadding=0 cellspacing=2\n                 align=center>\n";
     echo "<tr>\n              <td>Node ID:</td>\n              <td class=left>{$node_id}</td>\n          </tr>\n";
     if ($isvirtnode) {
         if (strcmp($node_id, $phys_nodeid)) {
             echo "<tr>\n                      <td>Phys ID:</td>\n                      <td class=left>\n\t   \t          <a href='shownode.php3?node_id={$phys_nodeid}'>\n                             {$phys_nodeid}</a></td>\n                  </tr>\n";
         }
     }
     if (!$short && !$noperm) {
         if ($vname) {
             echo "<tr>\n                      <td>Virtual Name:</td>\n                      <td class=left>{$vname}</td>\n                  </tr>\n";
         }
         if ($pid) {
             echo "<tr>\n                      <td>Project: </td>\n                      <td class=\"left\">\n                          <a href='showproject.php3?pid={$pid}'>{$pid}</a></td>\n                  </tr>\n";
             echo "<tr>\n                      <td>Experiment:</td>\n                      <td><a href='showexp.php3?pid={$pid}&eid={$eid}'>\n                             {$eid}</a></td>\n                  </tr>\n";
         }
     }
     echo "<tr>\n              <td>Node Type:</td>\n              <td class=left>\n  \t          <a href='shownodetype.php3?node_type={$type}'>{$type}</td>\n          </tr>\n";
     $feat_result = DBQueryFatal("select * from node_features " . "where node_id='{$node_id}'");
     if (mysql_num_rows($feat_result) > 0) {
         $features = "";
         $count = 0;
         while ($row = mysql_fetch_array($feat_result)) {
             if ($count > 0 && $count % 2 == 0) {
                 $features .= "<br>";
             }
             $features .= " " . $row["feature"];
             $count += 1;
         }
         echo "<tr><td>Features:</td><td class=left>{$features}</td></tr>";
     }
     if (!$short && !$noperm) {
         echo "<tr>\n                  <td>Def Boot OS:</td>\n                  <td class=left>";
         SpitOSIDLink($def_boot_osid);
         echo "    </td>\n              </tr>\n";
         if ($eventstate) {
             $when = strftime("20%y-%m-%d %H:%M:%S", $state_timestamp);
             echo "<tr>\n                     <td>EventState:</td>\n                     <td class=left>{$eventstate} ({$when})</td>\n                  </tr>\n";
         }
         if ($op_mode) {
             $when = strftime("20%y-%m-%d %H:%M:%S", $op_mode_timestamp);
             echo "<tr>\n                     <td>Operating Mode:</td>\n                     <td class=left>{$op_mode} ({$when})</td>\n                  </tr>\n";
         }
         if ($allocstate) {
             $when = strftime("20%y-%m-%d %H:%M:%S", $allocstate_timestamp);
             echo "<tr>\n                     <td>AllocState:</td>\n                     <td class=left>{$allocstate} ({$when})</td>\n                  </tr>\n";
         }
     }
     if (!$short) {
         #
         # Location info.
         #
         if (isset($building)) {
             echo "<tr>\n                      <td>Location (bldg/floor/room):</td>\n                      <td class=left>{$building}";
             if (isset($floor)) {
                 echo "/{$floor}";
             }
             if (isset($room)) {
                 echo "/{$room}";
             }
             echo "</td>\n                      </tr>\n";
         }
         if (isset($meters_x) && isset($meters_y)) {
             echo "<tr>\n                      <td>Location Coordinates:</td>\n                      <td class=left>x={$meters_x}, y={$meters_y} meters";
             if (isset($orientation)) {
                 echo " (o={$orientation} degrees)";
             }
             echo "</td>\n                  </tr>\n";
         }
         if (OPSGUY() && (isset($contact) || isset($email))) {
             $lcstr = "";
             if (isset($contact)) {
                 $lcstr .= "{$contact}:";
             }
             if (isset($email)) {
                 $lcstr .= " <a href='mailto:{$email}'>{$email}</a>";
             }
             if (isset($phone)) {
                 $lcstr .= " {$phone}";
             }
             echo "<tr>\n                      <td>Location Contact:</td>\n                      <td class=left>{$lcstr}\n                      </td>\n                  </tr>\n";
         }
     }
     if (!$short && !$noperm) {
         #
         # We want the last login for this node, but only if its *after*
         # the experiment was created (or swapped in).
         #
         if ($lastnodeuidlogin = TBNodeUidLastLogin($node_id)) {
             $foo = $lastnodeuidlogin["date"] . " " . $lastnodeuidlogin["time"] . " " . "(" . $lastnodeuidlogin["uid"] . ")";
             echo "<tr>\n                      <td>Last Login:</td>\n                      <td class=left>{$foo}</td>\n                 </tr>\n";
         }
         if ($last_act) {
             echo "<tr>\n                      <td>Last Activity:</td>\n                      <td class=left>{$last_act}</td>\n                  </tr>\n";
             $idletime = $this->IdleTime();
             echo "<tr>\n                      <td>Idle Time:</td>\n                      <td class=left>{$idletime} hours</td>\n                  </tr>\n";
             echo "<tr>\n                      <td>Last Act. Report:</td>\n                      <td class=left>{$last_report}</td>\n                  </tr>\n";
             echo "<tr>\n                      <td>Last TTY Act.:</td>\n                      <td class=left>{$last_tty_act}</td>\n                  </tr>\n";
             echo "<tr>\n                      <td>Last Net. Act.:</td>\n                      <td class=left>{$last_net_act}</td>\n                  </tr>\n";
             echo "<tr>\n                      <td>Last CPU Act.:</td>\n                      <td class=left>{$last_cpu_act}</td>\n                  </tr>\n";
             echo "<tr>\n                      <td>Last Ext. Act.:</td>\n                      <td class=left>{$last_ext_act}</td>\n                  </tr>\n";
         }
     }
     if (!$short && !$noperm) {
         if (!$isvirtnode && !$isremotenode) {
             echo "<tr>\n                      <td>Def Boot Command&nbsp;Line:</td>\n                      <td class=left>{$def_boot_cmd_line}</td>\n                  </tr>\n";
             echo "<tr>\n                      <td>Next Boot OS:</td>\n                      <td class=left>";
             if ($next_boot_osid) {
                 SpitOSIDLink($next_boot_osid);
             } else {
                 echo "&nbsp;";
             }
             echo "    </td>\n                  </tr>\n";
             echo "<tr>\n                      <td>Next Boot Command Line:</td>\n                      <td class=left>{$next_boot_cmd_line}</td>\n                  </tr>\n";
             echo "<tr>\n                      <td>Temp Boot OS:</td>\n                      <td class=left>";
             if ($temp_boot_osid) {
                 SpitOSIDLink($temp_boot_osid);
             } else {
                 echo "&nbsp;";
             }
             echo "    </td>\n                  </tr>\n";
         } elseif ($isvirtnode) {
             if (!$isplabdslice) {
                 echo "<tr>\n                          <td>IP Port Low:</td>\n                          <td class=left>{$ipport_low}</td>\n                      </tr>\n";
                 echo "<tr>\n                          <td>IP Port Next:</td>\n                          <td class=left>{$ipport_next}</td>\n                      </tr>\n";
                 echo "<tr>\n                          <td>IP Port High:</td>\n                          <td class=left>{$ipport_high}</td>\n                      </tr>\n";
             }
             echo "<tr>\n                      <td>SSHD Port:</td>\n                     <td class=left>{$sshdport}</td>\n                  </tr>\n";
         }
         echo "<tr>\n                  <td>Startup Command:</td>\n                  <td class=left>{$startupcmd}</td>\n              </tr>\n";
         echo "<tr>\n                  <td>Tarballs:</td>\n                  <td class=left>{$tarballs}</td>\n              </tr>\n";
         echo "<tr>\n                  <td>RPMs:</td>\n                  <td class=left>{$rpms}</td>\n              </tr>\n";
         echo "<tr>\n                  <td>Boot Errno:</td>\n                  <td class=left>{$boot_errno}</td>\n              </tr>\n";
         if (!$isvirtnode && !$isremotenode) {
             echo "<tr>\n                      <td>Router Type:</td>\n                      <td class=left>{$routertype}</td>\n                  </tr>\n";
         }
         if ($IP) {
             echo "<tr>\n                      <td>Control Net IP:</td>\n                      <td class=left>{$IP}</td>\n                  </tr>\n";
             if ($mngmnt_IP) {
                 echo "<tr>\n                          <td>Management IP:</td>\n                          <td class=left>{$mngmnt_IP}</td>\n                       </tr>\n";
             }
         } elseif ($phys_IP) {
             echo "<tr>\n                      <td>Physical IP:</td>\n                      <td class=left>{$phys_IP}</td>\n                  </tr>\n";
         }
         if ($rsrvrole) {
             echo "<tr>\n                      <td>Role:</td>\n                      <td class=left>{$rsrvrole}</td>\n                  </tr>\n";
         }
         if ($reserved_pid) {
             echo "<tr>\n                      <td>Reserved Pid:</td>\n                      <td class=left>\n                          <a href='showproject.php3?pid={$reserved_pid}'>\n                               {$reserved_pid}</a></td>\n                  </tr>\n";
         }
         if ($uuid) {
             echo "<tr>\n                      <td>UUID:</td>\n                      <td class=left>{$uuid}</td>\n                  </tr>\n";
         }
         #
         # Show battery stuff
         #
         if (isset($battery_voltage) && isset($battery_percentage)) {
             echo "<tr>\n    \t              <td>Battery Volts/Percent</td>\n\t\t      <td class=left>";
             printf("%.2f/%.2f ", $battery_voltage, $battery_percentage);
             if (isset($battery_timestamp)) {
                 echo "(" . date("m/d/y H:i:s", $battery_timestamp) . ")";
             }
             echo "    </td>\n\t\t  </tr>\n";
         }
         if ($isplabdslice) {
             $query_result = DBQueryFatal("select leaseend from plab_slice_nodes " . "where node_id='{$node_id}'");
             if (mysql_num_rows($query_result) != 0) {
                 $row = mysql_fetch_array($query_result);
                 $leaseend = $row["leaseend"];
                 echo "<tr>\n                     <td>Lease Expiration:</td>\n                     <td class=left>{$leaseend}</td>\n                 </tr>\n";
             }
         }
         if ($isremotenode) {
             if ($isvirtnode) {
                 $phys_this->ShowWideAreaNode(1);
             } else {
                 $this->ShowWideAreaNode(1);
             }
         }
         #
         # Show any auxtypes the node has
         #
         $query_result = DBQueryFatal("select type, count from node_auxtypes " . "where node_id='{$node_id}'");
         if (mysql_num_rows($query_result) != 0) {
             echo "<tr>\n                      <td align=center colspan=2>\n                      Auxiliary Types\n                      </td>\n                  </tr>\n";
             echo "<tr><th>Type</th><th>Count</th>\n";
             while ($row = mysql_fetch_array($query_result)) {
                 $type = $row["type"];
                 $count = $row["count"];
                 echo "<tr>\n    \t    \t          <td>{$type}</td>\n\t\t          <td class=left>{$count}</td>\n\t\t      </td>\n";
             }
         }
     }
     if (!$short) {
         #
         # Get interface info.
         #
         echo "<tr>\n                  <td align=center colspan=2>Interface Info</td>\n              </tr>\n";
         echo "<tr><th>Interface</th><th>Model; protocols</th>\n";
         $query_result = DBQueryFatal("select i.*,it.*,c.*,s.capval as channel " . "  from interfaces as i " . "left join interface_types as it on " . "     i.interface_type=it.type " . "left join interface_capabilities as c on " . "     i.interface_type=c.type and " . "     c.capkey='protocols' " . "left join interface_settings as s on " . "     s.node_id=i.node_id and s.iface=i.iface and " . "     s.capkey='channel' " . "where i.node_id='{$node_id}' and " . "      i.role='" . TBDB_IFACEROLE_EXPERIMENT . "'" . "order by iface");
         while ($row = mysql_fetch_array($query_result)) {
             $iface = $row["iface"];
             $type = $row["type"];
             $man = $row["manufacturer"];
             $model = $row["model"];
             $protocols = $row["capval"];
             $channel = $row["channel"];
             if (isset($channel)) {
                 $channel = " (channel {$channel})";
             } else {
                 $channel = "";
             }
             echo "<tr>\n                      <td>{$iface}:&nbsp; {$channel}</td>\n                      <td class=left>{$type} ({$man} {$model}; {$protocols})</td>\n                  </tr>\n";
         }
         #
         # Get subboss info.
         #
         echo "<tr>\n              <td align=center colspan=2>Subboss Info</td>\n            </tr>\n";
         echo "<tr><th>Service</th><th>Subboss Node ID</th>\n";
         $query_result = DBQueryFatal("select service,subboss_id from subbosses " . "where node_id ='{$node_id}' and disabled=0");
         while ($row = mysql_fetch_array($query_result)) {
             $service = $row["service"];
             $subboss = $row["subboss_id"];
             echo "<tr>\n                  <td>{$service}</td>\n                  <td class=left>{$subboss}</td>\n                 </tr>\n";
         }
         #
         # Switch info. Very useful for debugging.
         #
         if (!$noperm) {
             $query_result = DBQueryFatal("select i.*,w.* from interfaces as i " . "left join wires as w on i.node_id=w.node_id1 " . "   and i.card=w.card1 and i.port=w.port1 " . "where i.node_id='{$node_id}' and " . "      w.node_id1 is not null " . "order by iface");
             echo "<tr></tr><tr>\n                    <td align=center colspan=2>Switch Info</td>\n                  </tr>\n";
             echo "<tr><th>Iface:role &nbsp; card,port</th>\n                      <th>Switch &nbsp; card,port</th>\n";
             while ($row = mysql_fetch_array($query_result)) {
                 $iface = $row["iface"];
                 $role = $row["role"];
                 $card = $row["card1"];
                 $port = $row["port1"];
                 $switch = $row["node_id2"];
                 $switch_card = $row["card2"];
                 $switch_port = $row["port2"];
                 echo "<tr>\n                      <td>{$iface}:{$role} &nbsp; {$card},{$port}</td>\n                      <td class=left>" . "{$switch}: &nbsp; {$switch_card},{$switch_port}</td>\n                  </tr>\n";
             }
         }
     }
     #
     # Spit out node attributes
     #
     $query_result = DBQueryFatal("select attrkey,attrvalue from node_attributes " . "where node_id='{$node_id}' " . ($noperm ? "and attrkey!='root_password'" : ""));
     if (!$short && mysql_num_rows($query_result)) {
         echo "<tr>\n                    <td align=center colspan=2>Node Attributes</td>\n                  </tr>\n";
         echo "<tr><th>Attribute</th><th>Value</th>\n";
         while ($row = mysql_fetch_array($query_result)) {
             $attrkey = $row["attrkey"];
             $attrvalue = $row["attrvalue"];
             echo "<tr>\n                        <td>{$attrkey}</td>\n                        <td>{$attrvalue}</td>\n                      </td>\n";
         }
     }
     if (!($short || $noperm || $isvirtnode)) {
         $query_result = DBQueryFatal("select n.node_id,pid,eid,exptidx " . " from nodes as n " . "left join reserved as r on r.node_id=n.node_id " . "where n.phys_nodeid='{$node_id}' and " . "      n.node_id!=n.phys_nodeid");
         if (mysql_num_rows($query_result)) {
             echo "<tr>\n                       <td align=center colspan=2>Virtual/Sub Nodes</td>\n                      </tr>\n";
             echo "<tr><th>Node ID</th><th>Experiment</th>\n";
             while ($row = mysql_fetch_array($query_result)) {
                 $vnodeid = $row["node_id"];
                 $vpid = $row["pid"];
                 $veid = $row["eid"];
                 $vidx = $row["exptidx"];
                 $url1 = CreateURL("shownode", URLARG_NODEID, $vnodeid);
                 echo "<tr>\n                            <td><a href='{$url1}'>{$vnodeid}</a></td>\n";
                 if (isset($veid)) {
                     $url2 = CreateURL("showexp", URLARG_EID, $vidx);
                     echo "<td><a href='{$url2}'>{$vpid}/{$veid}</a></td>\n";
                 } else {
                     echo "<td>No Experiment</a></td>\n";
                 }
                 echo "</td>\n";
             }
         }
     }
     echo "</table>\n";
 }
Ejemplo n.º 3
0
}
if (count($errors)) {
    SPITFORM($action, $formfields, $errors);
    PAGEFOOTER();
    exit(1);
}
#
# Generate a temporary file and write in the data.
#
if ($action != "delete") {
    list($usec, $sec) = explode(' ', microtime());
    srand((double) $sec + (double) $usec * 100000);
    $foo = rand();
    $datafile = "/tmp/{$uid}-{$foo}.txt";
    if (!($fp = fopen($datafile, "w"))) {
        TBERROR("Could not create temporary file {$datafile}", 1);
    }
    fwrite($fp, $formfields["value"]);
    fclose($fp);
    chmod($datafile, 0666);
    $command_opts = " -f {$datafile} {$command_opts}";
}
#
# The backend does the actual work.
#
$pid = $template->pid();
$gid = $template->gid();
$retval = SUEXEC($uid, "{$unix_pid},{$unix_gid}", "webtemplate_metadata " . "{$command_opts} {$template_guid}/{$template_vers}", SUEXEC_ACTION_IGNORE);
if ($action != "delete") {
    unlink($datafile);
}
Ejemplo n.º 4
0
 function Show()
 {
     global $WIKISUPPORT, $CVSSUPPORT, $TBPROJ_DIR, $TBCVSREPO_DIR;
     global $MAILMANSUPPORT, $OPSCVSURL, $USERNODE;
     $group = $this->DefaultGroup();
     $pid = $this->pid();
     $proj_idx = $this->pid_idx();
     $proj_created = $this->created();
     $proj_name = $this->name();
     $proj_URL = $this->URL();
     $proj_public = YesNo($this->ispublic());
     $proj_funders = $this->funders();
     $proj_head_idx = $this->head_idx();
     $proj_members = $this->num_members();
     $proj_pcs = $this->num_pcs();
     # These are now booleans, not actual counts.
     $proj_linked = YesNo($this->linked_to_us());
     $proj_why = nl2br($this->why());
     $approved = YesNo($this->approved());
     $expt_count = $this->expt_count();
     $expt_last = $this->expt_last();
     $wikiname = $group->wikiname();
     $cvsrepo_public = $this->cvsrepo_public();
     $allow_workbench = $this->allow_workbench();
     # Before project approval, display ron/plab request status.
     if ($this->approved()) {
         $proj_ronpcs = YesNo(strpos($this->pcremote_ok(), "pcron") !== false);
         $proj_plabpcs = YesNo(strpos($this->pcremote_ok(), "pcplabphys") !== false);
     } else {
         $proj_ronpcs = YesNo($this->num_ron());
         $proj_plabpcs = YesNo($this->num_pcplab());
     }
     if (!($head_user = User::Lookup($proj_head_idx))) {
         TBERROR("Could not lookup object for user {$proj_head_idx}", 1);
     }
     $showuser_url = CreateURL("showuser", $head_user);
     $showproj_url = CreateURL("showproject", $this);
     $proj_head_uid = $head_user->uid();
     if (!$expt_last) {
         $expt_last = "&nbsp;";
     }
     echo "<center>\n              <h3>Project Profile</h3>\n              </center>\n              <table align=center cellpadding=2 border=1>\n";
     #
     # Generate the table.
     #
     echo "<tr>\n                  <td>Name: </td>\n                  <td class=\"left\">\n                      <a href='{$showproj_url}'>{$pid} ({$proj_idx})</a></td>\n              </tr>\n";
     echo "<tr>\n                  <td>Description: </td>\n                  <td class=\"left\">{$proj_name}</td>\n              </tr>\n";
     echo "<tr>\n                  <td>Project Head: </td>\n                  <td class=\"left\">\n                      <a href='{$showuser_url}'>{$proj_head_uid}</a></td>\n              </tr>\n";
     echo "<tr>\n              <td>URL: </td>\n                  <td class=\"left\">\n                      <a href='{$proj_URL}'>{$proj_URL}</a></td>\n              </tr>\n";
     if ($WIKISUPPORT && isset($wikiname)) {
         $wikiurl = "gotowiki.php3?redurl={$wikiname}/WebHome";
         echo "<tr>\n                      <td>Project Wiki:</td>\n                      <td class=\"left\">\n                          <a href='{$wikiurl}'>{$wikiname}</a></td>\n                  </tr>\n";
     }
     if ($CVSSUPPORT) {
         $cvsdir = "{$TBCVSREPO_DIR}/{$pid}";
         $cvsurl = "cvsweb/cvswebwrap.php3?pid={$pid}";
         echo "<tr>\n                      <td>Project CVS Repository:</td>\n                      <td class=\"left\">\n                          {$cvsdir} <a href='{$cvsurl}'>(CVSweb)</a></td>\n                  </tr>\n";
         $YesNo = YesNo($cvsrepo_public);
         $flip = $cvsrepo_public ? 0 : 1;
         echo "<tr>\n                      <td>CVS Repository Publically Readable?:</td>\n                      <td><a href=toggle.php?pid={$pid}&type=cvsrepo_public" . "&value={$flip}>{$YesNo}</a> (Click to toggle)</td>\n                  </tr>\n";
         if ($cvsrepo_public) {
             $puburl = "{$OPSCVSURL}/?cvsroot={$pid}";
             $pserver = ":pserver:anoncvs@{$USERNODE}:/cvsrepos/{$pid}";
             echo "<tr>\n                          <td>Public CVSWeb Address:</td>\n                          <td><a href={$puburl}>" . htmlspecialchars($puburl) . "</a></td>\n                      </tr>\n";
             echo "<tr>\n                          <td>CVS pserver Address:</td>\n                          <td>" . htmlspecialchars($pserver) . "</td>\n                      </tr>\n";
         }
     }
     if ($MAILMANSUPPORT) {
         $mmurl = "gotommlist.php3?pid={$pid}";
         echo "<tr>\n                      <td>Project Mailing List:</td>\n                      <td class=\"left\">\n                          <a href='{$mmurl}'>{$pid}-users</a> ";
         if (ISADMIN()) {
             $mmurl .= "&wantadmin=1";
             echo "<a href='{$mmurl}'>(admin access)</a>";
         }
         echo "    </td>\n                  </tr>\n";
         if (ISADMIN()) {
             $mmurl = "gotommlist.php3?listname={$pid}-admin&asadmin=1";
             echo "<tr>\n                         <td>Project Admin Mailing List:</td>\n                         <td class=\"left\">\n                             <a href='{$mmurl}'>{$pid}-admin</a> ";
             $mmurl = "gotommlist.php3?listname={$pid}-admin&wantadmin=1";
             echo "<a href='{$mmurl}'>(admin access)</a>";
             echo "    </td>\n                     </tr>\n";
         }
     }
     echo "<tr>\n                  <td>Publicly Visible: </td>\n                  <td class=\"left\">{$proj_public}</td>\n              </tr>\n";
     echo "<tr>\n                  <td>Link to Us?: </td>\n                  <td class=\"left\">{$proj_linked}</td>\n              </tr>\n";
     echo "<tr>\n                  <td>Funders: </td>\n                  <td class=\"left\">{$proj_funders}</td>\n              </tr>\n";
     echo "<tr>\n                  <td>#Project Members: </td>\n                  <td class=\"left\">{$proj_members}</td>\n              </tr>\n";
     echo "<tr>\n                  <td>#PCs: </td>\n                  <td class=\"left\">{$proj_pcs}</td>\n              </tr>\n";
     echo "<tr>\n                  <td>Planetlab Access: </td>\n                  <td class=\"left\">{$proj_plabpcs}</td>\n              </tr>\n";
     echo "<tr>\n                  <td>RON Access: </td>\n                  <td class=\"left\">{$proj_ronpcs}</td>\n              </tr>\n";
     # Fine-grained Datapository access: show node_ids over all sub-groups.
     # Should probably do likewise in individual sub-group pages.
     # "dp_projects" node_attributes are lists of group gid_idxs.
     $query_result = DBQueryFatal("select distinct g.gid_idx, a.node_id " . "  from groups as g, node_attributes as a " . "where g.pid_idx='{$proj_idx}' " . "  and a.attrkey='dp_projects' " . "  and FIND_IN_SET(g.gid_idx, a.attrvalue) " . "order by g.gid_idx, a.node_id");
     $proj_dp_nodes = "";
     while ($row = mysql_fetch_array($query_result)) {
         $node_id = $row["node_id"];
         if ($proj_dp_nodes) {
             $proj_dp_nodes .= ", ";
         }
         $proj_dp_nodes .= $node_id;
     }
     if ($proj_dp_nodes) {
         echo "<tr>\n\t\t      <td>Datapository Access: </td>\n\t\t      <td class=\"left\">{$proj_dp_nodes}</td>\n\t\t  </tr>\n";
     }
     echo "<tr>\n                  <td>Created: </td>\n                  <td class=\"left\">{$proj_created}</td>\n              </tr>\n";
     echo "<tr>\n                  <td>Experiments Created:</td>\n                  <td class=\"left\">{$expt_count}</td>\n              </tr>\n";
     echo "<tr>\n                  <td>Date of last experiment:</td>\n                  <td class=\"left\">{$expt_last}</td>\n              </tr>\n";
     echo "<tr>\n                  <td>Approved?: </td>\n                  <td class=\"left\">{$approved}</td>\n\t      </tr>\n";
     if (ISADMIN()) {
         $YesNo = YesNo($allow_workbench);
         $flip = $allow_workbench ? 0 : 1;
         echo "<tr>\n                      <td>Allow Workbench:</td>\n                      <td><a href=toggle.php?pid={$pid}&type=workbench" . "&value={$flip}>{$YesNo}</a> (Click to toggle)</td>\n                  </tr>\n";
     }
     echo "<tr>\n                  <td colspan='2'>Why?:</td>\n              </tr>\n";
     echo "<tr>\n                  <td colspan='2' width=600>{$proj_why}</td>\n              </tr>\n";
     echo "</table>\n";
 }
Ejemplo n.º 5
0
 function Group()
 {
     $gid_idx = $this->gid_idx();
     if ($this->group) {
         return $this->group;
     }
     $this->group = Group::Lookup($gid_idx);
     if (!$this->group) {
         TBERROR("Could not lookup group {$gid_idx}!", 1);
     }
     return $this->group;
 }
Ejemplo n.º 6
0
 if ($type == "cm" && isset($query) && $query != $defaultsearchstring) {
     $slicelist = array();
     $uuidlist = array();
     $safe_query = escapeshellarg($query);
     $fp = popen("{$TBSUEXEC_PATH} {$uid} nobody " . "webmaptoslice -w {$safe_query}", "r");
     if (!$fp) {
         TBERROR("Could not start maptoslice: {$safe_query}", 1);
     }
     while ($line = fgets($fp)) {
         $uuidlist[] = rtrim($line);
     }
     $status = pclose($fp);
     if ($status > 0 || !count($uuidlist)) {
         USERERROR("No slices matching your search term", 1);
     } elseif ($status < 0) {
         TBERROR("Could not run maptoslice: {$safe_query}", 1);
     }
     foreach ($uuidlist as $uuid) {
         $slicelist[] = GeniSlice::Lookup($type, $uuid);
     }
 } else {
     $slicelist = GeniSlice::AllSlices($type);
 }
 $which = $type == "cm" ? "Component Manager" : ($type == "sa" ? "Slice Authority" : "Clearing House");
 if (!$slicelist || !count($slicelist)) {
     continue;
 }
 # The form attributes:
 $table = array('#id' => $type, '#title' => $which, '#sortable' => 1, '#headings' => array("idx" => "ID", "hrn" => "HRN", "created" => "Created", "expires" => "Expires"));
 $rows = array();
 foreach ($slicelist as $slice) {
Ejemplo n.º 7
0
require "Sajax.php";
sajax_init();
sajax_export("Show", "GraphChange");
#
# Only known and logged in users ...
#
$this_user = CheckLoginOrDie();
$uid = $this_user->uid();
$isadmin = ISADMIN();
#
# Verify page arguments
#
$reqargs = RequiredPageArguments("template", PAGEARG_TEMPLATE);
$optargs = OptionalPageArguments("action", PAGEARG_STRING, "show", PAGEARG_STRING, "confirmed", PAGEARG_STRING);
if (!($experiment = $template->GetExperiment())) {
    TBERROR("Could not find experiment object for template!", 1);
}
# Need these below
$guid = $template->guid();
$vers = $template->vers();
$pid = $template->pid();
$eid = $template->eid();
$tid = $template->tid();
$exptidx = $experiment->idx();
$unix_gid = $experiment->UnixGID();
$this_url = CreateURL("template_show", $template);
$project = $template->GetProject();
$unix_pid = $project->unix_gid();
#
# Verify Permission.
#
Ejemplo n.º 8
0
 function Show()
 {
     $osid = $this->osid();
     $os_description = $this->description();
     $os_OS = $this->OS();
     $os_version = $this->version();
     $os_path = $this->path();
     $os_magic = $this->magic();
     $os_osfeatures = $this->osfeatures();
     $os_op_mode = $this->op_mode();
     $os_pid = $this->pid();
     $os_shared = $this->shared();
     $os_osname = $this->osname();
     $creator = $this->creator();
     $created = $this->created();
     $mustclean = $this->mustclean();
     $nextosid = $this->nextosid();
     $def_parentosid = $this->def_parentosid();
     $max_concurrent = $this->max_concurrent();
     $reboot_waittime = $this->reboot_waittime();
     $uuid = $this->uuid();
     $ezid = $this->ezid();
     $mfs = $this->mfs();
     if (!($creator_user = User::Lookup($creator))) {
         TBERROR("Error getting object for user {$creator}", 1);
     }
     $showuser_url = CreateURL("showuser", $creator_user);
     if (!$os_description) {
         $os_description = "&nbsp;";
     }
     if (!$os_version) {
         $os_version = "&nbsp;";
     }
     if (!$os_path) {
         $os_path = "&nbsp;";
     }
     if (!$os_magic) {
         $os_magic = "&nbsp;";
     }
     if (!$os_osfeatures) {
         $os_osfeatures = "&nbsp;";
     }
     if (!$os_op_mode) {
         $os_op_mode = "&nbsp;";
     }
     if (!$created) {
         $created = "N/A";
     }
     if (!$reboot_waittime) {
         $reboot_waittime = "&nbsp;";
     }
     #
     # Generate the table.
     #
     echo "<table align=center border=1>\n";
     echo "<tr>\n                <td>Name: </td>\n                <td class=\"left\">{$os_osname}</td>\n              </tr>\n";
     echo "<tr>\n                <td>Project: </td>\n                <td class=\"left\">\n                  <a href='showproject.php3?pid={$os_pid}'>{$os_pid}</a></td>\n              </tr>\n";
     echo "<tr>\n                <td>Creator: </td>\n                <td class=left>\n                  <a href='{$showuser_url}'>{$creator}</a></td>\n \t      </tr>\n";
     echo "<tr>\n                <td>Created: </td>\n                <td class=left>{$created}</td>\n    \t      </tr>\n";
     echo "<tr>\n                <td>Description: </td>\n                <td class=\"left\">{$os_description}</td>\n              </tr>\n";
     echo "<tr>\n                <td>Operating System: </td>\n                <td class=\"left\">{$os_OS}</td>\n              </tr>\n";
     echo "<tr>\n                <td>Version: </td>\n                <td class=\"left\">{$os_version}</td>\n             </tr>\n";
     echo "<tr>\n                <td>Path: </td>\n                <td class=\"left\">{$os_path}</td>\n              </tr>\n";
     echo "<tr>\n                <td>Magic (uname -r -s): </td>\n                <td class=\"left\">{$os_magic}</td>\n              </tr>\n";
     echo "<tr>\n                <td>Features: </td>\n                <td class=\"left\">{$os_osfeatures}</td>\n              </tr>\n";
     echo "<tr>\n                <td>Operational Mode: </td>\n                <td class=\"left\">{$os_op_mode}</td>\n              </tr>\n";
     if (isset($max_concurrent) and $max_concurrent > 0) {
         echo "<tr>\n                    <td>Max Concurrent Usage: </td>\n                    <td class=\"left\">{$max_concurrent}</td>\n                  </tr>\n";
     }
     echo "<tr>\n                <td>Reboot Waittime: </td>\n                <td class=\"left\">{$reboot_waittime}</td>\n              </tr>\n";
     echo "<tr>\n                <td>Shared?: </td>\n                <td class=left>" . YesNo($os_shared) . "</td>\n              </tr>\n";
     echo "<tr>\n                <td>Must Clean?: </td>\n                <td class=left>" . YesNo($mustclean) . "</td>\n              </tr>\n";
     if ($nextosid) {
         if ($nextosid == 0) {
             echo "<tr>\n\t\t        <td>Next Osid: </td>\n\t\t        <td class=left>\n\t\t\t    Mapped via DB table: osid_map</td></tr>\n";
         } else {
             $nextosinfo = OSinfo::Lookup($nextosid);
             $nextosname = $nextosinfo->osname();
             echo "<tr>\n                        <td>Next Osid: </td>\n                        <td class=left>\n                            <a href='showosinfo.php3?osid={$nextosid}'>\n                                            {$nextosname}</a></td>\n                      </tr>\n";
         }
     }
     if ($def_parentosid) {
         $nextosinfo = OSinfo::Lookup($def_parentosid);
         $nextosname = $nextosinfo->osname();
         echo "<tr>\n                      <td>Parent Osid: </td>\n                      <td class=left>\n                          <a href='showosinfo.php3?osid={$def_parentosid}'>\n                                           {$nextosname}</a></td>\n                  </tr>\n";
     }
     if ($ezid) {
         echo "<tr>\n                        <td>Image Link: </td>\n                        <td class=left>\n                            <a href='showimageid.php3?imageid={$osid}'>\n                                            {$os_osname}</a></td>\n                      </tr>\n";
     }
     if ($mfs) {
         echo "<tr>\n                        <td>MFS: </td>\n                        <td class=left>Yes</td>\n                      </tr>\n";
     }
     echo "<tr>\n                <td>Internal ID: </td>\n                <td class=\"left\">{$osid}</td>\n              </tr>\n";
     echo "<tr>\n                <td>UUID: </td>\n                <td class=left>{$uuid}</td>\n              </tr>\n";
     if ($def_parentosid) {
         $parent_result = DBQueryFatal("select m.parent_osid,o.osname,o.pid " . "   from os_submap as m " . "left join os_info as o on o.osid=m.parent_osid " . "where m.osid='{$osid}'");
         if (mysql_num_rows($parent_result)) {
             while ($prow = mysql_fetch_array($parent_result)) {
                 $posid = $prow["parent_osid"];
                 $posname = $prow["osname"];
                 echo "<tr>";
                 echo "  <td>Parent {$posid}:</td>";
                 echo "  <td class=left>";
                 echo "   <a href='showosinfo.php3?osid={$posid}'>";
                 echo "{$posname}</a></td>\n";
                 echo "</tr>\n";
             }
         }
     }
     echo "</table>\n";
 }
Ejemplo n.º 9
0
function FormValidateFileUpload($name, &$errors, $attributes)
{
    $error_label = CombineLabels($parent_label, $attributes);
    # Check for required fields not filled out
    if (isset($attributes['#required']) && $attributes['#required'] && !(isset($_FILES[$name]['name']) && $_FILES[$name]['size'] != 0)) {
        $errors[$error_label] = "Missing required value";
    } elseif (isset($attributes['#checkslot'])) {
        $check = $attributes['#checkslot'];
        if (function_exists($check)) {
            $check($name, $errors, $attributes, null);
        } else {
            TBERROR("Could not parse checkslot: {$check}", 1);
        }
    }
}
Ejemplo n.º 10
0
function SPITFORM($template, $formfields, $errors)
{
    PAGEHEADER("Edit Template Events");
    if ($template->EventList($eventlist) != 0) {
        TBERROR("Could not get eventlist for template!", 1);
    }
    $guid = $template->guid();
    $vers = $template->vers();
    echo $template->PageHeader();
    echo "<br>\n";
    echo "<center>\n";
    $template->Show();
    echo "</center>\n";
    echo "<br>\n";
    if (!count($eventlist)) {
        echo "<center>";
        echo "<font size=+1 color=red>This template has no events!</font>\n";
        echo "</center>\n";
        return;
    }
    if ($errors) {
        echo "<table class=nogrid\n                     align=center border=0 cellpadding=6 cellspacing=0>\n              <tr>\n                 <th align=center colspan=2>\n                   <font size=+1 color=red>\n                      &nbsp;Oops, please fix the following errors!&nbsp;\n                   </font>\n                 </td>\n              </tr>\n";
        while (list($name, $message) = each($errors)) {
            # XSS prevention.
            $message = CleanString($message);
            echo "<tr>\n                     <td align=right>\n                       <font color=red>{$name}:&nbsp;</font></td>\n                     <td align=left>\n                       <font color=red>{$message}</font></td>\n                  </tr>\n";
        }
        echo "</table><br>\n";
    }
    # XSS prevention.
    while (list($key, $val) = each($formfields)) {
        $formfields[$key] = CleanString($val);
    }
    $url = CreateURL("template_editevents", $template);
    echo "<form action='{$url}'  method=post>\n";
    echo "<table align=center border=1>\n";
    echo "<tr>";
    echo "<th align=center>Delete</th>\n";
    echo "<th align=center>Time</th>\n";
    #    echo "<th align=center>Name</th>\n";
    echo "<th align=center>Node</th>\n";
    echo "<th align=center>Args</th>\n";
    echo "</tr><tr></tr>\n";
    #
    # Show a table of events with a delete button named by the event.
    #
    while (list($index, $dbrow) = each($eventlist)) {
        $vname = $dbrow["vname"];
        $vnode = $dbrow["vnode"];
        $delete_name = "delete_{$vname}";
        $time_name = "time_{$vname}";
        $args_name = "args_{$vname}";
        echo "<tr>";
        echo "<td align=center><input type=checkbox value=checked\n                         name=\"formfields[{$delete_name}]\"\n                         " . $formfields["{$delete_name}"] . ">\n              </td>\n";
        echo "<td class='pad4'>\n                  <input type=text\n                         name=\"formfields[{$time_name}]\"\n                         value=\"" . $formfields["{$time_name}"] . "\"\n\t                 size=10\n                         maxlength=10>\n              </td>\n";
        #	echo "<td class='pad4'>$vname</td>\n";
        echo "<td class='pad4'>{$vnode}</td>\n";
        echo "<td class='pad4'>\n                  <input type=text\n                         name=\"formfields[{$args_name}]\"\n                         value=\"" . $formfields["{$args_name}"] . "\"\n\t                 size=64\n                         maxlength=1024>\n              </td>\n";
        echo "</tr>\n";
    }
    echo "<tr>\n              <td class='pad4' align=center colspan=4>\n                <b><input type=submit name=save value='Save Changes'></b>\n              </td>\n         </tr>\n        </form>\n        </table>\n";
}
Ejemplo n.º 11
0
 function ExperimentList($listify = 1)
 {
     $pid = $this->pid();
     $gid = $this->gid();
     $query_result = DBQueryFatal("select idx from experiments " . "where pid='{$pid}' and gid='{$gid}'");
     if (!$listify) {
         return mysql_num_rows($query_result);
     }
     # Else, create a list of the groups.
     $result = array();
     while ($row = mysql_fetch_array($query_result)) {
         $idx = $row["idx"];
         if (!($experiment = Experiment::Lookup($idx))) {
             TBERROR("Group::ExperimentList: " . "Could not load experiment {$idx}!", 1);
         }
         $result[] = $experiment;
     }
     return $result;
 }
Ejemplo n.º 12
0
$reqargs = RequiredPageArguments("peer", PAGEARG_STRING);
$optargs = OptionalPageArguments("user", PAGEARG_USER);
$safe_peer = addslashes($peer);
$query_result = DBQueryFatal("select * from emulab_peers " . "where name='{$safe_peer}' or urn='{$safe_peer}'");
if (!mysql_num_rows($query_result)) {
    USERERROR("Unknown peer: {$peer}", 1);
}
$row = mysql_fetch_array($query_result);
$urn = $row['urn'];
$url = $row['weburl'];
#
# Allow admin to xlogin as another user.
#
if (isset($user) && !$this_user->SameUser($user)) {
    if ($isadmin) {
        $uid = $user->uid();
    } else {
        USERERROR("Not allowed to login as another user", 1);
    }
}
STARTBUSY("Contacting peer");
#
# Do the xlogin, which gives us back a hash to stick in the redirect URL.
#
SUEXEC($uid, "nobody", "webmanageremote xlogin " . escapeshellarg($urn) . " {$uid}", SUEXEC_ACTION_DIE);
STOPBUSY();
if (!preg_match("/^(\\w*)\$/", $suexec_output, $matches)) {
    TBERROR($suexec_output, 1);
}
$hash = $matches[1];
PAGEREPLACE("{$url}/peer_login.php?user={$uid}&key={$hash}");
Ejemplo n.º 13
0
} elseif (isset($index)) {
    $experiment = Experiment::Lookup($index);
}
#
# If we got a current experiment, great. Otherwise we have to lookup
# data for a historical experiment.
#
if (isset($experiment) && $experiment) {
    # Need these below.
    $pid = $experiment->pid();
    $gid = $experiment->gid();
    $eid = $experiment->eid();
    $idx = $experiment->idx();
    $stats = $experiment->GetStats();
    if (!$stats) {
        TBERROR("Could not load stats object for experiment {$pid}/{$eid}", 1);
    }
    $archive_idx = $stats->archive_idx();
    # Permission
    if (!$isadmin && !$experiment->AccessCheck($this_user, $TB_EXPT_READINFO)) {
        USERERROR("You do not have permission to view this archive!", 1);
    }
} elseif (isset($index)) {
    $stats = ExperimentStats::Lookup($index);
    if (!$stats) {
        PAGEARGERROR("Invalid experiment index: {$index}");
    }
    # Need these below.
    $pid = $stats->pid();
    $eid = $stats->eid();
    $gid = $stats->gid();
Ejemplo n.º 14
0
 function SetRunAnnotation($this_user, $runidx, $annotation)
 {
     $exptidx = $this->exptidx();
     $annoname = "__experimentrun_annotation_{$exptidx}_{$runidx}";
     $template = $this->template();
     $uid = $this_user->uid();
     $foo = rand();
     $datafile = "/tmp/{$uid}-{$foo}.txt";
     $guid = $template->guid();
     $vers = $template->vers();
     $action = $this->GetRunAnnotation($runidx) ? "modify" : "add";
     if (!($fp = fopen($datafile, "w"))) {
         TBERROR("Could not create temporary file {$datafile}", 1);
     }
     fwrite($fp, $annotation);
     fclose($fp);
     chmod($datafile, 0666);
     SUEXEC($this_user->uid(), $template->UnixGID(), "webtemplate_metadata -a {$action} -f {$datafile} -t annotation " . " {$annoname} {$guid}/{$vers}", SUEXEC_ACTION_CONTINUE);
     unlink($datafile);
     return 0;
 }
Ejemplo n.º 15
0
# of the node running the checkin. We could return an http error, but
# that would be of no help to the user on the other side.
#
function SPITSTATUS($code, $msg)
{
    header("HTTP/1.0 {$code} {$msg}");
    exit;
}
# Required arguments
$reqargs = RequiredPageArguments("xmlstuff", PAGEARG_ANYTHING);
$xmlname = tempnam("/tmp", "sitecheckin");
if (!$xmlname) {
    TBERROR("Could not create temporary filename", 0);
    SPITSTATUS(404, "Could not create temporary file!");
}
if (!($fp = fopen($xmlname, "w"))) {
    TBERROR("Could not open temp file {$xmlname}", 0);
    SPITSTATUS(404, "Could not open temporary file!");
}
fwrite($fp, $xmlstuff);
fclose($fp);
chmod($xmlname, 0666);
#
# Invoke the backend and return the status.
#
$retval = SUEXEC("elabman", $TBADMINGROUP, "websitecheckin {$xmlname}", SUEXEC_ACTION_IGNORE);
if ($retval) {
    SUEXECERROR(SUEXEC_ACTION_CONTINUE);
    SPITSTATUS(404, "Could not do a site checkin!");
}
unlink($xmlname);
Ejemplo n.º 16
0
         $gotone = 1;
     }
 }
 if (!$gotone) {
     $errors["Parameters"] = "You did not set any values";
 } else {
     #
     # Generate a temporary file and write in the XML goo.
     #
     list($usec, $sec) = explode(' ', microtime());
     srand((double) $sec + (double) $usec * 100000);
     $foo = rand();
     $parameter_xmlfile = "/tmp/{$uid}-{$foo}.xml";
     $deletexmlfile = 1;
     if (!($fp = fopen($parameter_xmlfile, "w"))) {
         TBERROR("Could not create temp file {$parameter_xmlfile}", 1);
     }
     fwrite($fp, "<template_parameters>\n");
     reset($parameter_masterlist);
     while (list($name, $default_value) = each($parameter_masterlist)) {
         if (isset($parameters[$name])) {
             $value = $parameters[$name];
         } else {
             $value = $default_value;
         }
         fwrite($fp, " <parameter name=\"{$name}\">");
         fwrite($fp, "<value>{$value}</value></parameter>\n");
     }
     fwrite($fp, "</template_parameters>\n");
     fclose($fp);
     chmod($parameter_xmlfile, 0666);
Ejemplo n.º 17
0
function ValidateArgument($name, $arg)
{
    switch ($name) {
        case PAGEARG_UID:
        case PAGEARG_PID:
        case PAGEARG_GID:
        case PAGEARG_EID:
        case PAGEARG_NODEID:
        case PAGEARG_PROJECT:
        case PAGEARG_GROUP:
        case PAGEARG_USER:
        case PAGEARG_EXPERIMENT:
        case PAGEARG_NODE:
        case PAGEARG_LOGFILE:
            if (preg_match("/^[-\\w]+\$/", "{$arg}")) {
                return 1;
            }
            PAGEARGERROR("Invalid argument for '{$name}': {$arg}");
            break;
        case PAGEARG_IMAGEID:
        case PAGEARG_IMAGE:
        case PAGEARG_OSID:
        case PAGEARG_OSINFO:
            if (preg_match("/^[-\\w\\.\\+]+\$/", "{$arg}")) {
                return 1;
            }
            PAGEARGERROR("Invalid argument for '{$name}': {$arg}");
            break;
        case PAGEARG_GUID:
        case PAGEARG_VERS:
        case PAGEARG_INSTANCE:
            if (preg_match("/^[\\d]+\$/", "{$arg}")) {
                return 1;
            }
            PAGEARGERROR("Invalid argument for '{$name}': {$arg}");
            break;
        case PAGEARG_METADATA:
            if (preg_match("/^[\\d]+\\/[\\d]+\$/", "{$arg}")) {
                return 1;
            }
            PAGEARGERROR("Invalid argument for '{$name}': {$arg}");
            break;
        case PAGEARG_INTEGER:
        case PAGEARG_NUMERIC:
            if (is_numeric($arg)) {
                return 1;
            }
            PAGEARGERROR("Invalid argument for '{$name}': {$arg}");
            break;
        case PAGEARG_ARRAY:
            if (is_array($arg)) {
                return 1;
            }
            PAGEARGERROR("'{$name}' is not an array: {$arg}");
            break;
        default:
            TBERROR("ValidateArgument: " . "Unknown argument type - {$name}", 1);
    }
    return 0;
}
Ejemplo n.º 18
0
 function ExperimentList($listify = 1, $group = null)
 {
     $uid_idx = $this->uid_idx();
     $gclause = "";
     # within optional group only.
     if ($group) {
         $pid = $group->pid();
         $gid = $group->gid();
         $gclause = "and pid='{$pid}' and gid='{$gid}'";
     }
     $query_result = DBQueryFatal("select idx from experiments " . "where creator_idx='{$uid_idx}' {$gclause}");
     if (!$listify) {
         return mysql_num_rows($query_result);
     }
     # Else, create a list of the groups.
     $result = array();
     while ($row = mysql_fetch_array($query_result)) {
         $idx = $row["idx"];
         if (!($experiment = Experiment::Lookup($idx))) {
             TBERROR("Group::ExperimentList: " . "Could not load experiment {$idx}!", 1);
         }
         $result[] = $experiment;
     }
     return $result;
 }
Ejemplo n.º 19
0
    echo "<form action='{$url}' method='post'>\n";
    echo "<tr>\n              <td>Use the text box (70 columns wide) to add a message to the\n                  email notification. </td>\n          </tr>\n";
    echo "<tr>\n             <td align=center class=left>\n                 <textarea name=message rows=15 cols=70></textarea>\n             </td>\n          </tr>\n";
    echo "<tr>\n              <td align=center>\n                  <b><input type='submit' value='Submit' name='submit'></td>\n          </tr>\n          </form>\n          </table>\n";
}
#
# On first load, display a virgin form and exit.
#
if (!isset($submit)) {
    SPITFORM($project, "", null);
    PAGEFOOTER();
    return;
}
# If there is a message in the text box, it is appended below.
if (!isset($message)) {
    $message = "";
}
if (!($leader = $project->GetLeader())) {
    TBERROR("Error getting leader for {$pid}", 1);
}
$headuid = $leader->uid();
$headuid_email = $leader->email();
$headname = $leader->name();
SendProjAdminMail($pid, "ADMIN", "{$headname} '{$headuid}' <{$headuid_email}>", "Project '{$pid}' Approval", "\n" . "This message is to notify you that your project '{$pid}'\n" . "has been approved.  We recommend that you save this link so that\n" . "you can send it to people you wish to have join your project.\n" . "Otherwise, tell them to go to {$TBBASE} and join it.\n" . "\n" . "    {$TBBASE}/joinproject.php3?target_pid={$pid}\n" . "\n" . ($message != "" ? "{$message}\n\n" : "") . "Thanks,\n" . "Testbed Operations\n");
echo "<center>\n      <h2>Done!</h2>\n      </center><br>\n";
sleep(1);
PAGEREPLACE(CreateURL("showproject", $project));
#
# Standard Testbed Footer
#
PAGEFOOTER();
Ejemplo n.º 20
0
 function AccessCheck($user, $access_type)
 {
     global $TBDB_TRUST_USER;
     $pid_idx = $this->pid_idx();
     if (!($project = Project::Lookup($pid_idx))) {
         TBERROR("ExperimentStats::AccessCheck: " . "Cannot map project {$pid_idx} to its object", 1);
     }
     return $project->AccessCheck($user, $TBDB_TRUST_USER);
 }
Ejemplo n.º 21
0
    # Fatal Error. Report to the user, even though there is not much he can
    # do with the error. Also reports to tbops.
    #
    if ($retval < 0) {
        SUEXECERROR(SUEXEC_ACTION_CONTINUE);
    }
    # User error. Tell user and exit.
    SUEXECERROR(SUEXEC_ACTION_USERERROR);
    return;
}
#
# Parse the last line of output. Ick.
#
if (preg_match("/^Template\\s+(\\w+)\\/(\\w+)\\s+is being/", $suexec_output_array[count($suexec_output_array) - 1], $matches)) {
    $guid = $matches[1];
    $vers = $matches[2];
    $template = Template::Lookup($guid, $vers);
    if (!$template) {
        TBERROR("Could not lookup template object for {$guid}/{$vers}", 1);
        return;
    }
    echo $template->PageHeader();
    echo "<br><br>\n";
    STARTLOG($template);
} else {
    SUEXECERROR(SUEXEC_ACTION_DIE);
}
#
# Standard Testbed Footer
#
PAGEFOOTER();
Ejemplo n.º 22
0
    # Fatal Error. Report to the user, even though there is not much he can
    # do with the error. Also reports to tbops.
    #
    if ($retval < 0) {
        SUEXECERROR(SUEXEC_ACTION_CONTINUE);
    }
    # User error. Tell user and exit.
    SUEXECERROR(SUEXEC_ACTION_USERERROR);
    return;
}
#
# We need to locate this instance for STARTLOG() below.
#
if (!preg_match("/^Instance\\s+[-\\w]+\\/[-\\w]+\\s+\\((\\d*)\\)/", $suexec_output_array[count($suexec_output_array) - 1], $matches)) {
    TBERROR("Could not locate instance object for {$pid}/{$eid}", 1);
}
$instance = TemplateInstance::LookupByIdx($matches[1]);
if (!$instance) {
    TBERROR("Could not map instance idx " . $matches[1] . " to its object!", 1);
}
#
# This does both the log output, and the state change watcher popup
#
if ($batchmode && !$preload) {
    echo "You template instantation has been queued and will run when\n          enough resources become available. This might happen\n          immediately, or it may take hours or days; you will be\n          notified via email when insantiation is complete, and again when\n          your experiment has completed.\n";
}
STARTLOG($instance->GetLogfile());
#
# Standard Testbed Footer
#
PAGEFOOTER();