Пример #1
0
        /// <summary>
        /// Performs a scan of the CSLG host specified in the textboxes. 
        /// </summary>
        /// <returns>True, if the scan succeeded, otherwise False.</returns>
        public bool PerformStorageSystemScan()
        {
            var items = new List<object>();
            StorageLinkCredentials credentials = null;
            SrCslgStorageSystemScanAction scanAction = null;

            if (_storageLinkObject != null || (Connection.IsConnected && !Helpers.FeatureForbidden(Connection, Host.RestrictStorageChoices) && Helpers.MidnightRideOrGreater(Connection)))
            {
                if (_srToReattach == null || _srToReattach.type == "cslg")
                {
                    credentials = GetStorageLinkCredentials(Connection);

                    if (credentials != null && credentials.IsValid)
                    {
                        scanAction = new SrCslgStorageSystemScanAction(Program.MainWindow, Connection,
                                                                       Program.StorageLinkConnections.GetCopy(),
                                                                       credentials.Host, credentials.Username,
                                                                       credentials.PasswordSecret);
                    }
                    else if (Helpers.BostonOrGreater(Connection))
                    {

                        var action = new SrCslgAdaptersScanAction(Connection);
                        var dialog = new ActionProgressDialog(action, ProgressBarStyle.Marquee);
                        // never show the error message if it fails.
                        action.Completed += s =>
                        {
                            if (!action.Succeeded)
                            {
                                Program.Invoke(dialog, dialog.Close);
                            }
                        };

                        dialog.ShowDialog(this);
                        if (action.Succeeded)
                        {
                            var adapters = action.GetAdapters();
                            items.AddRange(Util.PopulateList<object>(adapters));
                            items.Sort((x, y) => x.ToString().CompareTo(y.ToString()));
                        }
                        else
                            return false;
                    }
                    if (scanAction != null)
                    {
                        var dialog = new ActionProgressDialog(scanAction, ProgressBarStyle.Marquee);

                        // never show the error message if it fails.
                        scanAction.Completed += s =>
                                                    {
                                                        if (!scanAction.Succeeded)
                                                        {
                                                            Program.Invoke(dialog, dialog.Close);
                                                        }
                                                    };

                        dialog.ShowDialog(this);

                        if (scanAction.Succeeded)
                        {
                            _storages = scanAction.CslgSystemStorages;
                            items.AddRange(Util.PopulateList<object>(_storages));
                            items.Sort((x, y) => x.ToString().CompareTo(y.ToString()));
                        }
                    }
                }
            }

            bool bostonHasDell = false;
            bool bostonHasNetapp = false;
            if (Helpers.BostonOrGreater(Connection) && items != null)
            {
                bostonHasDell = (items.Find(item => ((StorageLinkAdapterBoston)item).Id == "DELL_EQUALLOGIC") != null);
                bostonHasNetapp = (items.Find(item => ((StorageLinkAdapterBoston)item).Id == "NETAPP") != null);
            }

            comboBoxStorageSystem.Items.Clear();

            if (_storageLinkObject != null)
            {
                // the wizard was launched with a storagelink-server, storage-system or storage-pool selected.
                if (scanAction != null && scanAction.Succeeded)
                {
                    comboBoxStorageSystem.Items.Add(new NonSelectableComboBoxItem(string.Format(Messages.CSLG_STORAGELINK_SERVER, credentials.Host), true));
                    comboBoxStorageSystem.Items.AddRange(items.ToArray());
                    comboBoxStorageSystem.Items.Add(new NonSelectableComboBoxItem(Messages.ADD_HOST, false));

                    // if a specific storage-system was selected when the wizard was launched then select that storage-system
                    // in the combo-box here.
                    var system = _storageLinkObject as StorageLinkSystem;

                    if (system == null)
                    {
                        // if a specific storage-pool was selected when the wizard was launched then select the storage-system
                        // of that storage-pool here.
                        var storagePool = _storageLinkObject as StorageLinkPool;
                        system = storagePool == null ? null : storagePool.StorageLinkSystem;
                    }

                    if (system != null)
                    {
                        comboBoxStorageSystem.SelectedItem = items.Find(o => ((CslgSystemStorage)o).StorageSystemId == system.opaque_ref);
                    }
                }
            }
            else if (_srToReattach != null)
            {
                if (_srToReattach.type == "equal")
                {
                    // a direct-connect Equallogic is being reattached. Only add this item.
                    comboBoxStorageSystem.Items.Add(Messages.CSLG_DELL_DIRECT);
                }
                else if (_srToReattach.type == "netapp")
                {
                    // a direct-connect NetApp is being reattached. Only add this item.
                    comboBoxStorageSystem.Items.Add(Messages.CSLG_NETAPP_DIRECT);
                }
                else if (credentials != null)
                {
                    // credentials can be null if we don't have a license which supports CSLG.

                    // re-attaching StorageLink SR
                    Debug.Assert(_srToReattach.type == "cslg");
                    comboBoxStorageSystem.Items.Add(new NonSelectableComboBoxItem(string.Format(Messages.CSLG_STORAGELINK_SERVER, credentials.Host), true));
                    comboBoxStorageSystem.Items.AddRange(items.ToArray());
                }
            }
            else
            {
                // a pool or host was selected in the mainwindow tree when the wizard was launched.
                bool canAdd = scanAction != null && scanAction.Succeeded && scanAction.StorageLinkConnection != null;
                bool showHeaders = scanAction != null && scanAction.Succeeded && (items.Count > 0 || scanAction.StorageLinkConnection != null);

                if (showHeaders || Helpers.BostonOrGreater(Connection))
                {
                    if (!bostonHasDell || !bostonHasNetapp)
                        comboBoxStorageSystem.Items.Add(new NonSelectableComboBoxItem(Messages.CSLG_DIRECT_CONNECTION, true));
                }

                if (!bostonHasDell)
                    comboBoxStorageSystem.Items.Add(Messages.CSLG_DELL_DIRECT);
                if (!bostonHasNetapp)
                    comboBoxStorageSystem.Items.Add(Messages.CSLG_NETAPP_DIRECT);

                if (showHeaders)
                {
                    comboBoxStorageSystem.Items.Add(new NonSelectableComboBoxItem(string.Format(Messages.CSLG_STORAGELINK_SERVER, credentials.Host), true));
                    comboBoxStorageSystem.Items.AddRange(items.ToArray());
                }

                if (canAdd)
                {
                    comboBoxStorageSystem.Items.Add(new NonSelectableComboBoxItem(Messages.ADD_HOST, false));
                }
            }

            if (Helpers.BostonOrGreater(Connection) && items != null && items.Count > 0)
            {
                if (!bostonHasDell || !bostonHasNetapp)
                    comboBoxStorageSystem.Items.Add(new NonSelectableComboBoxItem(Messages.CSLG_STORAGELINK_ADAPTERS, true));
                comboBoxStorageSystem.Items.AddRange(items.ToArray());
            }

            if (comboBoxStorageSystem.SelectedIndex < 0 && comboBoxStorageSystem.Items.Count > 0)
            {
                // select the first selectable item if nothing's already been selected.
                comboBoxStorageSystem.SelectedItem = Util.PopulateList<object>(comboBoxStorageSystem.Items).Find(s => !(s is NonSelectableComboBoxItem));
                if (_srToReattach != null && _srToReattach.type == "cslg" &&
                              Helpers.BostonOrGreater(Connection))
                {
                    comboBoxStorageSystem.SelectedItem =
                        Util.PopulateList<object>(comboBoxStorageSystem.Items).Find(s =>
                        {
                            var bostonadapter = s as StorageLinkAdapterBoston;
                            if (bostonadapter != null)
                            {
                                // sm_config["md_svid"] looks like "DELL__EQUALLOGIC__{GUID}"
                                // bostonadapter.Id looks like "DELL_EQUALLOGIC"
                                // Additionally, EMC__CLARIION is always SMI-S (CA-72968)
                                if (_srToReattach.sm_config.ContainsKey("md_svid"))
                                {
                                    var svid = _srToReattach.sm_config["md_svid"];
                                    if (svid.Replace("__", "_").StartsWith(bostonadapter.Id))
                                        return true;
                                    if (bostonadapter.Id == "SMIS_STORAGE_SYSTEM" && svid.StartsWith("EMC__CLARIION"))
                                        return true;
                                    return false;
                                }
                            }
                            return false;
                        });
                }
            }
            return true;
        }
