Пример #1
0
function VerifyPageArguments($argspec, $required)
{
    global $drewheader;
    if ($drewheader) {
        trigger_error("PAGEHEADER called before VerifyPageArguments " . "(called by RequiredPageArguments or OptionalPageArguments). " . "Won't be able to return proper HTTP status code on Error " . "in " . $_SERVER['SCRIPT_FILENAME'] . ",", E_USER_WARNING);
    }
    $result = array();
    while ($argspec and count($argspec) > 1) {
        $name = array_shift($argspec);
        $type = array_shift($argspec);
        $yep = 0;
        unset($object);
        switch ($type) {
            case PAGEARG_EXPERIMENT:
                if (isset($_REQUEST[URL_EXPERIMENT])) {
                    $idx = $_REQUEST[URL_EXPERIMENT];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_EXPERIMENT, $idx)) {
                        $object = Experiment::Lookup($idx);
                    }
                } elseif (isset($_REQUEST[URL_EXPTIDX])) {
                    $idx = $_REQUEST[URL_EXPTIDX];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_EXPERIMENT, $idx)) {
                        $object = Experiment::Lookup($idx);
                    }
                } elseif (isset($_REQUEST[URL_PID]) && isset($_REQUEST[URL_EID])) {
                    $pid = $_REQUEST[URL_PID];
                    $eid = $_REQUEST[URL_EID];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_PID, $pid) && ValidateArgument(PAGEARG_EID, $eid)) {
                        $object = Experiment::LookupByPidEid($pid, $eid);
                    }
                }
                break;
            case PAGEARG_TEMPLATE:
                if (isset($_REQUEST[URL_GUID]) && isset($_REQUEST[URL_VERS])) {
                    $guid = $_REQUEST[URL_GUID];
                    $vers = $_REQUEST[URL_VERS];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_GUID, $guid) && ValidateArgument(PAGEARG_VERS, $vers)) {
                        $object = Template::Lookup($guid, $vers);
                    }
                } elseif (isset($_REQUEST[URL_TEMPLATE])) {
                    $guidvers = $_REQUEST[URL_TEMPLATE];
                    $yep = 1;
                    if (preg_match("/^([\\d]+)\\/([\\d]+)\$/", $guidvers, $matches)) {
                        $guid = $matches[1];
                        $vers = $matches[2];
                        $object = Template::Lookup($guid, $vers);
                    } else {
                        PAGEARGERROR("Invalid argument for '{$type}': {$guidvers}");
                    }
                }
                break;
            case PAGEARG_INSTANCE:
                if (isset($_REQUEST[URL_INSTANCE])) {
                    $idx = $_REQUEST[URL_INSTANCE];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_INSTANCE, $idx)) {
                        $object = TemplateInstance::LookupByExptidx($idx);
                    }
                }
                break;
            case PAGEARG_METADATA:
                if (isset($_REQUEST[URL_METADATA])) {
                    $guidvers = $_REQUEST[URL_METADATA];
                    $yep = 1;
                    if (preg_match("/^([\\d]+)\\/([\\d]+)\$/", $guidvers, $matches)) {
                        $guid = $matches[1];
                        $vers = $matches[2];
                        $object = TemplateMetadata::Lookup($guid, $vers);
                    } else {
                        PAGEARGERROR("Invalid argument for '{$type}': {$guidvers}");
                    }
                }
                break;
            case PAGEARG_PROJECT:
                if (isset($_REQUEST[URL_PROJECT])) {
                    $idx = $_REQUEST[URL_PROJECT];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_PROJECT, $idx)) {
                        $object = Project::Lookup($idx);
                    }
                } elseif (isset($_REQUEST[URL_PID])) {
                    $pid = $_REQUEST[URL_PID];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_PID, $pid)) {
                        $object = Project::Lookup($pid);
                    }
                }
                break;
            case PAGEARG_GROUP:
                if (isset($_REQUEST[URL_GROUP])) {
                    $idx = $_REQUEST[URL_GROUP];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_GROUP, $idx)) {
                        $object = Group::Lookup($idx);
                    }
                } elseif (isset($_REQUEST[URL_PID]) && isset($_REQUEST[URL_GID])) {
                    $pid = $_REQUEST[URL_PID];
                    $gid = $_REQUEST[URL_GID];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_PID, $pid) && ValidateArgument(PAGEARG_GID, $gid)) {
                        $object = Group::LookupByPidGid($pid, $gid);
                    }
                }
                break;
            case PAGEARG_NODE:
                if (isset($_REQUEST[URL_NODE])) {
                    $idx = $_REQUEST[URL_NODE];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_NODE, $idx)) {
                        $object = Node::Lookup($idx);
                    }
                } elseif (isset($_REQUEST[URL_NODEID])) {
                    $nodeid = $_REQUEST[URL_NODEID];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_NODEID, $nodeid)) {
                        $object = Node::Lookup($nodeid);
                    }
                } elseif (isset($_REQUEST[URL_NODEID_ALT])) {
                    $nodeid = $_REQUEST[URL_NODEID_ALT];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_NODEID, $nodeid)) {
                        $object = Node::Lookup($nodeid);
                    }
                }
                break;
            case PAGEARG_USER:
                if (isset($_REQUEST[URL_USER])) {
                    $idx = $_REQUEST[URL_USER];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_USER, $idx)) {
                        $object = User::Lookup($idx);
                    }
                } elseif (isset($_REQUEST[URL_UID])) {
                    $uid = $_REQUEST[URL_UID];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_UID, $uid)) {
                        $object = User::Lookup($uid);
                    }
                }
                break;
            case PAGEARG_IMAGE:
                if (isset($_REQUEST[URL_IMAGEID])) {
                    $imageid = $_REQUEST[URL_IMAGEID];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_IMAGE, $imageid)) {
                        $object = Image::Lookup($imageid);
                    }
                } elseif (isset($_REQUEST[$name]) && $_REQUEST[$name] != "") {
                    $imageid = $_REQUEST[$name];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_IMAGE, $imageid)) {
                        $object = Image::Lookup($imageid);
                    }
                }
                break;
            case PAGEARG_OSINFO:
                if (isset($_REQUEST[URL_OSID])) {
                    $osid = $_REQUEST[URL_OSID];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_OSINFO, $osid)) {
                        $object = OSinfo::Lookup($osid);
                    }
                }
                break;
            case PAGEARG_BOOLEAN:
                if (isset($_REQUEST[$name]) && $_REQUEST[$name] != "") {
                    $object = $_REQUEST[$name];
                    $yep = 1;
                    if (strcasecmp("{$object}", "yes") == 0 || strcasecmp("{$object}", "1") == 0 || strcasecmp("{$object}", "true") == 0 || strcasecmp("{$object}", "on") == 0) {
                        $object = True;
                    } elseif (strcasecmp("{$object}", "no") == 0 || strcasecmp("{$object}", "0") == 0 || strcasecmp("{$object}", "false") == 0 || strcasecmp("{$object}", "off") == 0) {
                        $object = False;
                    }
                }
                break;
            case PAGEARG_INTEGER:
            case PAGEARG_NUMERIC:
            case PAGEARG_ARRAY:
                if (isset($_REQUEST[$name]) && $_REQUEST[$name] != "") {
                    $object = $_REQUEST[$name];
                    $yep = 1;
                    if (!ValidateArgument($type, $object)) {
                        unset($object);
                    }
                }
                break;
            case PAGEARG_ANYTHING:
                if (isset($_REQUEST[$name])) {
                    $object = $_REQUEST[$name];
                    $yep = 1;
                    # Anything allowed, caller BETTER check it.
                }
                break;
            case PAGEARG_ALPHALIST:
                if (isset($_REQUEST[$name])) {
                    $object = $_REQUEST[$name];
                    if (!preg_match("/^[\\d\\w\\-\\ \\,]+\$/", $object)) {
                        unset($object);
                    } else {
                        $object = preg_split("/[\\,\\;]+\\s*/", $_REQUEST[$name]);
                    }
                }
                break;
            case PAGEARG_STRING:
            default:
                if (isset($_REQUEST[$name])) {
                    $object = $_REQUEST[$name];
                    $yep = 1;
                    # Pages never get arguments with special chars. Check.
                    if (preg_match("/[\\'\"]/", $object)) {
                        $object = htmlspecialchars($object);
                        PAGEARGERROR("Invalid characters in '{$name}': {$object}");
                    }
                }
                break;
            case PAGEARG_PASSWORD:
            default:
                if (isset($_REQUEST[$name])) {
                    $object = $_REQUEST[$name];
                    $yep = 1;
                    # Only printable chars.
                    if (!preg_match("/^[ -~]+\$/", $object)) {
                        PAGEARGERROR("Invalid characters in '{$name}'");
                    }
                }
                break;
            case PAGEARG_LOGFILE:
                if (isset($_REQUEST[URL_LOGFILE])) {
                    $logid = $_REQUEST[URL_LOGFILE];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_LOGFILE, $logid)) {
                        $object = Logfile::Lookup($logid);
                    }
                }
                break;
        }
        if (isset($object)) {
            $result[$name] = $object;
            $GLOBALS[$name] = $object;
        } elseif ($yep) {
            #
            # Value supplied but could not be mapped to object.
            # Lets make that clear in the error message.
            #
            USERERROR("Could not map page arguments to '{$name}'", 1);
        } elseif ($required) {
            PAGEARGERROR("Must provide '{$name}' page argument");
        } else {
            unset($GLOBALS[$name]);
        }
    }
    return $result;
}
Пример #2
0
 function LookupByIdx($idx)
 {
     $foo = new TemplateInstance($idx);
     if ($foo->IsValid()) {
         return $foo;
     }
     return null;
 }
