Author: fapeeler
Date: Wed Apr 23 19:33:21 2014
New Revision: 1589498
URL: http://svn.apache.org/r1589498
Log:
VCL-736
using write command now
added ability to extend other OS's. Need to add notify_via_console routine
Modified:
vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm
vcl/trunk/managementnode/lib/VCL/inuse.pm
Modified: vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm
URL:
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm?rev=1589498&r1=1589497&r2=1589498&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm Wed Apr 23 19:33:21 2014
@@ -4667,6 +4667,48 @@ sub command_exists {
}
}
+#/////////////////////////////////////////////////////////////////////////////
+
+=head2 notify_user_console
+
+ Parameters : message, username(optional)
+ Returns : boolean
+ Description : Send a message to the user on the console
+
+=cut
+
+sub notify_user_console {
+ my $self = shift;
+ if (ref($self) !~ /Module/i) {
+ notify($ERRORS{'CRITICAL'}, 0, "subroutine was called as a
function, it must be called as a class method");
+ return;
+ }
+
+ my $message = shift;
+ if(!$message) {
+ notify($ERRORS{'WARNING'}, 0, "message argument was not
supplied");
+ return;
+ }
+
+ my $username = shift;
+ if (!$username) {
+ $username = $self->data->get_user_login_id();
+ }
+
+ my $computer_node_name = $self->data->get_computer_node_name();
+
+ my $cmd = "echo $message \| write $username";
+ my ($exit_status, $output) = $self->execute($cmd, 1);
+ if (!defined($output)) {
+ notify($ERRORS{'WARNING'}, 0, "failed to execute command to
determine if the '$cmd' shell command exists on $computer_node_name");
+ return;
+ }
+ else {
+ notify($ERRORS{'DEBUG'}, 0, "executed command to determine if
the '$cmd' shell command exists on $computer_node_name");
+ return 1;
+ }
+}
+
##/////////////////////////////////////////////////////////////////////////////
1;
__END__
Modified: vcl/trunk/managementnode/lib/VCL/inuse.pm
URL:
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/inuse.pm?rev=1589498&r1=1589497&r2=1589498&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/inuse.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/inuse.pm Wed Apr 23 19:33:21 2014
@@ -513,6 +513,13 @@ EOF
else {
notify($ERRORS{'DEBUG'}, 0, "user $user_login_id email notices
disabled - not notifying user of endtime");
}
+
+ # notify via console
+ if ( $self->os->can('notify_user_console') ) {
+ if ( $self->os->notify_user_console($short_message) ) {
+ notify($ERRORS{'DEBUG'}, 0, "Successfully notified user
$user_login_id via console method");
+ }
+ }
# Send message to machine
if ($computer_type =~ /blade|virtualmachine/) {
@@ -666,6 +673,13 @@ EOF
if ($is_parent_reservation && $user_emailnotices) {
mail($user_email, $subject, $message,
$user_affiliation_helpaddress);
}
+
+ # notify via console
+ if ( $self->os->can('notify_user_console') ) {
+ if ( $self->os->notify_user_console($short_message) ) {
+ notify($ERRORS{'DEBUG'}, 0, "Successfully notified user
$user_login_id via console method");
+ }
+ }
# Send IM
if ($is_parent_reservation && $user_imtype_name ne "none") {