Пример #1
0
        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);
            }
        }
Пример #2
0
 protected override void ExecuteCore(SelectedItemCollection selection)
 {
     foreach (SR sr in selection.AsXenObjects<SR>(CanExecute))
     {
         SrShareAction action = new SrShareAction(sr.Connection, sr);
         ActionProgressDialog dialog = new ActionProgressDialog(action, ProgressBarStyle.Marquee);
         dialog.ShowCancel = true;
         dialog.ShowDialog(Parent);
     }
 }
Пример #3
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns>Whether any SRs suitable for heartbeating were found.</returns>
        internal bool ScanForHeartbeatSRs()
        {
            System.Diagnostics.Trace.Assert(pool != null);

            // Start action and show progress with a dialog
            GetHeartbeatSRsAction action = new GetHeartbeatSRsAction(pool);
            ActionProgressDialog dialog = new ActionProgressDialog(action, ProgressBarStyle.Blocks);
            dialog.ShowCancel = true;
            dialog.ShowDialog(this);
            if (dialog.action.Cancelled || dialog.action.Cancelling || !dialog.action.IsCompleted)
                return false;

            if (!action.Succeeded || action.SRs.Count == 0)
            {
                dataGridViewExSRs.Enabled = false;
                return true;
            }

            dataGridViewExSRs.Enabled = true;

            List<SRWrapper> srs = action.SRs;
            srs.Sort((a, b) => a.enabled != b.enabled
                                   ? b.enabled.CompareTo(a.enabled)
                                   : (a.sr.NameWithoutHost.CompareTo(b.sr.NameWithoutHost)));

            dataGridViewExSRs.Rows.Clear();

            foreach (SRWrapper srWrapper in srs)
            {
                var row = new StorageRow(srWrapper);
                dataGridViewExSRs.Rows.Add(row);
                row.Enabled = srWrapper.enabled;

                // coming forward to this page after having already been through it once
                if (selectedHeartbeatSR != null && srWrapper.sr.opaque_ref == selectedHeartbeatSR.opaque_ref)
                {

                    if (srWrapper.enabled)
                        row.Selected = true;
                    else
                    {
                        selectedHeartbeatSR = null;
                        OnPageUpdated();
                    }
                }
            }

            return true;
        }
Пример #4
0
        private void SaveWLBConfig(WlbPoolConfiguration PoolConfiguration)
        {
            Dictionary<string, string> completeConfiguration = PoolConfiguration.ToDictionary();
            SendWlbConfigurationKind kind = SendWlbConfigurationKind.SetPoolConfiguration;

            // check for host configurations in the pool configuration
            if (PoolConfiguration.HostConfigurations.Count > 0)
            {
                // add the flag denoting that there are host configs to be saved
                kind |= SendWlbConfigurationKind.SetHostConfiguration;
                // get the key for each host config (host.uuid)
                foreach (string key in PoolConfiguration.HostConfigurations.ToDictionary().Keys)
                {
                    //Drop any exising copy from the pool configuration
                    if (completeConfiguration.ContainsKey(key))
                    {
                        completeConfiguration.Remove(key);
                    }
                    // and add the task to the collection
                    completeConfiguration.Add(key, PoolConfiguration.HostConfigurations.ToDictionary()[key]);
                }
            }

            // check for scheduled tasks in the pool configuration
            if (PoolConfiguration.ScheduledTasks.TaskList.Count > 0)
            {
                // add the flag denoting that there are scheduled tasks to be saved
                kind |= SendWlbConfigurationKind.SetScheduledTask;
                // get the key for each scheduled task
                foreach (string key in PoolConfiguration.ScheduledTasks.ToDictionary().Keys)
                {
                    //Drop any exising copy from the pool configuration
                    if (completeConfiguration.ContainsKey(key))
                    {
                        completeConfiguration.Remove(key);
                    }
                    // and add the task to the collection
                    completeConfiguration.Add(key, PoolConfiguration.ScheduledTasks.ToDictionary()[key]);
                }
            }

            SendWlbConfigurationAction action = new SendWlbConfigurationAction(_pool, PoolConfiguration.ToDictionary(), kind);
            ActionProgressDialog dialog = new ActionProgressDialog(action, ProgressBarStyle.Blocks);
            dialog.ShowCancel = true;
            dialog.ShowDialog(this);
            Program.MainWindow.UpdateToolbars();
        }
Пример #5
0
        public bool FiberChannelScan(IWin32Window owner, IXenConnection connection, out List<FibreChannelDevice> devices)
        {
            devices = new List<FibreChannelDevice>();

            Host master = Helpers.GetMaster(connection);
            if (master == null)
                return false;

            FibreChannelProbeAction action = new FibreChannelProbeAction(master, SrType);
            using (var  dialog = new ActionProgressDialog(action, ProgressBarStyle.Marquee))
                dialog.ShowDialog(owner); //Will block until dialog closes, action completed

            if (!action.Succeeded)
                return false;

            try
            {
                devices = FibreChannelProbeParsing.ProcessXML(action.Result);

                if (devices.Count == 0)
                {
                    using (var dlg = new ThreeButtonDialog(
                        new ThreeButtonDialog.Details(SystemIcons.Warning, Messages.FIBRECHANNEL_NO_RESULTS, Messages.XENCENTER)))
                    {
                        dlg.ShowDialog();
                    }

                    return false;
                }
                return true;
            }
            catch (Exception e)
            {
                log.Debug("Exception parsing result of fibre channel scan", e);
                log.Debug(e, e);
                using (var dlg = new ThreeButtonDialog(
                    new ThreeButtonDialog.Details(SystemIcons.Warning, Messages.FIBRECHANNEL_XML_ERROR, Messages.XENCENTER)))
                {
                    dlg.ShowDialog();
                }

                return false;
            }
        }
 private void buttonResolveAll_Click(object sender, EventArgs e)
 {
     List<AsyncAction> actions = new List<AsyncAction>();
     foreach (DataGridViewRow row in dataGridView1.Rows)
     {
         PreCheckHostRow preCheckHostRow = row as PreCheckHostRow;
         if (preCheckHostRow != null && preCheckHostRow.Problem != null)
         {
             bool cancelled;
             AsyncAction action = preCheckHostRow.Problem.SolveImmediately(out cancelled);
             
             if (action != null)
                 actions.Add(action);
         }
     }
     foreach (var asyncAction in actions)
     {
         _progressDialog = new ActionProgressDialog(asyncAction, ProgressBarStyle.Blocks);
         _progressDialog.ShowDialog(this);
         Program.Invoke(Program.MainWindow, RefreshRechecks);
     }
     Program.Invoke(Program.MainWindow, RefreshRechecks);
 }
Пример #7
0
        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            NewSRWizard wizard = new NewSRWizard(Connection);
            wizard.CheckNFSISORadioButton();

            if (wizard.ShowDialog() == DialogResult.Cancel)
                return;

            // Return if we lost connection
            if (Connection == null || Helpers.GetPoolOfOne(Connection) == null)
            {
                log.Error("Page_InstallationMedia: connection to the server was lost");
                return;
            }

            // There's a chance the cd radio button was disabled because we didnt have any isos to select from, so refresh that bool
            // and the enablement of that button.
            cds = Helpers.CDsExist(Connection);
            CdRadioButton.Enabled = (installed || installCd) && cds;

            // We can get a lot of refresh flickering in the ISO box as all the VDIs are discovered
            // Possibly slightly rude, but were going to have a pretend action here which gives it some breathing space before we look for VDIs
            DelegatedAsyncAction waitAction = new DelegatedAsyncAction(Connection, Messages.SR_REFRESH_ACTION_DESC, Messages.SR_REFRESH_ACTION_DESC, Messages.COMPLETED,
                delegate
                {
                    System.Threading.Thread.Sleep(10000);
                }, true);
            using (var dlg = new ActionProgressDialog(waitAction, System.Windows.Forms.ProgressBarStyle.Marquee))
                dlg.ShowDialog(this);

            // Set the connection on the drop down iso box. This causes a complete refresh rather than a mini one - otherwise we miss out on
            // getting event handlers for the new SR
            CdDropDownBox.connection = Connection;
        }
