Ejemplo n.º 1
0
 private void SRComboBoxEx_SelectedIndexChanged(object sender, EventArgs e)
 {
     this.UpdatePieChart();
     try
     {
         if (this.SelectedSR != null)
         {
             ComboBoxIconExItem          selectedItem = (ComboBoxIconExItem)this.SRComboBoxEx.SelectedItem;
             ToStringWrapper <WinAPI.SR> item         = (ToStringWrapper <WinAPI.SR>)selectedItem.Item;
             if (item != null)
             {
                 this.SRDisplayNameToolTip.SetToolTip(this.SRComboBoxEx, item.ToString());
             }
             else
             {
                 this.SRDisplayNameToolTip.SetToolTip(this.SRComboBoxEx, "");
             }
         }
         else
         {
             this.SRDisplayNameToolTip.SetToolTip(this.SRComboBoxEx, "");
         }
     }
     catch
     {
     }
 }
Ejemplo n.º 2
0
        private void populateHosts()
        {
            Program.AssertOnEventThread();

            ToStringWrapper <Host> previousSelection = NewMasterComboBox.SelectedItem as ToStringWrapper <Host>;

            NewMasterComboBox.BeginUpdate();
            try
            {
                NewMasterComboBox.Items.Clear();

                foreach (Host host in connection.Cache.Hosts)
                {
                    Host_metrics metrics = connection.Resolve <Host_metrics>(host.metrics);
                    if (host.opaque_ref == this.host.opaque_ref)
                    {
                        continue;
                    }

                    host.PropertyChanged -= new PropertyChangedEventHandler(host_PropertyChanged);
                    host.PropertyChanged += new PropertyChangedEventHandler(host_PropertyChanged);
                    if (host.enabled && metrics != null && metrics.live)
                    {
                        NewMasterComboBox.Items.Add(new ToStringWrapper <Host>(host, host.Name()));
                    }
                }

                SelectProperItemInNewMasterComboBox(previousSelection);
            }
            finally
            {
                NewMasterComboBox.EndUpdate();
            }
        }
Ejemplo n.º 3
0
        protected override void OnSelectionChangeCommitted(EventArgs e)
        {
            // let the base class take care of skipping the SR headings (CA-40779)
            base.OnSelectionChangeCommitted(e);

            ToStringWrapper <VDI> vdiNameWrapper = SelectedItem as ToStringWrapper <VDI>;

            if (vdiNameWrapper == null)
            {
                return;
            }

            // don't change the cdrom if we go from <empty> to <empty>
            if (vdiNameWrapper.item == null && cdrom != null && Helper.IsNullOrEmptyOpaqueRef(cdrom.VDI.opaque_ref))
            {
                return;
            }

            // don't change the cdrom if we leave the same one in
            if (vdiNameWrapper.item != null && cdrom != null && cdrom.VDI.opaque_ref == vdiNameWrapper.item.opaque_ref)
            {
                return;
            }

            if (cdrom == null)
            {
                return;
            }

            ChangeCD(vdiNameWrapper.item);
        }
        protected DataGridViewComboBoxCell FillGridComboBox(object xenRef)
        {
            var cb = new DataGridViewComboBoxCell {
                FlatStyle = FlatStyle.Flat, Sorted = true
            };

            XenRef <Host> hostRef = xenRef as XenRef <Host>;
            Host          host    = TargetConnection.Resolve(hostRef);

            var availableNetworks = TargetConnection.Cache.Networks.Where(net => ShowNetwork(host, net));

            foreach (XenAPI.Network netWork in availableNetworks)
            {
                if (!Messages.IMPORT_SELECT_NETWORK_PAGE_NETWORK_FILTER.Contains(netWork.Name))
                {
                    var wrapperItem = new ToStringWrapper <XenAPI.Network>(netWork, netWork.Name);

                    if (!cb.Items.Contains(wrapperItem))
                    {
                        cb.Items.Add(wrapperItem);
                    }
                }
            }

            return(cb);
        }
Ejemplo n.º 5
0
        private DataGridViewComboBoxCell FillGridComboBox()
        {
            DataGridViewComboBoxCell cell = new DataGridViewComboBoxCell {
                FlatStyle = FlatStyle.Flat
            };

            if (this.XenServerNetworks != null)
            {
                foreach (KeyValuePair <XenRef <Network>, Network> pair in this.XenServerNetworks)
                {
                    try {
                        Network item = pair.Value;
                        ToStringWrapper <Network> wrapper = new ToStringWrapper <Network>(item, item.name_label);
                        if (!cell.Items.Contains(wrapper))
                        {
                            cell.Items.Add(wrapper);
                        }
                    }
                    catch (Exception exception) {
                        LOG.Error(exception.Message);
                    }
                }
            }
            return(cell);
        }
