protected override void Run() { // set the password on the storagelink service. _storageLinkConnection.SetPassword(_username, _oldPassword, _newPassword); foreach (Pool pool in GetPoolsToCheck()) { // set the password on the pool other-config StorageLinkCredentials creds = pool.GetStorageLinkCredentials(); creds.SetPassword(_newPassword); foreach (PBD pbd in pool.Connection.Cache.PBDs) { creds = pbd.GetStorageLinkCredentials(); // set the password on the pbd device-config. if (creds != null && creds.Host == _storageLinkConnection.Host && creds.Username == _storageLinkConnection.Username && creds.Password != null) { creds.SetPassword(_newPassword); } } } }
protected override void Run() { if (Connection.IsConnected) { #if DEBUG Program.Invoke(Program.MainWindow, () => { // check that local SL creds have been moved to pool.other_config by StorageLinkConnectionManager. Settings.CslgCredentials localCrds = Settings.GetCslgCredentials(Connection); Debug.Assert(localCrds == null || string.IsNullOrEmpty(localCrds.Host)); }); #endif Pool pool = Helpers.GetPoolOfOne(Connection); pool.SetStorageLinkCredentials(_host, _username, _password); // other-config gets set on event thread. // so wait until other-config has been updated. WaitForUpdate(pool); // force an other-config change event. In case only the value of the secret has changed. Program.BeginInvoke(Program.MainWindow, () => pool.NotifyPropertyChanged("other_config")); foreach (PBD pbd in Connection.Cache.PBDs) { StorageLinkCredentials creds = pbd.GetStorageLinkCredentials(); if (creds != null && creds.Host == _host && creds.Username == _username) { creds.SetPassword(_password); } } } }
/// <summary> /// Moves deprecated locally stored StorageLink creds to the pool other-config. This can only be done by /// pool operators and above. /// </summary> private void MoveLocalCredentials() { // StorageLink credentials are stored in 3 places: // 1. In the device-config of any StorageLink PBDs. // 2. Locally in the Settings, once for each pool. This was a poor design choice in Midnight Ride. // 3. In the pool other-config. This is a replacement for the local settings. Implemented in Cowley. // This method moves locally stored settings to the pool other-config. This might not be // possible if the user doesn't have the privileges to do this. foreach (IXenConnection c in GetXenConnectionsCopy()) { Pool pool = Helpers.GetPoolOfOne(c); if (c.IsConnected && pool != null && Helpers.MidnightRideOrGreater(c) && !Helpers.FeatureForbidden(c, Host.RestrictStorageChoices)) { Settings.CslgCredentials localCreds = null; Invoke(() => localCreds = Settings.GetCslgCredentials(c)); if (localCreds != null && !string.IsNullOrEmpty(localCreds.Host) && !string.IsNullOrEmpty(localCreds.Username)) { StorageLinkCredentials creds = pool.GetStorageLinkCredentials(); if (creds == null || string.IsNullOrEmpty(creds.Host)) { // there aren't any creds on the pool object, but there are some locally. // Attempt to move them. try { string secretRef = Secret.get_by_uuid(c.Session, localCreds.PasswordSecret); string password = Secret.get_value(c.Session, secretRef); pool.SetStorageLinkCredentials(localCreds.Host, localCreds.Username, password); } catch (Failure) { } catch (WebException) { } } // remove the local creds. Invoke(() => Settings.SetCslgCredentials(c, new Settings.CslgCredentials(null, null, null))); } } } }
private void WaitForUpdate(Pool pool) { StorageLinkCredentials creds = null; for (int i = 0; i < 10; i++) { Program.Invoke(Program.MainWindow, () => creds = pool.GetStorageLinkCredentials()); if (creds != null && creds.Host == _host && creds.Username == _username) { return; } Thread.Sleep(500); } }
private StorageLinkCredentials GetStorageLinkCredentials(IXenConnection connection) { if (Helpers.BostonOrGreater(connection)) { return(null); } if (_storageLinkObject != null) { return(GetAllValidStorageLinkCreds().Find(c => c.Host == _storageLinkObject.StorageLinkConnection.Host && c.Username == _storageLinkObject.StorageLinkConnection.Username && c.Password == _storageLinkObject.StorageLinkConnection.Password)); } else { // just do a check that local creds have been correctly moved the server pool object. Settings.CslgCredentials localCreds = Settings.GetCslgCredentials(connection); Debug.Assert(localCreds == null || string.IsNullOrEmpty(localCreds.Host)); Pool pool = Helpers.GetPoolOfOne(connection); if (pool != null) { StorageLinkCredentials creds = pool.GetStorageLinkCredentials(); if (creds != null && creds.IsValid) { return(creds); } else { // if there aren't any creds then try importing from another pool. The user will probably only // have one set of CSLG creds and they just haven't set the creds to this pool yet. Do it for them. var credsList = GetAllValidStorageLinkCreds(); if (credsList.Count > 0 && !Helpers.BostonOrGreater(Connection)) { var action = new SetCslgCredentialsToPoolAction(pool.Connection, credsList[0].Host, credsList[0].Username, credsList[0].Password); new ActionProgressDialog(action, ProgressBarStyle.Marquee).ShowDialog(this); return(pool.GetStorageLinkCredentials()); } } } return(null); } }
public void SetXenObjects(IXenObject orig, IXenObject clone) { _xenObjectCopy = clone; allServersCheckBox.Checked = true; if (_xenObjectCopy != null && Helpers.MidnightRideOrGreater(_xenObjectCopy.Connection)) { Pool pool = Helpers.GetPoolOfOne(_xenObjectCopy.Connection); if (pool != null) { StorageLinkCredentials creds = pool.GetStorageLinkCredentials(); var otherConfig = new Dictionary <string, string>(pool.other_config); // retrieve CSLG credentials from the server. // need to set the default check-state for the "all servers" checkbox. // if the user has multiple valid sl connection creds, then set the checkbox to be unchecked. // otherwise set it checked. var credsList = new List <StorageLinkCredentials>(); foreach (Pool p in GetValidConnections().ConvertAll(c => Helpers.GetPoolOfOne(c)).FindAll(p => p != null)) { credsList.Add(p.GetStorageLinkCredentials()); credsList.AddRange(Array.ConvertAll(p.Connection.Cache.PBDs, pbd => pbd.GetStorageLinkCredentials())); } credsList.RemoveAll(c => c == null || !c.IsValid); allServersCheckBox.Checked = credsList.Count == 0 || credsList.TrueForAll(c => c.Host == credsList[0].Host); textBoxHostAddress.Text = creds == null ? string.Empty : creds.Host; textBoxUsername.Text = creds == null ? string.Empty : creds.Username; textBoxPassword.Text = creds == null ? string.Empty : creds.Password; if (textBoxUsername.Text.Length == 0) { textBoxUsername.Text = "admin"; } } _hasChanged = false; } }
private bool PerformStoragePoolScan() { StorageLinkCredentials credentials = GetStorageLinkCredentials(Connection); var scanAction = new SrCslgStoragePoolScanAction(Connection, Program.StorageLinkConnections.GetCopy(), credentials.Host, credentials.Username, credentials.PasswordSecret, SelectedStorageSystem.StorageSystemId); ActionProgressDialog dialog = new ActionProgressDialog(scanAction, ProgressBarStyle.Marquee); dialog.ShowDialog(this); if (scanAction.Succeeded) { StoragePools = scanAction.CslgStoragePools; } return(scanAction.Succeeded); }
private List <Pool> GetPoolsToCheck() { List <Pool> output = new List <Pool>(); foreach (IXenConnection c in _xenConnections) { Pool pool = Helpers.GetPoolOfOne(c); if (pool != null) { StorageLinkCredentials creds = pool.GetStorageLinkCredentials(); if (creds != null && creds.Host == _storageLinkConnection.Host && creds.Username == _storageLinkConnection.Username) { output.Add(pool); } } } return(output); }
/// <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); }