示例#1
0
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            List<Folder> folders = new List<Folder>(selection.AsXenObjects<Folder>(CanExecute));

            folders.RemoveAll((Predicate<Folder>)delegate(Folder folder)
            {
                // if the list contains any folders that are children to others in the list then
                // they will automatically get deleted, so remove them here.

                foreach (Folder f in folders)
                {
                    if (folder.opaque_ref.StartsWith(f.opaque_ref + "/"))
                    {
                        return true;
                    }
                }
                return false;
            });

            List<AsyncAction> actions = new List<AsyncAction>();
            foreach (Folder folder in folders)
            {
                actions.Add(new FolderAction((IXenObject)folder, null, FolderAction.Kind.Delete));
            }
            RunMultipleActions(actions, Messages.DELETING_FOLDERS, Messages.DELETING_FOLDERS, Messages.DELETED_FOLDERS, true);
        }
示例#2
0
 protected override void ExecuteCore(SelectedItemCollection selection)
 {
     if (selection != null && selection.AllItemsAre<IXenObject>(x => x is Host || x is Pool))
         MainWindowCommandInterface.ShowForm(typeof(BugToolWizard), selection.AsXenObjects<IXenObject>().ToArray());
     else
         MainWindowCommandInterface.ShowForm(typeof(BugToolWizard));
 }
 protected override void ExecuteCore(SelectedItemCollection selection)
 {
     foreach (SelectedItem item in selection)
     {
         new DisconnectCommand(MainWindowCommandInterface, item.Connection, false).Execute();
     }
 }
 protected override void ExecuteCore(SelectedItemCollection selection)
 {
     if (selection.FirstAsXenObject != null)
     {
         Execute(selection.FirstAsXenObject.Connection);
     }
 }
示例#5
0
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            if (_filenameSpecified)
            {
                Execute(_filename);
            }
            else
            {
                // Showing this dialog has the (undocumented) side effect of changing the working directory
                // to that of the file selected. This means a handle to the directory persists, making
                // it undeletable until the program exits, or the working dir moves on. So, save and
                // restore the working dir...
                string oldDir = "";
                try
                {
                    oldDir = Directory.GetCurrentDirectory();
                    OpenFileDialog dialog = new OpenFileDialog();
                    dialog.AddExtension = true;
                    dialog.Filter = string.Format("{0} (*.xensearch)|*.xensearch|{1} (*.*)|*.*", Messages.XENSEARCH_SAVED_SEARCH, Messages.ALL_FILES);
                    dialog.FilterIndex = 0;
                    dialog.RestoreDirectory = true;
                    dialog.DefaultExt = "xensearch";
                    dialog.CheckPathExists = false;

                    if (dialog.ShowDialog(Parent) == DialogResult.OK)
                        Execute(dialog.FileName);
                }
                finally
                {
                    Directory.SetCurrentDirectory(oldDir);
                }
            }
        }
示例#6
0
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            VM vm = selection[0].XenObject as VM;

            if (vm != null)
            {
                if (vm.VBDs.Count < vm.MaxVBDsAllowed)
                {
                    MainWindowCommandInterface.ShowPerXenModelObjectWizard(vm, new NewDiskDialog(vm.Connection, vm));
                }
                else
                {
                    new ThreeButtonDialog(
                        new ThreeButtonDialog.Details(
                            SystemIcons.Error, 
                            FriendlyErrorNames.VBDS_MAX_ALLOWED, 
                            Messages.DISK_ADD)).ShowDialog(Program.MainWindow);
                }
            }
            else
            {
                SR sr = (SR)selection[0].XenObject;
                MainWindowCommandInterface.ShowPerConnectionWizard(sr.Connection, new NewDiskDialog(sr.Connection, sr));
            }
        }