Ejemplo n.º 6
0
        private void AddVIFRow(VIF vif)
        {
            var row = new VifRow(vif);

            XenAPI.Network network = m_selectedConnection.Resolve(vif.network);
            bool           isGuestInstallerNetwork = network != null && network.IsGuestInstallerNetwork;

            ToStringWrapper <XenAPI.Network> comboBoxEntry = FindComboBoxEntryForNetwork(network);

            // CA-66962: Don't choose disallowed networks: choose a better one instead.
            // CA-79930/CA-73056: Except for the guest installer network, which we let
            // through for now, but hide it below.
            if (comboBoxEntry == null && !isGuestInstallerNetwork)
            {
                network       = GetDefaultNetwork();
                comboBoxEntry = FindComboBoxEntryForNetwork(network);
                vif.network   = new XenRef <XenAPI.Network>(network.opaque_ref);
            }

            row.CreateCells(m_networkGridView,
                            String.Format(Messages.NETWORKPICKER_INTERFACE, vif.device),
                            vif.MAC,
                            comboBoxEntry);
            row.Cells[0].ReadOnly = true;

            // CA-73056: A row for the guest installer network shouldn't show up. But we still need
            // it present but invisible, otherwise the corresponding VIF doesn't get created at all.
            // CA-218956 - Expose HIMN when showing hidden objects
            if (isGuestInstallerNetwork && !XenAdmin.Properties.Settings.Default.ShowHiddenVMs)
            {
                row.Visible = false;
            }

            m_networkGridView.Rows.Add(row);
        }
Ejemplo n.º 7
0
        protected void AddSR(ToStringWrapper <SR> srWrapper)
        {
            Items.Add(srWrapper);

            List <ToStringWrapper <VDI> > items = new List <ToStringWrapper <VDI> >();

            if (srWrapper.item.Physical)
            {
                List <ToStringWrapper <VDI> > vdis = new List <ToStringWrapper <VDI> >();
                foreach (VDI vdi in connection.ResolveAll <VDI>(srWrapper.item.VDIs))
                {
                    ToStringWrapper <VDI> vdiWrapper = new ToStringWrapper <VDI>(vdi, vdi.Name);
                    vdis.Add(vdiWrapper);
                }
                vdis.Sort(new Comparison <ToStringWrapper <VDI> >(delegate(ToStringWrapper <VDI> object1, ToStringWrapper <VDI> object2)
                {
                    return(Core.StringUtility.NaturalCompare(object1.item.Name, object2.item.Name));
                }));

                Host host = srWrapper.item.GetStorageHost();
                if (host != null)
                {
                    for (int i = 0; i < vdis.Count; i++)
                    {
                        items.Add(new ToStringWrapper <VDI>(vdis[i].item, "    " + string.Format(Messages.ISOCOMBOBOX_CD_DRIVE, i, host.Name)));
                    }
                }
            }
            else
            {
                if (srWrapper.item.IsToolsSR)
                {
                    foreach (VDI vdi in connection.ResolveAll <VDI>(srWrapper.item.VDIs))
                    {
                        if (Actions.InstallPVToolsAction.ISONameOld.Equals(vdi.name_label) ||
                            Actions.InstallPVToolsAction.ISONameNew.Equals(vdi.name_label))
                        {
                            items.Add(new ToStringWrapper <VDI>(vdi, "    " + vdi.Name));
                        }
                    }
                }
                else
                {
                    foreach (VDI vdi in connection.ResolveAll <VDI>(srWrapper.item.VDIs))
                    {
                        items.Add(new ToStringWrapper <VDI>(vdi, "    " + vdi.Name));
                    }
                    items.Sort(new Comparison <ToStringWrapper <VDI> >(delegate(ToStringWrapper <VDI> object1, ToStringWrapper <VDI> object2)
                    {
                        return(Core.StringUtility.NaturalCompare(object1.item.Name, object2.item.Name));
                    }));
                }
            }

            foreach (ToStringWrapper <VDI> vdiWrapper in items)
            {
                Items.Add(vdiWrapper);
            }
        }
Ejemplo n.º 8
0
        private void AddSR(ToStringWrapper <SR> srWrapper)
        {
            Items.Add(srWrapper);

            List <ToStringWrapper <VDI> > items = new List <ToStringWrapper <VDI> >();

            if (srWrapper.item.Physical())
            {
                List <ToStringWrapper <VDI> > vdis = new List <ToStringWrapper <VDI> >();
                foreach (VDI vdi in connection.ResolveAll <VDI>(srWrapper.item.VDIs))
                {
                    ToStringWrapper <VDI> vdiWrapper = new ToStringWrapper <VDI>(vdi, vdi.Name());
                    vdis.Add(vdiWrapper);
                }
                vdis.Sort((object1, object2) =>
                          StringUtility.NaturalCompare(object1.item.Name(), object2.item.Name()));

                Host host = srWrapper.item.GetStorageHost();
                if (host != null)
                {
                    for (int i = 0; i < vdis.Count; i++)
                    {
                        items.Add(new ToStringWrapper <VDI>(vdis[i].item, "    " + string.Format(Messages.ISOCOMBOBOX_CD_DRIVE, i, host.Name())));
                    }
                }
            }
            else
            {
                if (srWrapper.item.IsToolsSR())
                {
                    if (!Helpers.StockholmOrGreater(connection))
                    {
                        foreach (VDI vdi in connection.ResolveAll <VDI>(srWrapper.item.VDIs))
                        {
                            if (vdi.IsToolsIso())
                            {
                                items.Add(new ToStringWrapper <VDI>(vdi, "    " + vdi.Name()));
                            }
                        }
                    }
                }
                else
                {
                    foreach (VDI vdi in connection.ResolveAll <VDI>(srWrapper.item.VDIs))
                    {
                        items.Add(new ToStringWrapper <VDI>(vdi, "    " + vdi.Name()));
                    }

                    items.Sort((object1, object2) =>
                               StringUtility.NaturalCompare(object1.item.Name(), object2.item.Name()));
                }
            }

            foreach (ToStringWrapper <VDI> vdiWrapper in items)
            {
                Items.Add(vdiWrapper);
            }
        }