Пример #3
0
 function Show($short = 0, $sortby = "")
 {
     global $TBDBNAME, $TBDOCBASE, $WIKIDOCURL;
     $pid = $this->pid();
     $eid = $this->eid();
     $nodecounts = array();
     # Node counts, by class.
     $query_result = DBQueryFatal("select nt.class,count(*) from reserved as r " . "left join nodes as n on n.node_id=r.node_id " . "left join node_types as nt on n.type=nt.type " . "where pid='{$pid}' and eid='{$eid}' group by nt.class");
     while ($row = mysql_fetch_array($query_result)) {
         $class = $row[0];
         $count = $row[1];
         $nodecounts[$class] = $count;
     }
     $query_result = DBQueryFatal("select e.*, s.archive_idx, pl.slicename, " . "round(e.minimum_nodes+.1,0) as min_nodes, " . "round(e.maximum_nodes+.1,0) as max_nodes " . " from experiments as e " . "left join experiment_stats as s on s.exptidx=e.idx " . "left join plab_slices as pl" . " on e.pid = pl.pid and e.eid = pl.eid " . "where e.pid='{$pid}' and e.eid='{$eid}'");
     if (($exprow = mysql_fetch_array($query_result)) == 0) {
         TBERROR("Experiment {$eid} in project {$pid} is gone!\n", 1);
     }
     $exp_gid = $exprow["gid"];
     $exp_name = $exprow["expt_name"];
     $exp_swapped = $exprow["expt_swapped"];
     $exp_swapuid = $exprow["expt_swap_uid"];
     $exp_end = $exprow["expt_end"];
     $exp_created = $exprow["expt_created"];
     $exp_head = $exprow["expt_head_uid"];
     $exp_swapper = $exprow["swapper_idx"];
     $exp_state = $exprow["state"];
     $exp_shared = $exprow["shared"];
     $exp_path = $exprow["path"];
     $batchmode = $exprow["batchmode"];
     $canceled = $exprow["canceled"];
     $attempts = $exprow["attempts"];
     $expt_locked = $exprow["expt_locked"];
     $priority = $exprow["priority"];
     $swappable = $exprow["swappable"];
     $noswap_reason = $exprow["noswap_reason"];
     $idleswap = $exprow["idleswap"];
     $idleswap_timeout = $exprow["idleswap_timeout"];
     $noidleswap_reason = $exprow["noidleswap_reason"];
     $autoswap = $exprow["autoswap"];
     $autoswap_timeout = $exprow["autoswap_timeout"];
     $idle_ignore = $exprow["idle_ignore"];
     $savedisk = $exprow["savedisk"];
     $swapreqs = $exprow["swap_requests"];
     $lastswapreq = $exprow["last_swap_req"];
     $minnodes = $exprow["min_nodes"];
     $maxnodes = $exprow["max_nodes"];
     $virtnodes = $exprow["virtnode_count"];
     $syncserver = $exprow["sync_server"];
     $mem_usage = $exprow["mem_usage"];
     $cpu_usage = $exprow["cpu_usage"];
     $exp_slice = $exprow["slicename"];
     $linktest_level = $exprow["linktest_level"];
     $linktest_pid = $exprow["linktest_pid"];
     $usemodelnet = $exprow["usemodelnet"];
     $mnet_cores = $exprow["modelnet_cores"];
     $mnet_edges = $exprow["modelnet_edges"];
     $lockdown = $exprow["lockdown"];
     $skipvlans = $exprow["skipvlans"];
     $exptidx = $exprow["idx"];
     $archive_idx = $exprow["archive_idx"];
     $dpdb = $exprow["dpdb"];
     $dpdbname = $exprow["dpdbname"];
     $dpdbpassword = $exprow["dpdbpassword"];
     $uuid = $exprow["eid_uuid"];
     $paniced = $exprow["paniced"];
     $panic_date = $exprow["panic_date"];
     $autoswap_hrs = $autoswap_timeout / 60.0;
     $idleswap_hrs = $idleswap_timeout / 60.0;
     $noswap = "({$noswap_reason})";
     $noidleswap = "({$noidleswap_reason})";
     $autoswap_str = $autoswap_hrs . " hour" . ($autoswap_hrs == 1 ? "" : "s");
     $idleswap_str = $idleswap_hrs . " hour" . ($idleswap_hrs == 1 ? "" : "s");
     if (!($head_user = User::Lookup($exp_head))) {
         TBERROR("Error getting object for user {$exp_head}", 1);
     }
     $showuser_url = CreateURL("showuser", $head_user);
     if (!($swapper = User::Lookup($exp_swapper))) {
         TBERROR("Error getting object for user {$exp_swapper}", 1);
     }
     $swapper_uid = $swapper->uid();
     $swapper_url = CreateURL("showuser", $swapper);
     if ($swappable) {
         $swappable = "Yes";
     } else {
         $swappable = "<b>No</b> {$noswap}";
     }
     if ($idleswap) {
         $idleswap = "Yes (after {$idleswap_str})";
     } else {
         $idleswap = "<b>No</b> {$noidleswap}";
     }
     if ($autoswap) {
         $autoswap = "<b>Yes</b> (after {$autoswap_str})";
     } else {
         $autoswap = "No";
     }
     if ($idle_ignore) {
         $idle_ignore = "<b>Yes</b>";
     } else {
         $idle_ignore = "No";
     }
     if ($savedisk) {
         $savedisk = "<b>Yes</b>";
     } else {
         $savedisk = "No";
     }
     if ($expt_locked) {
         $expt_locked = "({$expt_locked})";
     } else {
         $expt_locked = "";
     }
     $query_result = DBQueryFatal("select cause_desc " . "from experiment_stats as s,errors,causes " . "where s.exptidx = {$exptidx} " . "and errors.cause = causes.cause " . "and s.last_error = errors.session");
     if ($row = mysql_fetch_array($query_result)) {
         $err_cause = $row[0];
     } else {
         $err_cause = '';
     }
     #
     # Generate the table.
     #
     echo "<table align=center border=1>\n";
     if (!$short) {
         $thisurl = CreateURL("showexp", $this);
         echo "<tr>\n                <td>Name: </td>\n                <td class=left><a href='{$thisurl}'>{$eid}</a></td>\n              </tr>\n";
         echo "<tr>\n                <td>Description: </td>\n                <td class=\"left\">{$exp_name}</td>\n              </tr>\n";
         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>Group: </td>\n                <td class=\"left\">\n                  <a href='showgroup.php3?pid={$pid}&gid={$exp_gid}'>{$exp_gid}</a>\n                </td>\n              </tr>\n";
         if (isset($exp_slice)) {
             echo "<tr>\n                  <td>Planetlab Slice: </td>\n                  <td class=\"left\">{$exp_slice}</td>\n                </tr>\n";
         }
     }
     echo "<tr>\n            <td>Creator: </td>\n            <td class=\"left\">\n              <a href='{$showuser_url}'>{$exp_head}</a></td>\n          </tr>\n";
     if (!$swapper->SameUser($head_user)) {
         echo "<tr>\n                      <td>Swapper: </td>\n                      <td class=\"left\">\n                          <a href='{$swapper_url}'>{$swapper_uid}</a></td>\n                  </tr>\n";
     }
     if (!$short) {
         $instance = TemplateInstance::LookupByExptidx($exptidx);
         if (!is_null($instance)) {
             $guid = $instance->guid();
             $vers = $instance->vers();
             echo "<tr>\n                    <td>Template: </td>\n                    <td class=\"left\">\n                       <a href='template_show.php?guid={$guid}&version={$vers}'>\n                          {$guid}/{$vers}</a>";
             if ($instance->runidx()) {
                 $runidx = $instance->runidx();
                 $runid = $instance->GetRunID($runidx);
                 $url = CreateURL("experimentrun_show", $instance, "runidx", $runidx);
                 echo " (Current Run:\n                       <a href='{$url}'>{$runid}</a>)</td>";
             } else {
                 $runidx = $instance->LastRunIdx();
                 $runid = $instance->GetRunID($runidx);
                 $url = CreateURL("experimentrun_show", $instance, "runidx", $runidx);
                 echo " (Last Run:\n                       <a href='{$url}'>{$runid}</a>)</td>";
             }
             echo "</tr>\n";
         }
         echo "<tr>\n                <td>Created: </td>\n                <td class=\"left\">{$exp_created}</td>\n              </tr>\n";
         if ($exp_swapped) {
             echo "<tr>\n                    <td>Last Swap/Modify: </td>\n                    <td class=\"left\">{$exp_swapped}\n                        (<a href='{$swapper_url}'>{$swapper_uid}</a>)</td>\n                  </tr>\n";
         }
         if (ISADMIN()) {
             echo "<tr>\n                    <td><a href='{$WIKIDOCURL}/Swapping#swapping'>Swappable:</a></td>\n                    <td class=\"left\">{$swappable}</td>\n                  </tr>\n";
         }
         echo "<tr>\n                  <td><a href='{$WIKIDOCURL}/Swapping#idleswap'>Idle-Swap:</a></td>\n                  <td class=\"left\">{$idleswap}</td>\n              </tr>\n";
         echo "<tr>\n                <td><a href='{$WIKIDOCURL}/Swapping#autoswap'>Max. Duration:</a></td>\n                <td class=\"left\">{$autoswap}</td>\n              </tr>\n";
         echo "<tr>\n                <td><a href='{$WIKIDOCURL}/Swapping#swapstatesave'>Save State:</a></td>\n                <td class=\"left\">{$savedisk}</td>\n              </tr>\n";
         if (ISADMIN()) {
             echo "<tr>\n                    <td>Idle Ignore:</td>\n                    <td class=\"left\">{$idle_ignore}</td>\n                 </tr>\n";
         }
         echo "<tr>\n                <td>Path: </td>\n                <td class=left>{$exp_path}</td>\n              </tr>\n";
         echo "<tr>\n                <td>Status: </td>\n                <td id=exp_state class=\"left\">{$exp_state} {$expt_locked}</td>\n              </tr>\n";
         if ($err_cause) {
             echo "<tr>\n                    <td>Last Error: </td>\n                    <td class=\"left\"><a href=\"showlasterror.php3?pid={$pid}&eid={$eid}\">{$err_cause}</a></td>\n                  </tr>\n";
         }
         if ($paniced) {
             echo "<tr>\n                    <td>Paniced on: </td>\n                    <td class=left>{$panic_date}</td>\n                  </tr>\n";
         }
         if ($linktest_pid) {
             $linktest_running = "<b>(Linktest Running)</b>";
         } else {
             $linktest_running = "";
         }
         echo "<tr>\n                <td><a href='{$WIKIDOCURL}/linktest'>" . "Linktest Level</a>: </td>\n                <td class=\"left\">{$linktest_level} {$linktest_running}</td>\n              </tr>\n";
     }
     if (count($nodecounts)) {
         echo "<tr>\n                 <td>Reserved Nodes: </td>\n                 <td class=\"left\">\n";
         while (list($class, $count) = each($nodecounts)) {
             echo "{$count} ({$class}) &nbsp; ";
         }
         echo "   </td>\n              </tr>\n";
     } elseif (!$short) {
         if ($minnodes != "") {
             echo "<tr>\n                      <td>Min/Max Nodes: </td>\n                      <td class=\"left\"><font color=green>\n                          {$minnodes}/{$maxnodes} (estimates)</font></td>\n                  </tr>\n";
         } else {
             echo "<tr>\n                      <td>Minumum Nodes: </td>\n                      <td class=\"left\"><font color=green>Unknown</font></td>\n                  </tr>\n";
         }
         if ($virtnodes) {
             echo "<tr>\n                      <td>Virtual Nodes: </td>\n                      <td class=\"left\"><font>\n                          {$virtnodes}</font></td>\n                  </tr>\n";
         } else {
             echo "<tr>\n                      <td>Virtual Nodes: </td>\n                      <td class=\"left\"><font color=green>Unknown</font></td>\n                  </tr>\n";
         }
     }
     if (!$short) {
         if ($mem_usage || $cpu_usage) {
             echo "<tr>\n                      <td>Mem Usage Est: </td>\n                      <td class=\"left\">{$mem_usage}</td>\n                  </tr>\n";
             echo "<tr>\n                      <td>CPU Usage Est: </td>\n                      <td class=\"left\">{$cpu_usage}</td>\n                  </tr>\n";
         }
         $lastact = $this->LastAct();
         $idletime = $this->IdleTime();
         $stale = $this->IdleStale();
         if ($lastact != -1) {
             echo "<tr>\n                      <td>Last Activity: </td>\n                      <td class=\"left\">{$lastact}</td>\n                  </tr>\n";
             if ($stale) {
                 $str = "(stale)";
             } else {
                 $str = "";
             }
             echo "<tr>\n                      <td>Idle Time: </td>\n                      <td class=\"left\">{$idletime} hours {$str}</td>\n                  </tr>\n";
         }
         if (!($swapreqs == "" || $swapreqs == 0)) {
             echo "<tr>\n                      <td>Swap Requests: </td>\n                      <td class=\"left\">{$swapreqs}</td>\n                  </tr>\n";
             echo "<tr>\n                      <td>Last Swap Req.: </td>\n                      <td class=\"left\">{$lastswapreq}</td>\n                  </tr>\n";
         }
         $lockflip = $lockdown ? 0 : 1;
         $lockval = $lockdown ? "Yes" : "No";
         echo "<tr>\n                   <td>Locked Down:</td>\n                   <td>{$lockval} (<a href=toggle.php?pid={$pid}&eid={$eid}" . "&type=lockdown&value={$lockflip}>Toggle</a>)\n                   </td>\n              </tr>\n";
         if (ISADMIN() || STUDLY() || OPSGUY()) {
             $thisflip = $skipvlans ? 0 : 1;
             $flipval = $skipvlans ? "Yes" : "No";
             echo "<tr>\n                       <td>Skip Vlans:</td>\n                       <td>{$flipval} (<a href=toggle.php?pid={$pid}&eid={$eid}" . "&type=skipvlans&value={$thisflip}>Toggle</a>)\n                       </td>\n                      </tr>\n";
         }
     }
     if ($batchmode) {
         echo "<tr>\n                    <td>Batch Mode: </td>\n                    <td class=\"left\">Yes</td>\n                  </tr>\n";
         echo "<tr>\n                    <td>Start Attempts: </td>\n                    <td class=\"left\">{$attempts}</td>\n                  </tr>\n";
     }
     if ($canceled) {
         echo "<tr>\n                 <td>Cancel Flag: </td>\n                 <td class=\"left\">{$canceled}</td>\n              </tr>\n";
     }
     if (!$short) {
         if (ISADMIN()) {
             echo "<tr>\n                        <td>UUID: </td>\n                        <td class=left>{$uuid}</td>\n                      </tr>\n";
         }
         if ($usemodelnet) {
             echo "<tr>\n                      <td>Use Modelnet: </td>\n                      <td class=\"left\">Yes</td>\n                  </tr>\n";
             echo "<tr>\n                      <td>Modelnet Phys Core Nodes: </td>\n                      <td class=\"left\">{$mnet_cores}</td>\n                  </tr>\n";
             echo "<tr>\n                      <td>Modelnet Phys Edge Nodes: </td>\n                      <td class=\"left\">{$mnet_edges}</td>\n                  </tr>\n";
         }
         if (isset($syncserver)) {
             echo "<tr>\n                      <td>Sync Server: </td>\n                      <td class=\"left\">{$syncserver}</td>\n                  </tr>\n";
         }
         if ($dpdb && $dpdbname && $dpdbpassword) {
             echo "<tr>\n                      <td>DataBase Name: </td>\n                      <td class=\"left\">{$dpdbname}</td>\n                  </tr>\n";
             echo "<tr>\n                      <td>DataBase User: </td>\n                      <td class=\"left\">E{$exptidx}</td>\n                  </tr>\n";
             echo "<tr>\n                      <td>DataBase Password: </td>\n                      <td class=\"left\">{$dpdbpassword}</td>\n                  </tr>\n";
         }
         echo "<tr>\n                  <td>Index: </td>\n                  <td class=\"left\">{$exptidx}";
         if ($archive_idx) {
             echo " ({$archive_idx}) ";
         }
         echo " </td>\n              </tr>\n";
     }
     if (!$short) {
         if ($this->geniflags()) {
             $slice = GeniSlice::Lookup("geni-cm", $uuid);
             if ($slice) {
                 $slice_hrn = $slice->hrn();
                 $slice_urn = $slice->urn();
                 if (ISADMIN()) {
                     $url = CreateURL("showslice", "slice_idx", $slice->idx(), "showtype", "cm");
                     echo "<tr>\n                                <td>Geni Slice (CM): </td>\n                                <td class=\"left\">\n                                     <a href='{$url}'>{$slice_urn}</a></td>\n                              </tr>\n";
                 } else {
                     echo "<tr>\n                                <td>Geni Slice (CM): </td>\n                                <td class=\"left\">{$slice_urn}</td>\n                              </tr>\n";
                 }
             }
         } else {
             $slice = GeniSlice::LookupByExperiment("geni-sa", $this);
             if ($slice) {
                 $slice_hrn = $slice->hrn();
                 $slice_urn = $slice->urn();
                 if (ISADMIN()) {
                     $url = CreateURL("showslice", "slice_idx", $slice->idx(), "showtype", "sa");
                     echo "<tr>\n                                 <td>Geni Slice (SA): </td>\n                                 <td class=\"left\">\n                                      <a href='{$url}'>{$slice_urn}</a></td>\n                             </tr>\n";
                 } else {
                     echo "<tr>\n                                <td>Geni Slice (SA): </td>\n                                <td class=\"left\">{$slice_urn}</td>\n                              </tr>\n";
                 }
                 $slice = GeniSlice::Lookup("geni-cm", $slice_hrn);
                 if ($slice) {
                     if (ISADMIN()) {
                         $url = CreateURL("showslice", "slice_idx", $slice->idx(), "showtype", "cm");
                         echo "<tr>\n                                     <td>Geni Slice (CM): </td>\n                                     <td class=\"left\">\n                                           <a href='{$url}'>{$slice_urn}</a></td>\n                                  </tr>\n";
                     } else {
                         echo "<tr>\n                                    <td>Geni Slice (SA): </td>\n                                    <td class=\"left\">{$slice_urn}</td>\n                                  </tr>\n";
                     }
                 }
             }
         }
     }
     echo "</table>\n";
 }
Пример #4
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();