private void RestoreGridHomeServerSelectionFromMapping()
        {
            foreach (DataGridViewRow row in m_dataGridView.Rows)
            {
                string sysId = (string)row.Cells[0].Tag;
                if (m_vmMappings.ContainsKey(sysId))
                {
                    var mapping = m_vmMappings[sysId];
                    DataGridViewEnableableComboBoxCell cbCell = row.Cells[m_colTarget.Index] as DataGridViewEnableableComboBoxCell;
                    if (cbCell == null)
                    {
                        return;
                    }

                    List <IEnableableXenObjectComboBoxItem> list =
                        cbCell.Items.OfType <IEnableableXenObjectComboBoxItem>().ToList();
                    IEnableableXenObjectComboBoxItem item =
                        list.FirstOrDefault(cbi => MatchingWithXenRefObject(cbi, mapping.XenRef));
                    if (item != null)
                    {
                        cbCell.Value = item;
                    }
                }
            }
        }
        protected override List <ReasoningFilter> CreateTargetServerFilterList(IEnableableXenObjectComboBoxItem item)
        {
            var filters = new List <ReasoningFilter>();

            if (item != null)
            {
                filters.Add(new HardwareCompatibilityFilter(item.Item, hardwarePlatformSettings));
            }

            return(filters);
        }
