Author: fapeeler
Date: Fri Sep 21 14:32:40 2012
New Revision: 1388527
URL: http://svn.apache.org/viewvc?rev=1388527&view=rev
Log:
VCL-584
handles setting user defined IPaddress
VCL-614
simple ping test to confirm ip address is not being used
VCL-629
Linux added chown command when adding users
Modified:
vcl/trunk/managementnode/lib/VCL/DataStructure.pm
vcl/trunk/managementnode/lib/VCL/Module/OS.pm
vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm
vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm
vcl/trunk/managementnode/lib/VCL/new.pm
vcl/trunk/managementnode/lib/VCL/reclaim.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=1388527&r1=1388526&r2=1388527&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/DataStructure.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/DataStructure.pm Fri Sep 21 14:32:40 2012
@@ -390,6 +390,9 @@ $SUBROUTINE_MAPPINGS{imagetype_name} = '
$SUBROUTINE_MAPPINGS{server_request_id} =
'$self->request_data->{reservation}{RESERVATION_ID}{serverrequest}{id}';
$SUBROUTINE_MAPPINGS{server_request_fixedIP} =
'$self->request_data->{reservation}{RESERVATION_ID}{serverrequest}{fixedIP}';
+$SUBROUTINE_MAPPINGS{server_request_router} =
'$self->request_data->{reservation}{RESERVATION_ID}{serverrequest}{router}';
+$SUBROUTINE_MAPPINGS{server_request_netmask} =
'$self->request_data->{reservation}{RESERVATION_ID}{serverrequest}{netmask}';
+$SUBROUTINE_MAPPINGS{server_request_DNSservers} =
'$self->request_data->{reservation}{RESERVATION_ID}{serverrequest}{DNSservers}';
$SUBROUTINE_MAPPINGS{server_request_fixedMAC} =
'$self->request_data->{reservation}{RESERVATION_ID}{serverrequest}{fixedMAC}';
$SUBROUTINE_MAPPINGS{server_request_admingroupid} =
'$self->request_data->{reservation}{RESERVATION_ID}{serverrequest}{admingroupid}';
$SUBROUTINE_MAPPINGS{server_request_logingroupid} =
'$self->request_data->{reservation}{RESERVATION_ID}{serverrequest}{logingroupid}';
Modified: vcl/trunk/managementnode/lib/VCL/Module/OS.pm
URL:
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/OS.pm?rev=1388527&r1=1388526&r2=1388527&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/OS.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/OS.pm Fri Sep 21 14:32:40 2012
@@ -799,6 +799,75 @@ sub update_ssh_known_hosts {
return 1;
}
+
+#/////////////////////////////////////////////////////////////////////////////
+
+=head2 server_request_set_fixedIP
+
+ Parameters : none
+ Returns : If successful: true
+ If failed: false
+ Description :
+
+=cut
+
+sub server_request_set_fixedIP {
+ 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() || return;
+ my $computer_id = $self->data->get_computer_id() || return;
+ my $computer_node_name = $self->data->get_computer_node_name() ||
return;
+ my $image_os_name = $self->data->get_image_os_name() || return;
+ my $image_os_type = $self->data->get_image_os_type() || return;
+ my $computer_ip_address = $self->data->get_computer_ip_address();
+ my $public_ip_configuration =
$self->data->get_management_node_public_ip_configuration() || return;
+ my $server_request_id = $self->data->get_server_request_id();
+ my $server_request_fixedIP =
$self->data->get_server_request_fixedIP();
+
+ if($server_request_id) {
+ if($server_request_fixedIP) {
+ #Update the info related to fixedIP
+ if(!$self->update_fixedIP_info()) {
+ notify($ERRORS{'WARNING'}, 0, "Unable to update information
related fixedIP for server_request $server_request_id");
+ }
+ # Try to set the static public IP address using the OS module
+ if ($self->can("set_static_public_address")) {
+ if ($self->set_static_public_address()) {
+ notify($ERRORS{'DEBUG'}, 0, "set static public IP address on
$computer_node_name using OS module's set_static_public_address() method");
$self->data->set_computer_ip_address($server_request_fixedIP);
+
+ # Delete cached network configuration information so it is
retrieved next time it is needed
+ delete $self->{network_configuration};
+
+ if (update_computer_address($computer_id,
$server_request_fixedIP)) {
+ notify($ERRORS{'OK'}, 0, "updated public IP address in
computer table for $computer_node_name, $server_request_fixedIP");
+ }
+
+ #Update Hostname to match Public assigned name
+ if ($self->can("update_public_hostname")) {
+ if($self->update_public_hostname()){
+ notify($ERRORS{'OK'}, 0, "Updated hostname based on
fixedIP $server_request_fixedIP");
+ }
+ }
+ }
+ else {
+ notify($ERRORS{'WARNING'}, 0, "failed to set static public IP
address on $computer_node_name");
+ return 0;
+ }
+ }
+ else {
+ notify($ERRORS{'WARNING'}, 0, "unable to set static public IP
address on $computer_node_name, " . ref($self) . " module does not implement a
set_static_public_address subroutine");
+ }
+ }
+ }
+
+ return 1;
+
+}
+
#/////////////////////////////////////////////////////////////////////////////
=head2 update_public_ip_address
@@ -829,7 +898,7 @@ sub update_public_ip_address {
my $image_os_type = $self->data->get_image_os_type() || return;
my $computer_ip_address = $self->data->get_computer_ip_address();
my $public_ip_configuration =
$self->data->get_management_node_public_ip_configuration() || return;
-
+
if ($public_ip_configuration =~ /dhcp/i) {
notify($ERRORS{'DEBUG'}, 0, "IP configuration is set to
$public_ip_configuration, attempting to retrieve dynamic public IP address from
$computer_node_name");
@@ -3064,6 +3133,56 @@ sub get_tools_file_paths {
return @return_files;
}
+#/////////////////////////////////////////////////////////////////////////////
+
+=head2 update_fixedIP_info
+
+ Parameters :
+ Returns : 1, 0
+ Description : checks for variables in variable table related to fixedIP
information for server reservations
+
+=cut
+
+sub update_fixedIP_info {
+
+ 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 $server_request_id = $self->data->get_server_request_id();
+ if(!$server_request_id) {
+ notify($ERRORS{'WARNING'}, 0, "Server request id not set.");
+ return;
+ }
+
+ my $variable_name = "fixedIPsr" . $server_request_id;
+ my $server_variable_data;
+
+ if($self->data->is_variable_set($variable_name)){
+ #fetch variable
+ $server_variable_data =
$self->data->get_variable($variable_name);
+
+ notify($ERRORS{'DEBUG'}, 0, "data is set for $variable_name"
. format_data($server_variable_data));
+
+ my $router = $server_variable_data->{router};
+ my $netmask = $server_variable_data->{netmask};
+ my @dns = @{$server_variable_data->{dns}};
+
+ notify($ERRORS{'OK'}, 0, "updated data server request
router info") if
($self->data->set_server_request_router($server_variable_data->{router}));
+ notify($ERRORS{'OK'}, 0, "updated data server request
netmask info") if
($self->data->set_server_request_netmask($server_variable_data->{netmask}));
+ notify($ERRORS{'OK'}, 0, "updated data server request
dns info") if
($self->data->set_server_request_DNSservers(@{$server_variable_data->{dns}}));
+ notify($ERRORS{'DEBUG'}, 0, "router= $router, netmask=
$netmask, dns= @dns");
+
+ }
+ else{
+ notify($ERRORS{'DEBUG'}, 0, "data is not set for $variable_name");
+ return 0;
+ }
+
+}
+
#///////////////////////////////////////////////////////////////////////////
1;
Modified: vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm
URL:
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm?rev=1388527&r1=1388526&r2=1388527&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm Fri Sep 21 14:32:40 2012
@@ -524,12 +524,17 @@ sub set_static_public_address {
}
my $computer_name = $self->data->get_computer_short_name();
+ my $server_request_id = $self->data->get_server_request_id();
+ my $server_request_fixedIP =
$self->data->get_server_request_fixedIP();
- # Make sure public IP configuration is static
+ # Make sure public IP configuration is static or this is a server
request
+
my $ip_configuration =
$self->data->get_management_node_public_ip_configuration();
if ($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;
+ if( !$server_request_fixedIP ) {
+ notify($ERRORS{'WARNING'}, 0, "static public address
can only be set if IP configuration is static or is a server request, current
value: $ip_configuration \nserver_request_fixedIP=$server_request_fixedIP");
+ return;
+ }
}
# Get the IP configuration
@@ -539,6 +544,13 @@ sub set_static_public_address {
my $default_gateway =
$self->data->get_management_node_public_default_gateway() || '<undefined>';
my @dns_servers = $self->data->get_management_node_public_dns_servers();
+ if ($server_request_fixedIP) {
+ $ip_address = $server_request_fixedIP;
+ $subnet_mask = $self->data->get_server_request_netmask();
+ $default_gateway = $self->data->get_server_request_router();
+ @dns_servers = $self->data->get_server_request_DNSservers();
+ }
+
# Assemble a string containing the static IP configuration
my $configuration_info_string = <<EOF;
public interface name: $interface_name
@@ -556,6 +568,13 @@ EOF
else {
notify($ERRORS{'OK'}, 0, "attempting to set static public IP
address on $computer_name:\n$configuration_info_string");
}
+
+ #Try to ping address to make sure it's available
+ #FIXME -- need to add other tests for checking ip_address is or is not
available.
+ if((_pingnode($ip_address))) {
+ notify($ERRORS{'WARNING'}, 0, "ip_address $ip_address is
pingable, can not assign to $computer_name ");
+ return;
+ }
# Assemble the ifcfg file path
my $network_scripts_path = "/etc/sysconfig/network-scripts";
@@ -2924,10 +2943,10 @@ sub create_user {
# $useradd_string = "/usr/sbin/useradd -u $user_uid -d
/home/$username -m $username -g vcl";
#}
if($user_standalone){
- $useradd_string = "/usr/sbin/useradd -d /home/$username -m
$username -g vcl";
+ $useradd_string = "/usr/sbin/useradd -d /home/$username -m
$username -g vcl; chown -R $username /home/$username";
}
else {
- $useradd_string = "/usr/sbin/useradd -u $user_uid -d
/home/$username -m $username -g vcl";
+ $useradd_string = "/usr/sbin/useradd -u $user_uid -d
/home/$username -m $username -g vcl; chown -R $username /home/$username";
}
Modified: vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm
URL:
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm?rev=1388527&r1=1388526&r2=1388527&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm Fri Sep 21 14:32:40
2012
@@ -690,7 +690,7 @@ sub post_load {
if (!$self->update_public_ip_address()) {
notify($ERRORS{'WARNING'}, 0, "failed to update IP address for
$computer_node_name");
- return 0;
+ return 0;
}
=item *
@@ -5864,7 +5864,7 @@ sub get_public_ip_address {
notify($ERRORS{'WARNING'}, 0, "unable to determine public IP
address assigned to $computer_node_name, static public IP address may not have
been set yet, management node public IP configuration:
$public_ip_configuration");
return;
}
-
+
# Management node is configured to use DHCP, failed to determine public
IP address on 1st try
# Check if DHCP is enabled on what was determined to be the public
interface
# DHCP should always be enabled or something is wrong
@@ -5872,8 +5872,8 @@ sub get_public_ip_address {
# Don't forcefully enable DHCP
if (!$self->is_dhcp_enabled($public_interface_name)) {
notify($ERRORS{'WARNING'}, 0, "unable to determine public IP
address assigned to $computer_node_name, DHCP is not enabled on public
interface: '$public_interface_name', management node public IP configuration:
$public_ip_configuration");
- return;
- }
+ return;
+ }
# Network interfaces may still be initializing
return $self->code_loop_timeout(
@@ -6043,26 +6043,26 @@ sub ipconfig_renew {
}
$ipconfig_command .= "$system32_path/ipconfig.exe /renew
\"$interface_name\"";
- # Run ipconfig
- my ($ipconfig_status, $ipconfig_output) = $self->execute({command =>
$ipconfig_command, timeout => 65, ignore_error => 1});
- if (!defined($ipconfig_output)) {
+ # Run ipconfig
+ my ($ipconfig_status, $ipconfig_output) =
$self->execute({command => $ipconfig_command, timeout => 65, ignore_error =>
1});
+ if (!defined($ipconfig_output)) {
notify($ERRORS{'WARNING'}, 0, "failed to execute command to
renew IP configuration for interface '$interface_name'");
return;
- }
- elsif (grep(/error occurred/i, @$ipconfig_output)) {
+ }
+ elsif (grep(/error occurred/i, @$ipconfig_output)) {
notify($ERRORS{'WARNING'}, 0, "failed to renew IP configuration
for interface '$interface_name', exit status: $ipconfig_status, output:\n" .
join("\n", @$ipconfig_output));
- return;
- }
- elsif ($ipconfig_status ne '0' || grep(/error occurred/i,
@$ipconfig_output)) {
+ return;
+ }
+ elsif ($ipconfig_status ne '0' || grep(/error occurred/i,
@$ipconfig_output)) {
notify($ERRORS{'WARNING'}, 0, "failed to renew IP configuration
for interface '$interface_name', exit status: $ipconfig_status, command:
'$ipconfig_command', output:\n" . join("\n", @$ipconfig_output));
return;
+ }
+ else {
+ notify($ERRORS{'OK'}, 0, "renewed IP configuration for
interface '$interface_name', output:\n" . join("\n", @$ipconfig_output));
+ return 1;
+ }
}
- else {
- notify($ERRORS{'OK'}, 0, "renewed IP configuration for
interface '$interface_name', output:\n" . join("\n", @$ipconfig_output));
- return 1;
- }
-}
-
+
#/////////////////////////////////////////////////////////////////////////////
=head2 delete_capture_configuration_files
@@ -8332,12 +8332,17 @@ sub set_static_public_address {
my $system32_path = $self->get_system32_path() || return;
my $computer_name = $self->data->get_computer_short_name();
+
+ my $server_request_id = $self->data->get_server_request_id();
+ my $server_request_fixedIP =
$self->data->get_server_request_fixedIP();
- # Make sure public IP configuration is static
+ # Make sure public IP configuration is static or this is a server
request
my $ip_configuration =
$self->data->get_management_node_public_ip_configuration();
if ($ip_configuration !~ /static/i) {
- notify($ERRORS{'WARNING'}, 0, "static public address can only
be set if IP configuration is static, current value: $ip_configuration");
+ if( !$server_request_fixedIP ) {
+ notify($ERRORS{'WARNING'}, 0, "static public
address can only be set if IP configuration is static, current value:
$ip_configuration \nserver_request_fixedIP=$server_request_fixedIP");
return;
+ }
}
# Get the IP configuration
@@ -8346,6 +8351,13 @@ sub set_static_public_address {
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_servers = $self->data->get_management_node_public_dns_servers();
+
+ if ($server_request_fixedIP) {
+ $ip_address = $server_request_fixedIP;
+ $subnet_mask = $self->data->get_server_request_netmask();
+ $default_gateway = $self->data->get_server_request_router();
+ @dns_servers = $self->data->get_server_request_DNSservers();
+ }
# Assemble a string containing the static IP configuration
my $configuration_info_string = <<EOF;
@@ -8364,6 +8376,13 @@ EOF
else {
notify($ERRORS{'OK'}, 0, "attempting to set static public IP
address on $computer_name:\n$configuration_info_string");
}
+
+ #Try to ping address to make sure it's available
+ #FIXME -- need to add other tests for checking ip_address is or is not
available.
+ if(_pingnode($ip_address)) {
+ notify($ERRORS{'WARNING'}, 0, "ip_address $ip_address is pingable, can
not assign to $computer_name ");
+ return;
+ }
my $primary_dns_server_address = shift @dns_servers;
notify($ERRORS{'DEBUG'}, 0, "primary DNS server address:
$primary_dns_server_address\nalternate DNS server address(s):\n" . (join("\n",
@dns_servers) || '<none>'));
Modified: vcl/trunk/managementnode/lib/VCL/new.pm
URL:
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/new.pm?rev=1388527&r1=1388526&r2=1388527&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/new.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/new.pm Fri Sep 21 14:32:40 2012
@@ -500,6 +500,8 @@ sub reload_image {
my $image_name = $self->data->get_image_name();
my $image_os_install_type =
$self->data->get_image_os_install_type();
my $imagerevision_id =
$self->data->get_imagerevision_id();
+ my $server_request_id =
$self->data->get_server_request_id();
+ my $server_request_fixedIP =
$self->data->get_server_request_fixedIP();
# Try to get the node status if the provisioning engine has implemented
a node_status() subroutine
my $node_status;
@@ -679,6 +681,7 @@ sub reload_image {
notify($ERRORS{'OK'}, 0, "node ready: successfully reloaded
$computer_short_name with $image_name");
insertloadlog($reservation_id, $computer_id, "nodeready",
"$computer_short_name was reloaded with $image_name");
}
+
# Update the current image ID in the computer table
if (update_currentimage($computer_id, $image_id, $imagerevision_id,
$image_id)) {
@@ -687,6 +690,19 @@ sub reload_image {
else {
notify($ERRORS{'WARNING'}, 0, "failed to update computer table
for $computer_short_name: currentimageid=$image_id");
}
+
+
+ if($server_request_id) {
+ notify($ERRORS{'DEBUG'}, 0, " SERVER_REQUEST_ID detected");
+ if($server_request_fixedIP) {
+ notify($ERRORS{'DEBUG'}, 0, "server_request_fixedIP is set calling
update_public_ip_address");
+ if(!$self->os->server_request_set_fixedIP()){
+ notify($ERRORS{'WARNING'}, 0, "failed
to update IP address for $computer_short_name");
+ insertloadlog($reservation_id,
$computer_id, "failed", "unable to set public IP address on
$computer_short_name possibly IP address is inuse");
+ return;
+ }
+ }
+ }
notify($ERRORS{'OK'}, 0, "returning 1");
return 1;
@@ -1284,7 +1300,6 @@ sub confirm_public_ip_address {
my $public_ip_address;
my $computer_ip_address =
$self->data->get_computer_ip_address();
my $computer_id = $self->data->get_computer_id();
- my $computer_short_name =
$self->data->get_computer_short_name();
#Try to get public IP address from OS module
if(!$self->os->can("get_public_ip_address")) {
Modified: vcl/trunk/managementnode/lib/VCL/reclaim.pm
URL:
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/reclaim.pm?rev=1388527&r1=1388526&r2=1388527&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/reclaim.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/reclaim.pm Fri Sep 21 14:32:40 2012
@@ -98,6 +98,19 @@ sub process {
my $computer_state_name =
$self->data->get_computer_state_name();
my $computer_currentimage_name =
$self->data->get_computer_currentimage_name(0);
my $server_request_id =
$self->data->get_server_request_id();
+
+ # Remove related fixedIPsr variable, if it exists
+ if ($server_request_id) {
+ my $variable_name = "fixedIPsr" . $server_request_id;
+ if($self->data->is_variable_set($variable_name)){
+ #Delete from variable table.
+ my $delete_sql_statement = "DELETE variable FROM variable WHERE
name = '$variable_name' ";
+ if (database_execute($delete_sql_statement)) {
+ notify($ERRORS{'OK'}, 0, "Detected
server reservation entry for $variable_name from variable table");
+ }
+ }
+ }
+
# Insert into computerloadlog if request state = timeout
if ($request_state_name =~ /timeout|deleted/) {
@@ -160,6 +173,7 @@ sub process {
}
+
# Update the request state to complete and exit
# Set the computer state to available if it isn't in the maintenance or
reloading state
if ($computer_state_name =~ /maintenance|reloading/) {
Modified: vcl/trunk/managementnode/lib/VCL/utils.pm
URL:
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/utils.pm?rev=1388527&r1=1388526&r2=1388527&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/utils.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/utils.pm Fri Sep 21 14:32:40 2012
@@ -4104,12 +4104,17 @@ EOF
$request_info->{reservation}{$reservation_id}{serverrequest}{id} ||= 0;
$request_info->{reservation}{$reservation_id}{serverrequest}{fixedIP} ||= 0;
$request_info->{reservation}{$reservation_id}{serverrequest}{fixedMAC} ||= 0;
+
$request_info->{reservation}{$reservation_id}{serverrequest}{router} ||= 0;
+
$request_info->{reservation}{$reservation_id}{serverrequest}{netmask} ||= 0;
+
$request_info->{reservation}{$reservation_id}{serverrequest}{DNSservers} ||= 0;
$request_info->{reservation}{$reservation_id}{serverrequest}{admingroupid} ||=
0;
$request_info->{reservation}{$reservation_id}{serverrequest}{logingroupid} ||=
0;
$request_info->{reservation}{$reservation_id}{serverrequest}{monitored} ||= 0;
$request_info->{reservation}{$reservation_id}{serverrequest}{ALLOW_USERS} ||= 0;
$request_info->{reservation}{$reservation_id}{READY} = '0';
+
+
}
# Set some default non-database values for the entire request