Ejemplo n.º 1
0
 public override void PopulatePage()
 {
     dataGridViewSRs.Rows.Clear();
     SelectedSRsUuids.Clear();
     _availableSRs.Clear();
     OnPageUpdated();
     spinnerIcon1.StartSpinning();
     _worker.RunWorkerAsync();
 }
Ejemplo n.º 2
0
        private void _worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            spinnerIcon1.StopSpinning();
            try
            {
                dataGridViewSRs.SuspendLayout();

                foreach (SR sr in _availableSRs)
                {
                    var  vdis = sr.Connection.ResolveAll(sr.VDIs);
                    bool poolMetadataDetected = vdis.Any(vdi => vdi.type == vdi_type.metadata);

                    SrRow row;
                    if (!FindRowByUuid(sr.uuid, out row))
                    {
                        row = new SrRow(sr, poolMetadataDetected, SelectedSRsUuids.Contains(sr.uuid));
                        dataGridViewSRs.Rows.Add(row);
                    }
                }

                // add new SRs
                foreach (var scannedDevice in ScannedDevices.Values)
                {
                    foreach (var srInfo in scannedDevice.SRList)
                    {
                        SrRow row;
                        if (!FindRowByUuid(srInfo.UUID, out row))
                        {
                            row = new SrRow(srInfo, scannedDevice.Type, srInfo.PoolMetadataDetected,
                                            SelectedSRsUuids.Contains(srInfo.UUID));
                            dataGridViewSRs.Rows.Add(row);
                        }
                    }
                }

                if (dataGridViewSRs.Rows.Count > 0)
                {
                    SortRows();
                }
            }
            finally
            {
                dataGridViewSRs.ResumeLayout();
            }

            OnPageUpdated();
        }
        private void PopulateSrList()
        {
            Pool currentPool = Helpers.GetPoolOfOne(Connection);

            if (currentPool == null)
            {
                return;
            }

            try
            {
                dataGridViewSRs.SuspendLayout();
                dataGridViewSRs.Rows.Clear();

                // add existing SRs
                List <SR> srs = new List <SR>(Connection.Cache.SRs);
                foreach (SR sr in srs)
                {
                    if (!sr.SupportsDatabaseReplication())
                    {
                        continue;
                    }

                    bool poolMetadataDetected = false;
                    log.DebugFormat("Looking for foreign pool metadata VDIs on SR {0}.", sr.Name);

                    List <VDI> vdis = sr.Connection.ResolveAll(sr.VDIs);

                    foreach (VDI vdi in vdis)
                    {
                        if (vdi.type != vdi_type.metadata)
                        {
                            continue;
                        }

                        /*if (vdi.metadata_of_pool.opaque_ref == currentPool.opaque_ref)
                         * {
                         *  continue;
                         * }*/

                        // found a metadata VDI
                        poolMetadataDetected = true;
                        break;
                    }

                    SrRow row;
                    if (!FindRowByUuid(sr.uuid, out row))
                    {
                        row = new SrRow(sr, poolMetadataDetected, SelectedSRsUuids.Contains(sr.uuid));
                        dataGridViewSRs.Rows.Add(row);
                    }
                }

                // add new SRs
                foreach (var scannedDevice in ScannedDevices.Values)
                {
                    foreach (var srInfo in scannedDevice.SRList)
                    {
                        SrRow row;
                        if (!FindRowByUuid(srInfo.UUID, out row))
                        {
                            row = new SrRow(srInfo, scannedDevice.Type, srInfo.PoolMetadataDetected,
                                            SelectedSRsUuids.Contains(srInfo.UUID));
                            dataGridViewSRs.Rows.Add(row);
                        }
                    }
                }

                //set the width of the last column
                columnMetadata.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                int storedWidth = columnMetadata.Width;
                columnMetadata.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                columnMetadata.MinimumWidth = storedWidth;
            }
            finally
            {
                dataGridViewSRs.ResumeLayout();
            }
        }