Пример #8
0
        /// <summary>
        /// Retrieve subscriptions and set _subscriptionCollection
        /// </summary>
        private void SetSubscriptionCollection()
        {
            _subscriptionCollection = null;

            WlbPoolConfiguration poolConfiguration;
            RetrieveWlbConfigurationAction action = new RetrieveWlbConfigurationAction(_pool);
            using (var dialog = new ActionProgressDialog(action, ProgressBarStyle.Blocks))
            {
                dialog.ShowCancel = true;
                dialog.ShowDialog(this);
            }

            if (action.Succeeded)
            {
                poolConfiguration = new WlbPoolConfiguration(action.WlbConfiguration);
                _isMROrLater = poolConfiguration.IsMROrLater;
                _isBostonOrLater = poolConfiguration.IsBostonOrLater;
                _isCreedenceOrLater = poolConfiguration.IsCreedenceOrLater;

                if (_isMROrLater && !_isBostonOrLater)
                {
                    _subscriptionCollection = new WlbReportSubscriptionCollection(action.WlbConfiguration);
                }

                if (_isBostonOrLater)
                {
                    this.splitContainerLeftPane.Panel2Collapsed = true;
                    this.wlbReportView1.btnSubscribe.Visible=false;
                }
            }
            else
            {
                throw (action.Exception);
            }
        }
Пример #9
0
        private void LoadPoolMetadata(VDI vdi)
        {
            Session metadataSession = null;
            try
            {
                VdiLoadMetadataAction action = new VdiLoadMetadataAction(Connection, vdi);
                ActionProgressDialog dialog = new ActionProgressDialog(action, ProgressBarStyle.Marquee);
                dialog.ShowDialog(this); //Will block until dialog closes, action completed

                if (action.Succeeded && action.MetadataSession != null)
                {
                    metadataSession = action.MetadataSession;
                    XenRef<VDI> vdiRef = new XenRef<VDI>(vdi);
                    if (action.PoolMetadata != null && !allPoolMetadata.ContainsKey(vdiRef))
                    {
                        allPoolMetadata.Add(vdiRef, action.PoolMetadata);
                    }
                }

            }
            finally
            {
                if (metadataSession != null)
                    metadataSession.logout();
            }
        }
Пример #10
0
        private void IntroduceSRs()
        {
            Pool pool = Helpers.GetPoolOfOne(Connection);
            if (pool == null)
            {
                log.Error("New SR Wizard: Pool has disappeared");
                return;
            }

            Host master = Connection.Resolve(pool.master);
            if (master == null)
            {
                log.Error("New SR Wizard: Master has disappeared");
                return;
            }

            // Start DR task
            foreach (var kvp in SelectedNewDevices)
            {
                var newDevice = kvp.Value;
                DrTaskCreateAction action = new DrTaskCreateAction(Connection, newDevice);
                ActionProgressDialog dialog = new ActionProgressDialog(action, ProgressBarStyle.Marquee);
                dialog.ShowCancel = true;
                dialog.ShowDialog(this);

                if(!cldl.IsStillConnected(Connection))
                    return;

                if (action.Succeeded)
                {
                    ScannedDevices[kvp.Key].SRList.Clear();
                    if (NewDrTaskIntroduced != null)
                        NewDrTaskIntroduced(action.Result);
                }
                else
                {
                    Exception exn = action.Exception;
                    log.Warn(exn, exn);
                    Failure failure = exn as Failure;
                    if (failure != null && failure.ErrorDescription[0] == "SR_BACKEND_FAILURE_140")
                    {
                        MessageBox.Show(this, failure.Message);
                    }
                    break;
                }
            }
        }
Пример #11
0
        private void buttonCifsScan_Click(object sender, EventArgs e)
        {
            try
            {
                CifsScanButton.Enabled = false;

                // Perform an SR.probe to see if there is already an SR present
                Dictionary<String, String> dconf = new Dictionary<String, String>();
                string[] fullpath = CifsServerPathTextBox.Text.Split(new char[] { ':' });
                dconf[SERVER] = fullpath[0];
                if (fullpath.Length > 1)
                {
                    dconf[SERVERPATH] = fullpath[1];
                }

                if (userNameTextBox.Text.Trim().Length > 0 || passwordTextBox.Text.Trim().Length > 0)
                {
                    dconf["username"] = userNameTextBox.Text;
                    dconf["password"] = passwordTextBox.Text;
                }

                Host master = Helpers.GetMaster(Connection);
                if (master == null)
                    return;

                // Start probe
                SrProbeAction action = new SrProbeAction(Connection, master, SR.SRTypes.smb, dconf);
                using (var dialog = new ActionProgressDialog(action, ProgressBarStyle.Marquee))
                {
                    dialog.ShowCancel = true;
                    dialog.ShowDialog(this);
                }

                if (radioButtonCifsNew.Enabled)
                    radioButtonCifsNew.Checked = true;

                listBoxCifsSRs.Items.Clear();

                if (!action.Succeeded)
                    return;

                List<SR.SRInfo> SRs = SR.ParseSRListXML(action.Result);
                if (SRs.Count == 0)
                {
                    // Disable box
                    ToggleReattachControlsEnabledState(false);
                    listBoxCifsSRs.Items.Add(Messages.NEWSR_NO_SRS_FOUND);
                    return;
                }

                // Fill box
                foreach(SR.SRInfo info in SRs)
                    listBoxCifsSRs.Items.Add(info);

                listBoxCifsSRs.TryAndSelectUUID();

                ToggleReattachControlsEnabledState(true);
            }
            finally
            {
                UpdateButtons();
            }
        }
Пример #12
0
        private void m_importXvaAction_Completed(object sender, EventArgs e)
        {
            Program.Invoke(this, () =>
            {
                Program.AssertOnEventThread();

                if (!(ImportXvaAction.Succeeded) || ImportXvaAction.Cancelled)
                {
                    // task failed or has been cancelled, unregister XenObjectsUpdated event handler
                    m_targetConnection.XenObjectsUpdated -= targetConnection_XenObjectsUpdated;

                    // Give the user a chance to correct any errors
                    m_actionDialog = null;
                    m_buttonPreviousEnabled = true;
                    OnPageUpdated();
                }
            });
        }
Пример #13
0
        private void OkButton_Click(object sender, EventArgs e)
        {
            if (SrListBox.SR == null || NameTextBox.Text == "" || !connection.IsConnected)
            {
                return;
            }

            if (DontCreateVDI)
            {
                DialogResult = DialogResult.OK;
                Close();
                return;
            }
            XenAPI.SR sr = SrListBox.SR;
            if (!sr.shared && TheVM != null && TheVM.HaPriorityIsRestart())
            {
                DialogResult dialogResult;
                using (var dlg = new WarningDialog(Messages.NEW_SR_DIALOG_ATTACH_NON_SHARED_DISK_HA,
                                                   ThreeButtonDialog.ButtonYes, ThreeButtonDialog.ButtonNo))
                {
                    dialogResult = dlg.ShowDialog(Program.MainWindow);
                }
                if (dialogResult != DialogResult.Yes)
                {
                    return;
                }
                new HAUnprotectVMAction(TheVM).RunExternal(TheVM.Connection.Session);
            }

            VDI vdi = NewDisk();


            if (TheVM != null)
            {
                var alreadyHasBootableDisk = HasBootableDisk(TheVM);

                Actions.DelegatedAsyncAction action = new Actions.DelegatedAsyncAction(connection,
                                                                                       string.Format(Messages.ACTION_DISK_ADDING_TITLE, NameTextBox.Text, sr.NameWithoutHost()),
                                                                                       Messages.ACTION_DISK_ADDING, Messages.ACTION_DISK_ADDED,
                                                                                       delegate(XenAPI.Session session)
                {
                    // Get legitimate unused userdevice numbers
                    string[] uds = XenAPI.VM.get_allowed_VBD_devices(session, TheVM.opaque_ref);
                    if (uds.Length == 0)
                    {
                        throw new Exception(FriendlyErrorNames.VBDS_MAX_ALLOWED);
                    }
                    string ud      = uds[0];
                    string vdiref  = VDI.create(session, vdi);
                    XenAPI.VBD vbd = NewDevice();
                    vbd.VDI        = new XenAPI.XenRef <XenAPI.VDI>(vdiref);
                    vbd.VM         = new XenAPI.XenRef <XenAPI.VM>(TheVM);

                    // CA-44959: only make bootable if there aren't other bootable VBDs.
                    vbd.bootable   = ud == "0" && !alreadyHasBootableDisk;
                    vbd.userdevice = ud;

                    // Now try to plug the VBD.
                    var plugAction = new VbdSaveAndPlugAction(TheVM, vbd, vdi.Name(), session, false);
                    plugAction.ShowUserInstruction += PlugAction_ShowUserInstruction;
                    plugAction.RunAsync();
                });

                action.VM = TheVM;
                using (var dialog = new ActionProgressDialog(action, ProgressBarStyle.Blocks))
                    dialog.ShowDialog();
                if (!action.Succeeded)
                {
                    return;
                }
            }
            else
            {
                CreateDiskAction action = new CreateDiskAction(vdi);
                using (var dialog = new ActionProgressDialog(action, ProgressBarStyle.Marquee))
                    dialog.ShowDialog();
                if (!action.Succeeded)
                {
                    return;
                }
            }
            DialogResult = DialogResult.OK;
            Close();
        }
