Ejemplo n.º 1
0
        private void PopulateComboBox()
        {
            var noneItem = new GpuTuple(null, null, null); // "None" item

            comboBoxGpus.Items.Add(noneItem);

            Array.Sort(gpu_groups);
            foreach (GPU_group gpu_group in gpu_groups)
            {
                if (Helpers.FeatureForbidden(Connection, Host.RestrictVgpu) || !vm.CanHaveVGpu)
                {
                    comboBoxGpus.Items.Add(new GpuTuple(gpu_group, null, null));  //GPU pass-through item
                }
                else
                {
                    var enabledTypes = Connection.ResolveAll(gpu_group.enabled_VGPU_types);
                    var allTypes     = Connection.ResolveAll(gpu_group.supported_VGPU_types);

                    var disabledTypes = allTypes.FindAll(t => !enabledTypes.Exists(e => e.opaque_ref == t.opaque_ref));

                    if (allTypes.Count > 1)
                    {
                        allTypes.Sort((t1, t2) =>
                        {
                            int result = t1.Capacity.CompareTo(t2.Capacity);
                            if (result != 0)
                            {
                                return(result);
                            }
                            return(t1.Name.CompareTo(t2.Name));
                        });
                        comboBoxGpus.Items.Add(new GpuTuple(gpu_group, allTypes.ToArray())); // Group item
                    }

                    foreach (var vgpuType in allTypes)
                    {
                        comboBoxGpus.Items.Add(new GpuTuple(gpu_group, vgpuType, disabledTypes.ToArray())); // GPU_type item
                    }
                }
            }

            foreach (var item in comboBoxGpus.Items)
            {
                var tuple = item as GpuTuple;
                if (tuple == null)
                {
                    continue;
                }

                if (tuple.Equals(currentGpuTuple))
                {
                    comboBoxGpus.SelectedItem = item;
                    break;
                }
            }
            if (comboBoxGpus.SelectedItem == null)
            {
                comboBoxGpus.SelectedItem = noneItem;
            }
        }
Ejemplo n.º 2
0
        private void PopulateComboBox()
        {
            var noneItem = new GpuTuple(null, null, null); // "None" item

            comboBoxGpus.Items.Add(noneItem);

            Array.Sort(gpu_groups);
            foreach (GPU_group gpu_group in gpu_groups)
            {
                if (Helpers.FeatureForbidden(Connection, Host.RestrictVgpu) || !vm.CanHaveVGpu())
                {
                    if (gpu_group.HasPassthrough())
                    {
                        comboBoxGpus.Items.Add(new GpuTuple(gpu_group, null, null));  //GPU pass-through item
                    }
                }
                else
                {
                    var enabledTypes = Connection.ResolveAll(gpu_group.enabled_VGPU_types);
                    var allTypes     = Connection.ResolveAll(gpu_group.supported_VGPU_types);

                    var disabledTypes = allTypes.FindAll(t => !enabledTypes.Exists(e => e.opaque_ref == t.opaque_ref));

                    if (gpu_group.HasVGpu())
                    {
                        allTypes.Sort();
                        allTypes.Reverse();
                        comboBoxGpus.Items.Add(new GpuTuple(gpu_group, allTypes.ToArray())); // Group item
                    }

                    foreach (var vgpuType in allTypes)
                    {
                        comboBoxGpus.Items.Add(new GpuTuple(gpu_group, vgpuType, disabledTypes.ToArray())); // GPU_type item
                    }
                }
            }

            foreach (var item in comboBoxGpus.Items)
            {
                var tuple = item as GpuTuple;
                if (tuple == null)
                {
                    continue;
                }

                if (tuple.Equals(currentGpuTuple))
                {
                    comboBoxGpus.SelectedItem = item;
                    break;
                }
            }
            if (comboBoxGpus.SelectedItem == null)
            {
                comboBoxGpus.SelectedItem = noneItem;
            }
        }
