You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vcl.apache.org by ar...@apache.org on 2015/02/06 23:32:42 UTC
svn commit: r1657980 - in /vcl/trunk/managementnode/lib/VCL: new.pm
reserved.pm utils.pm
Author: arkurth
Date: Fri Feb 6 22:32:42 2015
New Revision: 1657980
URL: http://svn.apache.org/r1657980
Log:
VCL-814
Moved code which sends the ready for connection email from new.pm to reserved.pm. The email now gets sent immediately after the Connect button appears.
VCL-174
Updated utils.pm::update_sublog_ipaddress. It was only handling a single sublog entry per request, meaning the sublog.IPaddress value was not being updated correctly for cluster requests. Changed it to accept a sublog.id argument. Updated the call to update_sublog_ipaddress in new.pm::reserve_computer to pass the updated arguments.
Modified:
vcl/trunk/managementnode/lib/VCL/new.pm
vcl/trunk/managementnode/lib/VCL/reserved.pm
vcl/trunk/managementnode/lib/VCL/utils.pm
Modified: vcl/trunk/managementnode/lib/VCL/new.pm
URL: http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/new.pm?rev=1657980&r1=1657979&r2=1657980&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/new.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/new.pm Fri Feb 6 22:32:42 2015
@@ -903,19 +903,11 @@ sub reserve_computer {
my $self = shift;
my $request_id = $self->data->get_request_id();
- my $request_state_name = $self->data->get_request_state_name();
- my $request_logid = $self->data->get_request_log_id();
+ my $sublog_id = $self->data->get_sublog_id();
my $reservation_is_parent = $self->data->is_parent_reservation;
my $reservation_id = $self->data->get_reservation_id();
my $computer_id = $self->data->get_computer_id();
my $computer_short_name = $self->data->get_computer_short_name();
- my $image_prettyname = $self->data->get_image_prettyname();
- my $user_affiliation_sitewwwaddress = $self->data->get_user_affiliation_sitewwwaddress();
- my $user_affiliation_helpaddress = $self->data->get_user_affiliation_helpaddress();
- my $user_email = $self->data->get_user_email();
- my $user_emailnotices = $self->data->get_user_emailnotices();
- my $user_imtype_name = $self->data->get_user_imtype_name();
- my $user_im_id = $self->data->get_user_im_id();
# Needed for computerloadflow
insertloadlog($reservation_id, $computer_id, "addinguser", "Adding user to $computer_short_name");
@@ -936,11 +928,8 @@ sub reserve_computer {
my $computer_public_ip_address = $self->data->get_computer_public_ip_address();
# Update sublog table with the IP address of the machine
- if (update_sublog_ipaddress($request_logid, $computer_public_ip_address)) {
- notify($ERRORS{'DEBUG'}, 0, "updated computer IP address in sublog table, log ID: $request_logid, IP address: $computer_public_ip_address");
- }
- else {
- notify($ERRORS{'WARNING'}, 0, "could not update sublog $request_logid for node $computer_short_name IP address $computer_public_ip_address");
+ if (!update_sublog_ipaddress($sublog_id, $computer_public_ip_address)) {
+ notify($ERRORS{'WARNING'}, 0, "could not update sublog $sublog_id for node $computer_short_name IP address $computer_public_ip_address");
}
# Check if request has been deleted
@@ -949,63 +938,6 @@ sub reserve_computer {
$self->state_exit('', 'available');
}
- my $mailstring;
- my $subject;
-
- # Assemble the message body reservations
- if ($request_state_name =~ /^(reinstall)$/) {
- $subject = "VCL -- $image_prettyname reservation reinstalled";
-
- $mailstring = <<"EOF";
-Your reservation was successfully reinstalled and you can proceed to reconnect.
-Please revisit the 'Current Reservations' page for any additional information.
-EOF
- }
- else {
- $subject = "VCL -- $image_prettyname reservation";
-
- $mailstring = <<"EOF";
-The resources for your VCL reservation have been successfully reserved.
-Connection will not be allowed until you click the 'Connect' button on the 'Current Reservations' page.
-You must acknowledge the reservation within the next 15 minutes or the resources will be reclaimed for other VCL users.
-
--Visit $user_affiliation_sitewwwaddress
--Select "Current Reservations"
--Click the "Connect" button
-Upon acknowledgement, all of the remaining connection details will be displayed.
-EOF
- }
-
- $mailstring .= <<"EOF";
-
-Thank You,
-VCL Team
-
-******************************************************************
-This is an automated notice. If you need assistance please respond
-with detailed information on the issue and a help ticket will be
-generated.
-
-To disable email notices
--Visit $user_affiliation_sitewwwaddress
--Select User Preferences
--Select General Preferences
-
-******************************************************************
-EOF
-
- if ($user_emailnotices) {
- mail($user_email, $subject, $mailstring, $user_affiliation_helpaddress);
- }
- else {
- # For email record keeping
- notify($ERRORS{'MAILMASTERS'}, 0, " $user_email\n$mailstring");
- }
-
- if ($user_imtype_name ne "none") {
- notify_via_im($user_imtype_name, $user_im_id, $mailstring, $user_affiliation_helpaddress);
- }
-
return 1;
} ## end sub reserve_computer
Modified: vcl/trunk/managementnode/lib/VCL/reserved.pm
URL: http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/reserved.pm?rev=1657980&r1=1657979&r2=1657980&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/reserved.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/reserved.pm Fri Feb 6 22:32:42 2015
@@ -116,6 +116,10 @@ sub process {
update_computer_state($computer_id, 'reserved');
insertloadlog($reservation_id, $computer_id, "reserved", "$computer_short_name successfully reserved");
+ # Send an email and/or IM to the user
+ # Do this after updating the computer state to reserved because this is when the Connect button appears
+ $self->_notify_user_ready();
+
# Insert acknowledgetimeout immediately before beginning to check user clicked Connect
# Web uses timestamp of this to determine when next to refresh the page
# Important because page should refresh as soon as possible to reservation timing out
@@ -343,6 +347,91 @@ sub user_acknowledged {
#/////////////////////////////////////////////////////////////////////////////
+=head2 _notify_user_ready
+
+ Parameters : none
+ Returns : boolean
+ Description : Notifies the user that the reservation is ready.
+
+=cut
+
+sub _notify_user_ready {
+ my $self = shift;
+
+ #my $request_id = $self->data->get_request_id();
+ my $request_state_name = $self->data->get_request_id();
+ #my $reservation_id = $self->data->get_reservation_id();
+ my $user_email = $self->data->get_user_email();
+ my $user_emailnotices = $self->data->get_user_emailnotices();
+ my $user_imtype_name = $self->data->get_user_imtype_name();
+ my $user_im_id = $self->data->get_user_im_id();
+ my $affiliation_sitewwwaddress = $self->data->get_user_affiliation_sitewwwaddress();
+ my $affiliation_helpaddress = $self->data->get_user_affiliation_helpaddress();
+ my $image_prettyname = $self->data->get_image_prettyname();
+ my $is_parent_reservation = $self->data->is_parent_reservation();
+
+ my $mailstring;
+ my $subject;
+
+ # Assemble the message body reservations
+ if ($request_state_name =~ /^(reinstall)$/) {
+ $subject = "VCL -- $image_prettyname reservation reinstalled";
+
+ $mailstring = <<"EOF";
+Your reservation was successfully reinstalled and you can proceed to reconnect.
+Please revisit the 'Current Reservations' page for any additional information.
+EOF
+ }
+ else {
+ $subject = "VCL -- $image_prettyname reservation";
+
+ $mailstring = <<"EOF";
+The resources for your VCL reservation have been successfully reserved.
+Connection will not be allowed until you click the 'Connect' button on the 'Current Reservations' page.
+You must acknowledge the reservation within the next 15 minutes or the resources will be reclaimed for other VCL users.
+
+-Visit $affiliation_sitewwwaddress
+-Select "Current Reservations"
+-Click the "Connect" button
+Upon acknowledgement, all of the remaining connection details will be displayed.
+EOF
+ }
+
+ $mailstring .= <<"EOF";
+
+Thank You,
+VCL Team
+
+******************************************************************
+This is an automated notice. If you need assistance please respond
+with detailed information on the issue and a help ticket will be
+generated.
+
+To disable email notices
+-Visit $affiliation_sitewwwaddress
+-Select User Preferences
+-Select General Preferences
+
+******************************************************************
+EOF
+
+ if ($is_parent_reservation && $user_emailnotices) {
+ mail($user_email, $subject, $mailstring, $affiliation_helpaddress);
+ }
+ else {
+ # For email record keeping
+ notify($ERRORS{'MAILMASTERS'}, 0, " $user_email\n$mailstring");
+ }
+
+ if ($user_imtype_name ne "none") {
+ notify_via_im($user_imtype_name, $user_im_id, $mailstring, $affiliation_helpaddress);
+ }
+
+ return 1;
+} ## end sub _notify_user_no_login
+
+#/////////////////////////////////////////////////////////////////////////////
+
=head2 _notify_user_no_login
Parameters : none
Modified: vcl/trunk/managementnode/lib/VCL/utils.pm
URL: http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/utils.pm?rev=1657980&r1=1657979&r2=1657980&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/utils.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/utils.pm Fri Feb 6 22:32:42 2015
@@ -5908,35 +5908,41 @@ sub clearfromblockrequest {
=head2 update_sublog_ipaddress
- Parameters : $computer_id, $computer_public_ip_address
- Returns : 0 or 1
- Description : updates log table with IPaddress of node when dynamic dhcp is
- enabled there is no way to track which IP was used
+ Parameters : $sublog_id, $computer_public_ip_address
+ Returns : boolean
+ Description : Updates the sublog table with the public IP address of the
+ computer.
=cut
sub update_sublog_ipaddress {
- my ($logid, $computer_public_ip_address) = @_;
- my ($package, $filename, $line, $sub) = caller(0);
- # Check the passed parameter
- if (!(defined($computer_public_ip_address))) {
- notify($ERRORS{'WARNING'}, 0, "computer public IP address argument was not specified");
- return 0;
+ my ($sublog_id, $computer_public_ip_address) = @_;
+ if (!defined($sublog_id)) {
+ notify($ERRORS{'WARNING'}, 0, "sublog ID argument was not specified");
+ return;
}
- if (!(defined($logid))) {
- notify($ERRORS{'WARNING'}, 0, "logid was not specified");
- return 0;
+ elsif (!defined($computer_public_ip_address)) {
+ notify($ERRORS{'WARNING'}, 0, "computer public IP address argument was not specified");
+ return;
}
# Construct the SQL statement
- my $sql_statement = "UPDATE sublog SET IPaddress = \'$computer_public_ip_address\' WHERE logid=$logid";
+ my $sql_statement = <<EOF;
+UPDATE
+sublog
+SET
+sublog.IPaddress = '$computer_public_ip_address'
+WHERE
+sublog.id = $sublog_id
+EOF
# Call the database execute subroutine
if (database_execute($sql_statement)) {
+ notify($ERRORS{'DEBUG'}, 0, "updated sublog table, sublog ID: $sublog_id, IP address: $computer_public_ip_address");
return 1;
}
else {
- notify($ERRORS{'WARNING'}, 0, "unable to update sublog table logid = $logid with ipaddress $computer_public_ip_address");
+ notify($ERRORS{'WARNING'}, 0, "failed to update sublog table, sublog ID: $sublog_id, IP address: $computer_public_ip_address");
return 0;
}
} ## end sub update_sublog_ipaddress