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=730217&r1=730216&r2=730217&view=diff ============================================================================== --- incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT.pm (original) +++ incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT.pm Tue Dec 30 11:26:51 2008 @@ -364,8 +364,8 @@ return; } -# Check progress, locate MAC and IP address for this node, monitor /var/log/messages for communication from node -# dhcp req/ack, xcat calls, etc + # Check progress, locate MAC and IP address for this node, monitor /var/log/messages for communication from node + # dhcp req/ack, xcat calls, etc my ($eth0MACaddress, $privateIP); if (open(MACTAB, "$XCAT_ROOT/etc/mac.tab")) { my @mactab = <MACTAB>; @@ -661,7 +661,8 @@ READYFLAG: #check /var/log/messages file for READY - + + # Wait for READY flag if (open(TAIL, "</var/log/messages")) { seek TAIL, -1, 2; for (;;) { @@ -687,7 +688,7 @@ close(TAIL); goto SSHDATTEMPT; } - if ($readycount > 2) { + #if ($readycount > 2) { #check ssh status just in case we missed the flag my $sshd = _sshd_status($computer_node_name, $image_name); @@ -697,7 +698,7 @@ close(TAIL); goto SSHDATTEMPT; } - } ## end if ($readycount > 2) + #} ## end if ($readycount > 2) if (!$ready) { notify($ERRORS{'OK'}, 0, "$computer_node_name not ready yet, sleeping for 40 seconds"); sleep 40; @@ -861,11 +862,57 @@ else { notify($ERRORS{'CRITICAL'}, 0, "could not execute $XCAT_ROOT/sbin/makesshgkh $computer_node_name $!"); } + + # IP configuration + if ($IPCONFIGURATION ne "manualDHCP") { + insertloadlog($reservation_id, $computer_id, "info", "detected change required in IP address configuration on node"); + + #not default setting + if ($IPCONFIGURATION eq "dynamicDHCP") { + my $assignedIPaddress = getdynamicaddress($computer_node_name, $image_os_name); + if ($assignedIPaddress) { + + #update computer table + if (update_computer_address($computer_id, $assignedIPaddress)) { + notify($ERRORS{'OK'}, 0, "dynamic address collected $assignedIPaddress -- updated computer table"); + insertloadlog($reservation_id, $computer_id, "dynamicDHCPaddress", "SUCCESS collected dynamicDHCP address"); + } + else { + notify($ERRORS{'OK'}, 0, "failed to update dynamic address $assignedIPaddress for$computer_id $computer_node_name "); + insertloadlog($reservation_id, $computer_id, "dynamicDHCPaddress", "FAILED to update dynamicDHCP address failing reservation"); + return 0; + } + } ## end if ($assignedIPaddress) + else { + notify($ERRORS{'CRITICAL'}, 0, "could not fetch dynamic address from $computer_node_name $image_name"); + insertloadlog($reservation_id, $computer_id, "dynamicDHCPaddress", "FAILED to collected dynamicDHCP address failing reservation"); + return 0; + } + } ## end if ($IPCONFIGURATION eq "dynamicDHCP") + elsif ($IPCONFIGURATION eq "static") { + insertloadlog($reservation_id, $computer_id, "info", "setting staticIPaddress"); + + if (setstaticaddress($computer_node_name, $image_os_name, $computer_ip_address)) { + 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"); + } + else { + insertloadlog($reservation_id, $computer_id, "staticIPaddress", "failed to set static IP address on public interface"); + return 0; + } + } ## end elsif ($IPCONFIGURATION eq "static") [ if ($IPCONFIGURATION eq "dynamicDHCP") + } ## end if ($IPCONFIGURATION ne "manualDHCP") # Perform post load tasks # Windows specific routines - if ($image_os_name =~ /winxp|wxp|win2003/) { + if ($image_os_name =~ /winvista/) { + # If Vista, don't perform post-load tasks here + # new.pm calls the Vista module's post_load() subroutine to perform the same tasks as below + notify($ERRORS{'OK'}, 0, "vista image, skipping OS preparation tasks in xCAT.pm, returning 1"); + return 1; + } + elsif ($image_os_name =~ /winxp|wxp|win2003|winvista/) { insertloadlog($reservation_id, $computer_id, "info", "randomizing system level passwords"); @@ -948,11 +995,10 @@ } #while } #reboot -#win2003 only - need to set private adapter to static without a gateway -# win2003 and probably vista zero out one gateway and we only need a gateway on the public adapter -# so we need to remove the one on the private side -# downside - we need to reset it to dhcp before making an image..... - + #win2003 only - need to set private adapter to static without a gateway + # win2003 and probably vista zero out one gateway and we only need a gateway on the public adapter + # so we need to remove the one on the private side + # downside - we need to reset it to dhcp before making an image..... if ($image_os_name =~ /^(win2003)/) { insertloadlog($reservation_id, $computer_id, "info", "detected OS which requires network gateway modification"); notify($ERRORS{'OK'}, 0, "detected win2003 OS, proceeding to change private adapter to static from dhcp on $computer_node_name"); @@ -1135,46 +1181,6 @@ } ## end elsif ($image_os_name =~ /^(rh[0-9]image|rhel[0-9]|fc[0-9]image|rhfc[0-9]|rhas[0-9]|esx[0-9]+)/) [ if ($image_os_name =~ /winxp|wxp|win2003/) - # IP configuration - if ($IPCONFIGURATION ne "manualDHCP") { - insertloadlog($reservation_id, $computer_id, "info", "detected change required in IP address configuration on node"); - - #not default setting - if ($IPCONFIGURATION eq "dynamicDHCP") { - my $assignedIPaddress = getdynamicaddress($computer_node_name, $image_os_name); - if ($assignedIPaddress) { - - #update computer table - if (update_computer_address($computer_id, $assignedIPaddress)) { - notify($ERRORS{'OK'}, 0, "dynamic address collected $assignedIPaddress -- updated computer table"); - insertloadlog($reservation_id, $computer_id, "dynamicDHCPaddress", "SUCCESS collected dynamicDHCP address"); - } - else { - notify($ERRORS{'OK'}, 0, "failed to update dynamic address $assignedIPaddress for$computer_id $computer_node_name "); - insertloadlog($reservation_id, $computer_id, "dynamicDHCPaddress", "FAILED to update dynamicDHCP address failing reservation"); - return 0; - } - } ## end if ($assignedIPaddress) - else { - notify($ERRORS{'CRITICAL'}, 0, "could not fetch dynamic address from $computer_node_name $image_name"); - insertloadlog($reservation_id, $computer_id, "dynamicDHCPaddress", "FAILED to collected dynamicDHCP address failing reservation"); - return 0; - } - } ## end if ($IPCONFIGURATION eq "dynamicDHCP") - elsif ($IPCONFIGURATION eq "static") { - insertloadlog($reservation_id, $computer_id, "info", "setting staticIPaddress"); - - if (setstaticaddress($computer_node_name, $image_os_name, $computer_ip_address)) { - 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"); - } - else { - insertloadlog($reservation_id, $computer_id, "staticIPaddress", "failed to set static IP address on public interface"); - return 0; - } - } ## end elsif ($IPCONFIGURATION eq "static") [ if ($IPCONFIGURATION eq "dynamicDHCP") - } ## end if ($IPCONFIGURATION ne "manualDHCP") - return 1; } ## end sub load
Modified: incubator/vcl/trunk/managementnode/lib/VCL/new.pm URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/new.pm?rev=730217&r1=730216&r2=730217&view=diff ============================================================================== --- incubator/vcl/trunk/managementnode/lib/VCL/new.pm (original) +++ incubator/vcl/trunk/managementnode/lib/VCL/new.pm Tue Dec 30 11:26:51 2008 @@ -138,7 +138,7 @@ notify($ERRORS{'OK'}, 0, "originating request laststate = $request_laststate_name"); notify($ERRORS{'OK'}, 0, "originating computer state = $computer_state_name"); notify($ERRORS{'OK'}, 0, "originating computer type = $computer_type"); - + # If state is tomaintenance, place machine into maintenance state and set request to complete if ($request_state_name =~ /tomaintenance/) { notify($ERRORS{'OK'}, 0, "this is a 'tomaintenance' request"); @@ -165,7 +165,7 @@ notify($ERRORS{'OK'}, 0, "exiting"); exit; } ## end if ($request_state_name =~ /tomaintenance/) - + # Confirm requested computer is available if ($self->computer_not_being_used()) { notify($ERRORS{'OK'}, 0, "$computer_short_name is not being used"); @@ -575,95 +575,124 @@ $node_status_string = 'reload'; } - # Check the status string returned by node_status - if ($node_status_string !~ /^ready/i) { - notify($ERRORS{'OK'}, 0, "node status is $node_status_string, $computer_short_name will be reloaded"); - insertloadlog($reservation_id, $computer_id, "loadimageblade", "$computer_short_name must be reloaded with $image_name"); - - # Make sure provisioning module's load() subroutine exists - if (!$self->provisioner->can("load")) { - notify($ERRORS{'CRITICAL'}, 0, ref($self->provisioner) . "->load() subroutine does not exist, returning"); - insertloadlog($reservation_id, $computer_id, "failed", ref($self->provisioner) . "->load() subroutine does not exist"); - return; - } + # Check the status string returned by node_status = 'ready' + if ($node_status_string =~ /^ready/i) { + # node_status returned 'ready' + notify($ERRORS{'OK'}, 0, "node_status returned '$node_status_string', $computer_short_name will not be reloaded"); + insertloadlog($reservation_id, $computer_id, "info", "node status is $node_status_string, $computer_short_name will not be reloaded"); + + notify($ERRORS{'OK'}, 0, "returning 1"); + return 1; + } + + # node_status did not return 'ready' + notify($ERRORS{'OK'}, 0, "node status is $node_status_string, $computer_short_name will be reloaded"); + insertloadlog($reservation_id, $computer_id, "loadimageblade", "$computer_short_name must be reloaded with $image_name"); - # Make sure the image exists on this management node's local disks - # Attempt to retrieve it if necessary - if ($self->provisioner->can("does_image_exist")) { - notify($ERRORS{'DEBUG'}, 0, "calling " . ref($self->provisioner) . "->does_image_exist()"); - - if ($self->provisioner->does_image_exist($image_name)) { - notify($ERRORS{'OK'}, 0, "$image_name exists on this management node"); - insertloadlog($reservation_id, $computer_id, "doesimageexists", "confirmed image exists"); - } - else { - notify($ERRORS{'OK'}, 0, "$image_name does not exist on this management node"); + # Make sure provisioning module's load() subroutine exists + if (!$self->provisioner->can("load")) { + notify($ERRORS{'CRITICAL'}, 0, ref($self->provisioner) . "->load() subroutine does not exist, returning"); + insertloadlog($reservation_id, $computer_id, "failed", ref($self->provisioner) . "->load() subroutine does not exist"); + return; + } - # Try to retrieve the image files from another management node - if ($self->provisioner->can("retrieve_image")) { - notify($ERRORS{'DEBUG'}, 0, "calling " . ref($self->provisioner) . "->retrieve_image()"); - if ($self->provisioner->retrieve_image($image_name)) { - notify($ERRORS{'OK'}, 0, "$image_name was retrieved from another management node"); - } - else { - notify($ERRORS{'CRITICAL'}, 0, "$image_name does not exist on management node and could not be retrieved"); - insertloadlog($reservation_id, $computer_id, "failed", "requested image does not exist on management node and could not be retrieved"); - return; - } - } ## end if ($self->provisioner->can("retrieve_image"... + # Make sure the image exists on this management node's local disks + # Attempt to retrieve it if necessary + if ($self->provisioner->can("does_image_exist")) { + notify($ERRORS{'DEBUG'}, 0, "calling " . ref($self->provisioner) . "->does_image_exist()"); + + if ($self->provisioner->does_image_exist($image_name)) { + notify($ERRORS{'OK'}, 0, "$image_name exists on this management node"); + insertloadlog($reservation_id, $computer_id, "doesimageexists", "confirmed image exists"); + } + else { + notify($ERRORS{'OK'}, 0, "$image_name does not exist on this management node"); + + # Try to retrieve the image files from another management node + if ($self->provisioner->can("retrieve_image")) { + notify($ERRORS{'DEBUG'}, 0, "calling " . ref($self->provisioner) . "->retrieve_image()"); + + if ($self->provisioner->retrieve_image($image_name)) { + notify($ERRORS{'OK'}, 0, "$image_name was retrieved from another management node"); + } else { - notify($ERRORS{'CRITICAL'}, 0, "unable to retrieve image from another management node, retrieve_image() is not implemented by " . ref($self->provisioner)); - insertloadlog($reservation_id, $computer_id, "failed", "failed requested image does not exist on management node, retrieve_image() is not implemented"); + notify($ERRORS{'CRITICAL'}, 0, "$image_name does not exist on management node and could not be retrieved"); + insertloadlog($reservation_id, $computer_id, "failed", "requested image does not exist on management node and could not be retrieved"); return; } - } ## end else [ if ($self->provisioner->does_image_exist($image_name... - } ## end if ($self->provisioner->can("does_image_exist"... - else { - notify($ERRORS{'OK'}, 0, "unable to check if image exists, does_image_exist() not implemented by " . ref($self->provisioner)); - } + } ## end if ($self->provisioner->can("retrieve_image"... + else { + notify($ERRORS{'CRITICAL'}, 0, "unable to retrieve image from another management node, retrieve_image() is not implemented by " . ref($self->provisioner)); + insertloadlog($reservation_id, $computer_id, "failed", "failed requested image does not exist on management node, retrieve_image() is not implemented"); + return; + } + } ## end else [ if ($self->provisioner->does_image_exist($image_name... + } ## end if ($self->provisioner->can("does_image_exist"... + else { + notify($ERRORS{'OK'}, 0, "unable to check if image exists, does_image_exist() not implemented by " . ref($self->provisioner)); + } - # Update the computer state to reloading - if (update_computer_state($computer_id, "reloading")) { - notify($ERRORS{'OK'}, 0, "computer $computer_short_name state set to reloading"); - insertloadlog($reservation_id, $computer_id, "info", "computer state updated to reloading"); - } - else { - notify($ERRORS{'CRITICAL'}, 0, "unable to set $computer_short_name into reloading state, returning"); - insertloadlog($reservation_id, $computer_id, "failed", "unable to set computer $computer_short_name state to reloading"); - return; - } - # Call provisioning module's load() subroutine - notify($ERRORS{'OK'}, 0, "calling " . ref($self->provisioner) . "->load() subroutine"); - insertloadlog($reservation_id, $computer_id, "info", "calling " . ref($self->provisioner) . "->load() subroutine"); - if ($self->provisioner->load($node_status)) { - notify($ERRORS{'OK'}, 0, "$image_name was successfully reloaded on $computer_short_name"); - insertloadlog($reservation_id, $computer_id, "loadimagecomplete", "$image_name was successfully reloaded on $computer_short_name"); - } - else { - notify($ERRORS{'CRITICAL'}, 0, "$image_name failed to load on $computer_short_name, returning"); - insertloadlog($reservation_id, $computer_id, "loadimagefailed", "$image_name failed to load on $computer_short_name"); - return; - } + # Update the computer state to reloading + if (update_computer_state($computer_id, "reloading")) { + notify($ERRORS{'OK'}, 0, "computer $computer_short_name state set to reloading"); + insertloadlog($reservation_id, $computer_id, "info", "computer state updated to reloading"); + } + else { + notify($ERRORS{'CRITICAL'}, 0, "unable to set $computer_short_name into reloading state, returning"); + insertloadlog($reservation_id, $computer_id, "failed", "unable to set computer $computer_short_name state to reloading"); + return; + } + - # Update the current image ID in the computer table - if (update_currentimage($computer_id, $image_id, $imagerevision_id, $image_id)) { - notify($ERRORS{'OK'}, 0, "updated computer table for $computer_short_name: currentimageid=$image_id"); + # Call provisioning module's load() subroutine + notify($ERRORS{'OK'}, 0, "calling " . ref($self->provisioner) . "->load() subroutine"); + insertloadlog($reservation_id, $computer_id, "info", "calling " . ref($self->provisioner) . "->load() subroutine"); + if ($self->provisioner->load($node_status)) { + notify($ERRORS{'OK'}, 0, "$image_name was successfully reloaded on $computer_short_name"); + insertloadlog($reservation_id, $computer_id, "loadimagecomplete", "$image_name was successfully reloaded on $computer_short_name"); + } + else { + notify($ERRORS{'CRITICAL'}, 0, "$image_name failed to load on $computer_short_name, returning"); + insertloadlog($reservation_id, $computer_id, "loadimagefailed", "$image_name failed to load on $computer_short_name"); + return; + } + + + # Update the current image ID in the computer table + if (update_currentimage($computer_id, $image_id, $imagerevision_id, $image_id)) { + notify($ERRORS{'OK'}, 0, "updated computer table for $computer_short_name: currentimageid=$image_id"); + } + else { + notify($ERRORS{'WARNING'}, 0, "failed to update computer table for $computer_short_name: currentimageid=$image_id"); + } + + + # Check if OS module's post_load() subroutine exists + if ($self->os->can("post_load")) { + notify($ERRORS{'OK'}, 0, ref($self->os) . "->post_load() subroutine exists"); + + # Call OS module's post_load() subroutine + notify($ERRORS{'OK'}, 0, "calling " . ref($self->os) . "->post_load() subroutine"); + insertloadlog($reservation_id, $computer_id, "info", "calling " . ref($self->os) . "->post_load() subroutine"); + if ($self->os->post_load()) { + notify($ERRORS{'OK'}, 0, "successfully performed OS post-load tasks for $image_name on $computer_short_name"); + insertloadlog($reservation_id, $computer_id, "info", "performed OS post-load tasks for $image_name on $computer_short_name"); } else { - notify($ERRORS{'WARNING'}, 0, "failed to update computer table for $computer_short_name: currentimageid=$image_id"); + notify($ERRORS{'CRITICAL'}, 0, "failed to perform OS post-load tasks for $image_name on $computer_short_name, returning"); + insertloadlog($reservation_id, $computer_id, "loadimagefailed", "failed to perform OS post-load tasks for $image_name on $computer_short_name"); + return; } - - insertloadlog($reservation_id, $computer_id, "nodeready", "$computer_short_name was reloaded with $image_name"); - } ## end if ($node_status_string !~ /^ready/i) - + } else { - # node_status returned 'ready' - notify($ERRORS{'OK'}, 0, "node_status returned '$node_status_string', $computer_short_name will not be reloaded"); - insertloadlog($reservation_id, $computer_id, "info", "node status is $node_status_string, $computer_short_name will not be reloaded"); + notify($ERRORS{'OK'}, 0, ref($self->os) . "->post_load() subroutine does not exist"); } + 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"); + notify($ERRORS{'OK'}, 0, "returning 1"); return 1; } ## end sub reload_image @@ -1017,8 +1046,33 @@ else { notify($ERRORS{'CRITICAL'}, 0, "failed to update password entry reservation_id $reservation_id"); } + + # Set the password in the DataStructure object + $self->data->set_reservation_password($reservation_password); + + # Windows Vista reservation tasks + # Much of this subroutine will be rearranged once other OS's are modularized + if ($image_os_name =~ /winvista/) { + if ($request_forimaging) { + # Set the Administrator password + notify($ERRORS{'OK'}, 0, "attempting to set Administrator password to $reservation_password on $computer_short_name"); + if (!$self->os->set_password('Administrator')) { + notify($ERRORS{'WARNING'}, 0, "reserve computer failed: unable to set password for administrator account on $computer_short_name"); + return 0; + } + } + else { + # Add the users to the computer + # OS add_users() subroutine will add the primary reservation user and any imagemeta group users + notify($ERRORS{'OK'}, 0, "attempting to add users to $computer_short_name"); + if (!$self->os->add_users()) { + notify($ERRORS{'WARNING'}, 0, "reserve computer failed: unable to add users to $computer_short_name"); + return 0; + } + } + } - if ($image_os_type =~ /windows/ && $request_forimaging) { + elsif ($image_os_type =~ /windows/ && $request_forimaging) { if (changewindowspasswd($computer_short_name, "administrator", $reservation_password)) { notify($ERRORS{'OK'}, 0, "password changed for administrator account on $computer_short_name to $reservation_password"); } Modified: incubator/vcl/trunk/managementnode/lib/VCL/reclaim.pm URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/reclaim.pm?rev=730217&r1=730216&r2=730217&view=diff ============================================================================== --- incubator/vcl/trunk/managementnode/lib/VCL/reclaim.pm (original) +++ incubator/vcl/trunk/managementnode/lib/VCL/reclaim.pm Tue Dec 30 11:26:51 2008 @@ -107,6 +107,7 @@ my $image_os_name = $request_data->{reservation}{$reservation_id}{image}{OS}{name}; my $imagerevision_imagename = $request_data->{reservation}{$reservation_id}{imagerevision}{imagename}; my $user_unityid = $request_data->{user}{unityid}; + my $computer_currentimage_name = $self->data->get_computer_currentimage_name(); # Assemble a consistent prefix for notify messages my $notify_prefix = "req=$request_id, res=$reservation_id:"; @@ -161,17 +162,58 @@ # The request will either be changed to "reload" or they will be cleaned # up based on the OS. # Lab computers only need to have sshd disabled. - + elsif ($computer_type =~ /blade|virtualmachine/) { notify($ERRORS{'OK'}, 0, "$notify_prefix computer type is $computer_type"); - # Check if request laststate is reserved + # Check if request laststate is reserved # This is the only case where computers will be cleaned and not reloaded if ($request_laststate_name =~ /reserved/) { notify($ERRORS{'OK'}, 0, "$notify_prefix request laststate is $request_laststate_name, attempting to clean up computer for next user"); + # *** BEGIN MODULARIZED OS CODE *** + # Attempt to get the name of the image currently loaded on the computer + # This should match the computer table's current image + if ($self->os->can("get_current_image_name")) { + notify($ERRORS{'OK'}, 0, "calling " . ref($self->os) . "::get_current_image_name() subroutine"); + my $current_image_name; + if ($current_image_name = $self->os->get_current_image_name()) { + notify($ERRORS{'OK'}, 0, "retrieved name of image currently loaded on $computer_shortname: $current_image_name"); + } + else { + # OS module's get_current_image_name() subroutine returned false, reload is necessary + notify($ERRORS{'WARNING'}, 0, "failed to retrieve name of image currently loaded on $computer_shortname, computer will be reloaded"); + $self->insert_reload_and_exit(); + } + + # Make sure the computer table's current image name matches what's on the computer + if ($current_image_name eq $computer_currentimage_name) { + notify($ERRORS{'OK'}, 0, "computer table current image name ($computer_currentimage_name) matches OS's current image name ($current_image_name)"); + } + else { + # Computer table current image name does not match current image, reload is necessary + notify($ERRORS{'WARNING'}, 0, "computer table current image name (" . string_to_ascii($computer_currentimage_name) . ") does not match OS's current image name (" . string_to_ascii($current_image_name) . "), computer will be reloaded"); + $self->insert_reload_and_exit(); + } + } + + # Attempt to call modularized OS module's sanitize() subroutine + # This subroutine should perform all the tasks necessary to sanitize the OS if it was reserved and not logged in to + if ($self->os->can("sanitize")) { + notify($ERRORS{'OK'}, 0, "calling " . ref($self->os) . "::sanitize() subroutine"); + if ($self->os->sanitize()) { + notify($ERRORS{'OK'}, 0, "OS has been sanitized on $computer_shortname"); + } + else { + # OS module's sanitize() subroutine returned false, meaning reload is necessary + notify($ERRORS{'WARNING'}, 0, "failed to sanitize OS on $computer_shortname, computer will be reloaded"); + $self->insert_reload_and_exit(); + } + } + # *** END MODULARIZED OS CODE *** + # Check the image OS type and clean up computer accordingly - if ($image_os_name =~ /^(win|vmwarewin|vmwareesxwin)/) { + elsif ($image_os_name =~ /^(win|vmwarewin|vmwareesxwin)/) { # Loaded Windows image needs to be cleaned up notify($ERRORS{'OK'}, 0, "$notify_prefix attempting steps to clean up loaded $image_os_name image"); @@ -379,6 +421,62 @@ } } ## end sub process + +#///////////////////////////////////////////////////////////////////////////// + +=head2 insert_reload_and_exit + + Parameters : $request_data_hash_reference + Returns : 1 if successful, 0 otherwise + Description : + +=cut + +sub insert_reload_and_exit { + my $self = shift; + my $request_data = $self->data->get_request_data; + my $reservation_id = $self->data->get_reservation_id(); + my $computer_id = $self->data->get_computer_id(); + + # Retrieve next image + my $next_image_name; + my $next_image_id; + my $next_imagerevision_id; + + if($self->predictor->can("get_next_image")){ + ($next_image_name, $next_image_id, $next_imagerevision_id) = $self->predictor->get_next_image(); + } + else{ + notify($ERRORS{'WARNING'}, 0, "predictor module does not support get_next_image, calling get_next_image_default"); + ($next_image_name, $next_image_id, $next_imagerevision_id) = get_next_image_default($computer_id); + } + + # Update the DataStructure object with the next image values + # These will be used by insert_reload_request() + $self->data->set_image_name($next_image_name); + $self->data->set_image_id($next_image_id); + $self->data->set_imagerevision_id($next_imagerevision_id); + + notify($ERRORS{'OK'}, 0, "next image: name=$next_image_name, image id=$next_image_id, imagerevisionid=$next_imagerevision_id"); + + # Insert reload request data into the datbase + if (insert_reload_request($request_data)) { + notify($ERRORS{'OK'}, 0, "inserted reload request into database for computer id=$computer_id, image=$next_image_name"); + + # Switch the request state to complete, leave the computer state as is, log ending to EOR, exit + switch_state($request_data, 'complete', '', 'EOR', '1'); + } + else { + notify($ERRORS{'CRITICAL'}, 0, "failed to insert reload request into database for computer id=$computer_id image=$next_image_name"); + + # Switch the request and computer states to failed, log ending to failed, exit + switch_state($request_data, 'failed', 'failed', 'failed', '1'); + } + + # Make sure this VCL state process exits + exit; +} + #///////////////////////////////////////////////////////////////////////////// 1; Modified: incubator/vcl/trunk/managementnode/lib/VCL/reserved.pm URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/reserved.pm?rev=730217&r1=730216&r2=730217&view=diff ============================================================================== --- incubator/vcl/trunk/managementnode/lib/VCL/reserved.pm (original) +++ incubator/vcl/trunk/managementnode/lib/VCL/reserved.pm Tue Dec 30 11:26:51 2008 @@ -192,17 +192,32 @@ # User has acknowledged notify($ERRORS{'OK'}, 0, "user acknowledged, remote IP: $remote_ip"); + # Attempt to call modularized OS module's grant_access() subroutine + if ($self->os->can("grant_access")) { + # If grant_access() has been implemented by OS module, + # don't check for remote IP and open RDP firewall port directly in this module + # OS module's grant_access() subroutine to perform the same tasks as below + notify($ERRORS{'OK'}, 0, "calling " . ref($self->os) . "::grant_access() subroutine"); + if ($self->os->grant_access()) { + notify($ERRORS{'OK'}, 0, "OS access has been granted on $nodename"); + } + else { + notify($ERRORS{'WARNING'}, 0, "failed to grant OS access on $nodename"); + } + } + + # Older style code, remove below once all OS's have been modularized # Check if computer type is blade - if ($computer_type =~ /blade|virtualmachine/) { + elsif ($computer_type =~ /blade|virtualmachine/) { notify($ERRORS{'OK'}, 0, "blade or virtual machine detected: $computer_type"); # different senerios # standard -- 1-1-1 with connection checks # group access M-N-K -- multiple users need access # standard with no connection checks - + if ($image_os_name =~ /win|vmwarewin/) { notify($ERRORS{'OK'}, 0, "Windows image detected: $image_os_name"); - + # Determine whether to open RDP port for single IP or group access if ($user_group_member_count > 0) { # Imagemeta user group defined and member count is > 0 Modified: incubator/vcl/trunk/managementnode/lib/VCL/utils.pm URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/utils.pm?rev=730217&r1=730216&r2=730217&view=diff ============================================================================== --- incubator/vcl/trunk/managementnode/lib/VCL/utils.pm (original) +++ incubator/vcl/trunk/managementnode/lib/VCL/utils.pm Tue Dec 30 11:26:51 2008 @@ -6109,7 +6109,7 @@ # Set the image identity file path my $imagerevision_imagename = $request_info{reservation}{$reservation_id}{imagerevision}{imagename}; my $identity_file_path; - if ($imagerevision_imagename =~ /^(win|vmwarewin|vmwareesxwin)/) { + if ($imagerevision_imagename =~ /^(win|vmwarewin|vmwareesxwin|vista)/) { $identity_file_path = $IDENTITY_wxp; } elsif ($imagerevision_imagename =~ /^(rh|fc|esx)/) { @@ -6128,7 +6128,7 @@ notify($ERRORS{'OK'}, 0, "MPLS reservation: $request_id:$reservation_id"); } else { - notify($ERRORS{'WARNING'}, 0, "unsupported image type: $imagerevision_imagename"); + notify($ERRORS{'WARNING'}, 0, "unsupported image type: '$imagerevision_imagename'"); } $request_info{reservation}{$reservation_id}{image}{IDENTITY} = $identity_file_path;