private static bool CanReattachSR(SR sr)
 {
     return(sr != null &&
            !sr.HasPBDs() &&
            !HelpersGUI.GetActionInProgress(sr) &&
            !(sr.type == "cslg" && Helpers.FeatureForbidden(sr.Connection, Host.RestrictStorageChoices)) &&
            (SM.GetByType(sr.Connection, sr.type) != null));
 }
Exemple #2
0
        private SM GetSmForRadioButton(RadioButton radioButton)
        {
            SrWizardType wizardType = (SrWizardType)radioButton.Tag;
            SM           sm         = SM.GetByType(Connection, wizardType.Type.ToString());

            //check also for Netapp and EqualLogic because these don't have dedicated buttons
            if (radioButton == radioButtonCslg)
            {
                if (sm == null)
                {
                    sm = SM.GetByType(Connection, SR.SRTypes.netapp.ToString());
                }
                if (sm == null)
                {
                    sm = SM.GetByType(Connection, SR.SRTypes.equal.ToString());
                }
            }
            return(sm);
        }
Exemple #3
0
        private bool CheckCanCreateVdiOnIsoSr(out string error)
        {
            error = string.Empty;

            SM sm = null;

            if (SelectedIsoSR != null)
            {
                sm = SM.GetByType(Connection, SelectedIsoSR.type);
            }

            if (sm != null && sm.capabilities.Contains("VDI_CREATE"))
            {
                return(true);
            }

            error = Messages.IMPORT_OPTIONS_PAGE_CANNOT_USE_SELECTED_ISO_LIBRARY;
            return(false);
        }
        public override void PopulatePage()
        {
            radioButtonCslg.Visible = !Helpers.CreedenceOrGreater(Connection); //Hide iSL radio button for Creedence or higher (StorageLink is not supported)

            radioButtonCifs.Visible = !Helpers.FeatureForbidden(Connection, Host.RestrictCifs);

            foreach (var radioButton in RadioButtons)
            {
                var frontend = (SrWizardType)radioButton.Tag;
                frontend.ResetSrName(Connection);
                frontend.AllowToCreateNewSr   = SrToReattach == null && !DisasterRecoveryTask;
                frontend.DisasterRecoveryTask = DisasterRecoveryTask;
                frontend.SrToReattach         = SrToReattach;
            }

            _matchingFrontends = 0;

            if (Connection == null)
            {
                // disable all except CSLG
                Array.ForEach(RadioButtons, r => r.Enabled = r.Checked = ((SrWizardType)r.Tag).Type == SR.SRTypes.cslg);
                _matchingFrontends = 1;
                return;
            }

            if (SrToReattach == null)
            {
                // CA-21758: Use SM.other_config HideFromXenCenter flag to hide backends in the New SR wizard
                // Only do this when we're doing a create.

                if (!Properties.Settings.Default.ShowHiddenVMs)
                {
                    foreach (RadioButton radioButton in RadioButtons)
                    {
                        SrWizardType wizardType = (SrWizardType)radioButton.Tag;

                        SM sm = SM.GetByType(Connection, wizardType.Type.ToString());

                        if (sm != null && sm.IsHidden)
                        {
                            radioButton.Visible = false;
                        }
                    }
                }

                foreach (RadioButton radioButton in RadioButtons)
                {
                    if (radioButton.Visible && radioButton.Tag.GetType() == m_preselectedWizardType)
                    {
                        radioButton.Checked = true;
                    }
                }
            }
            else
            {
                // If we're reconfiguring then try and select the correct page.  If we find more than one matching frontend
                // (ISO SRs - CA-19605) then just disable non-matching ones and leave it at the first page

                foreach (RadioButton radioButton in RadioButtons)
                {
                    SrWizardType wizardType = (SrWizardType)radioButton.Tag;

                    if (wizardType.Type.ToString() == SrToReattach.type)
                    {
                        if (_matchingFrontends == 0)
                        {
                            radioButton.Checked = true;
                        }
                        _matchingFrontends++;
                    }
                    else
                    {
                        radioButton.Enabled = false;
                    }
                }

                if (SrToReattach.type == SR.SRTypes.netapp.ToString() || SrToReattach.type == SR.SRTypes.equal.ToString())
                {
                    // the user is trying to reattach a netapp or Equallogic storage
                    // then move on to the correct page as there aren't radio buttons for them.
                    // we need to reenable the radioButtonCslg because it was disabled at the above iterations

                    _matchingFrontends++;
                    radioButtonCslg.Enabled = radioButtonCslg.Checked = true;

                    if (SrToReattach.type == SR.SRTypes.netapp.ToString())
                    {
                        radioButtonCslg.Tag = ((SrWizardType_Cslg)radioButtonCslg.Tag).ToNetApp();
                    }
                    else if (SrToReattach.type == SR.SRTypes.equal.ToString())
                    {
                        radioButtonCslg.Tag = ((SrWizardType_Cslg)radioButtonCslg.Tag).ToEqualLogic();
                    }
                }

                if (SrToReattach.type == "iso")
                {
                    string isoType;
                    if (SrToReattach.sm_config.TryGetValue("iso_type", out isoType))
                    {
                        if (isoType == "cifs")
                        {
                            radioButtonCifsIso.Checked = true;
                            _matchingFrontends--;
                        }
                        else if (isoType == "nfs_iso")
                        {
                            radioButtonNfsIso.Checked = true;
                            _matchingFrontends--;
                        }
                    }
                }
            }
        }