Ejemplo n.º 9
0
 private void ClearHosts()
 {
     if (tableLayoutPanelNewMaster.Visible)
     {
         NewMasterComboBox.Enabled = false;
         hostSelection             = NewMasterComboBox.SelectedItem as ToStringWrapper <Host>;
         NewMasterComboBox.Items.Clear();
     }
 }
Ejemplo n.º 10
0
        private String getIscsiIQN()
        {
            ToStringWrapper <IScsiIqnInfo> wrapper = comboBoxIscsiIqns.SelectedItem as ToStringWrapper <IScsiIqnInfo>;

            if (wrapper == null)
            {
                return("");
            }
            return(wrapper.item.TargetIQN);
        }
Ejemplo n.º 11
0
        private static CustomListRow CreateNewRow <T>(string key, ToStringWrapper <T> value, bool valueBold) where T : IEquatable <T>
        {
            CustomListItem Label = new CustomListItem(key, BaseTabPage.ItemLabelFont, BaseTabPage.ItemLabelForeColor);

            Label.Anchor            = AnchorStyles.Top;
            Label.itemBorder.Bottom = BaseTabPage.ITEM_SPACING;
            CustomListItem Value = new CustomListItem(value, valueBold ? BaseTabPage.ItemValueFontBold : BaseTabPage.ItemValueFont, BaseTabPage.ItemValueForeColor);

            Value.Anchor            = AnchorStyles.Top;
            Value.itemBorder.Bottom = BaseTabPage.ITEM_SPACING;
            return(new CustomListRow(BaseTabPage.ItemBackColor, Label, Value));
        }
Ejemplo n.º 12
0
        private CustomListRow CreateNewRow <T>(string key, ToStringWrapper <T> value, bool valueBold) where T : IEquatable <T>
        {
            CustomListItem item = new CustomListItem(key, BaseTabPage.ItemLabelFont, BaseTabPage.ItemLabelForeColor);

            item.Anchor            = AnchorStyles.Top;
            item.itemBorder.Bottom = 4;
            CustomListItem item2 = new CustomListItem(value, valueBold ? BaseTabPage.ItemValueFontBold : BaseTabPage.ItemValueFont, BaseTabPage.ItemValueForeColor);

            item2.Anchor            = AnchorStyles.Top;
            item2.itemBorder.Bottom = 4;
            return(new CustomListRow(BaseTabPage.ItemBackColor, new CustomListItem[] { item, item2 }));
        }
Ejemplo n.º 13
0
        private Dictionary <String, String> GetDeviceConfig(SR.SRTypes srType)
        {
            Dictionary <String, String>    dconf = new Dictionary <String, String>();
            ToStringWrapper <IScsiIqnInfo> iqn   = comboBoxIscsiIqns.SelectedItem as ToStringWrapper <IScsiIqnInfo>;

            if (iqn == null || !LunMap.ContainsKey(getIscsiLUN()))
            {
                return(null);
            }

            if (srType == SR.SRTypes.gfs2)
            {
                if (_srToIntroduce != null && _srToIntroduce.Configuration != null)
                {
                    dconf = _srToIntroduce.Configuration;
                }

                dconf["provider"]     = "iscsi";
                dconf["target"]       = iqn.item.IpAddress;
                dconf["port"]         = iqn.item.Port.ToString();
                dconf["targetIQN"]    = getIscsiIQN();
                dconf["SCSIid"]       = LunMap[getIscsiLUN()].ScsiID;
                dconf["chapuser"]     = IScsiChapUserTextBox.Text;
                dconf["chappassword"] = IScsiChapSecretTextBox.Text;

                return(dconf);
            }

            // Reset target IP address to home address specified in IQN scan.
            // Allows multi-homing - see CA-11607
            dconf[TARGET]    = iqn.item.IpAddress;
            dconf[PORT]      = iqn.item.Port.ToString();
            dconf[TARGETIQN] = getIscsiIQN();

            ISCSIInfo info = LunMap[getIscsiLUN()];

            if (info.LunID == -1)
            {
                dconf[LUNSERIAL] = info.Serial;
            }
            else
            {
                dconf[SCSIID] = info.ScsiID;
            }

            if (IscsiUseChapCheckBox.Checked)
            {
                dconf[CHAPUSER]     = IScsiChapUserTextBox.Text;
                dconf[CHAPPASSWORD] = IScsiChapSecretTextBox.Text;
            }

            return(dconf);
        }
