[LON-CAPA-cvs] cvs: loncom /cgi clusterstatus.pl

raeburn raeburn@source.lon-capa.org
Thu, 15 Jan 2009 22:34:18 -0000


raeburn		Thu Jan 15 22:34:18 2009 EDT

  Modified files:              
    /loncom/cgi	clusterstatus.pl 
  Log:
  - Users of clusterstatus.pl need to have a role in one of the domain(s) to which the server where the script is being run belongs.
  - Only display "Reroute to" if there are servers to which rerouting can occur.
  
  
Index: loncom/cgi/clusterstatus.pl
diff -u loncom/cgi/clusterstatus.pl:1.26 loncom/cgi/clusterstatus.pl:1.27
--- loncom/cgi/clusterstatus.pl:1.26	Thu Dec 25 01:56:03 2008
+++ loncom/cgi/clusterstatus.pl	Thu Jan 15 22:34:18 2009
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 $|=1;
 # Generates a html page showing various status reports about the domain or cluster
-# $Id: clusterstatus.pl,v 1.26 2008/12/25 01:56:03 raeburn Exp $
+# $Id: clusterstatus.pl,v 1.27 2009/01/15 22:34:18 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -260,13 +260,15 @@
 sub allreroutes {
     my $local=shift;
     &takeoffline($local);
-    print(&Apache::lonlocal::mt('Reroute to:').' <font size="1">');
-    foreach my $remote (sort keys %hostname) {
+    my $reroute;
+    foreach my $remote (sort(keys(%hostname))) {
 	unless ($local eq $remote) {
-	    &reroute($local,$remote);
+	    $reroute .= &reroute($local,$remote);
 	}
     }
-    print('</font>');
+    if ($reroute) {
+        print(&Apache::lonlocal::mt('Reroute to:').' <font size="1">'.$reroute.'</font>');
+    }
 }
 
 # ========================================================= Produce a green bar
@@ -740,8 +742,22 @@
     %hostname = %allhostname;
     $scope = 'Cluster';
 } else {
+    my $roledom = $env{'request.role.domain'}; 
+    if ((!$roledom) || ($roledom eq 'public'))  {
+        print &LONCAPA::lonauthcgi::unauthorized_msg('clusterstatus'); 
+        exit;
+    }
     undef(%hostname);
     my @poss_domains = &Apache::lonnet::current_machine_domains();
+    if (!grep(/^\Q$roledom\E$/,@poss_domains)) {
+        my $home = &Apache::lonnet::domain($roledom,'primary');
+        print &LONCAPA::lonauthcgi::unauthorized_msg('clusterstatus');
+        print '<br /><span class="LC_warning">'.&mt("You need to select a role in this server's domain ([_1]) to display domain status for this server and other servers in the domain.",$roledom).'</span><br />';
+        if ($home) {
+            print '<span class="LC_warning">'.&mt("Alternatively, you'll need to [_1]switch server[_2] to display domain status for servers in the domain of your current role ([_3]).",'<a href="/adm/switchserver?otherserver='.$home.'&role='.$env{'request.role'}.'">','</a>',$roledom).'/span>';
+        }
+        exit;
+    }
     foreach my $host (keys(%allhostname)) {
         if (grep(/^\Q$hostdom{$host}\E$/,@poss_domains)) {
             $hostname{$host} = $allhostname{$host};