示例#7
0
        protected sealed override void ExecuteCore(SelectedItemCollection selection)
        {
            ConfirmVMDeleteDialog dialog = new ConfirmVMDeleteDialog(selection.AsXenObjects<VM>());

            if (MainWindowCommandInterface.RunInAutomatedTestMode || dialog.ShowDialog(Parent) == DialogResult.Yes)
            {
                CommandErrorDialog errorDialog = null;
                Dictionary<SelectedItem, string> cantExecuteReasons = GetCantExecuteReasons();

                if (cantExecuteReasons.Count > 0)
                {
                    errorDialog = new CommandErrorDialog(ErrorDialogTitle, ErrorDialogText, GetCantExecuteReasons());
                }

                List<AsyncAction> actions = new List<AsyncAction>();
                foreach (VM vm in selection.AsXenObjects<VM>(CanExecute))
                {
                    var snapshotsToDelete = dialog.DeleteSnapshots.FindAll(x => x.Connection.Resolve(x.snapshot_of) == vm);
                    actions.Add(GetAction(vm, dialog.DeleteDisks, snapshotsToDelete));
                }
                RunMultipleActions(actions, Messages.ACTION_VMS_DESTROYING_TITLE, Messages.ACTION_VM_DESTROYING, Messages.ACTION_VM_DESTROYED, true);

                if (errorDialog != null)
                {
                    errorDialog.ShowDialog(Parent);
                }
            }
        }
 protected override bool CanExecuteCore(SelectedItemCollection selection)
 {
     if (selection.FirstAsXenObject != null && selection.FirstAsXenObject.Connection != null && selection.FirstAsXenObject.Connection.IsConnected &&
         (selection.PoolAncestor != null || selection.HostAncestor != null)) // this check ensures there's no cross-pool 
         return !Helpers.FeatureForbidden(selection.FirstAsXenObject.Connection, Host.RestrictExportResourceData);
     return false;
 }
示例#9
0
 protected override void ExecuteCore(SelectedItemCollection selection)
 {
     foreach (VirtualTreeNode node in _nodes)
     {
         node.ExpandAll();
     }
 }
示例#10
0
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            VDI vdi = (VDI)selection[0].XenObject;

            
            MainWindowCommandInterface.ShowPerXenModelObjectWizard(vdi, new MoveVirtualDiskDialog(vdi));
        }
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            ApplyLicenseEditionAction action = new ApplyLicenseEditionAction(xos, _edition, _licenseServerAddress, _licenseServerPort, null);
            ActionProgressDialog actionProgress = new ActionProgressDialog(action, ProgressBarStyle.Marquee);

            // close dialog even when there's an error as this action shows its own error dialog box.
            action.Completed += s =>
                                    {
                                        Program.Invoke(Program.MainWindow, () =>
                                        {
                                            Failure f = action.Exception as Failure;
                                            if (f != null && f.ErrorDescription[0] == Failure.RBAC_PERMISSION_DENIED_FRIENDLY)
                                                return;
                                            actionProgress.Close();
                                        });

                                        if (action.Exception != null)
                                        {
                                            ShowLicensingFailureDialog(action.LicenseFailures, action.Exception.Message, Parent);
                                        }
                                    };

            actionProgress.ShowDialog(Parent);

            if (actionProgress.action.Succeeded)
            {
                InvokeSuccedded(null);
            }
        }
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            var vdi = (VDI)selection[0].XenObject;
            string svid = vdi.sm_config["SVID"];
            var storageLinkVolume = vdi.StorageLinkVolume(Program.StorageLinkConnections.GetCopy());
            string volumeName = storageLinkVolume==null? "":storageLinkVolume.Name;

            var action = new DelegatedAsyncAction(
                vdi.Connection,
                string.Format(Messages.REMOVE_STORAGELINK_VOLUME_ACTION_TITLE, volumeName, _slr),
                string.Format(Messages.REMOVE_STORAGELINK_VOLUME_ACTION_START, volumeName, _slr),
                string.Format(Messages.REMOVE_STORAGELINK_VOLUME_ACTION_FINSH, volumeName, _slr), 
                s => _slr.StorageLinkConnection.RemoveStorageVolumesFromStorageRepository(_slr, new[] { svid }));
            
            action.AppliesTo.Add(vdi.opaque_ref);
            action.AppliesTo.Add(svid);
            action.AppliesTo.Add(_slr.opaque_ref);

            SR sr = _slr.SR(ConnectionsManager.XenConnectionsCopy);

            if(sr != null)
            {
                action.AppliesTo.Add(sr.opaque_ref);
            }

            action.RunAsync();
        }
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            IXenObject selected = selection.FirstAsXenObject;
            var server = GetStorageLinkServer(selected);
            if (server == null)
                return;
            var dialog = new AddStorageLinkSystemDialog(server.StorageLinkConnection);
            var parent = Parent ?? (Control)Program.MainWindow;

            dialog.FormClosing += (s, e) =>
                {
                    if (dialog.DialogResult == DialogResult.OK)
                    {
                        var adapter = dialog.StorageAdapter;
                        var port = dialog.StorageSystemPort;
                        var address = dialog.StorageSystemAddress;
                        var username = dialog.StorageSystemUsername;
                        var password = dialog.StorageSystemPassword;
                        var ns = dialog.StorageSystemNamespace;

                        // There are no RBAC complexities here since only pool-operator and above can access the password for the storagelink service. 
                        // Therefore only pool-operator and above can get here. These roles are permitted to add and remove storage systems.

                        var action = new StorageLinkDelegatedAsyncAction(
                            () => server.StorageLinkConnection.AddStorageSystem(adapter, port, address, username, password, ns),
                            string.Format(Messages.ADD_STORAGE_LINK_SYSTEM_ACTION_TITLE, address),
                            string.Format(Messages.ADD_STORAGE_LINK_SYSTEM_ACTION_START_DESCRIPTION, address),
                            string.Format(Messages.ADD_STORAGE_LINK_SYSTEM_ACTION_END_DESCRIPTION, address));

                        var actionWithWait = new DelegatedAsyncAction(null,
                            string.Format(Messages.ADD_STORAGE_LINK_SYSTEM_ACTION_TITLE, address),
                            string.Format(Messages.ADD_STORAGE_LINK_SYSTEM_ACTION_START_DESCRIPTION, address),
                            string.Format(Messages.ADD_STORAGE_LINK_SYSTEM_ACTION_END_DESCRIPTION, address), ss =>
                            {
                                int storageSystemCountBefore = server.StorageLinkConnection.Cache.StorageSystems.Count;
                                action.RunExternal(ss);

                                for (int i = 0; i < 60 && action.Succeeded && server.StorageLinkConnection.Cache.StorageSystems.Count == storageSystemCountBefore; i++)
                                {
                                    if((i%5)==0)
                                    {
                                        log.Info("Waiting for StorageLink storage-system to be added to cache."); 
                                    }

                                    Thread.Sleep(500);
                                }
                            }, true);

                        actionWithWait.AppliesTo.Add(server.opaque_ref);
                        actionWithWait.Completed += ss => OnCompleted(new CompletedEventArgs(actionWithWait.Succeeded));

                        new ActionProgressDialog(actionWithWait, ProgressBarStyle.Continuous) { ShowCancel = true }.ShowDialog(dialog);

                        // keep creds dialog open if it failed.
                        e.Cancel = !actionWithWait.Succeeded;
                    }
                };

            dialog.Show(parent);
        }