Пример #14
0
        private void buttonAuthorize_Click(object sender, EventArgs e)
        {
            try
            {
                Exception delegateException = null;
                log.Debug("Testing logging in with the new credentials");
                DelegatedAsyncAction loginAction = new DelegatedAsyncAction(connection,
                                                                            Messages.AUTHORIZING_USER,
                                                                            Messages.CREDENTIALS_CHECKING,
                                                                            Messages.CREDENTIALS_CHECK_COMPLETE,
                                                                            delegate
                {
                    try
                    {
                        elevatedSession = connection.ElevatedSession(TextBoxUsername.Text.Trim(), TextBoxPassword.Text);
                    }
                    catch (Exception ex)
                    {
                        delegateException = ex;
                    }
                });

                using (var dlg = new ActionProgressDialog(loginAction, ProgressBarStyle.Marquee, false))
                    dlg.ShowDialog(this);

                // The exception would have been handled by the action progress dialog, just return the user to the sudo dialog
                if (loginAction.Exception != null)
                {
                    return;
                }

                if (HandledAnyDelegateException(delegateException))
                {
                    return;
                }

                if (elevatedSession.IsLocalSuperuser || SessionAuthorized(elevatedSession))
                {
                    elevatedUsername = TextBoxUsername.Text.Trim();
                    elevatedPassword = TextBoxPassword.Text;
                    DialogResult     = DialogResult.OK;
                    Close();
                    return;
                }

                ShowNotAuthorisedDialog();
                return;
            }
            catch (Exception ex)
            {
                log.DebugFormat("Exception when attempting to sudo action: {0} ", ex);
                using (var dlg = new ThreeButtonDialog(
                           new ThreeButtonDialog.Details(
                               SystemIcons.Error,
                               String.Format(Messages.USER_AUTHORIZATION_FAILED, TextBoxUsername.Text),
                               Messages.XENCENTER)))
                {
                    dlg.ShowDialog(Parent);
                }
            }
            finally
            {
                // Check whether we have a successful elevated session and whether we have been asked to log it out
                // If non successful (most likely the new subject is not authorized) then log it out anyway.
                if (elevatedSession != null && DialogResult != DialogResult.OK)
                {
                    elevatedSession.Connection.Logout(elevatedSession);
                    elevatedSession = null;
                }
            }
        }
Пример #15
0
        private void Build()
        {
            var pool = Helpers.GetPoolOfOne(connection);

            bool is_host = xenObjectCopy is Host;
            bool is_vm   = xenObjectCopy is VM && !((VM)xenObjectCopy).is_a_snapshot;
            bool is_sr   = xenObjectCopy is SR;

            bool is_pool    = xenObjectCopy is Pool;
            bool is_vdi     = xenObjectCopy is VDI;
            bool is_network = xenObjectCopy is XenAPI.Network;

            bool is_hvm     = is_vm && ((VM)xenObjectCopy).IsHVM;
            bool is_in_pool = Helpers.GetPool(xenObjectCopy.Connection) != null;

            bool is_pool_or_standalone = is_pool || (is_host && !is_in_pool);

            bool wlb_enabled = (Helpers.WlbEnabledAndConfigured(xenObjectCopy.Connection));

            bool is_VMPP = xenObjectCopy is VMPP;

            bool is_VM_appliance = xenObjectCopy is VM_appliance;

            ContentPanel.SuspendLayout();
            verticalTabs.BeginUpdate();

            try
            {
                verticalTabs.Items.Clear();

                ShowTab(GeneralEditPage = new GeneralEditPage());

                if (!is_VMPP && !is_VM_appliance)
                {
                    ShowTab(CustomFieldsEditPage = new CustomFieldsDisplayPage {
                        AutoScroll = true
                    });
                }

                if (is_vm)
                {
                    ShowTab(VCpuMemoryEditPage     = new CPUMemoryEditPage());
                    ShowTab(StartupOptionsEditPage = new BootOptionsEditPage());
                    ShowTab(VMHAEditPage           = new VMHAEditPage {
                        VerticalTabs = verticalTabs
                    });
                }

                if (is_vm || is_host || (is_sr && Helpers.ClearwaterOrGreater(connection)))
                {
                    if (Helpers.FeatureForbidden(xenObjectCopy, Host.RestrictAlerts))
                    {
                        PerfmonAlertUpsellEditPage = new UpsellPage {
                            Image = Properties.Resources._000_Alert2_h32bit_16, Text = Messages.ALERTS
                        };
                        PerfmonAlertUpsellEditPage.SetAllTexts(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_ALERTS : Messages.UPSELL_BLURB_ALERTS + Messages.UPSELL_BLURB_ALERTS_MORE,
                                                               InvisibleMessages.UPSELL_LEARNMOREURL_ALERTS);
                        ShowTab(PerfmonAlertUpsellEditPage);
                    }
                    else
                    {
                        ShowTab(PerfmonAlertEditPage = new PerfmonAlertEditPage {
                            AutoScroll = true
                        });
                    }
                }

                if (is_pool_or_standalone)
                {
                    if (Helpers.FeatureForbidden(xenObjectCopy, Host.RestrictAlerts))
                    {
                        PerfmonAlertOptionsUpsellEditPage = new UpsellPage {
                            Image = Properties.Resources._000_Email_h32bit_16, Text = Messages.EMAIL_OPTIONS
                        };
                        PerfmonAlertOptionsUpsellEditPage.SetAllTexts(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_ALERTS : Messages.UPSELL_BLURB_ALERTS + Messages.UPSELL_BLURB_ALERTS_MORE,
                                                                      InvisibleMessages.UPSELL_LEARNMOREURL_ALERTS);
                        ShowTab(PerfmonAlertOptionsUpsellEditPage);
                    }
                    else
                    {
                        ShowTab(PerfmonAlertOptionsEditPage = new PerfmonAlertOptionsPage());
                    }
                }

                if (is_host)
                {
                    ShowTab(hostMultipathPage1     = new HostMultipathPage());
                    ShowTab(HostPowerONEditPage    = new HostPowerONEditPage());
                    ShowTab(LogDestinationEditPage = new LogDestinationEditPage());
                }

                if (is_pool)
                {
                    ShowTab(PoolPowerONEditPage = new PoolPowerONEditPage());
                }

                if ((is_pool_or_standalone && Helpers.VGpuCapability(xenObjectCopy.Connection)) ||
                    (is_host && ((Host)xenObjectCopy).CanEnableDisableIntegratedGpu))
                {
                    ShowTab(PoolGpuEditPage = new PoolGpuEditPage());
                }

                if (is_pool_or_standalone && !Helpers.FeatureForbidden(xenObject.Connection, Host.RestrictSslLegacySwitch))
                {
                    ShowTab(SecurityEditPage = new SecurityEditPage());
                }

                if (is_pool_or_standalone && !Helpers.FeatureForbidden(xenObject.Connection, Host.RestrictLivePatching))
                {
                    ShowTab(LivePatchingEditPage = new LivePatchingEditPage());
                }

                if (is_network)
                {
                    ShowTab(editNetworkPage = new EditNetworkPage());
                }

                if (is_vm && !wlb_enabled)
                {
                    ShowTab(HomeServerPage = new HomeServerEditPage());
                }

                if (is_vm && ((VM)xenObjectCopy).CanHaveGpu)
                {
                    if (Helpers.FeatureForbidden(xenObjectCopy, Host.RestrictGpu))
                    {
                        GpuUpsellEditPage = new UpsellPage {
                            Image = Properties.Resources._000_GetMemoryInfo_h32bit_16, Text = Messages.GPU
                        };
                        GpuUpsellEditPage.SetAllTexts(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_GPU : Messages.UPSELL_BLURB_GPU + Messages.UPSELL_BLURB_GPU_MORE,
                                                      InvisibleMessages.UPSELL_LEARNMOREURL_GPU);
                        ShowTab(GpuUpsellEditPage);
                    }
                    else
                    {
                        ShowTab(GpuEditPage = new GpuEditPage());
                    }
                }

                if (is_hvm)
                {
                    ShowTab(VMAdvancedEditPage = new VMAdvancedEditPage());
                }

                if (is_vm && Helpers.ContainerCapability(xenObject.Connection) && ((VM)xenObjectCopy).CanBeEnlightened)
                {
                    ShowTab(VMEnlightenmentEditPage = new VMEnlightenmentEditPage());
                }

                if (is_vm && Helpers.ContainerCapability(xenObject.Connection) && ((VM)xenObjectCopy).CanHaveCloudConfigDrive)
                {
                    ShowTab(CloudConfigParametersPage = new Page_CloudConfigParameters());
                }

                if (is_VMPP)
                {
                    ShowTab(newPolicyVMsPage1 = new NewVMGroupVMsPage <VMPP> {
                        Pool = pool
                    });
                    ShowTab(newPolicySnapshotTypePage1      = new NewPolicySnapshotTypePage());
                    ShowTab(newPolicySnapshotFrequencyPage1 = new NewPolicySnapshotFrequencyPage {
                        Pool = pool
                    });
                    ShowTab(newPolicyArchivePage1 = new NewPolicyArchivePage {
                        Pool = pool, PropertiesDialog = this
                    });
                    ShowTab(newPolicyEmailPage1 = new NewPolicyEmailPage {
                        PropertiesDialog = this
                    });
                }

                if (is_VM_appliance)
                {
                    ShowTab(newVMApplianceVMsPage1 = new NewVMGroupVMsPage <VM_appliance> {
                        Pool = pool
                    });
                    ShowTab(newVmApplianceVmOrderAndDelaysPage1 = new NewVMApplianceVMOrderAndDelaysPage {
                        Pool = pool
                    });
                }

                //
                // Now add one tab per VBD (for VDIs only)
                //

                if (!is_vdi)
                {
                    return;
                }

                ShowTab(vdiSizeLocation = new VDISizeLocationPage());

                VDI vdi = xenObjectCopy as VDI;

                List <VBDEditPage> vbdEditPages = new List <VBDEditPage>();

                foreach (VBD vbd in vdi.Connection.ResolveAll(vdi.VBDs))
                {
                    VBDEditPage editPage = new VBDEditPage();

                    editPage.SetXenObjects(null, vbd);
                    vbdEditPages.Add(editPage);
                    ShowTab(editPage);
                }

                if (vbdEditPages.Count <= 0)
                {
                    return;
                }

                using (var dialog = new ActionProgressDialog(
                           new DelegatedAsyncAction(vdi.Connection, Messages.DEVICE_POSITION_SCANNING,
                                                    Messages.DEVICE_POSITION_SCANNING, Messages.DEVICE_POSITION_SCANNED,
                                                    delegate(Session session)
                {
                    foreach (VBDEditPage page in vbdEditPages)
                    {
                        page.UpdateDevicePositions(session);
                    }
                }),
                           ProgressBarStyle.Continuous))
                {
                    dialog.ShowCancel = true;
                    dialog.ShowDialog(Program.MainWindow);
                }
            }
            finally
            {
                ContentPanel.ResumeLayout();
                verticalTabs.EndUpdate();
                verticalTabs.SelectedIndex = 0;
            }
        }
        private void buttonResolveAll_Click(object sender, EventArgs e)
        {
            Dictionary<AsyncAction, AsyncAction> actions = new Dictionary<AsyncAction, AsyncAction>();
            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                PreCheckItemRow preCheckRow = row as PreCheckItemRow;
                if (preCheckRow != null && preCheckRow.Problem != null)
                {
                    bool cancelled;
                    AsyncAction action = preCheckRow.Problem.SolveImmediately(out cancelled);
                    if (action != null)
                    {
                        actions.Add(action, preCheckRow.Problem.UnwindChanges());
                    }
                }
            }
            foreach (var asyncAction in actions.Keys)
            {
                _progressDialog = new ActionProgressDialog(asyncAction, ProgressBarStyle.Blocks);
                _progressDialog.ShowDialog(this);

                if (asyncAction.Succeeded && actions[asyncAction] != null)
                    RevertActions.Add(actions[asyncAction]);
                Program.Invoke(Program.MainWindow, RefreshRechecks);
            }
            Program.Invoke(Program.MainWindow, RefreshRechecks);
        }