Ejemplo n.º 3
0
        public void ShowHideWarnings()
        {
            if (!gpusAvailable)
            {
                return;
            }

            imgExperimental.Visible = labelExperimental.Visible =
                VgpuType != null && VgpuType.experimental;

            if (vm.power_state != vm_power_state.Halted)
            {
                imgRDP.Visible             = labelRDP.Visible =
                    imgNeedDriver.Visible  = labelNeedDriver.Visible =
                        imgNeedGpu.Visible = labelNeedGpu.Visible =
                            imgHA.Visible  = labelHA.Visible =
                                false;

                imgStopVM.Visible = labelStopVM.Visible = true;

                labelGpuType.Enabled = comboBoxGpus.Enabled = false;
                return;
            }

            Pool pool = Helpers.GetPool(Connection);

            if (pool != null && pool.ha_enabled && VM.HaPriorityIsRestart(Connection, SelectedPriority))
            {
                imgRDP.Visible                = labelRDP.Visible =
                    imgNeedDriver.Visible     = labelNeedDriver.Visible =
                        imgNeedGpu.Visible    = labelNeedGpu.Visible =
                            imgStopVM.Visible = labelStopVM.Visible =
                                false;

                imgHA.Visible = labelHA.Visible = true;

                labelGpuType.Enabled = comboBoxGpus.Enabled = false;
                return;
            }

            labelGpuType.Enabled = comboBoxGpus.Enabled = true;
            GpuTuple tuple = comboBoxGpus.SelectedItem as GpuTuple;

            imgStopVM.Visible = labelStopVM.Visible =
                imgHA.Visible = labelHA.Visible = false;

            imgRDP.Visible = labelRDP.Visible =
                HasChanged && currentGpuTuple.GpuGroup == null &&
                tuple != null && !tuple.IsFractionalVgpu;

            imgNeedGpu.Visible          = labelNeedGpu.Visible =
                labelNeedDriver.Visible = imgNeedDriver.Visible =
                    tuple != null && tuple.GpuGroup != null;
        }
Ejemplo n.º 4
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            GpuTuple tuple = comboBoxTypes.SelectedItem as GpuTuple;

            if (tuple == null || tuple.VgpuTypes == null || tuple.VgpuTypes.Length == 0)
            {
                SelectedTuple = null;
            }
            else
            {
                SelectedTuple = tuple;
            }
        }
Ejemplo n.º 5
0
        public override void PopulatePage()
        {
            currentGpuTuple = new GpuTuple(null, null, null);

            if (vm.VGPUs.Count != 0)
            {
                VGPU vgpu = Connection.Resolve(vm.VGPUs[0]);
                if (vgpu != null)
                {
                    var vgpuGroup = Connection.Resolve(vgpu.GPU_group);

                    if (Helpers.FeatureForbidden(Connection, Host.RestrictVgpu) || !vm.CanHaveVGpu())
                    {
                        if (vgpuGroup.HasPassthrough())
                        {
                            currentGpuTuple = new GpuTuple(vgpuGroup, null, null); //GPU pass-through item
                        }
                    }
                    else
                    {
                        VGPU_type vgpuType = Connection.Resolve(vgpu.type);
                        currentGpuTuple = new GpuTuple(vgpuGroup, vgpuType, null);
                    }
                }
            }

            // vGPU was introduced in Clearwater SP1
            gpu_groups = !Helpers.ClearwaterSp1OrGreater(Connection) //We used to check host.RestrictVgpu here (instead of checking the API version); this is not correct anymore, because vGPU is a licensed feature.
                 ? Connection.Cache.GPU_groups
                 : Connection.Cache.GPU_groups.Where(g => g.PGPUs.Count > 0 && g.supported_VGPU_types.Count != 0).ToArray();
            //not showing empty groups

            gpusAvailable = gpu_groups.Length > 0;

            if (gpusAvailable)
            {
                PopulateComboBox();
                ShowHideWarnings();
            }
            else
            {
                labelRubric.Text = Helpers.GetPool(Connection) == null
                                       ? Messages.GPU_RUBRIC_NO_GPUS_SERVER
                                       : Messages.GPU_RUBRIC_NO_GPUS_POOL;

                tableLayoutPanel1.Visible = false;
                warningsTable.Visible     = false;
            }
        }
