cluster-status.php 3.36 KB
Newer Older
1 2
<?php
#
3
# Copyright (c) 2000-2018 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 23 24 25 26 27 28 29
# 
# {{{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/>.
# 
# }}}
#
chdir("..");
include("defs.php3");
include_once("geni_defs.php");
chdir("apt");
include("quickvm_sup.php");
include_once("instance_defs.php");
30
include_once("aggregate_defs.php");
31 32 33 34 35 36 37 38 39 40
$page_title = "Cluster Status";

#
# Get current user.
#
RedirectSecure();
$this_user = CheckLoginOrRedirect();
$isadmin   = (ISADMIN() ? 1 : 0);
$isfadmin  = (ISFOREIGN_ADMIN() ? 1 : 0);

41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
#
# Verify page arguments. Cluster is a domain that we turn into a URN.
#
$optargs = OptionalPageArguments("cluster",  PAGEARG_STRING);

if (isset($cluster)) {
    $aggregate = Aggregate::LookupByNickname($cluster);
    if (!$aggregate) {
        SPITUSERERROR("No such cluster: $cluster");
        exit();
    }
    if ($aggregate->adminonly() && !($isadmin || $isfadmin)) {
        SPITUSERERROR("No permission to view cluster: $cluster");
        exit();
    }
}
57 58 59 60 61 62
SPITHEADER(1);

#
# The apt_aggregates table should tell us what clusters, but for
# now it is always the local cluster
#
63 64 65 66
if (isset($aggregate)) {
    $aggregates = array($aggregate->nickname() => $aggregate->urn());
}
elseif ($TBMAINSITE && $ISCLOUD) {
67 68 69 70 71
    $aggregates =
        array("Emulab"    => "urn:publicid:IDN+emulab.net+authority+cm",
              "APT"       => "urn:publicid:IDN+apt.emulab.net+authority+cm",
              "Wisconsin" => "urn:publicid:IDN+wisc.cloudlab.us+authority+cm",
              "Clemson"   => "urn:publicid:IDN+clemson.cloudlab.us+authority+cm",
Leigh Stoller's avatar
Leigh Stoller committed
72 73
              "Utah"      => "urn:publicid:IDN+utah.cloudlab.us+authority+cm",
              "OneLab"    => "urn:publicid:IDN+lab.onelab.eu+authority+cm");
74 75
}
else {
Leigh Stoller's avatar
Leigh Stoller committed
76 77
    $aggregate  = Aggregate::Lookup($DEFAULT_AGGREGATE_URN);
    $aggregates = array($aggregate->nickname() => $aggregate->urn());
78
}
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
echo "<link rel='stylesheet'
            href='css/tablesorter.css'>\n";

# Place to hang the toplevel template.
echo "<div id='page-body'></div>\n";

echo "<script type='text/javascript'>\n";
echo "    window.ISADMIN    = $isadmin;\n";
echo "    window.ISFADMIN   = $isfadmin;\n";
echo "</script>\n";

echo "<script type='text/plain' id='agglist-json'>\n";
echo htmlentities(json_encode($aggregates)) . "\n";
echo "</script>\n";

94 95 96 97
REQUIRE_UNDERSCORE();
REQUIRE_SUP();
REQUIRE_MOMENT();
SPITREQUIRE("js/cluster-status.js",
98 99 100 101
            "<script src='js/lib/jquery.tablesorter.min.js'></script>".
            "<script src='js/lib/jquery.tablesorter.widgets.min.js'></script>".
            "<script src='js/lib/sugar.min.js'></script>".
            "<script src='js/lib/jquery.tablesorter.parser-date.js'></script>");
102 103

AddTemplateList(array("cluster-status", "cluster-status-templates"));
104 105
SPITFOOTER();
?>