Пример #17
0
        private void Scan()
        {
            DelegatedAsyncAction saveVMsAction = new DelegatedAsyncAction(connection, Messages.SAVING_VMS_ACTION_TITLE,
                                                                          Messages.SAVING_VMS_ACTION_DESC, Messages.COMPLETED, delegate(Session session)
            {
                //Save Evacuated VMs for later
                host.SaveEvacuatedVMs(session);
            }, "host.remove_from_other_config", "host.add_to_other_config");

            DelegatedAsyncAction action = new DelegatedAsyncAction(connection, Messages.MAINTENANCE_MODE,
                                                                   Messages.SCANNING_VMS, Messages.SCANNING_VMS, delegate(Session session)
            {
                reasons = new Dictionary <XenRef <VM>, string[]>();

                // WLB: get host wlb evacuate recommendation if wlb is enabled
                if (Helpers.WlbEnabled(host.Connection))
                {
                    try
                    {
                        reasons = XenAPI.Host.retrieve_wlb_evacuate_recommendations(session, host.opaque_ref);
                    }
                    catch (Exception ex)
                    {
                        log.Debug(ex.Message, ex);
                    }
                }


                // WLB: in case wlb has no recommendations or get errors when retrieve recommendation,
                //      assume retrieve_wlb_evacuate_recommendations returns 0 recommendation
                //      or return recommendations for all running vms on this host
                if (reasons.Count == 0 || !ValidRecommendation(reasons))
                {
                    reasons = Host.get_vms_which_prevent_evacuation(session, host.opaque_ref);
                }

                // take care of errors
                Program.Invoke(this, delegate()
                {
                    foreach (KeyValuePair <XenRef <VM>, String[]> kvp in reasons)
                    {
                        //WLB: filter out errors
                        if (string.Compare(kvp.Value[0].Trim(), "wlb", true) != 0)
                        {
                            ProcessError(kvp.Key.opaque_ref, kvp.Value);
                        }

                        //Update NewMasterComboBox for host power on recommendation
                        if ((session.Connection.Resolve(kvp.Key)).is_control_domain)
                        {
                            Host powerOnHost = session.Connection.Cache.Find_By_Uuid <Host>(kvp.Value[(int)RecProperties.ToHost]);
                            if (powerOnHost != null)
                            {
                                var previousSelection = NewMasterComboBox.SelectedItem as ToStringWrapper <Host>;
                                var hostToAdd         = new ToStringWrapper <Host>(powerOnHost, powerOnHost.Name());
                                if (NewMasterComboBox.Items.Count == 0)
                                {
                                    powerOnHost.PropertyChanged -= new PropertyChangedEventHandler(host_PropertyChanged);
                                    powerOnHost.PropertyChanged += new PropertyChangedEventHandler(host_PropertyChanged);
                                    NewMasterComboBox.Items.Add(hostToAdd);
                                }
                                else
                                {
                                    foreach (ToStringWrapper <Host> tswh in NewMasterComboBox.Items)
                                    {
                                        if (tswh.item.CompareTo(powerOnHost) != 0)
                                        {
                                            powerOnHost.PropertyChanged -= new PropertyChangedEventHandler(host_PropertyChanged);
                                            powerOnHost.PropertyChanged += new PropertyChangedEventHandler(host_PropertyChanged);
                                            NewMasterComboBox.Items.Add(hostToAdd);
                                        }
                                    }
                                }
                                SelectProperItemInNewMasterComboBox(previousSelection);
                            }
                        }
                    }
                });
            }, true);

            SetSession(saveVMsAction);
            SetSession(action);
            saveVMsAction.RunAsync();
            using (var dlg = new ActionProgressDialog(action, ProgressBarStyle.Blocks))
                dlg.ShowDialog(this);
            RefreshEntermaintenanceButton();
        }
Пример #18
0
        public override void PageLeave(PageLoadedDirection direction, ref bool cancel)
        {
            if (direction == PageLoadedDirection.Back)
                return;

            // For Miami hosts we need to ensure an SR.probe()
            // has been performed, and that the user has made a decision. Show the iSCSI choices dialog until
            // they click something other than 'Cancel'. For earlier host versions, warn that data loss may
            // occur.

            Host master = Helpers.GetMaster(Connection);
            if (master == null)
            {
                cancel = true;
                return;
            }

            Dictionary<String, String> dconf = DeviceConfig;
            if (dconf == null)
            {
                cancel = true;
                return;
            }

            // Start probe
            SrProbeAction IscsiProbeAction = new SrProbeAction(Connection, master, SR.SRTypes.lvmoiscsi, dconf);
            using (var  dialog = new ActionProgressDialog(IscsiProbeAction, ProgressBarStyle.Marquee))
            {
                dialog.ShowCancel = true;
                dialog.ShowDialog(this);
            }

            // Probe has been performed. Now ask the user if they want to Reattach/Format/Cancel.
            // Will return false on cancel
            cancel = !ExamineIscsiProbeResults(IscsiProbeAction);
            iscsiProbeError = cancel;

            base.PageLeave(direction, ref cancel);
        }