Ejemplo n.º 6
0
        public override void PopulatePage()
        {
            currentGpuTuple = new GpuTuple(null, null, null);

            if (vm.VGPUs.Count != 0)
            {
                VGPU vgpu = Connection.Resolve(vm.VGPUs[0]);
                if (vgpu != null)
                {
                    var vgpuGroup = Connection.Resolve(vgpu.GPU_group);

                    if (Helpers.FeatureForbidden(Connection, Host.RestrictVgpu) || !vm.CanHaveVGpu())
                    {
                        if (vgpuGroup.HasPassthrough())
                        {
                            currentGpuTuple = new GpuTuple(vgpuGroup, null, null); //GPU pass-through item
                        }
                    }
                    else
                    {
                        VGPU_type vgpuType = Connection.Resolve(vgpu.type);
                        currentGpuTuple = new GpuTuple(vgpuGroup, vgpuType, null);
                    }
                }
            }

            gpu_groups = Connection.Cache.GPU_groups.Where(g => g.PGPUs.Count > 0 && g.supported_VGPU_types.Count != 0).ToArray();
            //not showing empty groups

            gpusAvailable = gpu_groups.Length > 0;

            if (gpusAvailable)
            {
                PopulateComboBox();
                ShowHideWarnings();
            }
            else
            {
                labelRubric.Text = Helpers.GetPool(Connection) == null
                                       ? Messages.GPU_RUBRIC_NO_GPUS_SERVER
                                       : Messages.GPU_RUBRIC_NO_GPUS_POOL;

                tableLayoutPanel1.Visible = false;
                warningsTable.Visible     = false;
            }
        }
Ejemplo n.º 7
0
        private void PopulateComboBox()
        {
            var noneItem = new GpuTuple(null, null, null); // "None" item
            comboBoxGpus.Items.Add(noneItem);

            Array.Sort(gpu_groups);
            foreach (GPU_group gpu_group in gpu_groups)
            {
                if (Helpers.FeatureForbidden(Connection, Host.RestrictVgpu) || !vm.CanHaveVGpu)
                {
                    comboBoxGpus.Items.Add(new GpuTuple(gpu_group, null, null));  //GPU pass-through item
                }
                else
                {
                    var enabledTypes = Connection.ResolveAll(gpu_group.enabled_VGPU_types);
                    var allTypes = Connection.ResolveAll(gpu_group.supported_VGPU_types);

                    var disabledTypes = allTypes.FindAll(t => !enabledTypes.Exists(e => e.opaque_ref == t.opaque_ref));

                    if (gpu_group.HasVGpu)
                    {
                        allTypes.Sort();
                        allTypes.Reverse();
                        comboBoxGpus.Items.Add(new GpuTuple(gpu_group, allTypes.ToArray())); // Group item
                    }

                    foreach (var vgpuType in allTypes)
                        comboBoxGpus.Items.Add(new GpuTuple(gpu_group, vgpuType, disabledTypes.ToArray())); // GPU_type item
                }
            }

            foreach (var item in comboBoxGpus.Items)
            {
                var tuple = item as GpuTuple;
                if (tuple == null)
                    continue;

                if (tuple.Equals(currentGpuTuple))
                {
                    comboBoxGpus.SelectedItem = item;
                    break;
                }
            }
            if (comboBoxGpus.SelectedItem == null)
                comboBoxGpus.SelectedItem = noneItem;
        }
Ejemplo n.º 8
0
        public override void PopulatePage()
        {
            currentGpuTuple = new GpuTuple(null, null, null);

            if (vm.VGPUs.Count != 0)
            {
                VGPU vgpu = Connection.Resolve(vm.VGPUs[0]);
                if (vgpu != null)
                {
                    var vgpuGroup = Connection.Resolve(vgpu.GPU_group);

                    if (Helpers.FeatureForbidden(Connection, Host.RestrictVgpu) || !vm.CanHaveVGpu)
                        currentGpuTuple = new GpuTuple(vgpuGroup, null, null);
                    else
                    {
                        VGPU_type vgpuType = Connection.Resolve(vgpu.type);
                        currentGpuTuple = new GpuTuple(vgpuGroup, vgpuType, null);
                    }
                }
            }

            // vGPU was introduced in Clearwater SP1
            gpu_groups = !Helpers.ClearwaterSp1OrGreater(Connection) //We used to check host.RestrictVgpu here (instead of checking the API version); this is not correct anymore, because vGPU is a licensed feature.
                 ? Connection.Cache.GPU_groups
                 : Connection.Cache.GPU_groups.Where(g => g.PGPUs.Count > 0 && g.supported_VGPU_types.Count != 0).ToArray();
                   //not showing empty groups

            gpusAvailable = gpu_groups.Length > 0;

            if (gpusAvailable)
            {
                PopulateComboBox();
                ShowHideWarnings();
            }
            else
            {
                labelRubric.Text = Helpers.GetPool(Connection) == null
                                       ? Messages.GPU_RUBRIC_NO_GPUS_SERVER
                                       : Messages.GPU_RUBRIC_NO_GPUS_POOL;

                tableLayoutPanel1.Visible = false;
                warningsTable.Visible = false;
            }
        }
