Author: arkurth
Date: Wed Aug 22 17:46:29 2012
New Revision: 1376156

URL: http://svn.apache.org/viewvc?rev=1376156&view=rev
Log:
VCL-620
Added code to libvirt.pm::post_maintenance_action to delete the VM from the 
host when it is unassigned from the host.

Modified:
    
vcl/branches/vcl-2.3-bugfixes/managementnode/lib/VCL/Module/Provisioning/libvirt.pm
    vcl/trunk/managementnode/lib/VCL/Module/Provisioning/libvirt.pm

Modified: 
vcl/branches/vcl-2.3-bugfixes/managementnode/lib/VCL/Module/Provisioning/libvirt.pm
URL: 
http://svn.apache.org/viewvc/vcl/branches/vcl-2.3-bugfixes/managementnode/lib/VCL/Module/Provisioning/libvirt.pm?rev=1376156&r1=1376155&r2=1376156&view=diff
==============================================================================
--- 
vcl/branches/vcl-2.3-bugfixes/managementnode/lib/VCL/Module/Provisioning/libvirt.pm
 (original)
+++ 
vcl/branches/vcl-2.3-bugfixes/managementnode/lib/VCL/Module/Provisioning/libvirt.pm
 Wed Aug 22 17:46:29 2012
@@ -766,8 +766,9 @@ sub power_reset {
 
  Parameters  : none
  Returns     : boolean
- Description : Performs tasks to the computer after it has been put into
-               maintenance mode.
+ Description : Performs tasks when a VM is unassigned from a host:
+               -Deletes domain from node
+               -Unassigns VM from VM host (sets computer.vmhostid to NULL)
 
 =cut
 
@@ -778,6 +779,25 @@ sub post_maintenance_action {
                return;
        }
        
+       my $domain_name = shift || $self->get_domain_name();
+       my $node_name = $self->data->get_vmhost_short_name();
+       my $computer_id = $self->data->get_computer_id();
+       
+       # Delete the domains on the node which were created for the computer 
being put into maintenance
+       if (!$self->delete_existing_domains()) {
+               notify($ERRORS{'WARNING'}, 0, "failed to delete existing 
$domain_name domains on $node_name");
+               return;
+       }
+       
+       # Unassign the VM from the VM host, change computer.vmhostid to NULL
+       if (switch_vmhost_id($computer_id, 'NULL')) {
+               notify($ERRORS{'OK'}, 0, "set vmhostid to NULL for for 
$domain_name");
+       }
+       else {
+               notify($ERRORS{'WARNING'}, 0, "failed to set the vmhostid to 
NULL for $domain_name");
+               return;
+       }
+       
        return 1;
 } ## end sub post_maintenance_action
 

Modified: vcl/trunk/managementnode/lib/VCL/Module/Provisioning/libvirt.pm
URL: 
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/libvirt.pm?rev=1376156&r1=1376155&r2=1376156&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/Provisioning/libvirt.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/Provisioning/libvirt.pm Wed Aug 22 
17:46:29 2012
@@ -766,8 +766,9 @@ sub power_reset {
 
  Parameters  : none
  Returns     : boolean
- Description : Performs tasks to the computer after it has been put into
-               maintenance mode.
+ Description : Performs tasks when a VM is unassigned from a host:
+               -Deletes domain from node
+               -Unassigns VM from VM host (sets computer.vmhostid to NULL)
 
 =cut
 
@@ -778,6 +779,25 @@ sub post_maintenance_action {
                return;
        }
        
+       my $domain_name = shift || $self->get_domain_name();
+       my $node_name = $self->data->get_vmhost_short_name();
+       my $computer_id = $self->data->get_computer_id();
+       
+       # Delete the domains on the node which were created for the computer 
being put into maintenance
+       if (!$self->delete_existing_domains()) {
+               notify($ERRORS{'WARNING'}, 0, "failed to delete existing 
$domain_name domains on $node_name");
+               return;
+       }
+       
+       # Unassign the VM from the VM host, change computer.vmhostid to NULL
+       if (switch_vmhost_id($computer_id, 'NULL')) {
+               notify($ERRORS{'OK'}, 0, "set vmhostid to NULL for for 
$domain_name");
+       }
+       else {
+               notify($ERRORS{'WARNING'}, 0, "failed to set the vmhostid to 
NULL for $domain_name");
+               return;
+       }
+       
        return 1;
 } ## end sub post_maintenance_action
 


Reply via email to