Author: arkurth
Date: Mon Jun 15 16:51:15 2009
New Revision: 784858
URL: http://svn.apache.org/viewvc?rev=784858&view=rev
Log:
VCL-158
Added keys to hash in DataStructure.pm to allow management node static IP
parameters to be accessed.
Added code to add static IP configuration information to the hash returned by
get_management_node_info().
Added the following subs to Windows_mod.pm:
get_public_default_gateway()
get_private_subnet_mask()
set_static_public_address()
set_static_private_address()
delete_default_routes()
set_public_default_route()
Updated xCAT.pm, xCAT21.pm, and vmware.pm to check if the OS module has
implemented a set_static_public_address() function. This gets called instead of
utils.pm::setstaticaddress().
VCL-159
Changed wait time for ssh to respond from approximately 5 minutes to 10.
Updated power_off() and power_on() to call wait_for_on/off() after executing
rpower instead of simply waiting 2 seconds. They now wait up to 1 minute for
the node to power on or off.
Updated wait_for_on/off() to accept node name arguments instead of requiring
VCL-23
Changed Windows_mod.pm's get_private_ip_addresses() and
get_public_ip_addresses() sub to return single values and renamed them
accordingly. Updated subroutines in Version_6.pm which call this. Version_6.pm
is the only module using these subs.
Other
Added code to utils.pm::run_ssh_command() to use the managementnode SSH keys
value if no identity key paths are provided as an argument.
Modified:
incubator/vcl/trunk/managementnode/lib/VCL/DataStructure.pm
incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows_mod.pm
incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows_mod/Version_6.pm
incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/vmware.pm
incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT.pm
incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT21.pm
incubator/vcl/trunk/managementnode/lib/VCL/utils.pm
Modified: incubator/vcl/trunk/managementnode/lib/VCL/DataStructure.pm
URL:
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/DataStructure.pm?rev=784858&r1=784857&r2=784858&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/DataStructure.pm (original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/DataStructure.pm Mon Jun 15
16:51:15 2009
@@ -460,6 +460,11 @@
$SUBROUTINE_MAPPINGS{management_node_predictive_module_id} =
'$ENV{management_node_info}{predictivemoduleid}';
$SUBROUTINE_MAPPINGS{management_node_ssh_port} =
'$ENV{management_node_info}{sshport}';
+$SUBROUTINE_MAPPINGS{management_node_public_ip_configuration} =
'$ENV{management_node_info}{PUBLIC_IP_CONFIGURATION}';
+$SUBROUTINE_MAPPINGS{management_node_public_subnet_mask} =
'$ENV{management_node_info}{PUBLIC_SUBNET_MASK}';
+$SUBROUTINE_MAPPINGS{management_node_public_default_gateway} =
'$ENV{management_node_info}{PUBLIC_DEFAULT_GATEWAY}';
+$SUBROUTINE_MAPPINGS{management_node_public_dns_server} =
'$ENV{management_node_info}{PUBLIC_DNS_SERVER}';
+
$SUBROUTINE_MAPPINGS{management_node_predictive_module_name} =
'$ENV{management_node_info}{predictive_name}';
$SUBROUTINE_MAPPINGS{management_node_predictive_module_pretty_name} =
'$ENV{management_node_info}{predictive_prettyname}';
$SUBROUTINE_MAPPINGS{management_node_predictive_module_description} =
'$ENV{management_node_info}{predictive_description}';
Modified: incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows_mod.pm
URL:
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows_mod.pm?rev=784858&r1=784857&r2=784858&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows_mod.pm
(original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows_mod.pm Mon Jun
15 16:51:15 2009
@@ -4663,7 +4663,7 @@
#/////////////////////////////////////////////////////////////////////////////
-=head2 get_private_ip_addresses
+=head2 get_private_ip_address
Parameters :
Returns :
@@ -4671,7 +4671,7 @@
=cut
-sub get_private_ip_addresses {
+sub get_private_ip_address {
my $self = shift;
if (ref($self) !~ /windows/i) {
notify($ERRORS{'CRITICAL'}, 0, "subroutine was called as a
function, it must be called as a class method");
@@ -4686,16 +4686,15 @@
}
my $interface_name = (keys(%{$network_configuration}))[0];
-
- my $ip_address = $network_configuration->{$interface_name}{ip_address};
- notify($ERRORS{'DEBUG'}, 0, "returning IP address: $ip_address");
-
+ my $ip_address_config =
$network_configuration->{$interface_name}{ip_address};
+ my $ip_address = (keys(%$ip_address_config))[0];
+ notify($ERRORS{'DEBUG'}, 0, "returning private IP address:
$ip_address");
return $ip_address;
}
#/////////////////////////////////////////////////////////////////////////////
-=head2 get_public_ip_addresses
+=head2 get_public_ip_address
Parameters :
Returns :
@@ -4703,7 +4702,7 @@
=cut
-sub get_public_ip_addresses {
+sub get_public_ip_address {
my $self = shift;
if (ref($self) !~ /windows/i) {
notify($ERRORS{'CRITICAL'}, 0, "subroutine was called as a
function, it must be called as a class method");
@@ -4718,11 +4717,101 @@
}
my $interface_name = (keys(%{$network_configuration}))[0];
+ my $ip_address_config =
$network_configuration->{$interface_name}{ip_address};
+ my $ip_address = (keys(%$ip_address_config))[0];
+ notify($ERRORS{'DEBUG'}, 0, "returning public IP address: $ip_address");
+ return $ip_address;
+}
+
+#/////////////////////////////////////////////////////////////////////////////
+
+=head2 get_public_default_gateway
+
+ Parameters :
+ Returns :
+ Description :
+
+=cut
+
+sub get_public_default_gateway {
+ my $self = shift;
+ if (ref($self) !~ /windows/i) {
+ notify($ERRORS{'CRITICAL'}, 0, "subroutine was called as a
function, it must be called as a class method");
+ return;
+ }
- my $ip_address = $network_configuration->{$interface_name}{ip_address};
- notify($ERRORS{'DEBUG'}, 0, "returning IP address: $ip_address");
+ my $default_gateway;
+
+ # Check if management node is using static public IP configuration
+ my $ip_configuration =
$self->data->get_management_node_public_ip_configuration();
+ if ($ip_configuration && $ip_configuration =~ /static/i) {
+ notify($ERRORS{'DEBUG'}, 0, "retrieving static default gateway
configured for management node");
+ $default_gateway =
$self->data->get_management_node_public_default_gateway();
+ }
+ else {
+ if (!$ip_configuration) {
+ notify($ERRORS{'WARNING'}, 0, "management node public
IP configuration could not be retrieved, retrieving dynamic default gateway
currently being used on computer");
+ }
+ else {
+ notify($ERRORS{'DEBUG'}, 0, "retrieving dynamic default
gateway currently being used on computer");
+ }
+
+ # Make sure network configuration was retrieved
+ my $network_configuration =
$self->get_network_configuration('public');
+ if (!$network_configuration) {
+ notify($ERRORS{'WARNING'}, 0, "unable to retrieve
network configuration");
+ return;
+ }
+
+ my $interface_name = (keys(%{$network_configuration}))[0];
+ $default_gateway =
$network_configuration->{$interface_name}{default_gateway};
+ }
+
+ if (!$default_gateway) {
+ notify($ERRORS{'WARNING'}, 0, "unable to determine default
gateway");
+ return;
+ }
- return $ip_address;
+ notify($ERRORS{'DEBUG'}, 0, "returning public default gateway address:
$default_gateway");
+ return $default_gateway;
+}
+
+#/////////////////////////////////////////////////////////////////////////////
+
+=head2 get_private_subnet_mask
+
+ Parameters :
+ Returns :
+ Description :
+
+=cut
+
+sub get_private_subnet_mask {
+ my $self = shift;
+ if (ref($self) !~ /windows/i) {
+ notify($ERRORS{'CRITICAL'}, 0, "subroutine was called as a
function, it must be called as a class method");
+ return;
+ }
+
+ # Get private network configuration
+ my $network_configuration = $self->get_network_configuration('private');
+ if (!$network_configuration) {
+ notify($ERRORS{'WARNING'}, 0, "unable to retrieve network
configuration");
+ return;
+ }
+
+ my $interface_name = (keys(%{$network_configuration}))[0];
+ my $ip_addresses =
$network_configuration->{$interface_name}{ip_address};
+ my $ip_address = (keys(%$ip_addresses))[0];
+ my $subnet_mask = $ip_addresses->{$ip_address};
+
+ if (!$subnet_mask) {
+ notify($ERRORS{'WARNING'}, 0, "unable to determine private
subnet mask, network configuration:\n" . format_data($network_configuration));
+ return;
+ }
+
+ notify($ERRORS{'DEBUG'}, 0, "returning private subnet mask:
$subnet_mask");
+ return $subnet_mask;
}
#/////////////////////////////////////////////////////////////////////////////
@@ -7004,6 +7093,271 @@
#/////////////////////////////////////////////////////////////////////////////
+=head2 set_static_public_address
+
+ Parameters :
+ Returns : If successful: true
+ If failed: false
+ Description : Sets a static IP address for the public interface. The IP
address
+ stored in the database for the computer is used. The subnet
+ mask, default gateway, and DNS servers
configured for the
+ management node are used.
+
+ A persistent route is added to the
routing table to the public
+ default gateway.
+
+=cut
+
+sub set_static_public_address {
+ my $self = shift;
+ unless (ref($self) && $self->isa('VCL::Module')) {
+ notify($ERRORS{'CRITICAL'}, 0, "subroutine can only be called
as a VCL::Module module object method");
+ return;
+ }
+
+ # Make sure public IP configuration is static
+ my $ip_configuration =
$self->data->get_management_node_public_ip_configuration() || 'undefined';
+ unless ($ip_configuration =~ /static/i) {
+ notify($ERRORS{'WARNING'}, 0, "static public address can only
be set if IP configuration is static, current value: $ip_configuration");
+ return;
+ }
+
+ # Get the IP configuration
+ my $public_interface_name = $self->get_public_interface_name() ||
'undefined';
+ my $public_ip_address = $self->data->get_computer_ip_address() ||
'undefined';
+
+ my $subnet_mask = $self->data->get_management_node_public_subnet_mask()
|| 'undefined';
+ my $default_gateway =
$self->data->get_management_node_public_default_gateway() || 'undefined';
+ my $dns_server = $self->data->get_management_node_public_dns_server()
|| 'undefined';
+
+ # Make sure required info was retrieved
+ if ("$public_interface_name $subnet_mask $default_gateway $dns_server"
=~ /undefined/) {
+ notify($ERRORS{'WARNING'}, 0, "unable to retrieve required
network configuration:\ninterface: $public_interface_name\npublic IP address:
$public_ip_address\nsubnet mask=$subnet_mask\ndefault
gateway=$default_gateway\ndns server=$dns_server");
+ return;
+ }
+
+ my $management_node_keys = $self->data->get_management_node_keys();
+ my $computer_node_name = $self->data->get_computer_node_name();
+
+ notify($ERRORS{'DEBUG'}, 0, "network configuration:\ninterface:
$public_interface_name\npublic IP address: $public_ip_address\nsubnet
mask=$subnet_mask\ndefault gateway=$default_gateway\ndns server=$dns_server");
+
+ # Assemble the commands
+ my $address_command = "netsh interface ip set address
name=\"$public_interface_name\" source=static addr=$public_ip_address
mask=$subnet_mask gateway=$default_gateway gwmetric=0";
+ my $dns_command = "netsh interface ip set dns
name=\"$public_interface_name\" source=static addr=$dns_server register=none";
+
+ # Set the static public IP address
+ my ($address_exit_status, $address_output) =
run_ssh_command($computer_node_name, $management_node_keys, $address_command);
+ if (defined($address_exit_status) && $address_exit_status == 0) {
+ notify($ERRORS{'DEBUG'}, 0, "set static public IP address to
$public_ip_address");
+ }
+ elsif (defined($address_exit_status)) {
+ notify($ERRORS{'WARNING'}, 0, "failed to set static public IP
address to $public_ip_address, exit status: $address_exit_status,
output:\...@{$address_output}");
+ return;
+ }
+ else {
+ notify($ERRORS{'WARNING'}, 0, "failed to run ssh command to set
static public IP address to $public_ip_address");
+ return;
+ }
+
+ # Set the static DNS server address
+ my ($dns_exit_status, $dns_output) =
run_ssh_command($computer_node_name, $management_node_keys, $dns_command);
+ if (defined($dns_exit_status) && $dns_exit_status == 0) {
+ notify($ERRORS{'DEBUG'}, 0, "set static DNS server address to
$dns_server");
+ }
+ elsif (defined($dns_exit_status)) {
+ notify($ERRORS{'WARNING'}, 0, "failed to set static DNS server
address to $dns_server, exit status: $dns_exit_status,
output:\...@{$dns_output}");
+ return;
+ }
+ else {
+ notify($ERRORS{'WARNING'}, 0, "failed to run ssh command to set
static DNS server address to $dns_server");
+ return;
+ }
+
+ # Add persistent static public default route
+ if (!$self->set_public_default_route()) {
+ notify($ERRORS{'WARNING'}, 0, "failed to add persistent static
public default route");
+ return;
+ }
+
+ notify($ERRORS{'OK'}, 0, "configured static address for public
interface '$public_interface_name'");
+ return 1;
+}
+
+#/////////////////////////////////////////////////////////////////////////////
+
+=head2 set_static_private_address
+
+ Parameters : None
+ Returns : If successful: true
+ If failed: false
+ Description : Configures the private interface to use a static IP address. The
+ address and subnet mask used will be the same as what is
+ currently configured for the computer.
+
+=cut
+
+sub set_static_private_address {
+ my $self = shift;
+ unless (ref($self) && $self->isa('VCL::Module')) {
+ notify($ERRORS{'CRITICAL'}, 0, "subroutine can only be called
as a VCL::Module module object method");
+ return;
+ }
+
+ # Get the IP configuration
+ my $private_interface_name = $self->get_private_interface_name() ||
'undefined';
+ my $private_ip_address = $self->get_private_ip_address() || 'undefined';
+ my $private_subnet_mask = $self->get_private_subnet_mask() ||
'undefined';
+
+ # Make sure required info was retrieved
+ if ("$private_interface_name $private_ip_address $private_subnet_mask"
=~ /undefined/) {
+ notify($ERRORS{'WARNING'}, 0, "unable to retrieve required
network configuration:\ninterface: $private_interface_name\nprivate IP address:
$private_ip_address\nsubnet mask=$private_subnet_mask");
+ return;
+ }
+
+ my $management_node_keys = $self->data->get_management_node_keys();
+ my $computer_node_name = $self->data->get_computer_node_name();
+
+ notify($ERRORS{'DEBUG'}, 0, "private network configuration:\ninterface:
$private_interface_name\nprivate IP address: $private_ip_address\nsubnet mask:
$private_subnet_mask");
+
+ # Set the static private IP address
+ my $set_command = "/bin/cygstart.exe cmd.exe /c netsh interface ip set
address name=\"$private_interface_name\" source=static addr=$private_ip_address
mask=$private_subnet_mask";
+ my ($set_exit_status, $set_output) =
run_ssh_command($computer_node_name, $management_node_keys, $set_command);
+ if (defined($set_exit_status) && $set_exit_status == 0) {
+ notify($ERRORS{'DEBUG'}, 0, "set static private IP address to
$private_ip_address");
+ }
+ elsif (defined($set_exit_status)) {
+ notify($ERRORS{'WARNING'}, 0, "failed to set static private IP
address to $private_ip_address, exit status: $set_exit_status,
output:\...@{$set_output}");
+ return;
+ }
+ else {
+ notify($ERRORS{'WARNING'}, 0, "failed to run ssh command to set
static private IP address to $private_ip_address");
+ return;
+ }
+
+ # Wait briefly while command is executed
+ sleep 1;
+
+ # Show the static private IP address configuration
+ my $show_command = "netsh interface ip show address
name=\"$private_interface_name\"";
+ my ($show_exit_status, $show_output) =
run_ssh_command($computer_node_name, $management_node_keys, $show_command);
+ if (defined($show_exit_status) && $show_exit_status == 0) {
+ notify($ERRORS{'DEBUG'}, 0, "private IP address configuration:
" . join("\n", @$show_output));
+ }
+ elsif (defined($show_exit_status)) {
+ notify($ERRORS{'WARNING'}, 0, "failed to display private IP
address configuration, exit status: $show_exit_status,
output:\...@{$show_output}");
+ return;
+ }
+ else {
+ notify($ERRORS{'WARNING'}, 0, "failed to run ssh command to
display private IP address configuration");
+ return;
+ }
+
+ # Check the show address output
+ if (grep(/DHCP enabled:\s+No/i, @$show_output)) {
+ notify($ERRORS{'OK'}, 0, "configured static address for private
interface '$private_interface_name'");
+ return 1;
+ }
+ else {
+ notify($ERRORS{'WARNING'}, 0, "failed to configure static
address for private interface '$private_interface_name'");
+ return;
+ }
+}
+
+#/////////////////////////////////////////////////////////////////////////////
+
+=head2 delete_default_routes
+
+ Parameters :
+ Returns : If successful: true
+ If failed: false
+ Description : Deletes all default (0.0.0.0) routes.
+
+=cut
+
+sub delete_default_routes {
+ my $self = shift;
+ unless (ref($self) && $self->isa('VCL::Module')) {
+ notify($ERRORS{'CRITICAL'}, 0, "subroutine can only be called
as a VCL::Module module object method");
+ return;
+ }
+
+ my $management_node_keys = $self->data->get_management_node_keys();
+ my $computer_node_name = $self->data->get_computer_node_name();
+
+ # Delete all default routes
+ my $route_delete_command = "route delete 0.0.0.0";
+ my ($route_delete_exit_status, $route_delete_output) =
run_ssh_command($computer_node_name, $management_node_keys,
$route_delete_command);
+ if (defined($route_delete_exit_status) && $route_delete_exit_status ==
0) {
+ notify($ERRORS{'OK'}, 0, "deleted all default routes");
+ }
+ elsif (defined($route_delete_exit_status)) {
+ notify($ERRORS{'WARNING'}, 0, "failed to delete all default
routes, exit status: $route_delete_exit_status,
output:\...@{$route_delete_output}");
+ return;
+ }
+ else {
+ notify($ERRORS{'WARNING'}, 0, "failed to run ssh command to
delete all default routes");
+ return;
+ }
+
+ return 1;
+}
+
+#/////////////////////////////////////////////////////////////////////////////
+
+=head2 set_public_default_route
+
+ Parameters : None
+ Returns : If successful: true
+ If failed: false
+ Description : Adds a persistent route to the default gateway for the public
+ network.
+
+=cut
+
+sub set_public_default_route {
+ my $self = shift;
+ unless (ref($self) && $self->isa('VCL::Module')) {
+ notify($ERRORS{'CRITICAL'}, 0, "subroutine can only be called
as a VCL::Module module object method");
+ return;
+ }
+
+ # Get the default gateway address
+ my $default_gateway =
$self->data->get_management_node_public_default_gateway();
+ if (!$default_gateway) {
+ notify($ERRORS{'WARNING'}, 0, "unable to retrieve default
gateway address");
+ return;
+ }
+
+ # Delete all default routes before adding
+ # Do this only after successfully retrieving default gateway address
+ if (!$self->delete_default_routes()) {
+ notify($ERRORS{'WARNING'}, 0, "unable to delete existing
default routes");
+ return;
+ }
+
+ my $management_node_keys = $self->data->get_management_node_keys();
+ my $computer_node_name = $self->data->get_computer_node_name();
+
+ # Add a persistent route to the public default gateway
+ my $route_add_command = "route -p ADD 0.0.0.0 MASK 0.0.0.0
$default_gateway METRIC 1";
+ my ($route_add_exit_status, $route_add_output) =
run_ssh_command($computer_node_name, $management_node_keys, $route_add_command);
+ if (defined($route_add_exit_status) && $route_add_exit_status == 0) {
+ notify($ERRORS{'OK'}, 0, "added persistent route to public
default gateway: $default_gateway");
+ }
+ elsif (defined($route_add_exit_status)) {
+ notify($ERRORS{'WARNING'}, 0, "failed to add persistent route
to public default gateway: $default_gateway, exit status:
$route_add_exit_status, output:\...@{$route_add_output}");
+ return;
+ }
+ else {
+ notify($ERRORS{'WARNING'}, 0, "failed to run ssh command to add
persistent route to public default gateway: $default_gateway");
+ return;
+ }
+
+ return 1;
+}
+
+#/////////////////////////////////////////////////////////////////////////////
+
1;
__END__
Modified:
incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows_mod/Version_6.pm
URL:
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows_mod/Version_6.pm?rev=784858&r1=784857&r2=784858&view=diff
==============================================================================
---
incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows_mod/Version_6.pm
(original)
+++
incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows_mod/Version_6.pm
Mon Jun 15 16:51:15 2009
@@ -529,15 +529,12 @@
my $computer_node_name = $self->data->get_computer_node_name();
# Get the computer's private IP address
- my @private_ip_addresses = keys(%{$self->get_private_ip_addresses()});
- if (!...@private_ip_addresses) {
- notify($ERRORS{'WARNING'}, 0, "unable to retrieve private IP
addresses");
+ my $private_ip_address = $self->get_private_ip_address();
+ if (!$private_ip_address) {
+ notify($ERRORS{'WARNING'}, 0, "unable to retrieve private IP
address");
return;
}
- # Join together the IP addresses in case multiple addresses are bound
- my $private_ip_address_string = join("," , @private_ip_addresses);
-
# First delete any rules which allow ping and then add a new rule
my $add_rule_command;
$add_rule_command .= 'netsh.exe advfirewall firewall delete rule';
@@ -547,26 +544,26 @@
$add_rule_command .= ' ;';
$add_rule_command .= ' netsh.exe advfirewall firewall add rule';
- $add_rule_command .= ' name="VCL: allow incoming ping to: ' .
$private_ip_address_string . '"';
- $add_rule_command .= ' description="Allows incoming ping (ICMP type 8)
messages to: ' . $private_ip_address_string . '"';
+ $add_rule_command .= ' name="VCL: allow incoming ping to: ' .
$private_ip_address . '"';
+ $add_rule_command .= ' description="Allows incoming ping (ICMP type 8)
messages to: ' . $private_ip_address . '"';
$add_rule_command .= ' protocol=icmpv4:8,any';
$add_rule_command .= ' action=allow';
$add_rule_command .= ' enable=yes';
$add_rule_command .= ' dir=in';
- $add_rule_command .= ' localip=' . $private_ip_address_string;
+ $add_rule_command .= ' localip=' . $private_ip_address;
# Add the firewall rule
my ($add_rule_exit_status, $add_rule_output) =
run_ssh_command($computer_node_name, $management_node_keys, $add_rule_command);
if (defined($add_rule_output) && @$add_rule_output[-1] =~ /Ok\./i) {
- notify($ERRORS{'OK'}, 0, "added firewall rule to allow incoming
ping to: $private_ip_address_string");
+ notify($ERRORS{'OK'}, 0, "added firewall rule to allow incoming
ping to: $private_ip_address");
}
elsif (defined($add_rule_exit_status)) {
- notify($ERRORS{'WARNING'}, 0, "failed to add firewall rule to
allow incoming ping to: $private_ip_address_string, exit status:
$add_rule_exit_status, output:\...@{$add_rule_output}");
+ notify($ERRORS{'WARNING'}, 0, "failed to add firewall rule to
allow incoming ping to: $private_ip_address, exit status:
$add_rule_exit_status, output:\...@{$add_rule_output}");
return;
}
else {
- notify($ERRORS{'WARNING'}, 0, "failed to add firewall rule to
allow incoming ping to: $private_ip_address_string");
+ notify($ERRORS{'WARNING'}, 0, "failed to add firewall rule to
allow incoming ping to: $private_ip_address");
return;
}
@@ -707,15 +704,12 @@
my $computer_node_name = $self->data->get_computer_node_name();
# Get the computer's private IP address
- my @private_ip_addresses = keys(%{$self->get_private_ip_addresses()});
- if (!...@private_ip_addresses) {
- notify($ERRORS{'WARNING'}, 0, "unable to retrieve private IP
addresses");
+ my $private_ip_address = $self->get_private_ip_address();
+ if (!$private_ip_address) {
+ notify($ERRORS{'WARNING'}, 0, "unable to retrieve private IP
address");
return;
}
- # Join together the IP addresses in case multiple addresses are bound
- my $private_ip_address_string = join("," , @private_ip_addresses);
-
# First delete any rules which allow RDP and then add a new rule
my $add_rule_command;
$add_rule_command .= 'netsh.exe advfirewall firewall delete rule';
@@ -726,27 +720,27 @@
$add_rule_command .= ' ;';
$add_rule_command .= ' netsh.exe advfirewall firewall add rule';
- $add_rule_command .= ' name="VCL: allow RDP port 3389 to: ' .
$private_ip_address_string . '"';
- $add_rule_command .= ' description="Allows incoming RDP (TCP port 3389)
traffic to: ' . $private_ip_address_string . '"';
+ $add_rule_command .= ' name="VCL: allow RDP port 3389 to: ' .
$private_ip_address . '"';
+ $add_rule_command .= ' description="Allows incoming RDP (TCP port 3389)
traffic to: ' . $private_ip_address . '"';
$add_rule_command .= ' protocol=TCP';
$add_rule_command .= ' localport=3389';
$add_rule_command .= ' action=allow';
$add_rule_command .= ' enable=yes';
$add_rule_command .= ' dir=in';
- $add_rule_command .= ' localip=' . $private_ip_address_string;
+ $add_rule_command .= ' localip=' . $private_ip_address;
# Add the firewall rule
my ($add_rule_exit_status, $add_rule_output) =
run_ssh_command($computer_node_name, $management_node_keys, $add_rule_command);
if (defined($add_rule_output) && @$add_rule_output[-1] =~ /Ok\./i) {
- notify($ERRORS{'OK'}, 0, "added firewall rule to enable RDP to:
$private_ip_address_string");
+ notify($ERRORS{'OK'}, 0, "added firewall rule to enable RDP to:
$private_ip_address");
}
elsif (defined($add_rule_exit_status)) {
- notify($ERRORS{'WARNING'}, 0, "failed to add firewall rule to
enable RDP to: $private_ip_address_string, exit status: $add_rule_exit_status,
output:\...@{$add_rule_output}");
+ notify($ERRORS{'WARNING'}, 0, "failed to add firewall rule to
enable RDP to: $private_ip_address, exit status: $add_rule_exit_status,
output:\...@{$add_rule_output}");
return;
}
else {
- notify($ERRORS{'WARNING'}, 0, "failed to add firewall rule to
enable RDP to: $private_ip_address_string");
+ notify($ERRORS{'WARNING'}, 0, "failed to add firewall rule to
enable RDP to: $private_ip_address");
return;
}
@@ -881,15 +875,12 @@
my $computer_node_name = $self->data->get_computer_node_name();
# Get the computer's private IP address
- my @private_ip_addresses = keys(%{$self->get_private_ip_addresses()});
- if (!...@private_ip_addresses) {
- notify($ERRORS{'WARNING'}, 0, "unable to retrieve private IP
addresses");
+ my $private_ip_address = $self->get_private_ip_address();
+ if (!$private_ip_address) {
+ notify($ERRORS{'WARNING'}, 0, "unable to retrieve private IP
address");
return;
}
- # Join together the IP addresses in case multiple addresses are bound
- my $private_ip_address_string = join("," , @private_ip_addresses);
-
# First delete any rules which allow ping and then add a new rule
my $add_rule_command;
$add_rule_command .= 'netsh.exe advfirewall firewall delete rule';
@@ -900,27 +891,27 @@
$add_rule_command .= ' ;';
$add_rule_command .= ' netsh.exe advfirewall firewall add rule';
- $add_rule_command .= ' name="VCL: allow SSH port 22 to: ' .
$private_ip_address_string . '"';
- $add_rule_command .= ' description="Allows incoming SSH (TCP port 22)
traffic to: ' . $private_ip_address_string . '"';
+ $add_rule_command .= ' name="VCL: allow SSH port 22 to: ' .
$private_ip_address . '"';
+ $add_rule_command .= ' description="Allows incoming SSH (TCP port 22)
traffic to: ' . $private_ip_address . '"';
$add_rule_command .= ' protocol=TCP';
$add_rule_command .= ' localport=22';
$add_rule_command .= ' action=allow';
$add_rule_command .= ' enable=yes';
$add_rule_command .= ' dir=in';
- $add_rule_command .= ' localip=' . $private_ip_address_string;
+ $add_rule_command .= ' localip=' . $private_ip_address;
# Add the firewall rule
my ($add_rule_exit_status, $add_rule_output) =
run_ssh_command($computer_node_name, $management_node_keys, $add_rule_command);
if (defined($add_rule_output) && @$add_rule_output[-1] =~ /Ok\./i) {
- notify($ERRORS{'OK'}, 0, "added firewall rule to enable SSH to:
$private_ip_address_string");
+ notify($ERRORS{'OK'}, 0, "added firewall rule to enable SSH to:
$private_ip_address");
}
elsif (defined($add_rule_exit_status)) {
- notify($ERRORS{'WARNING'}, 0, "failed to add firewall rule to
enable SSH to: $private_ip_address_string, exit status: $add_rule_exit_status,
output:\...@{$add_rule_output}");
+ notify($ERRORS{'WARNING'}, 0, "failed to add firewall rule to
enable SSH to: $private_ip_address, exit status: $add_rule_exit_status,
output:\...@{$add_rule_output}");
return;
}
else {
- notify($ERRORS{'WARNING'}, 0, "failed to add firewall rule to
enable SSH to: $private_ip_address_string");
+ notify($ERRORS{'WARNING'}, 0, "failed to add firewall rule to
enable SSH to: $private_ip_address");
return;
}
Modified:
incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/vmware.pm
URL:
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/vmware.pm?rev=784858&r1=784857&r2=784858&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/vmware.pm
(original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/vmware.pm
Mon Jun 15 16:51:15 2009
@@ -1102,8 +1102,17 @@
} ## end if ($IPCONFIGURATION eq "dynamicDHCP")
elsif ($IPCONFIGURATION eq "static") {
insertloadlog($reservation_id, $vmclient_computerid,
"staticIPaddress", "setting static IP address for node");
- if (setstaticaddress($computer_shortname,
$vmclient_OSname, $vmclient_publicIPaddress, $image_os_type)) {
+ if ($self->os->can("set_static_public_address") &&
$self->os->set_static_public_address()) {
+ notify($ERRORS{'DEBUG'}, 0, "set static public
address using OS module's set_static_public_address() method");
+ insertloadlog($reservation_id,
$vmclient_computerid, "staticIPaddress", "SUCCESS set static IP address on
public interface");
+ }
+ elsif (setstaticaddress($computer_shortname,
$vmclient_OSname, $vmclient_publicIPaddress, $image_os_type)) {
# good set static address
+ insertloadlog($reservation_id,
$vmclient_computerid, "staticIPaddress", "SUCCESS set static IP address on
public interface");
+ }
+ else {
+ insertloadlog($reservation_id,
$vmclient_computerid, "staticIPaddress", "failed to set static IP address on
public interface");
+ return 0;
}
}
} ## end if ($IPCONFIGURATION ne "manualDHCP")
Modified: incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT.pm
URL:
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT.pm?rev=784858&r1=784857&r2=784858&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT.pm
(original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT.pm Mon
Jun 15 16:51:15 2009
@@ -740,6 +740,7 @@
$sshd_start_time = time() if !$sshd_start_time;
while (!$sshdstatus) {
+ notify($ERRORS{'DEBUG'}, 0, "checking sshd status of
$computer_node_name");
my $sshd_status = _sshd_status($computer_node_name,
$image_name, $image_os_type);
if ($sshd_status eq "on") {
@@ -752,9 +753,10 @@
insertloadlog($reservation_id, $computer_id, "info",
"synchronizing keys");
} ## end if ($sshd_status eq "on")
else {
+ notify($ERRORS{'DEBUG'}, 0, "sshd is not responding
yet");
#either sshd is off or N/A, we wait
- if ($wait_loops >= 7) {
+ if ($wait_loops >= 14) {
if ($sshd_attempts < 3) {
goto SSHDATTEMPT;
}
@@ -908,7 +910,11 @@
elsif ($IPCONFIGURATION eq "static") {
insertloadlog($reservation_id, $computer_id, "info",
"setting staticIPaddress");
- if (setstaticaddress($computer_node_name,
$image_os_name, $computer_ip_address, $image_os_type)) {
+ if ($self->os->can("set_static_public_address") &&
$self->os->set_static_public_address()) {
+ notify($ERRORS{'DEBUG'}, 0, "set static public
address using OS module's set_static_public_address() method");
+ insertloadlog($reservation_id, $computer_id,
"staticIPaddress", "SUCCESS set static IP address on public interface");
+ }
+ elsif (setstaticaddress($computer_node_name,
$image_os_name, $computer_ip_address, $image_os_type)) {
notify($ERRORS{'DEBUG'}, 0, "set static address
on $computer_ip_address $computer_node_name ");
insertloadlog($reservation_id, $computer_id,
"staticIPaddress", "SUCCESS set static IP address on public interface");
}
@@ -1975,7 +1981,11 @@
}
_rpower($computer_node_name, 'on');
- sleep 2;
+
+ # Wait up to 1 minute for the computer power status to be on
+ if (wait_for_on($computer_node_name, 1)) {
+ last;
+ }
$power_status = power_status($computer_node_name);
} ## end while ($power_status !~ /on/)
@@ -1997,7 +2007,7 @@
sub power_off {
my $argument_1 = shift;
my $argument_2 = shift;
-
+
my $computer_node_name;
# Check if subroutine was called as an object method
@@ -2033,9 +2043,14 @@
notify($ERRORS{'WARNING'}, 0, "failed to turn
$computer_node_name off, rpower status not is off after 3 attempts");
return;
}
-
+
+ # Attempt to run rpower <node> off
_rpower($computer_node_name, 'off');
- sleep 2;
+
+ # Wait up to 1 minute for the computer power status to be off
+ if (wait_for_off($computer_node_name, 1)) {
+ last;
+ }
$power_status = power_status($computer_node_name);
} ## end while ($power_status !~ /off/)
@@ -2111,17 +2126,43 @@
=cut
sub wait_for_on {
- my $self = shift;
- if (ref($self) !~ /xcat/i) {
- notify($ERRORS{'CRITICAL'}, 0, "subroutine was called as a
function, it must be called as a class method");
- return;
+ my $argument_1 = shift;
+ my $argument_2 = shift;
+ my $argument_3 = shift;
+
+ my $self;
+ my $computer_node_name;
+ my $total_wait_minutes;
+
+ # Check if subroutine was called as an object method
+ if (ref($argument_1) =~ /xcat/i) {
+ $self = $argument_1;
+
+ if (defined $argument_3) {
+ $computer_node_name = $argument_2;
+ $total_wait_minutes = $argument_3;
+ }
+ else {
+ $computer_node_name =
$self->data->get_computer_node_name();
+ $total_wait_minutes = $argument_2;
+ }
+
+ } ## end if (ref($argument_1) =~ /xcat/i)
+ else {
+ # Subroutine was not called as an object method, 2 arguments
must be specified
+ $computer_node_name = $argument_1;
+ $total_wait_minutes = $argument_2;
}
- my $computer_node_name = $self->data->get_computer_node_name();
+ # Check if computer was determined
+ if (!$computer_node_name) {
+ notify($ERRORS{'WARNING'}, 0, "computer could not be determined
from arguments");
+ return;
+ }
- # Attempt to get the total number of minutes to wait from the arguments
- my $total_wait_minutes = shift;
+ # Make sure total wait minutes was determined
if (!defined($total_wait_minutes) || $total_wait_minutes !~ /^\d+$/) {
+ notify($ERRORS{'DEBUG'}, 0, "total wait minutes argument not
specified, using default of 5 minutes");
$total_wait_minutes = 5;
}
@@ -2141,7 +2182,7 @@
sleep $attempt_delay;
}
- if ($self->power_status() =~ /on/i) {
+ if (power_status($computer_node_name) =~ /on/i) {
notify($ERRORS{'OK'}, 0, "$computer_node_name is on");
return 1;
}
@@ -2164,17 +2205,43 @@
=cut
sub wait_for_off {
- my $self = shift;
- if (ref($self) !~ /xcat/i) {
- notify($ERRORS{'CRITICAL'}, 0, "subroutine was called as a
function, it must be called as a class method");
- return;
+ my $argument_1 = shift;
+ my $argument_2 = shift;
+ my $argument_3 = shift;
+
+ my $self;
+ my $computer_node_name;
+ my $total_wait_minutes;
+
+ # Check if subroutine was called as an object method
+ if (ref($argument_1) =~ /xcat/i) {
+ $self = $argument_1;
+
+ if (defined $argument_3) {
+ $computer_node_name = $argument_2;
+ $total_wait_minutes = $argument_3;
+ }
+ else {
+ $computer_node_name =
$self->data->get_computer_node_name();
+ $total_wait_minutes = $argument_2;
+ }
+
+ } ## end if (ref($argument_1) =~ /xcat/i)
+ else {
+ # Subroutine was not called as an object method, 2 arguments
must be specified
+ $computer_node_name = $argument_1;
+ $total_wait_minutes = $argument_2;
}
- my $computer_node_name = $self->data->get_computer_node_name();
+ # Check if computer was determined
+ if (!$computer_node_name) {
+ notify($ERRORS{'WARNING'}, 0, "computer could not be determined
from arguments");
+ return;
+ }
- # Attempt to get the total number of minutes to wait from the arguments
- my $total_wait_minutes = shift;
+ # Make sure total wait minutes was determined
if (!defined($total_wait_minutes) || $total_wait_minutes !~ /^\d+$/) {
+ notify($ERRORS{'DEBUG'}, 0, "total wait minutes argument not
specified, using default of 5 minutes");
$total_wait_minutes = 5;
}
@@ -2194,7 +2261,7 @@
sleep $attempt_delay;
}
- if ($self->power_status() =~ /off/i) {
+ if (power_status($computer_node_name) =~ /off/i) {
notify($ERRORS{'OK'}, 0, "$computer_node_name is off");
return 1;
}
Modified:
incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT21.pm
URL:
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT21.pm?rev=784858&r1=784857&r2=784858&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT21.pm
(original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT21.pm
Mon Jun 15 16:51:15 2009
@@ -1019,7 +1019,11 @@
elsif ($IPCONFIGURATION eq "static") {
insertloadlog($reservation_id, $computer_id, "info",
"setting staticIPaddress");
- if (setstaticaddress($computer_node_name,
$image_os_name, $computer_ip_address, $image_os_type)) {
+ if ($self->os->can("set_static_public_address") &&
$self->os->set_static_public_address()) {
+ notify($ERRORS{'DEBUG'}, 0, "set static public
address using OS module's set_static_public_address() method");
+ insertloadlog($reservation_id, $computer_id,
"staticIPaddress", "SUCCESS set static IP address on public interface");
+ }
+ elsif (setstaticaddress($computer_node_name,
$image_os_name, $computer_ip_address, $image_os_type)) {
notify($ERRORS{'DEBUG'}, 0, "set static address
on $computer_ip_address $computer_node_name ");
insertloadlog($reservation_id, $computer_id,
"staticIPaddress", "SUCCESS set static IP address on public interface");
}
Modified: incubator/vcl/trunk/managementnode/lib/VCL/utils.pm
URL:
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/utils.pm?rev=784858&r1=784857&r2=784858&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/utils.pm (original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/utils.pm Mon Jun 15 16:51:15 2009
@@ -6577,7 +6577,8 @@
# Set default values if not passed as an argument
$user = "root" if (!$user);
$port = 22 if (!$port);
-
+ $identity_paths = $ENV{management_node_info}{keys} if (!defined
$identity_paths || length($identity_paths) == 0);
+
# TODO: Add ssh path to config file and set global variable
# Locate the path to the ssh binary
my $ssh_path;
@@ -6596,7 +6597,7 @@
}
# Format the identity path string
- if ($identity_paths) {
+ if (defined $identity_paths && length($identity_paths) > 0) {
# Add -i to beginning of string
$identity_paths = "-i $identity_paths";
@@ -7125,7 +7126,7 @@
#/////////////////////////////////////////////////////////////////////////////
-=head2 get_management_node_id
+=head2 get_management_node_info
Parameters : Either a management node hostname or database ID
Returns : Hash containing data contained in the managementnode table
@@ -7263,6 +7264,12 @@
# Get the OS name
my $os_name = lc($^O);
$management_node_info->{OSNAME} = $os_name;
+
+ # Add the public IP address configuration variables
+ $management_node_info->{PUBLIC_IP_CONFIGURATION} = $IPCONFIGURATION;
+ $management_node_info->{PUBLIC_SUBNET_MASK} = $NETMASK;
+ $management_node_info->{PUBLIC_DEFAULT_GATEWAY} = $GATEWAY;
+ $management_node_info->{PUBLIC_DNS_SERVER} = $DNSserver;
notify($ERRORS{'DEBUG'}, 0, "management node info retrieved from
database for $shortname");
return $management_node_info;