示例#14
0
 public static WizardMode GetWizardMode(SelectedItemCollection selection)
 {
     return selection != null && selection.Count > 0 && selection[0].XenObject is VM
                && (selection[0].XenObject as VM).power_state == vm_power_state.Suspended
                    ? WizardMode.Migrate
                    : WizardMode.Move;
 }
        protected override bool CanExecuteCore(SelectedItemCollection selection)
        {
            bool oneIsConnected = false;
            bool foundHost = false;
            bool foundPool = false;

            foreach (SelectedItem item in selection)
            {
                if (new DisconnectHostCommand(MainWindowCommandInterface, item).CanExecute())
                {
                    oneIsConnected = true;
                }
                else if (new DisconnectPoolCommand(MainWindowCommandInterface, item).CanExecute())
                {
                    oneIsConnected = true;
                }

                if (item.XenObject is Host)
                {
                    foundHost = true;
                }
                else if (item.XenObject is Pool)
                {
                    foundPool = true;
                }
            }

            return oneIsConnected && foundHost && foundPool;
        }
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            if (Helpers.FeatureForbidden(selection[0].XenObject, Host.RestrictWLB))
            {
                // Show upsell dialog
                UpsellDialog dlg = new UpsellDialog(Messages.UPSELL_BLURB_WLB, InvisibleMessages.UPSELL_LEARNMOREURL_WLB);
                dlg.ShowDialog(Parent);
                return;
            }

            try
            {
                WorkloadReports WlbReportWin = new WorkloadReports(_reportFile, _run)
                    {
                        Pool = selection[0].PoolAncestor,
                        Hosts = selection[0].Connection.Cache.Hosts
                    };

                MainWindowCommandInterface.ShowPerConnectionWizard(selection[0].Connection, WlbReportWin);
            }
            catch (Failure exn)
            {
                log.Error(exn, exn);
            }
        }
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            VM vm = (VM)selection[0].XenObject;

            using (var dlg = new ThreeButtonDialog(
                        new ThreeButtonDialog.Details(
                            SystemIcons.Warning,
                            string.Format(Messages.CONVERT_TEMPLATE_DIALOG_TEXT, vm.Name.Ellipsise(25)),
                            Messages.CONVERT_TO_TEMPLATE),
                        new ThreeButtonDialog.TBDButton(Messages.CONVERT, DialogResult.OK, ThreeButtonDialog.ButtonType.ACCEPT, true),
                        ThreeButtonDialog.ButtonCancel))
            {
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    List<AsyncAction> actions = new List<AsyncAction>();
                    actions.Add(new SetVMOtherConfigAction(vm.Connection, vm, "instant", "true"));
                    actions.Add(new VMToTemplateAction(vm));

                    MainWindowCommandInterface.CloseActiveWizards(vm);

                    RunMultipleActions(actions, string.Format(Messages.ACTION_VM_TEMPLATIZING_TITLE, vm.Name),
                                       Messages.ACTION_VM_TEMPLATIZING, Messages.ACTION_VM_TEMPLATIZED, true);
                }
            }
        }