Пример #19
0
        private void LoadMetadata()
        {
            allPoolMetadata.Clear();

            GetMetadataVDIsAction action = new GetMetadataVDIsAction(Connection, SelectedSRsUuids);

            if (!cldl.IsStillConnected(Connection))
                return;

            ActionProgressDialog dialog = new ActionProgressDialog(action, ProgressBarStyle.Marquee);
            dialog.ShowDialog(this);

            if (!cldl.IsStillConnected(Connection))
                return;

            if (action.Succeeded && action.VDIs != null)
            {
                foreach (VDI vdi in action.VDIs)
                {
                    var inUse = Connection.ResolveAll(vdi.VBDs).Where(vbd => vbd.currently_attached).Any();
                    if (!inUse)
                        LoadPoolMetadata(vdi);
                    else
                        log.DebugFormat("This metadata VDI is in use: '{0}' (UUID='{1}', SR='{2})'; will not attempt to load metadata from it", vdi.Name,
                                       vdi.uuid, Connection.Resolve(vdi.SR).Name);
                }
            }
        }
Пример #20
0
        private void ButtonRemove_Click(object sender, EventArgs e)
        {
            Program.AssertOnEventThread();
            
            // Double check, this method is called from a context menu as well and the state could have changed under it
            if (!ButtonRemove.Enabled)
                return;

            List<Subject> subjectsToRemove = new List<Subject>();
            foreach (AdSubjectRow r in GridViewSubjectList.SelectedRows)
                subjectsToRemove.Add(r.subject);

            var removeMessage = subjectsToRemove.Count == 1
                ? string.Format(Messages.QUESTION_REMOVE_AD_USER_ONE, subjectsToRemove[0].DisplayName ?? subjectsToRemove[0].SubjectName)
                : string.Format(Messages.QUESTION_REMOVE_AD_USER_MANY, subjectsToRemove.Count);

            DialogResult questionDialog = new ThreeButtonDialog(
                                new ThreeButtonDialog.Details(
                                    null,
                                    removeMessage,
                                    Messages.AD_FEATURE_NAME),
                                ThreeButtonDialog.ButtonYes,
                                new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, ThreeButtonDialog.ButtonType.CANCEL, true)).ShowDialog(this);

            //CA-64818: DialogResult can be No if the No button has been hit
            //or Cancel if the dialog has been closed from the control box
            if (questionDialog != DialogResult.Yes)
                return;

            // Warn if user is revoking his currently-in-use credentials
            Session session = pool.Connection.Session;
            if (session != null && session.Subject != null)
            {
                foreach (Subject entry in subjectsToRemove)
                {
                    if (entry.opaque_ref == session.Subject)
                    {
                        string subjectName = entry.DisplayName ?? entry.SubjectName;
                        if (subjectName == null)
                        {
                            subjectName = entry.subject_identifier;
                        }
                        else
                        {
                            subjectName = subjectName.Ellipsise(256);
                        }
                        string msg = string.Format(entry.IsGroup ? Messages.AD_CONFIRM_SUICIDE_GROUP : Messages.AD_CONFIRM_SUICIDE,
                                    subjectName, Helpers.GetName(pool).Ellipsise(50));

                        DialogResult r = new ThreeButtonDialog(
                            new ThreeButtonDialog.Details(
                                SystemIcons.Warning,
                                msg,
                                Messages.AD_FEATURE_NAME),
                            ThreeButtonDialog.ButtonYes,
                            new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, ThreeButtonDialog.ButtonType.CANCEL, true)).ShowDialog(this);

                        //CA-64818: DialogResult can be No if the No button has been hit
                        //or Cancel if the dialog has been closed from the control box
                        if (r != DialogResult.Yes)
                            return;

                        break;
                    }
                }
            }
            removeUserDialog = new ActionProgressDialog(
                new AddRemoveSubjectsAction(pool, new List<string>(), subjectsToRemove), ProgressBarStyle.Continuous);
            removeUserDialog.ShowDialog();
        }
Пример #21
0
        /// <summary>
        /// Invokes and executes a call to the Kirkwood database via Xapi 
        /// to obtain report configuration data including the actual
        /// rdlc report definitions
        /// </summary>
        /// <returns>Report definition list XML document</returns>
        private XmlDocument GetServerReportsConfig()
        {
            string returnValue;
            XmlDocument xmlReportsDoc = new XmlDocument();
            string reportName = "get_report_definitions";

            // Parameters
            Dictionary<string, string> parms = new Dictionary<string, string>();
            parms.Add("LocaleCode", Program.CurrentLanguage);
            if (_isCreedenceOrLater)
            {
                parms.Add("ReportVersion", "Creedence");
                parms.Add("PoolId", _pool.uuid);
            }

            AsyncAction action = new WlbReportAction(_pool.Connection,
                                                Helpers.GetMaster(_pool.Connection),
                                                reportName,
                                                Messages.WLB_REPORT_DEFINITIONS,
                                                true,
                                                parms);

            using (var dlg = new ActionProgressDialog(action, ProgressBarStyle.Marquee))
                dlg.ShowDialog();

            returnValue = action.Result;

            if ((action.Succeeded) && (!String.IsNullOrEmpty(returnValue)))
            {
                try
                {
                    xmlReportsDoc.LoadXml(returnValue);

                    string rdlcText;

                    foreach (XmlNode currentRdlc in xmlReportsDoc.SelectNodes(@"Reports/Report/Rdlc"))
                    {
                        rdlcText = currentRdlc.InnerText;
                        currentRdlc.InnerText = String.Empty;
                        currentRdlc.InnerText = rdlcText;
                    }
                }
                catch (Exception)
                {
                    xmlReportsDoc = null;
                }
            }

            return xmlReportsDoc;
        }
Пример #22
0
        private void DownloadAndInstall()
        {
            if (dataGridViewUpdates.SelectedRows.Count == 0)
                return;

            XenServerPatchAlert patchAlert = dataGridViewUpdates.SelectedRows[0].Tag as XenServerPatchAlert;
            if (patchAlert == null)
                return;

            string patchUri = patchAlert.Patch.PatchUrl;
            if (string.IsNullOrEmpty(patchUri))
                return;

            Uri address = new Uri(patchUri);
            string tempFile = Path.GetTempFileName();

            var action = new DownloadAndUnzipXenServerPatchAction(patchAlert.Description, address, tempFile);
            ActionProgressDialog dialog = new ActionProgressDialog(action, ProgressBarStyle.Continuous, false) { ShowCancel = true };
            dialog.ShowDialog(this);

            if (action.Succeeded)
            {
                var wizard = new PatchingWizard();
                wizard.Show();
                wizard.NextStep();
                wizard.AddFile(action.PatchPath);
                wizard.NextStep();
                if (patchAlert.Hosts.Count > 0)
                {
                    wizard.SelectServers(patchAlert.Hosts);
                    wizard.NextStep();
                }
                else
                {
                    string disconnectedServerNames =
                        dataGridViewUpdates.SelectedRows[0].Cells[ColumnAppliesTo.Index].Value.ToString();

                    new ThreeButtonDialog(
                        new ThreeButtonDialog.Details(SystemIcons.Warning,
                                                      string.Format(Messages.UPDATES_WIZARD_DISCONNECTED_SERVER,
                                                                    disconnectedServerNames),
                                                      Messages.UPDATES_WIZARD)).ShowDialog(this);
                }
            }
        }
