Example #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;
        }
Example #2
0
        private void buttonDiscoverBostonSS_Click(object sender, EventArgs e)
        {
            SrCslgStorageSystemScanAction action = new SrCslgStorageSystemScanAction(Connection, SelectedStorageAdapter.Id, textBoxTarget.Text, textBoxUsername.Text, textBoxPassword.Text);
            new ActionProgressDialog(action, ProgressBarStyle.Marquee).ShowDialog(this);

            var items = new List<object>();
            if (action.Succeeded)
            {
                var storages = action.CslgSystemStorages;
                items.AddRange(Util.PopulateList<object>(storages));
                items.Sort((x, y) => x.ToString().CompareTo(y.ToString()));
            }

            comboBoxStorageSystemBoston.Items.Clear();
            if (items.Count > 0)
            {
                comboBoxStorageSystemBoston.Enabled = true;
                comboBoxStorageSystemBoston.Items.Add(new NonSelectableComboBoxItem(string.Format(Messages.CSLG_STORAGELINK_SERVER, textBoxTarget.Text), true));
                comboBoxStorageSystemBoston.Items.AddRange(items.ToArray());
                // select the first selectable item
                comboBoxStorageSystemBoston.SelectedItem = comboBoxStorageSystemBoston.Items[1];
            }
            else
                comboBoxStorageSystemBoston.Enabled = false;
        }
        private void testConnectionButton_Click(object sender, EventArgs e)
        {
            string password = textBoxPassword.Text.Trim();
            string address = textBoxHostAddress.Text.Trim();
            string username = textBoxUsername.Text.Trim();

            string title = string.Format(Messages.STORAGELINK_TEST_CONNECTION, address);

            DelegatedAsyncAction action = null;
            action = new DelegatedAsyncAction(_xenObjectCopy.Connection, title, "", "", s =>
                {
                    string secretUuid = Secret.CreateSecret(_xenObjectCopy.Connection.Session, password);
                    var scanAction = new SrCslgStorageSystemScanAction(Program.MainWindow,_xenObjectCopy.Connection,Program.StorageLinkConnections.GetCopy(), address, username, secretUuid);
                    scanAction.RunExternal(action.Session);

                    string secretRef = Secret.get_by_uuid(_xenObjectCopy.Connection.Session, secretUuid);
                    Secret.destroy(_xenObjectCopy.Connection.Session, secretRef);
                }, true);

            action.AppliesTo.Add(_xenObjectCopy.opaque_ref);

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

            passFailLabel.Visible = true;
            passFailLabel.Text = action.Succeeded ? Messages.CSLG_EDIT_CONNECTION_PASSED : Messages.CSLG_EDIT_CONNECTION_FAILED;
            passFailPictureBox.Image = action.Succeeded ? Resources._000_Tick_h32bit_16 : Resources._000_Abort_h32bit_16;
        }