Author: arkurth
Date: Mon Dec 15 21:46:41 2014
New Revision: 1645767

URL: http://svn.apache.org/r1645767
Log:
VCL-755
Fixed all locations that were using get_management_node_info()->{} to first get 
the info, check if defined, then access the hash key.

Modified:
    vcl/trunk/managementnode/lib/VCL/DataStructure.pm
    vcl/trunk/managementnode/lib/VCL/Module/OS/OSX.pm
    vcl/trunk/managementnode/lib/VCL/Module/Provisioning/vbox.pm
    vcl/trunk/managementnode/lib/VCL/healthcheck.pm
    vcl/trunk/managementnode/lib/VCL/utils.pm

Modified: vcl/trunk/managementnode/lib/VCL/DataStructure.pm
URL: 
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/DataStructure.pm?rev=1645767&r1=1645766&r2=1645767&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/DataStructure.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/DataStructure.pm Mon Dec 15 21:46:41 2014
@@ -1790,10 +1790,13 @@ sub get_management_node_public_default_g
        my $default_gateway;
        
        # Attempt to retrieve the default gateway explicitly configured for 
this management node
-       $default_gateway = get_management_node_info()->{PUBLIC_DEFAULT_GATEWAY};
-       if ($default_gateway && is_valid_ip_address($default_gateway)) {
-               notify($ERRORS{'DEBUG'}, 0, "returning default gateway 
configured in vcld.conf: $default_gateway");
-               return $default_gateway;
+       my $management_node_info = get_management_node_info();
+       if ($management_node_info) {
+               $default_gateway = 
$management_node_info->{PUBLIC_DEFAULT_GATEWAY};
+               if ($default_gateway && is_valid_ip_address($default_gateway)) {
+                       notify($ERRORS{'DEBUG'}, 0, "returning default gateway 
configured for management node: $default_gateway");
+                       return $default_gateway;
+               }
        }
        
        # Attempt to retrieve the gateway from the route command
@@ -1876,9 +1879,15 @@ sub get_management_node_public_default_g
 
 sub get_management_node_public_dns_servers {
        # Attempt to retrieve the DNS server addresses configured for this 
management node
-       my $dns_address_string = 
get_management_node_info()->{PUBLIC_DNS_SERVER};
+       my $management_node_info = get_management_node_info();
+       if (!$management_node_info) {
+               notify($ERRORS{'WARNING'}, 0, "unable to determine public DNS 
servers, management node information could not be retrieved");
+               return;
+       }
+       
+       my $dns_address_string = $management_node_info->{PUBLIC_DNS_SERVER};
        if (!$dns_address_string) {
-               notify($ERRORS{'DEBUG'}, 0, "no public dns server addresses are 
configured for the management node");
+               notify($ERRORS{'DEBUG'}, 0, "no public DNS server addresses are 
configured for the management node");
                return ();
        }
        
@@ -1898,7 +1907,13 @@ sub get_management_node_public_dns_serve
 =cut
 
 sub get_management_node_identity_key_paths {
-       my $keys_string = get_management_node_info()->{keys};
+       my $management_node_info = get_management_node_info();
+       if (!$management_node_info) {
+               notify($ERRORS{'WARNING'}, 0, "unable to determine public 
management node identity key paths, management node information could not be 
retrieved");
+               return;
+       }
+       
+       my $keys_string = $management_node_info->{keys};
        if (!$keys_string) {
                notify($ERRORS{'WARNING'}, 0, "no identity key paths are 
configured for the management node");
                return ();

Modified: vcl/trunk/managementnode/lib/VCL/Module/OS/OSX.pm
URL: 
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/OS/OSX.pm?rev=1645767&r1=1645766&r2=1645767&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/OS/OSX.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/OS/OSX.pm Mon Dec 15 21:46:41 2014
@@ -1799,14 +1799,6 @@ sub add_user {
                return 0;
        }
        
-       #Make sure the identity key was passed
-       my $image_identity = shift;
-       $image_identity = $self->data->get_image_identity() if 
(!$image_identity);
-       if (!$image_identity) {
-               notify($ERRORS{'WARNING'}, 0, "image identity keys could not be 
determined");
-               return 0;
-       }
-       
        my $useradd_cmd = $self->get_node_configuration_directory() . "/useradd 
$user_login_id $reservation_password";
        if ($self->execute($useradd_cmd,1)) {
                notify($ERRORS{'DEBUG'}, 0, "added user: $user_login_id to 
$computer_node_name");

Modified: vcl/trunk/managementnode/lib/VCL/Module/Provisioning/vbox.pm
URL: 
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/vbox.pm?rev=1645767&r1=1645766&r2=1645767&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/Provisioning/vbox.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/Provisioning/vbox.pm Mon Dec 15 
21:46:41 2014
@@ -469,7 +469,6 @@ sub capture { ## This is going to need t
 
        my $image_id       = $self->data->get_image_id;
        my $image_os_name  = $self->data->get_image_os_name;
-       my $image_identity = $self->data->get_image_identity;
        my $image_os_type  = $self->data->get_image_os_type;
        my $image_name     = $self->data->get_image_name();
 

Modified: vcl/trunk/managementnode/lib/VCL/healthcheck.pm
URL: 
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/healthcheck.pm?rev=1645767&r1=1645766&r2=1645767&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/healthcheck.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/healthcheck.pm Mon Dec 15 21:46:41 2014
@@ -613,7 +613,17 @@ sub _image_revision_check {
 sub send_report {
        my ($hck) = @_;
        
-       my $sysadmin_email = get_management_node_info()->{SYSADMIN_EMAIL};
+       my $management_node_info = get_management_node_info();
+       if (!$management_node_info) {
+               notify($ERRORS{'WARNING'}, 0, "unable to send report, 
management node information could not be retrieved");
+               return;
+       }
+       
+       my $sysadmin_email = $management_node_info->{SYSADMIN_EMAIL};
+       if (!$sysadmin_email) {
+               notify($ERRORS{'WARNING'}, 0, "unable to send report, 
management node information does not contain a SYSADMIN_EMAIL value");
+               return;
+       }
 
        #notify($ERRORS{'OK'},0,"$hck->{globalmsg}->{body}\n\n 
$hck->{globalmsg}->{failedbody}\n");
        if (defined($hck->{computercount})) {

Modified: vcl/trunk/managementnode/lib/VCL/utils.pm
URL: 
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/utils.pm?rev=1645767&r1=1645766&r2=1645767&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/utils.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/utils.pm Mon Dec 15 21:46:41 2014
@@ -3506,7 +3506,11 @@ EOF
        my $image_owner_user_info = get_user_info($image_owner_id);
        $image_info->{owner} = $image_owner_user_info;
        
-       $image_info->{IDENTITY} = get_management_node_info()->{keys};
+       # TODO: Get rid of the IDENTITY key, it shouldn't be used anymore
+       my $management_node_info = get_management_node_info();
+       if ($management_node_info) {
+               $image_info->{IDENTITY} = $management_node_info->{keys};
+       }
        
        #notify($ERRORS{'DEBUG'}, 0, "retrieved info for image 
'$image_identifier':\n" . format_data($image_info));
        $ENV{image_info}{$image_identifier} = $image_info;
@@ -3998,7 +4002,11 @@ sub run_ssh_command {
        $user = "root" if (!$user);
        $port = 22 if (!$port);
        $timeout_seconds = 0 if (!$timeout_seconds);
-       $identity_paths = get_management_node_info()->{keys} if (!defined 
$identity_paths || length($identity_paths) == 0);
+       
+       if (!defined $identity_paths || length($identity_paths) == 0) {
+               my $management_node_info = get_management_node_info();
+               $identity_paths = $management_node_info->{keys}
+       }
        
        # TESTING: use the new subroutine if $ENV{execute_new} is set and the 
command isn't one that's known to fail with the new subroutine
        if ($ENV{execute_new} && $command !~ 
/(vmkfstools|qemu-img|Convert-VHD|scp)/) {
@@ -6717,11 +6725,14 @@ EOF
        }
        
        # Check if the user's affiliation is listed in the management node's 
NOT_STANDALONE list
-       elsif (my $not_standalone_list = 
get_management_node_info()->{NOT_STANDALONE}) {
-               my $user_affiliation_name = $user_info->{affiliation}{name};
-               if (grep(/^$user_affiliation_name$/i, split(/[,;]/, 
$not_standalone_list))) {
-                       notify($ERRORS{'DEBUG'}, 0, "non-standalone affiliation 
found for user $user_login_id:\nuser affiliation: $user_affiliation_name\nnot 
standalone list: $not_standalone_list");
-                       $user_info->{STANDALONE} = 0;
+       else {
+               my $management_node_info = get_management_node_info();
+               if ($management_node_info) {
+                       my $not_standalone_list = 
$management_node_info->{NOT_STANDALONE};
+                       if (grep(/^$user_affiliation_name$/i, split(/[,;]/, 
$not_standalone_list))) {
+                               notify($ERRORS{'DEBUG'}, 0, "non-standalone 
affiliation found for user $user_login_id:\nuser affiliation: 
$user_affiliation_name\nnot standalone list: $not_standalone_list");
+                               $user_info->{STANDALONE} = 0;
+                       }
                }
        }
        


Reply via email to