Пример #23
0
        private void RunFinalAction(out bool closeWizard)
        {
            FinalAction = null;
            closeWizard = false;

            // Override the WizardBase: try running the SR create/attach. If it succeeds, close the wizard.
            // Otherwise show the error and allow the user to adjust the settings and try again.
            Pool pool = Helpers.GetPoolOfOne(xenConnection);
            if (pool == null)
            {
                log.Error("New SR Wizard: Pool has disappeared");
                new ThreeButtonDialog(
                   new ThreeButtonDialog.Details(SystemIcons.Warning, string.Format(Messages.NEW_SR_CONNECTION_LOST, Helpers.GetName(xenConnection)), Messages.XENCENTER)).ShowDialog(this);

                closeWizard = true;
                return;
            }

            Host master = xenConnection.Resolve(pool.master);
            if (master == null)
            {
                log.Error("New SR Wizard: Master has disappeared");
                new ThreeButtonDialog(
                   new ThreeButtonDialog.Details(SystemIcons.Warning, string.Format(Messages.NEW_SR_CONNECTION_LOST, Helpers.GetName(xenConnection)), Messages.XENCENTER)).ShowDialog(this);

                closeWizard = true;
                return;
            }

            if (_srToReattach != null && !_srToReattach.IsDetached && _srToReattach.Connection == xenConnection)
            {
                // Error - cannot reattach attached SR
                MessageBox.Show(this,
                    String.Format(Messages.STORAGE_IN_USE, _srToReattach.Name, Helpers.GetName(xenConnection)),
                    Text, MessageBoxButtons.OK, MessageBoxIcon.Error);

                FinishCanceled();
                return;
            }

            // show warning prompt if required
            if (!AskUserIfShouldContinue())
            {
                FinishCanceled();
                return;
            }

            List<AsyncAction> actionList = GetActions(master, m_srWizardType.DisasterRecoveryTask);

            if (actionList.Count == 1)
                FinalAction = actionList[0];
            else
                FinalAction = new ParallelAction(xenConnection, Messages.NEW_SR_WIZARD_FINAL_ACTION_TITLE,
                                                 Messages.NEW_SR_WIZARD_FINAL_ACTION_START,
                                                 Messages.NEW_SR_WIZARD_FINAL_ACTION_END, actionList);

            // if this is a Disaster Recovery Task, it could be either a "Find existing SRs" or an "Attach SR needed for DR" case
            if (m_srWizardType.DisasterRecoveryTask)
            {
                closeWizard = true;
                return;
            }

            ProgressBarStyle progressBarStyle = FinalAction is SrIntroduceAction ? ProgressBarStyle.Blocks : ProgressBarStyle.Marquee;
            ActionProgressDialog dialog = new ActionProgressDialog(FinalAction, progressBarStyle) {ShowCancel = true};

            if (m_srWizardType is SrWizardType_LvmoHba)
            {
                foreach (var asyncAction in actionList)
                {
                    asyncAction.Completed += asyncAction_Completed;
                }

                ActionProgressDialog closureDialog = dialog;
                // close dialog even when there's an error for HBA SR type as there will be the Summary page displayed.
                FinalAction.Completed +=
                    (s, ea) => Program.Invoke(Program.MainWindow, () =>
                                                                      {
                                                                          if (closureDialog != null)
                                                                              closureDialog.Close();
                                                                      });
            }
            dialog.ShowDialog(this);

            if (!FinalAction.Succeeded && FinalAction is SrReattachAction && !_srToReattach.IsDetached)
            {
                // reattach failed. Ensure SR is now detached.
                dialog = new ActionProgressDialog(new SrAction(SrActionKind.Detach, _srToReattach), progressBarStyle);
                dialog.ShowCancel = false;
                dialog.ShowDialog();
            }

            // If action failed and frontend wants to stay open, just return
            if (!FinalAction.Succeeded)
            {
                DialogResult = DialogResult.None;
                FinishCanceled();

                if (m_srWizardType.AutoDescriptionRequired)
                {
                    foreach (var srDescriptor in m_srWizardType.SrDescriptors)
                    {
                        srDescriptor.Description = null;
                    }
                }

                return;
            }

            // Close wizard
            closeWizard = true;
        }
Пример #24
0
        private void ToolStripMenuItemDownload_Click(object sender, EventArgs e)
        {
            DataGridViewRow clickedRow = FindAlertRow(sender as ToolStripMenuItem);
            if (clickedRow == null)
                return;

            XenServerPatchAlert patchAlert = (XenServerPatchAlert) clickedRow.Tag;

            if (patchAlert == null)
                return;

            string patchUri = patchAlert.Patch.PatchUrl;
            if (string.IsNullOrEmpty(patchUri))
                return;

            Uri address = new Uri(patchUri);
            string tempFile = Path.GetTempFileName();

            var action = new DownloadAndUnzipXenServerPatchAction(patchAlert.Description, address, tempFile);
            ActionProgressDialog dialog = new ActionProgressDialog(action, ProgressBarStyle.Continuous, false) { ShowCancel = true };
            dialog.ShowDialog(this);

            if (action.Succeeded)
            {
                var wizard = new PatchingWizard();
                wizard.Show();
                wizard.NextStep();
                wizard.AddFile(action.PatchPath);
                wizard.NextStep();

                var hosts = patchAlert.DistinctHosts;
                if (hosts.Count > 0)
                {
                    wizard.SelectServers(hosts);
                }
                else
                {
                    string disconnectedServerNames = clickedRow.Cells[ColumnLocation.Index].Value.ToString();

                    new ThreeButtonDialog(
                        new ThreeButtonDialog.Details(SystemIcons.Warning,
                                                      string.Format(Messages.UPDATES_WIZARD_DISCONNECTED_SERVER,
                                                                    disconnectedServerNames),
                                                      Messages.UPDATES_WIZARD)).ShowDialog(this);
                }
            }
        }
        private void ExecuteSolution(PreCheckHostRow preCheckHostRow)
        {
            bool cancelled;
            AsyncAction action = preCheckHostRow.Problem.SolveImmediately(out cancelled);

            if (action != null)
            {
                action.Completed += action_Completed;
                _progressDialog = new ActionProgressDialog(action, ProgressBarStyle.Blocks);
                _progressDialog.ShowDialog(this);
            }
            else
            {
                if (preCheckHostRow.Problem is WarningWithInformationUrl)
                    (preCheckHostRow.Problem as WarningWithInformationUrl).LaunchUrlInBrowser();
                else if (preCheckHostRow.Problem is ProblemWithInformationUrl)
                    (preCheckHostRow.Problem as ProblemWithInformationUrl).LaunchUrlInBrowser();
                    
                else if (!cancelled)
                    new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Information,
                                                                        string.Format(Messages.PATCHING_WIZARD_SOLVE_MANUALLY, preCheckHostRow.Problem.Description).Replace("\\n", "\n"),
                                                                        Messages.PATCHINGWIZARD_PRECHECKPAGE_TEXT)).ShowDialog(this);
            }
        }
Пример #26
0
 private void RunMultipleActions(string title, string startDescription, string endDescription,
     List<AsyncAction> subActions)
 {
     if (subActions.Count > 0)
     {
         using (MultipleAction multipleAction = new MultipleAction(xenConnection, title, startDescription,
                                                                   endDescription, subActions, false, true))
         {
             ActionProgressDialog dialog = new ActionProgressDialog(multipleAction, ProgressBarStyle.Blocks);
             dialog.ShowDialog(Program.MainWindow);
         }
     }
 }