Ejemplo n.º 14
0
        private Dictionary <String, String> GetDeviceConfig(SR.SRTypes srType)
        {
            Dictionary <String, String>    dconf = new Dictionary <String, String>();
            ToStringWrapper <IScsiIqnInfo> iqn   = comboBoxIscsiIqns.SelectedItem as ToStringWrapper <IScsiIqnInfo>;

            if (iqn == null || !LunMap.ContainsKey(getIscsiLUN()))
            {
                return(null);
            }

            if (srType == SR.SRTypes.gfs2)
            {
                // build the uri for gfs2
                var jsonUri = new JavaScriptSerializer().Serialize(new
                {
                    provider     = "iscsi",
                    ips          = iqn.item.IpAddress,
                    port         = iqn.item.Port.ToString(),
                    iqns         = getIscsiIQN(),
                    ScsiId       = LunMap[getIscsiLUN()].ScsiID,
                    chapuser     = IScsiChapUserTextBox.Text,
                    chappassword = IScsiChapSecretTextBox.Text
                });
                dconf[URI] = jsonUri;

                return(dconf);
            }

            // Reset target IP address to home address specified in IQN scan.
            // Allows multi-homing - see CA-11607
            dconf[TARGET]    = iqn.item.IpAddress;
            dconf[PORT]      = iqn.item.Port.ToString();
            dconf[TARGETIQN] = getIscsiIQN();

            ISCSIInfo info = LunMap[getIscsiLUN()];

            if (info.LunID == -1)
            {
                dconf[LUNSERIAL] = info.Serial;
            }
            else
            {
                dconf[SCSIID] = info.ScsiID;
            }

            if (IscsiUseChapCheckBox.Checked)
            {
                dconf[CHAPUSER]     = IScsiChapUserTextBox.Text;
                dconf[CHAPPASSWORD] = IScsiChapSecretTextBox.Text;
            }

            return(dconf);
        }
Ejemplo n.º 15
0
        private String getIscsiHost()
        {
            // If the user has selected an IQN, use the host from that IQN (due to multi-homing,
            // this may differ from the host they first entered). Otherwise use the host
            // they first entered,
            ToStringWrapper <IScsiIqnInfo> wrapper = comboBoxIscsiIqns.SelectedItem as ToStringWrapper <IScsiIqnInfo>;

            if (wrapper != null)
            {
                return(wrapper.item.IpAddress);
            }
            return(textBoxIscsiHost.Text.Trim());
        }
        private DataGridViewComboBoxCell FillGridComboBox(object xenRef, List<object> targetRefs, IStorageResource resource, ref List<ToStringWrapper<SR>> commonSRs)
        {
            var cb = new DataGridViewComboBoxCell { FlatStyle = FlatStyle.Flat };

            foreach (var pbd in TargetConnection.Cache.PBDs)
            {
                if (pbd.SR == null)
                    continue;

                var sr = TargetConnection.Resolve(pbd.SR);
                if (sr == null || sr.IsDetached() || !sr.Show(XenAdminConfigManager.Provider.ShowHiddenVMs))
                    continue;

                if ((sr.content_type.ToLower() == "iso" || sr.type.ToLower() == "iso") && !resource.SRTypeInvalid)
                    continue;
                if (sr.content_type.ToLower() != "iso" && resource.SRTypeInvalid)
                    continue;

                bool srOnHost = pbd.host != null && pbd.host.Equals(xenRef);

                if ((sr.shared || srOnHost) &&
                    (!IsExtraSpaceNeeded(resource.SR, sr) ||
                     resource.TryCalcRequiredDiskCapacity(out ulong capacity) && (ulong)sr.FreeSpace() > capacity &&
                     SrsAreSuitable(resource.SR, sr)))
                {
                    var count = (from ToStringWrapper<SR> existingItem in cb.Items
                                 where existingItem.item.opaque_ref == sr.opaque_ref
                                 select existingItem).Count();
                    if (count > 0)
                        continue; //iterating through pbds

                    var newItem = new ToStringWrapper<SR>(sr, GetSRDropDownItemDisplayString);
                    cb.Items.Add(newItem);

                    if (SR.IsDefaultSr(sr))
                        cb.Value = newItem;

                    //store items to populate the m_comboBoxSr

                    if ((sr.shared || (targetRefs.Count == 1 && srOnHost && targetRefs[0].Equals(xenRef))))
                    {
                        var num = (from ToStringWrapper<SR> existingItem in commonSRs
                                   where existingItem.item.opaque_ref == sr.opaque_ref
                                   select existingItem).Count();
                        if (num <= 0)
                            commonSRs.Add(newItem);
                    }
                }
            }
            return cb;
        }
