Beispiel #1
0
 private void Update()
 {
     if (TheVDI.type == vdi_type.crashdump || TheVDI.type == vdi_type.ephemeral || TheVDI.type == vdi_type.suspend)
     {
         Show = false;
     }
     else if ((TheVDI.VBDs.Count > 0 && !TheVDI.sharable))
     {
         bool allRO = true;
         foreach (VBD vbd in TheVDI.Connection.ResolveAll <VBD>(TheVDI.VBDs))
         {
             if (!vbd.IsReadOnly() && vbd.currently_attached)
             {
                 allRO = false;
                 break;
             }
         }
         Show = allRO;
         if (Show)
         {
             ForceReadOnly = true;
             Text          = String.IsNullOrEmpty(TheVDI.Name()) ? Messages.NO_NAME : TheVDI.Name();
             if (!string.IsNullOrEmpty(TheVDI.Description()))
             {
                 Description = string.Format(Messages.ATTACHDISK_SIZE_DESCRIPTION, TheVDI.Description(), Util.DiskSizeString(TheVDI.virtual_size));
             }
             else
             {
                 Description = Util.DiskSizeString(TheVDI.virtual_size);
             }
             Image = Images.GetImage16For(Icons.VDI);
         }
     }
     else
     {
         Show          = true;
         ForceReadOnly = TheVDI.read_only;
         Text          = String.IsNullOrEmpty(TheVDI.Name()) ? Messages.NO_NAME : TheVDI.Name();
         if (!string.IsNullOrEmpty(TheVDI.Description()))
         {
             Description = string.Format(Messages.ATTACHDISK_SIZE_DESCRIPTION, TheVDI.Description(), Util.DiskSizeString(TheVDI.virtual_size));
         }
         else
         {
             Description = Util.DiskSizeString(TheVDI.virtual_size);
         }
         Image = Images.GetImage16For(Icons.VDI);
     }
 }
Beispiel #2
0
        private void LoadValues()
        {
            if (DiskTemplate == null)
            {
                return;
            }

            NameTextBox.Text        = DiskTemplate.Name();
            DescriptionTextBox.Text = DiskTemplate.Description();
            SrListBox.selectSRorDefaultorAny(connection.Resolve(DiskTemplate.SR));

            // select the appropriate unit, based on size (CA-45905)
            currentSelectedUnits = DiskTemplate.virtual_size >= Util.BINARY_GIGA ? DiskSizeUnits.GB : DiskSizeUnits.MB;
            SelectedUnits        = currentSelectedUnits;
            SetNumUpDownIncrementAndDecimals(DiskSizeNumericUpDown, SelectedUnits.ToString());
            decimal newValue = (decimal)Math.Round((double)DiskTemplate.virtual_size / GetUnits(), DiskSizeNumericUpDown.DecimalPlaces);

            DiskSizeNumericUpDown.Value = newValue >= DiskSizeNumericUpDown.Minimum && newValue <= DiskSizeNumericUpDown.Maximum ?
                                          newValue : DiskSizeNumericUpDown.Maximum;

            if (MinSize > 0)
            {
                min = (decimal)((double)MinSize / GetUnits());
            }
            DiskSizeNumericUpDown.Enabled = CanResize;

            Text          = Messages.EDIT_DISK;
            OkButton.Text = Messages.OK;
        }
Beispiel #3
0
        public NewDiskDialog(IXenConnection connection, VM vm, Host affinity,
                             SrPicker.SRPickerType pickerUsage = SrPicker.SRPickerType.VM, VDI diskTemplate = null,
                             bool canResize = true, long minSize = 0, IEnumerable <VDI> vdiNamesInUse = null)
            : base(connection ?? throw new ArgumentNullException(nameof(connection)))
        {
            InitializeComponent();

            TheVM                  = vm;
            _VDINamesInUse         = vdiNamesInUse ?? new List <VDI>();
            diskSpinner1.CanResize = canResize;

            if (diskTemplate == null)
            {
                NameTextBox.Text = GetDefaultVDIName();
                diskSpinner1.Populate(minSize: minSize);
                UpdateErrorsAndButtons();
                SrListBox.PopulateAsync(pickerUsage, connection, affinity, null, null);
            }
            else
            {
                DiskTemplate            = diskTemplate;
                NameTextBox.Text        = DiskTemplate.Name();
                DescriptionTextBox.Text = DiskTemplate.Description();
                Text          = Messages.EDIT_DISK;
                OkButton.Text = Messages.OK;
                diskSpinner1.Populate(DiskTemplate.virtual_size, minSize);
                UpdateErrorsAndButtons();
                SrListBox.PopulateAsync(pickerUsage, connection, affinity, connection.Resolve(DiskTemplate.SR), null);
            }
        }
Beispiel #4
0
        public NewDiskDialog(IXenConnection connection, VM vm, Host affinity,
                             SrPicker.SRPickerType pickerUsage = SrPicker.SRPickerType.VM, VDI diskTemplate = null,
                             bool canResize = true, long minSize = 0, IEnumerable <VDI> vdiNamesInUse = null)
            : base(connection ?? throw new ArgumentNullException(nameof(connection)))
        {
            InitializeComponent();

            TheVM          = vm;
            _VDINamesInUse = vdiNamesInUse ?? new List <VDI>();

            SrListBox.Connection = connection;
            SrListBox.Usage      = pickerUsage;
            SrListBox.SetAffinity(affinity);

            Pool pool_sr = Helpers.GetPoolOfOne(connection);

            if (pool_sr != null)
            {
                SrListBox.DefaultSR = connection.Resolve(pool_sr.default_SR); //if default sr resolves to null the first sr in the list will be selected
            }

            if (diskTemplate == null)
            {
                NameTextBox.Text = GetDefaultVDIName();
                SrListBox.selectDefaultSROrAny();
                diskSpinner1.Populate(minSize: minSize);
            }
            else
            {
                DiskTemplate            = diskTemplate;
                NameTextBox.Text        = DiskTemplate.Name();
                DescriptionTextBox.Text = DiskTemplate.Description();
                SrListBox.selectSRorDefaultorAny(connection.Resolve(DiskTemplate.SR));
                Text          = Messages.EDIT_DISK;
                OkButton.Text = Messages.OK;
                diskSpinner1.Populate(DiskTemplate.virtual_size, minSize);
            }

            diskSpinner1.CanResize = canResize;
        }
Beispiel #5
0
        private object CellValue(int col)
        {
            switch (col)
            {
            case 0:
                return(VBD.userdevice);

            case 1:
                return(VDI.Name());

            case 2:
                return(VDI.Description());

            case 3:
                return(SR.Name());

            case 4:
                string name;
                return(VDI.sm_config.TryGetValue("displayname", out name) ? name : "");

            case 5:
                return(VDI.SizeText());

            case 6:
                return(VBD.IsReadOnly() ? Messages.YES : Messages.NO);

            case 7:
                return(GetPriorityString(VBD.GetIoNice()));

            case 8:
                return(VBD.currently_attached ? Messages.YES : Messages.NO);

            case 9:
                return(VBD.device == "" ? Messages.STORAGE_PANEL_UNKNOWN : string.Format("/dev/{0}", VBD.device));

            default:
                throw new ArgumentException(String.Format("Invalid column number {0} in VBDRenderer.CellValue()", col));
            }
        }