Пример #27
0
        private void Build()
        {
            var pool = Helpers.GetPoolOfOne(connection);

            bool is_host = xenObjectCopy is Host;
            bool is_vm = xenObjectCopy is VM && !((VM)xenObjectCopy).is_a_snapshot;
            bool is_sr = xenObjectCopy is SR;

            bool is_pool = xenObjectCopy is Pool;
            bool is_vdi = xenObjectCopy is VDI;
            bool is_network = xenObjectCopy is XenAPI.Network;

            bool is_hvm = is_vm && ((VM)xenObjectCopy).IsHVM;
            bool is_in_pool = Helpers.GetPool(xenObjectCopy.Connection) != null;

            bool is_pool_or_standalone = is_pool || (is_host && !is_in_pool);

            bool wlb_enabled = (Helpers.WlbEnabledAndConfigured(xenObjectCopy.Connection));

            bool is_VMPP = xenObjectCopy is VMPP;

            bool is_VM_appliance = xenObjectCopy is VM_appliance;

            ContentPanel.SuspendLayout();
            verticalTabs.BeginUpdate();

            try
            {
                verticalTabs.Items.Clear();

                ShowTab(GeneralEditPage = new GeneralEditPage());

                if (!is_VMPP && !is_VM_appliance)
                    ShowTab(CustomFieldsEditPage = new CustomFieldsDisplayPage {AutoScroll = true});

                if (is_vm)
                {
                    ShowTab(VCpuMemoryEditPage = new CPUMemoryEditPage());
                    ShowTab(StartupOptionsEditPage = new BootOptionsEditPage());

                    if (!Helpers.BostonOrGreater(xenObjectCopy.Connection) && Helpers.FeatureForbidden(xenObjectCopy, Host.RestrictHAFloodgate))
                    {
                        VMHAUpsellEditPage = new UpsellPage {Image = Properties.Resources._001_PowerOn_h32bit_16, Text = Messages.START_UP_OPTIONS};
                        VMHAUpsellEditPage.SetAllTexts(Messages.UPSELL_BLURB_HA, InvisibleMessages.UPSELL_LEARNMOREURL_HA);
                        ShowTab(VMHAUpsellEditPage);
                    }
                    else
                    {
                        ShowTab(VMHAEditPage = new VMHAEditPage {VerticalTabs = verticalTabs});
                    }
                }

                if (is_vm || is_host || (is_sr && Helpers.ClearwaterOrGreater(connection)))
                {
                    if (Helpers.FeatureForbidden(xenObjectCopy, Host.RestrictAlerts))
                    {
                        PerfmonAlertUpsellEditPage = new UpsellPage {Image = Properties.Resources._000_Alert2_h32bit_16, Text = Messages.ALERTS};
                        PerfmonAlertUpsellEditPage.SetAllTexts(Messages.UPSELL_BLURB_ALERTS, InvisibleMessages.UPSELL_LEARNMOREURL_ALERTS);
                        ShowTab(PerfmonAlertUpsellEditPage);
                    }
                    else
                    {
                        ShowTab(PerfmonAlertEditPage = new PerfmonAlertEditPage {AutoScroll = true});
                    }
                }

                if (is_pool_or_standalone)
                {
                    if (Helpers.FeatureForbidden(xenObjectCopy, Host.RestrictAlerts))
                    {
                        PerfmonAlertOptionsUpsellEditPage = new UpsellPage {Image = Properties.Resources._000_Email_h32bit_16, Text = Messages.EMAIL_OPTIONS};
                        PerfmonAlertOptionsUpsellEditPage.SetAllTexts(Messages.UPSELL_BLURB_ALERTS, InvisibleMessages.UPSELL_LEARNMOREURL_ALERTS);
                        ShowTab(PerfmonAlertOptionsUpsellEditPage);
                    }
                    else
                    {
                        ShowTab(PerfmonAlertOptionsEditPage = new PerfmonAlertOptionsPage());
                    }

                    if (!Helpers.FeatureForbidden(xenObjectCopy, Host.RestrictStorageChoices)
                        && !Helpers.BostonOrGreater(xenObjectCopy.Connection)
                        && Helpers.MidnightRideOrGreater(xenObjectCopy.Connection))
                        ShowTab(StorageLinkPage = new StorageLinkEditPage());
                }

                if (is_host)
                {
                    ShowTab(hostMultipathPage1 = new HostMultipathPage());

                    if (Helpers.MidnightRideOrGreater(xenObject.Connection))
                        ShowTab(HostPowerONEditPage = new HostPowerONEditPage());

                    ShowTab(LogDestinationEditPage = new LogDestinationEditPage());
                }
                
                if (is_pool && Helpers.MidnightRideOrGreater(xenObject.Connection))
                    ShowTab(PoolPowerONEditPage = new PoolPowerONEditPage());

                if ((is_pool_or_standalone && Helpers.VGpuCapability(xenObjectCopy.Connection))
                    || (is_host && ((Host)xenObjectCopy).CanEnableDisableIntegratedGpu))
                {
                    ShowTab(PoolGpuEditPage = new PoolGpuEditPage());
                }

                if (is_pool_or_standalone && Helpers.DundeeOrGreater(xenObject.Connection))
                    ShowTab(SecurityEditPage = new SecurityEditPage());

                if (is_network)
                    ShowTab(editNetworkPage = new EditNetworkPage());

                if (is_vm && !wlb_enabled)
                    ShowTab(HomeServerPage = new HomeServerEditPage());

                if (is_vm && ((VM)xenObjectCopy).CanHaveGpu)
                {
                    if (Helpers.BostonOrGreater(xenObject.Connection))
                    {
                        if (Helpers.FeatureForbidden(xenObjectCopy, Host.RestrictGpu))
                        {
                            GpuUpsellEditPage = new UpsellPage { Image = Properties.Resources._000_GetMemoryInfo_h32bit_16, Text = Messages.GPU };
                            GpuUpsellEditPage.SetAllTexts(Messages.UPSELL_BLURB_GPU, InvisibleMessages.UPSELL_LEARNMOREURL_GPU);
                            ShowTab(GpuUpsellEditPage);
                        }
                        else
                        {
                            ShowTab(GpuEditPage = new GpuEditPage());
                        }
                    }
                }

                if (is_hvm)
                {
                    ShowTab(VMAdvancedEditPage = new VMAdvancedEditPage());
                }

                if (is_vm && Helpers.ContainerCapability(xenObject.Connection) && ((VM)xenObjectCopy).CanBeEnlightened)
                    ShowTab(VMEnlightenmentEditPage = new VMEnlightenmentEditPage());

                if (is_vm && Helpers.ContainerCapability(xenObject.Connection) && ((VM)xenObjectCopy).CanHaveCloudConfigDrive)
                    ShowTab(CloudConfigParametersPage = new Page_CloudConfigParameters());

                if (is_VMPP)
                {
                    ShowTab(newPolicyVMsPage1 = new NewVMGroupVMsPage<VMPP> {Pool = pool});
                    ShowTab(newPolicySnapshotTypePage1 = new NewPolicySnapshotTypePage());
                    ShowTab(newPolicySnapshotFrequencyPage1 = new NewPolicySnapshotFrequencyPage {Pool = pool});
                    ShowTab(newPolicyArchivePage1 = new NewPolicyArchivePage {Pool = pool, PropertiesDialog = this});
                    ShowTab(newPolicyEmailPage1 = new NewPolicyEmailPage {PropertiesDialog = this});
                }

                if (is_VM_appliance)
                {
                    ShowTab(newVMApplianceVMsPage1 = new NewVMGroupVMsPage<VM_appliance> { Pool = pool });
                    ShowTab(newVmApplianceVmOrderAndDelaysPage1 = new NewVMApplianceVMOrderAndDelaysPage { Pool = pool });
                }

                //
                // Now add one tab per VBD (for VDIs only)
                //

                if (!is_vdi)
                    return;

                ShowTab(vdiSizeLocation = new VDISizeLocationPage());

                VDI vdi = xenObjectCopy as VDI;

                List<VBDEditPage> vbdEditPages = new List<VBDEditPage>();

                foreach (VBD vbd in vdi.Connection.ResolveAll(vdi.VBDs))
                {
                    VBDEditPage editPage = new VBDEditPage();

                    editPage.SetXenObjects(null, vbd);
                    vbdEditPages.Add(editPage);
                    ShowTab(editPage);
                }

                if (vbdEditPages.Count <= 0)
                    return;

                ActionProgressDialog dialog = new ActionProgressDialog(
                    new DelegatedAsyncAction(vdi.Connection, Messages.DEVICE_POSITION_SCANNING,
                        Messages.DEVICE_POSITION_SCANNING, Messages.DEVICE_POSITION_SCANNED,
                        delegate(Session session)
                        {
                            foreach (VBDEditPage page in vbdEditPages)
                                page.UpdateDevicePositions(session);
                        }),
                    ProgressBarStyle.Continuous);
                dialog.ShowCancel = true;
                dialog.ShowDialog(Program.MainWindow);
            }
            finally
            {
                ContentPanel.ResumeLayout();
                verticalTabs.EndUpdate();
                verticalTabs.SelectedIndex = 0;
            }
        }
Пример #28
0
        private void buttonIscsiPopulateLUNs_Click(object sender, EventArgs e)
        {
            buttonIscsiPopulateLUNs.Enabled = false;
            comboBoxIscsiLuns.Items.Clear();
            LunMap.Clear();

            if (IscsiUseChapCheckBox.Checked)
            {
                IscsiPopulateLunsAction = new Actions.ISCSIPopulateLunsAction(connection,
                    getIscsiHost(), getIscsiPort(), getIscsiIQN(), IScsiChapUserTextBox.Text, IScsiChapSecretTextBox.Text);
            }
            else
            {
                IscsiPopulateLunsAction = new Actions.ISCSIPopulateLunsAction(connection,
                    getIscsiHost(), getIscsiPort(), getIscsiIQN(), null, null);
            }

            IscsiPopulateLunsAction.Completed += IscsiPopulateLunsAction_Completed;
            using (var dialog = new ActionProgressDialog(IscsiPopulateLunsAction, ProgressBarStyle.Marquee))
            {
                dialog.ShowCancel = true;
                dialog.ShowDialog(this);
            }
        }