Ejemplo n.º 17
0
 private void PopulateComboBox()
 {
     try
     {
         int num  = 0;
         int num2 = -1;
         if (this.AvailableStorageRepositories != null)
         {
             List <ToStringWrapper <WinAPI.SR> > list = new List <ToStringWrapper <WinAPI.SR> >();
             foreach (WinAPI.SR sr in this.AvailableStorageRepositories)
             {
                 try
                 {
                     if ((this._defaultSR != null) && this._defaultSR.uuid.Equals(sr.uuid))
                     {
                         num2 = num;
                     }
                     this._otherUsedDiskSpace = 0L;
                     if (this.OtherUsedDiskSpaceDict.ContainsKey(sr))
                     {
                         this._otherUsedDiskSpace = this.OtherUsedDiskSpaceDict[sr];
                     }
                     list.Add(new ToStringWrapper <WinAPI.SR>(sr, new ToStringDelegate <WinAPI.SR>(Helpers.SrToString)));
                     ToStringWrapper <WinAPI.SR> item = new ToStringWrapper <WinAPI.SR>(sr, Helpers.SrToString(sr, this._otherUsedDiskSpace));
                     int imageIndex = Images.GetImageIndex16For(sr);
                     this.SRComboBoxEx.Items.Add(new ComboBoxIconExItem(item, imageIndex));
                 }
                 catch (Exception exception)
                 {
                     LOG.Error(exception.Message);
                 }
                 num++;
             }
         }
         if (this.SRComboBoxEx.Items.Count > 0)
         {
             if (num2 != -1)
             {
                 this.SRComboBoxEx.SelectedIndex = num2;
             }
             else
             {
                 this.SRComboBoxEx.SelectedIndex = 0;
             }
         }
     }
     catch
     {
     }
 }
Ejemplo n.º 18
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            ToStringWrapper <IScsiIqnInfo> iqn = comboBoxIscsiIqns.SelectedItem as ToStringWrapper <IScsiIqnInfo>;

            buttonAdd.Enabled = false;
            buttonCancel.Text = Messages.CLOSE;
            int start = comboBoxLun.Text.LastIndexOf("(");
            int end   = comboBoxLun.Text.LastIndexOf(")");

            _repairAction = new SrAddMirrorLUNAction(_sr.Connection, _sr, comboBoxLun.Text.Substring(start + 1, end - start - 1),
                                                     iqn.item.IpAddress, iqn.item.TargetIQN, iqn.item.Port.ToString(), IScsiChapUserTextBox.Text, IScsiChapSecretTextBox.Text);
            _repairAction.RunAsync();
            this.Close();
        }
Ejemplo n.º 19
0
        private void PopulateSiteList()
        {
            // We assume all VMs share a pool
            var vm = vms[0];

            foreach (var site in vm.Connection.Cache.PVS_sites)
            {
                var siteToAdd = new ToStringWrapper <PVS_site>(site, site.Name);
                pvsSiteList.Items.Add(siteToAdd);
            }

            if (pvsSiteList.Items.Count > 0)
            {
                pvsSiteList.SelectedIndex = 0;
            }
        }
Ejemplo n.º 20
0
        public void Build()
        {
            List <ToStringWrapper <NetworkInstance> > list = new List <ToStringWrapper <NetworkInstance> >();

            new List <ToStringWrapper <Network> >();
            try {
                this.networkOptionsControl1.TheDataGridView.Rows.Clear();
                if (this.VMwareNetworks != null)
                {
                    foreach (NetworkInstance instance in this.VMwareNetworks)
                    {
                        NetworkInstance item = instance;
                        ToStringWrapper <NetworkInstance> wrapper = new ToStringWrapper <NetworkInstance>(item, item.Name);
                        list.Add(wrapper);
                    }
                }
                foreach (ToStringWrapper <NetworkInstance> wrapper2 in list)
                {
                    DataGridViewRow         dataGridViewRow  = new DataGridViewRow();
                    DataGridViewTextBoxCell dataGridViewCell = new DataGridViewTextBoxCell {
                        Tag   = wrapper2,
                        Value = wrapper2.ToString()
                    };
                    dataGridViewRow.Cells.Add(dataGridViewCell);
                    DataGridViewComboBoxCell cell3 = (DataGridViewComboBoxCell)this.FillGridComboBox().Clone();
                    if (cell3.Items.Count > 0)
                    {
                        cell3.DisplayMember = "ToStringProperty";
                        cell3.ValueMember   = "Self";
                        cell3.Value         = cell3.Items[this.GetDefaultIndex()];
                        dataGridViewRow.Cells.Add(cell3);
                    }
                    else
                    {
                        DataGridViewTextBoxCell cell4 = new DataGridViewTextBoxCell {
                            Value = Messages.WIZARD_SELECT_NETWORK_PAGE_NO_AVAIL_NETWORKS
                        };
                        dataGridViewRow.Cells.Add(cell4);
                        cell4.ReadOnly = true;
                    }
                    this.networkOptionsControl1.TheDataGridView.Rows.Add(dataGridViewRow);
                }
            }
            catch (Exception exception) {
                LOG.Error(exception, exception);
            }
        }
Ejemplo n.º 21
0
        private void comboBoxIscsiIqns_SelectedIndexChanged(object sender, EventArgs e)
        {
            ToStringWrapper <IScsiIqnInfo> wrapper = comboBoxIscsiIqns.SelectedItem as ToStringWrapper <IScsiIqnInfo>;

            // Keep the IScsiTargetIqnComboBox tooltip in sync with the selected item
            if (wrapper != null)
            {
                TargetIqnToolTip.SetToolTip(comboBoxIscsiIqns, wrapper.ToString());
            }
            else
            {
                TargetIqnToolTip.SetToolTip(comboBoxIscsiIqns, "");
            }
            // Clear the LUN map and ComboBox because the user has changed the IQN.  The user
            // must re-discover the LUNs for the new IQN.
            ClearLunMapAndCombo();
        }