示例#18
0
		public ExportApplianceWizard(IXenConnection con, SelectedItemCollection selection)
			: base(con)
		{
			InitializeComponent();

		    m_pageExportAppliance = new ExportAppliancePage();
            m_pageRbac = new RBACWarningPage();
		    m_pageExportSelectVMs = new ExportSelectVMsPage();
            m_pageExportEula = new ExportEulaPage();
		    m_pageExportOptions = new ExportOptionsPage();
		    m_pageTvmIp = new TvmIpPage();
            m_pageFinish = new ExportFinishPage();

			m_selectedObject = selection.FirstAsXenObject;

			if (selection.Count == 1 && (m_selectedObject is VM || m_selectedObject is VM_appliance))
				m_pageExportAppliance.ApplianceFileName = m_selectedObject.Name;

			m_pageExportAppliance.OvfModeOnly = m_selectedObject is VM_appliance;
			m_pageTvmIp.IsExportMode = true;
			m_pageFinish.SummaryRetreiver = GetSummary;
			m_pageExportSelectVMs.SelectedItems = selection;

            AddPages(m_pageExportAppliance, m_pageExportSelectVMs, m_pageFinish);
		}
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            if (Helpers.FeatureForbidden(selection[0].XenObject, Host.RestrictWLB))
            {
                // Show upsell dialog
                UpsellDialog dlg = new UpsellDialog(Messages.UPSELL_BLURB_WLB, InvisibleMessages.UPSELL_LEARNMOREURL_WLB);
                dlg.ShowDialog(Parent);
                return;
            }

                try
                {
                    Dialogs.Wlb.DisableWLBDialog disableDialog = new XenAdmin.Dialogs.Wlb.DisableWLBDialog(string.Empty);
                    DialogResult dr = disableDialog.ShowDialog(MainWindow.ActiveForm);

                    if (dr == DialogResult.OK)
                    {
                        Actions.Wlb.DisableWLBAction action = new Actions.Wlb.DisableWLBAction(selection[0].PoolAncestor, true);
                        action.Completed += Program.MainWindow.action_Completed;
                        action.RunAsync();
                        Program.MainWindow.UpdateToolbars();
                    }
                }
                catch (Failure exn)
                {
                    log.Error(exn, exn);
                }
       }
示例#20
0
 protected override bool CanExecuteCore(SelectedItemCollection selection)
 {
     if (selection.Count == 1)
     {
         return CanReattachSR(selection[0].XenObject as SR);
     }
     return false;
 }
示例#21
0
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            Trace.Assert(selection.Count == 1);

            var action = new UpdateVIFAction(_vm, _vif, _proxyVIF);
            action.Completed += action_Completed;
            action.RunAsync();
        }
示例#22
0
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            VM vm = (VM)selection[0].XenObject;

            if (CrossPoolCopyVMCommand.CanExecute(vm, null))
                new CrossPoolCopyVMCommand(MainWindowCommandInterface, selection).Execute();
            else
                MainWindowCommandInterface.ShowPerXenModelObjectWizard(vm, new CopyVMDialog(vm));
        }
示例#23
0
 protected override void ExecuteCore(SelectedItemCollection selection)
 {
     List<AsyncAction> actions = new List<AsyncAction>();
     foreach (VM vm in selection.AsXenObjects<VM>())
     {
         actions.Add(new VMSnapshotDeleteAction(vm));
     }
     RunMultipleActions(actions, Messages.ACTION_VM_DELETE_SNAPSHOTS_TITLE, Messages.SNAPSHOT_DELETING, Messages.SNAPSHOTS_DELETED, true);
 }
示例#24
0
 protected override void ExecuteCore(SelectedItemCollection selection)
 {
     List<AsyncAction> actions = new List<AsyncAction>();
     foreach (SR sr in selection.AsXenObjects<SR>(CanExecute))
     {
         actions.Add(new SrAction(SrActionKind.Forget, sr));
     }
     RunMultipleActions(actions, Messages.ACTION_SRS_FORGETTING, Messages.FORGETTING_SRS, Messages.SRS_FORGOTTEN, true);
 }