Ejemplo n.º 9
0
        private void PopulateComboBox()
        {
            var noneItem = new GpuTuple(null, null, null);
            comboBoxGpus.Items.Add(noneItem);

            Array.Sort(gpu_groups);
            foreach (GPU_group gpu_group in gpu_groups)
            {
                if (Helpers.FeatureForbidden(Connection, Host.RestrictVgpu))
                {
                    comboBoxGpus.Items.Add(new GpuTuple(gpu_group, null, null));
                }
                else
                {
                    var enabledRefs = GPU_group.get_enabled_VGPU_types(Connection.Session, gpu_group.opaque_ref);
                    var enabledTypes = Connection.ResolveAll(enabledRefs);

                    var allTypes = Connection.ResolveAll(gpu_group.supported_VGPU_types);

                    var disabledTypes = allTypes.FindAll(t => !enabledTypes.Exists(e => e.opaque_ref == t.opaque_ref));

                    if (allTypes.Count > 1)
                    {
                        allTypes.Sort((t1, t2) =>
                        {
                            int result = t1.Capacity.CompareTo(t2.Capacity);
                            if (result != 0)
                                return result;
                            return t1.Name.CompareTo(t2.Name);
                        });

                        comboBoxGpus.Items.Add(new GpuTuple(gpu_group, allTypes.ToArray(), disabledTypes.ToArray()));

                        foreach (var vgpuType in allTypes)
                            comboBoxGpus.Items.Add(new GpuTuple(gpu_group, new[] { vgpuType }, disabledTypes.ToArray()));
                    }
                    else
                        comboBoxGpus.Items.Add(new GpuTuple(gpu_group, null, disabledTypes.ToArray()));
                }
            }

            foreach (var item in comboBoxGpus.Items)
            {
                var tuple = item as GpuTuple;
                if (tuple == null)
                    continue;

                if (tuple.Equals(currentGpuTuple))
                {
                    comboBoxGpus.SelectedItem = item;
                    break;
                }
            }
            if (comboBoxGpus.SelectedItem == null)
                comboBoxGpus.SelectedItem = noneItem;
        }
Ejemplo n.º 10
0
        public override void PopulatePage()
        {
            currentGpuTuple = new GpuTuple(null, null, null);

            if (vm.VGPUs.Count != 0)
            {
                VGPU vgpu = Connection.Resolve(vm.VGPUs[0]);
                if (vgpu != null)
                {
                    var vgpuGroup = Connection.Resolve(vgpu.GPU_group);

                    if (Helpers.FeatureForbidden(Connection, Host.RestrictVgpu))
                        currentGpuTuple = new GpuTuple(vgpuGroup, null, null);
                    else
                    {
                        VGPU_type vgpuType = Connection.Resolve(vgpu.type);
                        currentGpuTuple = new GpuTuple(vgpuGroup, new[] { vgpuType }, null);
                    }
                }
            }

            gpu_groups = Helpers.FeatureForbidden(Connection, Host.RestrictVgpu)
                 ? Connection.Cache.GPU_groups
                 : Connection.Cache.GPU_groups.Where(g => g.PGPUs.Count > 0 && g.supported_VGPU_types.Count != 0).ToArray();
                   //not showing empty groups

            gpusAvailable = gpu_groups.Length > 0;

            if (gpusAvailable)
            {
                PopulateComboBox();
                ShowHideWarnings();
            }
            else
            {
                labelRubric.Text = Helpers.GetPool(Connection) == null
                                       ? Messages.GPU_RUBRIC_NO_GPUS_SERVER
                                       : Messages.GPU_RUBRIC_NO_GPUS_POOL;

                tableLayoutPanel1.Visible = false;
                warningsTable.Visible = false;
            }
        }