Ejemplo n.º 22
0
        private void m_comboBoxISOLibraries_SelectedIndexChanged(object sender, EventArgs e)
        {
            ToStringWrapper <SR> wrapper = m_comboBoxISOLibraries.SelectedItem as ToStringWrapper <SR>;

            if (wrapper == null)
            {
                return;
            }

            if (IsNewISOLibraryItem(wrapper))
            {
                OpenNewSRWizard();
                return;
            }

            ResetControlsAfterSelectedIndexChanged();
        }
Ejemplo n.º 23
0
        private void PopulateCacheSrCombobox()
        {
            comboBoxCacheSr.Items.Clear();

            // add the "Not configured" item first
            var notConfiguredItem = new ToStringWrapper <SR>(null, Messages.PVS_CACHE_NOT_CONFIGURED);

            comboBoxCacheSr.Items.Add(notConfiguredItem);
            comboBoxCacheSr.SelectedItem = notConfiguredItem;

            // add Memeory SR; if no memory SR  found, add a placeholder (we will create the memory SR in ConfigurePvsCacheAction)
            var memorySr = Host.Connection.Cache.SRs.FirstOrDefault(s => s.GetSRType(false) == SR.SRTypes.tmpfs && s.CanBeSeenFrom(Host));

            if (memorySr == null)
            {
                // create a placeholder for the memory SR
                memorySr = new SR
                {
                    type       = SR.SRTypes.tmpfs.ToString(),
                    name_label = Messages.PVS_CACHE_MEMORY_SR_NAME,
                    shared     = false,
                    opaque_ref = Helper.NullOpaqueRef
                };
            }
            var memorySrItem = new ToStringWrapper <SR>(memorySr, Messages.PVS_CACHE_MEMORY_ONLY);

            comboBoxCacheSr.Items.Add(memorySrItem);
            if (OrigPvsCacheStorage != null && memorySr.opaque_ref == OrigPvsCacheStorage.SR.opaque_ref)
            {
                comboBoxCacheSr.SelectedItem = memorySrItem;
            }

            // add all suitable SRs
            var availableSRs = Host.Connection.Cache.SRs.Where(s => s.CanBeSeenFrom(Host) && SrIsSuitableForPvsCache(s)).ToList();

            availableSRs.Sort();
            foreach (var sr in availableSRs)
            {
                var newItem = new ToStringWrapper <SR>(sr, sr.Name);
                comboBoxCacheSr.Items.Add(newItem);
                if (OrigPvsCacheStorage != null && sr.opaque_ref == OrigPvsCacheStorage.SR.opaque_ref)
                {
                    comboBoxCacheSr.SelectedItem = newItem;
                }
            }
        }
Ejemplo n.º 24
0
        public override void PopulatePage()
        {
            m_comboBoxFormat.Items.Clear();
            var ovfItem = new ToStringWrapper <bool>(false, Messages.EXPORT_APPLIANCE_PAGE_FORMAT_OVFOVA);
            var xvaItem = new ToStringWrapper <bool>(true, Messages.EXPORT_APPLIANCE_PAGE_FORMAT_XVA);

            if (OvfModeOnly)
            {
                m_comboBoxFormat.Items.Add(ovfItem);
            }
            else
            {
                m_comboBoxFormat.Items.AddRange(new[] { ovfItem, xvaItem });
            }

            m_comboBoxFormat.SelectedItem = ovfItem;
        }
Ejemplo n.º 25
0
        private void IScsiTargetIqnComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            ToStringWrapper <IScsiIqnInfo> wrapper = comboBoxIscsiIqns.SelectedItem as ToStringWrapper <IScsiIqnInfo>;

            ClearLunMapAndCombo();
            HideAllErrorIconsAndLabels();

            if (wrapper != null)
            {
                TargetIqnToolTip.SetToolTip(comboBoxIscsiIqns, wrapper.ToString());
                IscsiPopulateLUNs();
            }
            else
            {
                TargetIqnToolTip.SetToolTip(comboBoxIscsiIqns, Messages.SELECT_TARGET_IQN);
            }
        }
Ejemplo n.º 26
0
        private void RepairButton_Click(object sender, EventArgs e)
        {
            CloseButton.Text = Messages.CLOSE;

            NewMasterComboBox.Enabled = false;
            ToStringWrapper <Host> newMaster = NewMasterComboBox.SelectedItem as ToStringWrapper <Host>;

            hostAction            = new EvacuateHostAction(host, newMaster != null ? newMaster.item : null, reasons ?? new Dictionary <XenRef <VM>, string[]>(), AddHostToPoolCommand.NtolDialog, AddHostToPoolCommand.EnableNtolDialog);
            hostAction.Completed += Program.MainWindow.action_Completed;
            SetSession(hostAction);

            //Closes all per-Connection and per-VM wizards for the given connection.
            Program.MainWindow.CloseActiveWizards(host.Connection);

            EvacuateButton.Enabled = false; // disable evac button, it will get re-enabled when action completes

            DoAction(hostAction);
        }