示例#25
0
 protected override void ExecuteCore(SelectedItemCollection selection)
 {
     var actions = new List<AsyncAction>();
     foreach (SR sr in selection.AsXenObjects<SR>(CanExecute))
     {
         actions.Add(new SrTrimAction(sr.Connection, sr));
     }
     RunMultipleActions(actions, null, Messages.ACTION_SR_TRIM_DESCRIPTION, Messages.ACTION_SR_TRIM_DONE, true);
 }
示例#26
0
 protected override bool CanExecuteCore(SelectedItemCollection selection)
 {
     if (selection.Count == 1)
     {
         VM vm = selection[0].XenObject as VM;
         return vm != null && !vm.is_a_template && !vm.is_a_snapshot;
     }
     return false;
 }
示例#27
0
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            string newName = _newName;
            Folders.FixupRelativePath(ref newName);

            FolderAction action = new FolderAction(_folder, newName, FolderAction.Kind.Rename);
            action.Completed += action_Completed;
            action.RunAsync();
        }
示例#28
0
 protected override void ExecuteCore(SelectedItemCollection selection)
 {
     List<AsyncAction> actions = new List<AsyncAction>();
     foreach (SR sr in selection.AsXenObjects<SR>(CanExecute))
     {
         actions.Add(new SrAction(SrActionKind.Destroy, sr));
     }
     RunMultipleActions(actions, Messages.ACTION_SRS_DESTROYING, string.Empty, string.Empty, true);
 }
示例#29
0
 protected override bool CanExecuteCore(SelectedItemCollection selection)
 {
     if (XenAdmin.Properties.Settings.Default.RequirePass && Program.MasterPassword == null)
     {
         // A master password is set, but they didn't enter it. Don't let them fiddle with the saved mater password session
         return false;
     }
     return base.CanExecuteCore(selection);
 }
示例#30
0
 protected override bool CanExecuteCore(SelectedItemCollection selection)
 {
     if (selection.ContainsOneItemOfType<IXenObject>())
     {
         IXenObject xenObject = selection[0].XenObject;
         return !(xenObject is Folder) && xenObject.Connection != null && xenObject.Connection.IsConnected;
     }
     return false;
 }
示例#31
0
        private void RefreshButtons()
        {
            SelectedItemCollection vdis = SelectedVDIs;

            // Delete button
            // The user can see that this disk is attached to more than one VMs. Allow deletion of multiple VBDs (non default behaviour),
            // but don't allow them to be deleted if a running vm is using the disk (default behaviour).

            DeleteVirtualDiskCommand deleteCmd = new DeleteVirtualDiskCommand(Program.MainWindow, vdis)
            {
                AllowMultipleVBDDelete = true
            };

            if (deleteCmd.CanExecute())
            {
                RemoveButton.Enabled = true;
                RemoveButtonContainer.RemoveAll();
            }
            else
            {
                RemoveButton.Enabled = false;
                RemoveButtonContainer.SetToolTip(deleteCmd.ToolTipText);
            }

            // Move button
            Command moveCmd = MoveVirtualDiskDialog.MoveMigrateCommand(Program.MainWindow, vdis);

            if (moveCmd.CanExecute())
            {
                buttonMove.Enabled = true;
                toolTipContainerMove.RemoveAll();
            }
            else
            {
                buttonMove.Enabled = false;
                toolTipContainerMove.SetToolTip(moveCmd.ToolTipText);
            }

            // Rescan button
            if (sr == null || sr.Locked)
            {
                buttonRescan.Enabled = false;
            }
            else if (HelpersGUI.BeingScanned(sr))
            {
                buttonRescan.Enabled = false;
                toolTipContainerRescan.SetToolTip(Messages.SCAN_IN_PROGRESS_TOOLTIP);
            }
            else
            {
                buttonRescan.Enabled = true;
                toolTipContainerRescan.RemoveAll();
            }

            // Add VDI button
            addVirtualDiskButton.Enabled = sr != null && !sr.Locked;

            // Properties button
            if (vdis.Count == 1)
            {
                VDI vdi = vdis.AsXenObjects <VDI>()[0];
                EditButton.Enabled = sr != null && !sr.Locked && !vdi.is_a_snapshot && !vdi.Locked;
            }
            else
            {
                EditButton.Enabled = false;
            }
        }