示例#3
0
        protected override List <ReasoningFilter> CreateTargetServerFilterList(IEnableableXenObjectComboBoxItem selectedItem)
        {
            var filters = new List <ReasoningFilter>();

            if (selectedItem != null)
            {
                filters.Add(new ResidentHostIsSameAsSelectionFilter(selectedItem.Item, selectedVMs));
                filters.Add(new CrossPoolMigrateCanMigrateFilter(selectedItem.Item, selectedVMs, wizardMode));
                filters.Add(new WlbEnabledFilter(selectedItem.Item, selectedVMs));
            }

            return(filters);
        }
        private bool MatchingWithXenRefObject(IEnableableXenObjectComboBoxItem item, object xenRef)
        {
            XenRef <Host> hostRef = xenRef as XenRef <Host>;

            if (hostRef != null)
            {
                return(hostRef.opaque_ref == item.Item.opaque_ref);
            }

            XenRef <Pool> poolRef = xenRef as XenRef <Pool>;

            if (poolRef != null)
            {
                return(poolRef.opaque_ref == item.Item.opaque_ref);
            }

            return(false);
        }
        protected override List <ReasoningFilter> CreateTargetServerFilterList(IEnableableXenObjectComboBoxItem selectedItem, List <string> vmOpaqueRefs)
        {
            var filters = new List <ReasoningFilter>();

            if (selectedItem != null && vmOpaqueRefs != null && selectedVMs != null)
            {
                List <VM> vmList = new List <VM>();
                foreach (string opaqueRef in vmOpaqueRefs)
                {
                    vmList.Add(selectedVMs.Find(vm => vm.opaque_ref == opaqueRef));
                }

                filters.Add(new ResidentHostIsSameAsSelectionFilter(selectedItem.Item, vmList));
                filters.Add(new CrossPoolMigrateCanMigrateFilter(selectedItem.Item, vmList, wizardMode, force, migrateFilterCache));
            }

            return(filters);
        }
        private void m_comboBoxConnection_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (updatingHomeServerList)
            {
                return;
            }

            //If the item is delay loading and them item is disabled, null the selection made
            //and clear the table containing server data
            IEnableableXenObjectComboBoxItem item = m_comboBoxConnection.SelectedItem as IEnableableXenObjectComboBoxItem;

            if (item != null && !item.Enabled)
            {
                m_comboBoxConnection.SelectedIndex = -1;
                m_dataGridView.Rows.Clear();
                ChosenItem = null;
                return;
            }

            AddHostExecutingComboBoxItem exeItem = m_comboBoxConnection.SelectedItem as AddHostExecutingComboBoxItem;

            if (exeItem != null && !updatingDestinationCombobox)
            {
                exeItem.ExecuteCommand(this);
            }

            else if (!updatingDestinationCombobox)
            {
                try
                {
                    Cursor.Current = Cursors.WaitCursor;
                    ChosenItem     = item == null ? null : item.Item;
                    PopulateDataGridView(item);
                }
                finally
                {
                    Cursor.Current = Cursors.Default;
                }
            }

            IsDirty = true;
        }
 /// <summary>
 /// Create a set of filters for the homeserver combo box selection
 /// </summary>
 /// <param name="item">selected item from the host combobox</param>
 /// <param name="vmOpaqueRefs">OpaqRefs of VMs which need to apply those filters</param>
 /// <returns></returns>
 protected virtual List <ReasoningFilter> CreateTargetServerFilterList(IEnableableXenObjectComboBoxItem item, List <string> vmOpaqueRefs)
 {
     return(new List <ReasoningFilter>());
 }
        private void PopulateDataGridView(IEnableableXenObjectComboBoxItem selectedItem)
        {
            Program.AssertOnEventThread();

            updatingHomeServerList = true;
            try
            {
                var target = m_comboBoxConnection.SelectedItem as DelayLoadingOptionComboBoxItem;

                m_dataGridView.SuspendLayout();

                ClearDataGridView();

                var hasPoolSharedStorage = target != null && HasPoolSharedStorage(target.Item.Connection);

                foreach (var kvp in m_vmMappings)
                {
                    var tb = new DataGridViewTextBoxCell {
                        Value = kvp.Value.VmNameLabel, Tag = kvp.Key
                    };
                    var cb = new DataGridViewEnableableComboBoxCell {
                        FlatStyle = FlatStyle.Flat
                    };
                    var homeserverFilters = CreateTargetServerFilterList(selectedItem, new List <string> {
                        kvp.Key
                    });

                    if (target != null)
                    {
                        if (hasPoolSharedStorage)
                        {
                            foreach (var pool in target.Item.Connection.Cache.Pools)
                            {
                                var item = new NoTargetServerPoolItem(pool);
                                cb.Items.Add(item);

                                if ((m_selectedObject != null && m_selectedObject.opaque_ref == pool.opaque_ref) ||
                                    (target.Item.opaque_ref == pool.opaque_ref))
                                {
                                    cb.Value = item;
                                }

                                break; //there exists one pool per connection
                            }
                        }

                        var sortedHosts = new List <Host>(target.Item.Connection.Cache.Hosts);
                        sortedHosts.Sort();

                        foreach (var host in sortedHosts)
                        {
                            var item = new DelayLoadingOptionComboBoxItem(host, homeserverFilters);
                            item.LoadSync();
                            cb.Items.Add(item);
                            if (item.Enabled && ((m_selectedObject != null && m_selectedObject.opaque_ref == host.opaque_ref) ||
                                                 (target.Item.opaque_ref == host.opaque_ref)))
                            {
                                cb.Value = item;
                            }
                        }
                    }

                    SetComboBoxPreSelection(cb);

                    var row = new DataGridViewRow();
                    row.Cells.AddRange(tb, cb);
                    m_dataGridView.Rows.Add(row);
                }

                HelpersGUI.ResizeGridViewColumnToAllCells(m_colTarget); //set properly the width of the last column

                if (restoreGridHomeServerSelection)
                {
                    RestoreGridHomeServerSelectionFromMapping();
                    restoreGridHomeServerSelection = false;
                }
            }
            finally
            {
                updatingHomeServerList = false;
                m_dataGridView.ResumeLayout();
            }
        }
        protected override List<ReasoningFilter> CreateTargetServerFilterList(IEnableableXenObjectComboBoxItem selectedItem)
        {
            var filters = new List<ReasoningFilter>();

            if(selectedItem != null)
            {
                filters.Add(new ResidentHostIsSameAsSelectionFilter(selectedItem.Item, selectedVMs));
                filters.Add(new CrossPoolMigrateCanMigrateFilter(selectedItem.Item, selectedVMs, wizardMode));
                filters.Add(new WlbEnabledFilter(selectedItem.Item, selectedVMs));
            }

            return filters;
        }
        private bool MatchingWithXenRefObject(IEnableableXenObjectComboBoxItem item, object xenRef)
        {
            XenRef<Host> hostRef = xenRef as XenRef<Host>;
            if (hostRef != null)
                return hostRef.opaque_ref == item.Item.opaque_ref;

            XenRef<Pool> poolRef = xenRef as XenRef<Pool>;
            if (poolRef != null)
                return poolRef.opaque_ref == item.Item.opaque_ref;

            return false;
        }
 /// <summary>
 /// Create a set of filters for the homeserver combo box selection
 /// </summary>
 /// <param name="item">selected item from the host combobox</param>
 /// <returns></returns>
 protected virtual List<ReasoningFilter> CreateHomeServerFilterList(IEnableableXenObjectComboBoxItem item)
 {
     return new List<ReasoningFilter>();
 }
示例#12
0
 /// <summary>
 /// Create a set of filters for the homeserver combo box selection
 /// </summary>
 /// <param name="item">selected item from the host combobox</param>
 /// <returns></returns>
 protected virtual List <ReasoningFilter> CreateHomeServerFilterList(IEnableableXenObjectComboBoxItem item)
 {
     return(new List <ReasoningFilter>());
 }
示例#13
0
        protected override List<ReasoningFilter> CreateTargetServerFilterList(IEnableableXenObjectComboBoxItem item)
        {
            var filters = new List<ReasoningFilter>();

            if (item != null)
                filters.Add(new HardwareCompatibilityFilter(item.Item, hardwarePlatformSettings));

            return filters;
        }