Ejemplo n.º 27
0
        private UInt16 getIscsiPort()
        {
            ToStringWrapper <IScsiIqnInfo> wrapper = comboBoxIscsiIqns.SelectedItem as ToStringWrapper <IScsiIqnInfo>;

            if (wrapper != null)
            {
                return(wrapper.item.Port);
            }

            // No combobox item was selected
            UInt16 port;

            if (UInt16.TryParse(textBoxIscsiPort.Text, out port))
            {
                return(port);
            }
            return(Util.DEFAULT_ISCSI_PORT);
        }
Ejemplo n.º 28
0
        protected override void OnSelectionChangeCommitted(EventArgs e)
        {
            // let the base class take care of skipping the SR headings (CA-40779)
            base.OnSelectionChangeCommitted(e);

            /*if (SelectedItem is ToStringWrapper<SR>)
             * {
             *  // This can occur if moving to the SR heading using the keyboard.
             *  // The base class prevents it from happening with mouse clicks.
             *  // TODO: This would be a lot neater if the base class stopped this happening
             *  // on keyboard events too.
             *  // Fires selectedIndexChanged event therefore
             *  // If selectedIndex + 1 is a Title it will move down the list
             *  // until it finds one which isn't a title (which is lucky)
             *  if (SelectedIndex < Items.Count - 1)
             *      SelectedIndex++;
             * }*/

            ToStringWrapper <VDI> vdiNameWrapper = SelectedItem as ToStringWrapper <VDI>;

            if (vdiNameWrapper == null)
            {
                return;
            }

            // dont change the cdrom if we go from <empty> to <empty>
            if (vdiNameWrapper.item == null && cdrom != null && Helper.IsNullOrEmptyOpaqueRef(cdrom.VDI.opaque_ref))
            {
                return;
            }

            // dont change the cdrom if we leave the same one in
            if (vdiNameWrapper.item != null && cdrom != null && cdrom.VDI.opaque_ref == vdiNameWrapper.item.opaque_ref)
            {
                return;
            }

            if (cdrom == null)
            {
                return;
            }

            ChangeCD(vdiNameWrapper.item);
        }
Ejemplo n.º 29
0
        private void comboBox1_TextChanged(object sender, EventArgs e)
        {
            SaveUpdate();

            dataGridView1.Rows.Clear();
            foreach (var value in SelectedEnumeration.Value.Options)
            {
                int row = dataGridView1.Rows.Add(value);
                dataGridView1[0, row].Tag = value;
            }

            comboBox2.Items.Clear();
            comboBox2.Items.AddRange(SelectedEnumeration.Value.Options.Select(a => a.Name).ToArray());
            if (SelectedEnumeration.Value.Default != null)
            {
                comboBox2.Text = SelectedEnumeration.Value.Default.Name;
            }

            m_lastSelection = SelectedEnumeration;
        }
Ejemplo n.º 30
0
        private void SelectProperItemInNewMasterComboBox(ToStringWrapper <Host> previousSelection)
        {
            bool selected = false;

            if (previousSelection != null)
            {
                foreach (ToStringWrapper <Host> host in NewMasterComboBox.Items)
                {
                    if (host.item.opaque_ref == previousSelection.item.opaque_ref)
                    {
                        NewMasterComboBox.SelectedItem = host;
                        selected = true;
                        break;
                    }
                }
            }

            if (NewMasterComboBox.Items.Count > 0 && !selected)
            {
                NewMasterComboBox.SelectedIndex = 0;
            }
        }
Ejemplo n.º 31
0
 private bool IsNewISOLibraryItem(ToStringWrapper<SR> wrapper)
 {
     return (wrapper.Equals(m_comboBoxISOLibraries.Items[m_comboBoxISOLibraries.Items.Count - 1]) &&
             wrapper.ToStringProperty.Equals(Messages.IMPORT_OPTIONS_PAGE_NEW_ISO_LIBRARY));
 }
        private DataGridViewComboBoxCell FillGridComboBox(object xenRef, List<object> targetRefs, IStorageResource resource, ref List<ToStringWrapper<SR>> commonSRs)
        {
            var cb = new DataGridViewComboBoxCell { FlatStyle = FlatStyle.Flat };

            foreach (var pbd in TargetConnection.Cache.PBDs)
            {
                if (pbd.SR == null)
                    continue;

                var sr = TargetConnection.Resolve(pbd.SR);
                if (sr == null)
                    continue;

                if ((sr.content_type.ToLower() == "iso" || sr.type.ToLower() == "iso") && !resource.SRTypeInvalid)
                    continue;
                if (sr.content_type.ToLower() != "iso" && resource.SRTypeInvalid)
                    continue;

                bool srOnHost = pbd.host != null && pbd.host.Equals(xenRef);

                if ((sr.shared || srOnHost) && (ulong)sr.FreeSpace > resource.RequiredDiskCapacity && SrIsSuitable(sr))
                {
                    var count = (from ToStringWrapper<SR> existingItem in cb.Items
                                 where existingItem.item.opaque_ref == sr.opaque_ref
                                 select existingItem).Count();
                    if (count > 0)
                        continue; //iterating through pbds

                    var newItem = new ToStringWrapper<SR>(sr, GetSRDropDownItemDisplayString);
                    cb.Items.Add(newItem);

                    if (SR.IsDefaultSr(sr))
                        cb.Value = newItem;

                    //store items to populate the m_comboBoxSr
                    //note that at this point the m_totalSpaceRequired is not the final value yet,
                    //but we can add the check to get a smaller list

                    if ((sr.shared || (targetRefs.Count == 1 && srOnHost && targetRefs[0].Equals(xenRef))))
                    {
                        var num = (from ToStringWrapper<SR> existingItem in commonSRs
                                   where existingItem.item.opaque_ref == sr.opaque_ref
                                   select existingItem).Count();
                        if (num <= 0)
                            commonSRs.Add(newItem);
                    }
                }
            }
            return cb;
        }
