private string FormatDiskValueText(IStorageResource resourceData, string diskLabel)
 {
     if (displayDiskCapacity && resourceData.TryCalcRequiredDiskCapacity(out ulong capacity))
     {
         return($"{diskLabel} ({Util.DiskSizeString(capacity)})");
     }
     return(diskLabel);
 }
Ejemplo n.º 2
0
 private string FormatDiskValueText(IStorageResource resourceData, string disklabel)
 {
     if (displayDiskCapacity)
     {
         return(string.Format("{0} ({1})", disklabel,
                              Util.DiskSizeString(resourceData.RequiredDiskCapacity)));
     }
     return(disklabel);
 }
Ejemplo n.º 3
0
        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)
                {
                    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);
        }
        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.º 5
0
 public StorageScope(IStorageResource scope)
 {
     Token            = new TransactionToken(scope);
     TransactionScope = this.StartTransaction();
 }
Ejemplo n.º 6
0
 public void Setup()
 {
     Resource = Mock.Of <IStorageResource>();
 }
Ejemplo n.º 7
0
 public TransactionToken(IStorageResource scope)
 {
     Scope = scope;
     Scope.TransactionLevel++;
     Debug.WriteLine($"[TransactionLevel]: {Scope.TransactionLevel}");
 }
 private string FormatDiskValueText(IStorageResource resourceData, string disklabel)
 {
     if(displayDiskCapacity)
         return string.Format("{0} ({1})", disklabel,
                                   Util.DiskSizeString(resourceData.RequiredDiskCapacity));
     return disklabel;
 }
        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.º 10
0
 public static void UseSybase(this IStorageResource storage) =>
 storage.Use(StorageType.Sybase);
Ejemplo n.º 11
0
 public static void UsePostgres(this IStorageResource storage) =>
 storage.Use(StorageType.Postgres);