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 2008/12/19 17:58:21 UTC

svn commit: r728065 - /incubator/vcl/trunk/managementnode/lib/VCL/utils.pm

Author: fapeeler
Date: Fri Dec 19 08:58:21 2008
New Revision: 728065

URL: http://svn.apache.org/viewvc?rev=728065&view=rev
Log:
getdynamicaddress - fixed checks for private address 127. 172., 192.,
address ranges. Previously could capture wrong address for win OS's. 
If someone installs a hypervisor or creates any additional adapters,
this routine needs to know which one is the public address to handout.

Modified:
    incubator/vcl/trunk/managementnode/lib/VCL/utils.pm

Modified: incubator/vcl/trunk/managementnode/lib/VCL/utils.pm
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/utils.pm?rev=728065&r1=728064&r2=728065&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/utils.pm (original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/utils.pm Fri Dec 19 08:58:21 2008
@@ -121,6 +121,7 @@
   get_management_node_id
   get_management_node_info
   get_management_node_requests
+  get_management_predictive_info
   get_next_image_default
   get_production_imagerevision_info
   get_request_by_computerid
@@ -1651,7 +1652,12 @@
 
 		@sshcmd = run_ssh_command($node, $identity, "netsh diag show ip", "root");
 		for my $l (@{$sshcmd[1]}) {
+			# skip class a,b,c private addresses
 			next if ($l =~ /IPAddress = $privateIP/);
+			next if ($l =~ /inet addr:10.([.0-9]*)/);
+			next if ($l =~ /inet addr:127([.0-9]*)/);
+			next if ($l =~ /inet addr:172([.0-9]*)/);
+			next if ($l =~ /inet addr:192.168([.0-9]*)/);
 			if ($l =~ /IPAddress = ([.0-9]*)/) {
 				if ($l !~ /IPAddress = $privateIP/) {
 					#to cover sites using eth0 as public
@@ -7079,6 +7085,80 @@
 
 #/////////////////////////////////////////////////////////////////////////////
 
+=head2 get_management_predictive_info
+
+ Parameters  : Either a management node hostname or database ID
+ Returns     : Hash containing data contained in the managementnode table
+ Description :
+
+=cut
+
+sub get_management_predictive_info {
+	my ($management_node_identifier) = @_;
+
+	my ($package, $filename, $line, $sub) = caller(0);
+
+	# Check the passed parameter
+	if (!(defined($management_node_identifier))) {
+		# If nothing was passed, assume management node is this machine
+		# Try to get the hostname of this machine
+		unless ($management_node_identifier = (hostname())[0]) {
+			notify($ERRORS{'WARNING'}, 0, "management node hostname or ID was not specified and hostname could not be determined");
+			return ();
+		}
+	}
+
+	my $select_statement = "
+   SELECT
+   managementnode.*,
+   predictivemodule.name AS predictive_name,
+   predictivemodule.prettyname AS predictive_prettyname,
+   predictivemodule.description AS predictive_description,
+   predictivemodule.perlpackage  AS predictive_perlpackage,
+	state.name AS statename
+   FROM
+   managementnode,
+   module predictivemodule,
+	state
+   WHERE
+   managementnode.predictivemoduleid = predictivemodule.id
+	AND managementnode.stateid = state.id
+   AND
+   ";
+
+	# Figure out if the ID or hostname was passed as the identifier and complete the SQL statement
+	# Check if it only contains digits
+	chomp $management_node_identifier;
+	if ($management_node_identifier =~ /^\d+$/) {
+		$select_statement .= "managementnode.id = $management_node_identifier";
+	}
+	else {
+		$select_statement .= "managementnode.hostname like \'$management_node_identifier%\'";
+	}
+
+	# Call the database select subroutine
+	# This will return an array of one or more rows based on the select statement
+	my @selected_rows = database_select($select_statement);
+
+	# Check to make sure 1 row was returned
+	if (scalar @selected_rows == 0) {
+		notify($ERRORS{'WARNING'}, 0, "zero rows were returned from database select");
+		return ();
+	}
+	elsif (scalar @selected_rows > 1) {
+		notify($ERRORS{'WARNING'}, 0, "" . scalar @selected_rows . " rows were returned from database select");
+		return ();
+	}
+	# Get the single returned row
+	# It contains a hash
+	my $management_node_info = $selected_rows[0];
+
+	notify($ERRORS{'DEBUG'}, 0, "management node info retrieved from database ");
+	return $management_node_info;
+}
+
+#/////////////////////////////////////////////////////////////////////////////
+
 =head2 get_management_node_id
 
  Parameters  : Either a management node hostname or database ID