Ejemplo n.º 33
0
		protected DataGridViewComboBoxCell FillGridComboBox(object xenRef)
		{
		    var cb = new DataGridViewComboBoxCell {FlatStyle = FlatStyle.Flat, Sorted = true};

			XenRef<Host> hostRef = xenRef as XenRef<Host>;
			Host host = TargetConnection.Resolve(hostRef);

            var availableNetworks = TargetConnection.Cache.Networks.Where(net => ShowNetwork(host, net));

			foreach (XenAPI.Network netWork in availableNetworks)
			{
				if (!Messages.IMPORT_SELECT_NETWORK_PAGE_NETWORK_FILTER.Contains(netWork.Name))
				{
					var wrapperItem = new ToStringWrapper<XenAPI.Network>(netWork, netWork.Name);

					if (!cb.Items.Contains(wrapperItem))
						cb.Items.Add(wrapperItem);
				}
			}

			return cb;
		}
 public EnableableSrComboboxItem(ToStringWrapper<SR> stringWrapper, ulong spaceRequired)
 {
     this.stringWrapper = stringWrapper;
     this.spaceRequired = spaceRequired;
 }
Ejemplo n.º 35
0
        public override void PopulatePage()
        {
            m_comboBoxFormat.Items.Clear();
            var ovfItem = new ToStringWrapper<bool>(false, Messages.EXPORT_APPLIANCE_PAGE_FORMAT_OVFOVA);
            var xvaItem = new ToStringWrapper<bool>(true, Messages.EXPORT_APPLIANCE_PAGE_FORMAT_XVA);

            if (OvfModeOnly)
                m_comboBoxFormat.Items.Add(ovfItem);
            else
                m_comboBoxFormat.Items.AddRange(new[] {ovfItem, xvaItem});

            m_comboBoxFormat.SelectedItem = ovfItem;
        }
Ejemplo n.º 36
0
        protected void AddSR(ToStringWrapper<SR> srWrapper)
        {
            Items.Add(srWrapper);

            List<ToStringWrapper<VDI>> items = new List<ToStringWrapper<VDI>>();
            if (srWrapper.item.Physical)
            {
                List<ToStringWrapper<VDI>> vdis = new List<ToStringWrapper<VDI>>();
                foreach (VDI vdi in connection.ResolveAll<VDI>(srWrapper.item.VDIs))
                {
                    ToStringWrapper<VDI> vdiWrapper = new ToStringWrapper<VDI>(vdi, vdi.Name);
                    vdis.Add(vdiWrapper);
                }
                vdis.Sort(new Comparison<ToStringWrapper<VDI>>(delegate(ToStringWrapper<VDI> object1, ToStringWrapper<VDI> object2)
                {
                    return Core.StringUtility.NaturalCompare(object1.item.Name, object2.item.Name);
                }));

                Host host = srWrapper.item.GetStorageHost();
                if (host != null)
                {
                    for (int i = 0; i < vdis.Count; i++)
                    {
                        items.Add(new ToStringWrapper<VDI>(vdis[i].item, "    " + string.Format(Messages.ISOCOMBOBOX_CD_DRIVE, i, host.Name)));
                    }
                }
            }
            else
            {
                if (srWrapper.item.IsToolsSR)
                {
                    foreach (VDI vdi in connection.ResolveAll<VDI>(srWrapper.item.VDIs))
                    {
                        if(Actions.InstallPVToolsAction.ISONameOld.Equals(vdi.name_label) ||
                            Actions.InstallPVToolsAction.ISONameNew.Equals(vdi.name_label))
                            items.Add(new ToStringWrapper<VDI>(vdi, "    " + vdi.Name));
                    }
                }
                else
                {
                    foreach (VDI vdi in connection.ResolveAll<VDI>(srWrapper.item.VDIs))
                    {
                        items.Add(new ToStringWrapper<VDI>(vdi, "    " + vdi.Name));
                    }
                    items.Sort(new Comparison<ToStringWrapper<VDI>>(delegate(ToStringWrapper<VDI> object1, ToStringWrapper<VDI> object2)
                    {
                        return Core.StringUtility.NaturalCompare(object1.item.Name, object2.item.Name);
                    }));
                }
            }

            foreach (ToStringWrapper<VDI> vdiWrapper in items)
            {
                Items.Add(vdiWrapper);
            }
        }