Пример #29
0
        public override void PageLeave(PageLoadedDirection direction, ref bool cancel)
        {
            if (direction == PageLoadedDirection.Back)
                return;

            Host master = Helpers.GetMaster(Connection);
            if (master == null)
            {
                cancel = true;
                return;
            }

            SrDescriptors = new List<LvmOhbaSrDescriptor>();

            var existingSrDescriptors = new List<LvmOhbaSrDescriptor>();
            var formatDiskDescriptors = new List<LvmOhbaSrDescriptor>();

            foreach (var device in _selectedDevices)
            {
                LvmOhbaSrDescriptor descr = CreateSrDescriptor(device);

                var action = new SrProbeAction(Connection, master, SrType, descr.DeviceConfig);
                using (var dlg = new ActionProgressDialog(action, ProgressBarStyle.Marquee))
                    dlg.ShowDialog(this);

                if (!action.Succeeded)
                {
                    cancel = true;
                    return;
                }

                descr.UUID = SrWizardHelpers.ExtractUUID(action.Result);

                if (!string.IsNullOrEmpty(SrWizardType.UUID))
                {
                    // Check LUN contains correct SR
                    if (descr.UUID == SrWizardType.UUID)
                    {
                        SrDescriptors.Add(descr);
                        continue;
                    }

                    using (var dlog = new ThreeButtonDialog(
                        new ThreeButtonDialog.Details(SystemIcons.Error,
                            String.Format(Messages.INCORRECT_LUN_FOR_SR, SrWizardType.SrName), Messages.XENCENTER)))
                    {
                        dlog.ShowDialog(this);
                    }

                    cancel = true;
                    return;
                }

                if (string.IsNullOrEmpty(descr.UUID))
                {
                    // No existing SRs were found on this LUN. If allowed to create
                    // a new SR, ask the user if they want to proceed and format.
                    if (!SrWizardType.AllowToCreateNewSr)
                    {
                        using (var dlog = new ThreeButtonDialog(
                            new ThreeButtonDialog.Details(SystemIcons.Error,
                                Messages.NEWSR_LUN_HAS_NO_SRS, Messages.XENCENTER)))
                        {
                            dlog.ShowDialog(this);
                        }

                        cancel = true;
                        return;
                    }

                    if (!Program.RunInAutomatedTestMode)
                        formatDiskDescriptors.Add(descr);
                }
                else
                {
                    // CA-17230: Check this isn't a detached SR. If it is then just continue
                    SR sr = SrWizardHelpers.SrInUse(descr.UUID);
                    if (sr != null)
                    {
                        SrDescriptors.Add(descr);
                        continue;
                    }

                    // We found a SR on this LUN. Will ask user for choice later.
                    existingSrDescriptors.Add(descr);
                }
            }

            if (!cancel && existingSrDescriptors.Count > 0)
            {
                var launcher = new LVMoHBAWarningDialogLauncher(this, existingSrDescriptors, true);
                launcher.ShowWarnings();
                cancel = launcher.Cancelled;
                if (!cancel && launcher.SrDescriptors.Count > 0)
                    SrDescriptors.AddRange(launcher.SrDescriptors);
            }

            if (!cancel && formatDiskDescriptors.Count > 0)
            {
                var launcher = new LVMoHBAWarningDialogLauncher(this, formatDiskDescriptors, false);
                launcher.ShowWarnings();
                cancel = launcher.Cancelled;
                if (!cancel && launcher.SrDescriptors.Count > 0)
                    SrDescriptors.AddRange(launcher.SrDescriptors);
            }

            base.PageLeave(direction, ref cancel);
        }
        private List<SR.SRInfo> ScanDeviceForSRs(SR.SRTypes type, string deviceId, Dictionary<string, string> dconf)
        {
            Host master = Helpers.GetMaster(Connection);
            if (master == null || dconf == null)
                return null;

            Dictionary<string, string> smconf = new Dictionary<string, string>();
            smconf[METADATA] = "true";

            // Start probe
            SrProbeAction srProbeAction = new SrProbeAction(Connection, master, type, dconf, smconf);
            using (var dlg = new ActionProgressDialog(srProbeAction, ProgressBarStyle.Marquee))
                dlg.ShowDialog(this);

            if (!srProbeAction.Succeeded)
                return null;

            try
            {
                var metadataSrs = SR.ParseSRListXML(srProbeAction.Result);

                if (ScannedDevices.ContainsKey(deviceId))
                {
                    //update SR list
                    ScannedDevices[deviceId].SRList.Clear();
                    ScannedDevices[deviceId].SRList.AddRange(metadataSrs);
                }
                else
                {
                    ScannedDevices.Add(deviceId, new ScannedDeviceInfo(type, dconf, metadataSrs));
                }

                return metadataSrs;
            }
            catch
            {
                return null;
            }
        }
Пример #31
0
        private void buttonNfsScan_Click(object sender, EventArgs e)
        {
            NfsScanButton.Enabled = false;

            // Perform an SR.probe to see if there is already an SR present
            Dictionary<String, String> dconf = new Dictionary<String, String>();
            string[] fullpath = NfsServerPathTextBox.Text.Trim().Split(new char[] { ':' });
            dconf[SERVER] = fullpath[0];
            if (fullpath.Length > 1)
            {
                dconf[SERVERPATH] = fullpath[1];
            }
            dconf[OPTIONS] = serverOptionsTextBox.Text;

            Host master = Helpers.GetMaster(Connection);
            if (master == null)
                return;

            if (Helpers.DundeeOrGreater(Connection))
                dconf[PROBEVERSION] = string.Empty; //this needs to be passed to the API in order to get back the NFS versions supported

            // Start probe
            SrProbeAction action = new SrProbeAction(Connection, master, SR.SRTypes.nfs, dconf);
            ActionProgressDialog dialog = new ActionProgressDialog(action, ProgressBarStyle.Marquee);
            dialog.ShowCancel = true;
            dialog.ShowDialog(this);

            try
            {
                NfsScanButton.Enabled = true;
                if (radioButtonNfsNew.Enabled)
                    radioButtonNfsNew.Checked = true;

                listBoxNfsSRs.Items.Clear();

                if (!action.Succeeded)
                    return;

                List<SR.SRInfo> SRs = SR.ParseSRListXML(action.Result);
                if (SRs.Count == 0)
                {
                    // Disable box
                    ToggleReattachControlsEnabledState(false);
                    listBoxNfsSRs.Items.Add(Messages.NEWSR_NO_SRS_FOUND);
                    return;
                }

                // Fill box
                foreach(SR.SRInfo info in SRs)
                    listBoxNfsSRs.Items.Add(info);

                listBoxNfsSRs.TryAndSelectUUID();

                GetSupportedNfsVersionsAndSetUI(action.Result);
                
                ToggleReattachControlsEnabledState(true);
            }
            finally
            {
                UpdateButtons();
            }
        }
Пример #32
0
 private void RevertResolvedPreChecks()
 {
     List<AsyncAction> subActions = GetUnwindChangesActions();
     if (subActions.Count > 0)
     {
         using (MultipleAction multipleAction = new MultipleAction(xenConnection, Messages.REVERT_WIZARD_CHANGES,
                                                                   Messages.REVERTING_WIZARD_CHANGES,
                                                                   Messages.REVERTED_WIZARD_CHANGES,
                                                                   subActions, true))
         {
             ActionProgressDialog dialog = new ActionProgressDialog(multipleAction, ProgressBarStyle.Blocks);
             dialog.ShowDialog(Program.MainWindow);
         }
     }
 }
 private void ExecuteSolution(PreCheckItemRow preCheckRow)
 {
     bool cancelled;
     AsyncAction action = preCheckRow.Problem.SolveImmediately(out cancelled);
     if (action != null)
     {
         action.Completed += action_Completed;
         _progressDialog = new ActionProgressDialog(action, ProgressBarStyle.Blocks);
         _progressDialog.ShowDialog(this);
         if (action.Succeeded)
         {
             var revertAction = preCheckRow.Problem.UnwindChanges();
             if (revertAction != null)
                 RevertActions.Add(revertAction);
         }
     }
 }
Пример #34
0
        private bool FiberChannelScan(List<FibreChannelDevice> devices)
        {
            Host master = Helpers.GetMaster(Connection);
            if (master == null)
                return false;

            FibreChannelProbeAction action = new FibreChannelProbeAction(master);
            ActionProgressDialog dialog = new ActionProgressDialog(action, ProgressBarStyle.Marquee);
            dialog.ShowDialog(this); //Will block until dialog closes, action completed

            if (!action.Succeeded)
                return false;

            try
            {
                FibreChannelProbeParsing.ProcessXML(action.Result, devices);
                return true;
            }
            catch (Exception e)
            {
                log.Debug("Exception parsing result of fibre channel scan", e);
                log.Debug(e, e);
                return false;
            }
        }