Пример #2
0
        /// <summary>
        /// Performs a scan of the CSLG host specified in the textboxes. 
        /// </summary>
        /// <returns>True, if the scan succeeded, otherwise False.</returns>
        public bool PerformStorageSystemScan()
        {
            var items = new List<object>();

            if (Connection.IsConnected && !Helpers.FeatureForbidden(Connection, Host.RestrictStorageChoices))
            {
                if (_srToReattach == null || _srToReattach.type == "cslg")
                {
                    var action = new SrCslgAdaptersScanAction(Connection);
                    var dialog = new ActionProgressDialog(action, ProgressBarStyle.Marquee);
                    // never show the error message if it fails.
                    action.Completed += s =>
                    {
                        if (!action.Succeeded)
                        {
                            Program.Invoke(dialog, dialog.Close);
                        }
                    };

                    dialog.ShowDialog(this);
                    if (action.Succeeded)
                    {
                        var adapters = action.GetAdapters();
                        items.AddRange(Util.PopulateList<object>(adapters));
                        items.Sort((x, y) => x.ToString().CompareTo(y.ToString()));
                    }
                    else
                        return false;
                }
            }

            bool bostonHasDell = false;
            bool bostonHasNetapp = false;
            if (items != null)
            {
                bostonHasDell = (items.Find(item => ((StorageLinkAdapterBoston)item).Id == "DELL_EQUALLOGIC") != null);
                bostonHasNetapp = (items.Find(item => ((StorageLinkAdapterBoston)item).Id == "NETAPP") != null);
            }

            comboBoxStorageSystem.Items.Clear();

            if (_srToReattach != null)
            {
                if (_srToReattach.type == "equal")
                {
                    // a direct-connect Equallogic is being reattached. Only add this item.
                    comboBoxStorageSystem.Items.Add(Messages.CSLG_DELL_DIRECT);
                }
                else if (_srToReattach.type == "netapp")
                {
                    // a direct-connect NetApp is being reattached. Only add this item.
                    comboBoxStorageSystem.Items.Add(Messages.CSLG_NETAPP_DIRECT);
                }
            }
            else
            {
                // a pool or host was selected in the mainwindow tree when the wizard was launched.
                if (!bostonHasDell || !bostonHasNetapp)
                    comboBoxStorageSystem.Items.Add(new NonSelectableComboBoxItem(Messages.CSLG_DIRECT_CONNECTION, true));

                if (!bostonHasDell)
                    comboBoxStorageSystem.Items.Add(Messages.CSLG_DELL_DIRECT);
                if (!bostonHasNetapp)
                    comboBoxStorageSystem.Items.Add(Messages.CSLG_NETAPP_DIRECT);
            }

            if (items != null && items.Count > 0)
            {
                if (!bostonHasDell || !bostonHasNetapp)
                    comboBoxStorageSystem.Items.Add(new NonSelectableComboBoxItem(Messages.CSLG_STORAGELINK_ADAPTERS, true));
                comboBoxStorageSystem.Items.AddRange(items.ToArray());
            }

            if (comboBoxStorageSystem.SelectedIndex < 0 && comboBoxStorageSystem.Items.Count > 0)
            {
                // select the first selectable item if nothing's already been selected.
                comboBoxStorageSystem.SelectedItem = Util.PopulateList<object>(comboBoxStorageSystem.Items).Find(s => !(s is NonSelectableComboBoxItem));
                if (_srToReattach != null && _srToReattach.type == "cslg")
                {
                    comboBoxStorageSystem.SelectedItem =
                        Util.PopulateList<object>(comboBoxStorageSystem.Items).Find(s =>
                        {
                            var bostonadapter = s as StorageLinkAdapterBoston;
                            if (bostonadapter != null)
                            {
                                // sm_config["md_svid"] looks like "DELL__EQUALLOGIC__{GUID}"
                                // bostonadapter.Id looks like "DELL_EQUALLOGIC"
                                // Additionally, EMC__CLARIION is always SMI-S (CA-72968)
                                if (_srToReattach.sm_config.ContainsKey("md_svid"))
                                {
                                    var svid = _srToReattach.sm_config["md_svid"];
                                    if (svid.Replace("__", "_").StartsWith(bostonadapter.Id))
                                        return true;
                                    if (bostonadapter.Id == "SMIS_STORAGE_SYSTEM" && svid.StartsWith("EMC__CLARIION"))
                                        return true;
                                    return false;
                                }
                            }
                            return false;
                        });
                }
            }
            return true;
        }