private void ScanForSRs(SR.SRTypes type)
        {
            var srs = new List <SR.SRInfo>();

            switch (type)
            {
            case SR.SRTypes.lvmohba:
                var devices = FiberChannelScan();
                if (devices != null && devices.Count > 0)
                {
                    foreach (FibreChannelDevice device in devices)
                    {
                        string deviceId    = string.IsNullOrEmpty(device.SCSIid) ? device.Path : device.SCSIid;
                        var    metadataSrs = ScanDeviceForSRs(SR.SRTypes.lvmohba, deviceId,
                                                              new Dictionary <string, string> {
                            { SCSIID, device.SCSIid }
                        });
                        if (metadataSrs != null && metadataSrs.Count > 0)
                        {
                            srs.AddRange(metadataSrs);
                        }
                    }
                }
                AddScanResultsToDataGridView(srs, SR.SRTypes.lvmohba);
                break;

            case SR.SRTypes.lvmoiscsi:
                using (var dialog = new IscsiDeviceConfigDialog(Connection))
                {
                    if (dialog.ShowDialog(this) == DialogResult.OK)
                    {
                        Dictionary <String, String> dconf = dialog.DeviceConfig;
                        string deviceId = string.IsNullOrEmpty(dconf[SCSIID]) ? dconf[LUNSERIAL] : dconf[SCSIID];

                        var metadataSrs = ScanDeviceForSRs(SR.SRTypes.lvmoiscsi, deviceId, dconf);
                        if (metadataSrs != null && metadataSrs.Count > 0)
                        {
                            srs.AddRange(metadataSrs);
                        }
                    }
                    else
                    {
                        // if the user cancels the dialog there is no need to show the "no SRs found" pop-up
                        return;
                    }
                }
                AddScanResultsToDataGridView(srs, SR.SRTypes.lvmoiscsi);
                break;
            }

            if (srs.Count == 0)
            {
                using (var dlg = new InformationDialog(Messages.DR_WIZARD_STORAGEPAGE_SCAN_RESULT_NONE))
                    dlg.ShowDialog(this);
            }
        }
Ejemplo n.º 2
0
        private void ScanForSRs(SR.SRTypes type)
        {
            var srs = new List <SR.SRInfo>();

            switch (type)
            {
            case SR.SRTypes.lvmohba:
                var devices = FiberChannelScan();
                if (devices != null && devices.Count > 0)
                {
                    foreach (FibreChannelDevice device in devices)
                    {
                        string deviceId    = string.IsNullOrEmpty(device.SCSIid) ? device.Path : device.SCSIid;
                        var    metadataSrs = ScanDeviceForSRs(SR.SRTypes.lvmohba, deviceId, GetFCDeviceConfig(device));
                        if (metadataSrs != null && metadataSrs.Count > 0)
                        {
                            srs.AddRange(metadataSrs);
                        }
                    }
                }
                AddScanResultsToDataGridView(srs, SR.SRTypes.lvmohba);
                break;

            case SR.SRTypes.lvmoiscsi:
                using (var dialog = new IscsiDeviceConfigDialog(Connection))
                {
                    if (dialog.ShowDialog(this) == DialogResult.OK)
                    {
                        Dictionary <String, String> dconf = dialog.DeviceConfig;
                        string deviceId = string.IsNullOrEmpty(dconf[SCSIID]) ? dconf[LUNSERIAL] : dconf[SCSIID];

                        var metadataSrs = ScanDeviceForSRs(SR.SRTypes.lvmoiscsi, deviceId, dconf);
                        if (metadataSrs != null && metadataSrs.Count > 0)
                        {
                            srs.AddRange(metadataSrs);
                        }
                    }
                }
                AddScanResultsToDataGridView(srs, SR.SRTypes.lvmoiscsi);
                break;
            }

            if (srs.Count == 0)
            {
                using (var dlg = new ThreeButtonDialog(
                           new ThreeButtonDialog.Details(SystemIcons.Information,
                                                         Messages.DR_WIZARD_STORAGEPAGE_SCAN_RESULT_NONE,
                                                         Messages.XENCENTER)))
                {
                    dlg.ShowDialog(this);
                }
            }
        }
        private void ScanForSRs(SR.SRTypes type)
        {
            bool          succeeded;
            List <string> srs = new List <string>();

            switch (type)
            {
            case SR.SRTypes.lvmohba:
                List <FibreChannelDevice> devices = new List <FibreChannelDevice>();
                succeeded = FiberChannelScan(devices);
                if (succeeded)
                {
                    foreach (FibreChannelDevice device in devices)
                    {
                        string deviceId = string.IsNullOrEmpty(device.SCSIid) ? device.Path : device.SCSIid;
                        succeeded = succeeded && ScanDeviceForSRs(SR.SRTypes.lvmohba, deviceId,
                                                                  GetFCDeviceConfig(device));

                        srs.AddRange(ScannedDevices[deviceId].SRList.Select(srInfo => srInfo.Name));
                    }
                }
                ShowScanResult(srs, succeeded);
                break;

            case SR.SRTypes.lvmoiscsi:
                IscsiDeviceConfigDialog dialog = new IscsiDeviceConfigDialog(Connection);
                if (dialog.ShowDialog(this) == DialogResult.OK)
                {
                    Dictionary <String, String> dconf = dialog.DeviceConfig;
                    string deviceId = string.IsNullOrEmpty(dconf[SCSIID]) ? dconf[LUNSERIAL] : dconf[SCSIID];

                    succeeded = ScanDeviceForSRs(SR.SRTypes.lvmoiscsi, deviceId, dconf);

                    if (succeeded)
                    {
                        srs.AddRange(ScannedDevices[deviceId].SRList.Select(srInfo => srInfo.Name));
                    }

                    ShowScanResult(srs, succeeded);
                }
                break;
            }
        }