You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vcl.apache.org by fa...@apache.org on 2014/11/19 18:59:41 UTC
svn commit: r1640613 - in /vcl/trunk/managementnode/lib/VCL: Module/OS.pm
reserved.pm utils.pm
Author: fapeeler
Date: Wed Nov 19 17:59:40 2014
New Revision: 1640613
URL: http://svn.apache.org/r1640613
Log:
VCL-799
moved update_cluster_info to OS.pm
Modified:
vcl/trunk/managementnode/lib/VCL/Module/OS.pm
vcl/trunk/managementnode/lib/VCL/reserved.pm
vcl/trunk/managementnode/lib/VCL/utils.pm
Modified: vcl/trunk/managementnode/lib/VCL/Module/OS.pm
URL: http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/OS.pm?rev=1640613&r1=1640612&r2=1640613&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/OS.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/OS.pm Wed Nov 19 17:59:40 2014
@@ -53,6 +53,7 @@ use warnings;
use diagnostics;
use English '-no_match_vars';
use Net::SSH::Expect;
+use List::Util qw(min max);
use VCL::utils;
@@ -3663,6 +3664,90 @@ sub firewall_compare_update {
return !$error_encountered;
}
+#/////////////////////////////////////////////////////////////////////////////
+
+=head2 update_cluster_info
+
+ Parameters :data hash
+ Returns : 0 or 1
+ Description :
+
+=cut
+
+sub update_cluster_info {
+
+ my $self = shift;
+ if (ref($self) !~ /VCL::Module/i) {
+ notify($ERRORS{'CRITICAL'}, 0, "subroutine was called as a function, it must be called as a class method");
+ return;
+ }
+
+ my $reservation_id = $self->data->get_reservation_id();
+ my $computer_short_name = $self->data->get_computer_short_name();
+ my $image_OS_type = $self->data->get_image_os_type();
+ my $is_cluster_parent = $self->data->get_request_is_cluster_parent();
+ my $is_cluster_child = $self->data->get_request_is_cluster_child();
+
+ my $cluster_info = "/tmp/$computer_short_name.cluster_info";
+ my @cluster_string = "";
+
+ #Get all the request data
+ my $request_data = $self->data->get_request_data();
+
+ my @reservation_ids = sort keys %{$request_data->{reservation}};
+
+ # parent reservation id lowest
+ my $parent_reservation_id = min @reservation_ids;
+ notify($ERRORS{'DEBUG'}, 0, "$computer_short_name is_cluster_parent = $is_cluster_parent ");
+ notify($ERRORS{'DEBUG'}, 0, "$computer_short_name is_cluster_child = $is_cluster_child ");
+ notify($ERRORS{'DEBUG'}, 0, "parent_reservation_id = $parent_reservation_id ");
+
+ foreach my $rid (keys %{$request_data->{reservation}}) {
+ if ($rid == $parent_reservation_id) {
+ push(@cluster_string, "parent= $request_data->{reservation}{$rid}{computer}{IPaddress}" . "\n");
+ notify($ERRORS{'DEBUG'}, 0, "writing parent= $request_data->{reservation}{$rid}{computer}{IPaddress}");
+ }
+ else {
+ push(@cluster_string, "child= $request_data->{reservation}{$rid}{computer}{IPaddress}" . "\n");
+ notify($ERRORS{'DEBUG'}, 0, "writing child= $request_data->{reservation}{$rid}{computer}{IPaddress}");
+ }
+ }
+
+ if (open(CLUSTERFILE, ">$cluster_info")) {
+ print CLUSTERFILE @cluster_string;
+ close(CLUSTERFILE);
+ }
+ else {
+ notify($ERRORS{'OK'}, 0, "could not write to $cluster_info");
+ }
+
+ my $identity;
+ #scp cluster file to each node
+ my $targetpath;
+ foreach my $resid (keys %{$request_data->{reservation}}) {
+ $identity = $request_data->{reservation}{$resid}{image}{IDENTITY};
+ my $node_name = $request_data->{reservation}{$resid}{computer}{SHORTNAME};
+ if ($image_OS_type =~ /linux/i) {
+ $targetpath = "$node_name:/etc/cluster_info";
+ }
+ elsif ($image_OS_type =~ /windows/i) {
+ $targetpath = "$node_name:C:\/cluster_info";
+ }
+ else {
+ $targetpath = "$node_name:/etc/cluster_info";
+ }
+
+ if (run_scp_command($cluster_info, $targetpath, $identity)) {
+ notify($ERRORS{'OK'}, 0, " successfully copied cluster_info file to $node_name");
+ }
+ } ## end foreach my $resid (keys %{$request_data->{reservation...
+
+ unlink $cluster_info;
+
+ return 1;
+
+} ## end sub update_cluster_info
+
#///////////////////////////////////////////////////////////////////////////
1;
Modified: vcl/trunk/managementnode/lib/VCL/reserved.pm
URL: http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/reserved.pm?rev=1640613&r1=1640612&r2=1640613&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/reserved.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/reserved.pm Wed Nov 19 17:59:40 2014
@@ -115,23 +115,23 @@ sub process {
$self->_notify_user_timeout($request_data);
switch_state($request_data, 'timeout', 'timeout', 'noack', 1);
}
-
- # User acknowledged request
- # Add the cluster information to the loaded computers if this is a cluster reservation
- if ($reservation_count > 1 && !update_cluster_info($request_data)) {
- $self->reservation_failed("update_cluster_info failed");
- }
-
+
# Call OS module's grant_access() subroutine which adds user accounts to computer
if ($self->os->can("grant_access") && !$self->os->grant_access()) {
$self->reservation_failed("OS module grant_access failed");
}
-
+
# Add additional user accounts, perform other configuration tasks if this is a server request
if ($server_request_id && !$self->os->manage_server_access()) {
$self->reservation_failed("OS module manage_server_access failed");
}
+ # User acknowledged request
+ # Add the cluster information to the loaded computers if this is a cluster reservation
+ if ($reservation_count > 1 && !$self->os->update_cluster_info()) {
+ $self->reservation_failed("update_cluster_info failed");
+ }
+
# Check if OS module's post_reserve() subroutine exists
if ($self->os->can("post_reserve") && !$self->os->post_reserve()) {
$self->reservation_failed("OS module post_reserve failed");
Modified: vcl/trunk/managementnode/lib/VCL/utils.pm
URL: http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/utils.pm?rev=1640613&r1=1640612&r2=1640613&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/utils.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/utils.pm Wed Nov 19 17:59:40 2014
@@ -238,7 +238,6 @@ our @EXPORT = qw(
update_changelog_request_user_remote_ip
update_changelog_reservation_remote_ip
update_changelog_reservation_user_remote_ip
- update_cluster_info
update_computer_imagename
update_computer_lastcheck
update_computer_private_ip_address
@@ -7284,88 +7283,6 @@ sub insert_reload_request {
#/////////////////////////////////////////////////////////////////////////////
-=head2 update_cluster_info
-
- Parameters :data hash
- Returns : 0 or 1
- Description :
-
-=cut
-
-sub update_cluster_info {
-
- my ($request_data) = @_;
- my ($package, $filename, $line, $sub) = caller(0);
- my ($calling_package, $calling_filename, $calling_line, $calling_sub) = caller(0);
-
- my $reservation_id = $request_data->{RESERVATIONID};
- my $computer_short_name = $request_data->{reservation}{$reservation_id}{computer}{SHORTNAME};
- my $image_OS_type = $request_data->{reservation}{$reservation_id}{image}{OS}{type};
- my $is_cluster_parent = $request_data->{PARENTIMAGE};
- my $is_cluster_child = $request_data->{SUBIMAGE};
-
- my $cluster_info = "/tmp/$computer_short_name.cluster_info";
- my @cluster_string = "";
-
-
-
- my @reservation_ids = sort keys %{$request_data->{reservation}};
-
- # parent reservation id lowest
- my $parent_reservation_id = min @reservation_ids;
- notify($ERRORS{'DEBUG'}, 0, "$computer_short_name is_cluster_parent = $is_cluster_parent ");
- notify($ERRORS{'DEBUG'}, 0, "$computer_short_name is_cluster_child = $is_cluster_child ");
- notify($ERRORS{'DEBUG'}, 0, "parent_reservation_id = $parent_reservation_id ");
-
- foreach my $rid (keys %{$request_data->{reservation}}) {
- if ($rid == $parent_reservation_id) {
- push(@cluster_string, "parent= $request_data->{reservation}{$rid}{computer}{IPaddress}" . "\n");
- notify($ERRORS{'DEBUG'}, 0, "writing parent= $request_data->{reservation}{$rid}{computer}{IPaddress}");
- }
- else {
- push(@cluster_string, "child= $request_data->{reservation}{$rid}{computer}{IPaddress}" . "\n");
- notify($ERRORS{'DEBUG'}, 0, "writing child= $request_data->{reservation}{$rid}{computer}{IPaddress}");
- }
- }
-
-
- if (open(CLUSTERFILE, ">$cluster_info")) {
- print CLUSTERFILE @cluster_string;
- close(CLUSTERFILE);
- }
- else {
- notify($ERRORS{'OK'}, 0, "could not write to $cluster_info");
- }
-
- my $identity;
- #scp cluster file to each node
- my $targetpath;
- foreach my $rid (keys %{$request_data->{reservation}}) {
- $identity = $request_data->{reservation}{$rid}{image}{IDENTITY};
- my $node_name = $request_data->{reservation}{$rid}{computer}{SHORTNAME};
- if ($image_OS_type =~ /linux/i) {
- $targetpath = "$node_name:/etc/cluster_info";
- }
- elsif ($image_OS_type =~ /windows/i) {
- $targetpath = "$node_name:C:\/cluster_info";
- }
- else {
- $targetpath = "$node_name:/etc/cluster_info";
- }
-
- if (run_scp_command($cluster_info, $targetpath, $identity)) {
- notify($ERRORS{'OK'}, 0, " successfully copied cluster_info file to $node_name");
- }
- } ## end foreach my $rid (keys %{$request_data->{reservation...
-
- unlink $cluster_info;
-
- return 1;
-
-} ## end sub update_cluster_info
-
-#/////////////////////////////////////////////////////////////////////////////
-
=head2 format_data
Parameters : $data