예제 #1
0
        protected override void Run()
        {
            int increment = 0;

            if (selectedToDelete.Count > 0)
            {
                increment = 100 / (selectedToDelete.Count * 3);
            }

            foreach (var vmAppliance in selectedToDelete)
            {
                // shutdown appliance
                if (vmAppliance.allowed_operations.Contains(vm_appliance_operation.hard_shutdown))
                {
                    Description = string.Format(Messages.VM_APPLIANCE_SHUTTING_DOWN, vmAppliance.Name);
                    VM_appliance.hard_shutdown(Session, vmAppliance.opaque_ref);
                    Description = string.Format(Messages.VM_APPLIANCE_SHUTTING_DOWN_COMPLETED, vmAppliance.Name);
                }

                PercentComplete += increment;

                Description = string.Format(Messages.DELETING_VM_APPLIANCE, vmAppliance.Name);
                // destroy VMs
                foreach (var vm in Connection.ResolveAll <VM>(vmAppliance.VMs))
                {
                    ShutdownAndDestroyVMsAction.DestroyVM(Session, vm);
                }

                PercentComplete += increment;

                // destroy appliance
                try
                {
                    VM_appliance.destroy(Session, vmAppliance.opaque_ref);
                }
                catch (Exception e)
                {
                    if (!e.Message.StartsWith("Object has been deleted"))
                    {
                        throw;
                    }
                }
                PercentComplete += increment;
            }
            Description     = Messages.DELETED_VM_APPLIANCES;
            PercentComplete = 100;
        }
예제 #2
0
 private void ShutdownAndDestroyVMs(List<VM> recoveredVMs)
 {
     var action = new ShutdownAndDestroyVMsAction(Pool.Connection, recoveredVMs);
     new Dialogs.ActionProgressDialog(action, ProgressBarStyle.Blocks).ShowDialog();
     SummaryReport.AddActionResult(action);
 }