Example #1
0
        private void Build()
        {
            var pool = Helpers.GetPoolOfOne(connection);

            bool is_host = xenObjectCopy is Host;
            bool is_vm   = xenObjectCopy is VM && !((VM)xenObjectCopy).is_a_snapshot;
            bool is_sr   = xenObjectCopy is SR;

            bool is_pool    = xenObjectCopy is Pool;
            bool is_vdi     = xenObjectCopy is VDI;
            bool is_network = xenObjectCopy is XenAPI.Network;

            bool is_hvm      = is_vm && ((VM)xenObjectCopy).IsHVM();
            bool is_template = is_vm && ((VM)xenObjectCopy).is_a_template;
            bool is_in_pool  = Helpers.GetPool(xenObjectCopy.Connection) != null;

            bool is_pool_or_standalone = is_pool || (is_host && !is_in_pool);

            bool wlb_enabled = (Helpers.WlbEnabledAndConfigured(xenObjectCopy.Connection));

            bool is_VM_appliance = xenObjectCopy is VM_appliance;

            bool is_VMSS = xenObjectCopy is VMSS;

            ContentPanel.SuspendLayout();
            verticalTabs.BeginUpdate();

            try
            {
                verticalTabs.Items.Clear();

                ShowTab(GeneralEditPage = new GeneralEditPage());

                if (!is_VM_appliance)
                {
                    ShowTab(CustomFieldsEditPage = new CustomFieldsDisplayPage {
                        AutoScroll = true
                    });
                }

                if (is_vm)
                {
                    ShowTab(VCpuMemoryEditPage     = new CPUMemoryEditPage());
                    ShowTab(StartupOptionsEditPage = new BootOptionsEditPage());
                    VMHAEditPage            = new VMHAEditPage();
                    VMHAEditPage.Populated += EditPage_Populated;
                    ShowTab(VMHAEditPage);
                }

                if (is_vm || is_host || is_sr)
                {
                    if (Helpers.FeatureForbidden(xenObjectCopy, Host.RestrictAlerts))
                    {
                        PerfmonAlertUpsellEditPage = new UpsellPage
                        {
                            Image     = Images.StaticImages._000_Alert2_h32bit_16,
                            Text      = Messages.ALERTS,
                            BlurbText = HiddenFeatures.LinkLabelHidden
                                ? Messages.UPSELL_BLURB_ALERTS
                                : Messages.UPSELL_BLURB_ALERTS + Messages.UPSELL_BLURB_TRIAL,
                            LearnMoreUrl = InvisibleMessages.UPSELL_LEARNMOREURL_TRIAL
                        };

                        ShowTab(PerfmonAlertUpsellEditPage);
                    }
                    else
                    {
                        ShowTab(PerfmonAlertEditPage = new PerfmonAlertEditPage {
                            AutoScroll = true
                        });
                    }
                }

                if (is_pool_or_standalone)
                {
                    if (Helpers.FeatureForbidden(xenObjectCopy, Host.RestrictAlerts))
                    {
                        PerfmonAlertOptionsUpsellEditPage = new UpsellPage
                        {
                            Image     = Images.StaticImages._000_Email_h32bit_16,
                            Text      = Messages.EMAIL_OPTIONS,
                            BlurbText = HiddenFeatures.LinkLabelHidden
                                ? Messages.UPSELL_BLURB_ALERTS
                                : Messages.UPSELL_BLURB_ALERTS + Messages.UPSELL_BLURB_TRIAL,
                            LearnMoreUrl = InvisibleMessages.UPSELL_LEARNMOREURL_TRIAL
                        };
                        ShowTab(PerfmonAlertOptionsUpsellEditPage);
                    }
                    else
                    {
                        ShowTab(PerfmonAlertOptionsEditPage = new PerfmonAlertOptionsPage());
                    }
                }

                if (is_host)
                {
                    ShowTab(hostMultipathPage1     = new HostMultipathPage());
                    ShowTab(LogDestinationEditPage = new LogDestinationEditPage());
                }

                if (is_host || is_pool)
                {
                    ShowTab(HostPowerONEditPage = new HostPowerONEditPage());
                }

                if ((is_pool_or_standalone && Helpers.VGpuCapability(xenObjectCopy.Connection)) ||
                    (is_host && ((Host)xenObjectCopy).CanEnableDisableIntegratedGpu()))
                {
                    ShowTab(PoolGpuEditPage = new PoolGpuEditPage());
                }

                if (is_pool_or_standalone && !Helpers.FeatureForbidden(xenObject.Connection, Host.RestrictSslLegacySwitch) && !Helpers.StockholmOrGreater(connection))
                {
                    ShowTab(SecurityEditPage = new SecurityEditPage());
                }

                if (is_pool_or_standalone && !Helpers.FeatureForbidden(xenObject.Connection, Host.RestrictLivePatching))
                {
                    ShowTab(LivePatchingEditPage = new LivePatchingEditPage());
                }

                if (is_pool_or_standalone && !Helpers.FeatureForbidden(xenObject.Connection, Host.RestrictIGMPSnooping) && Helpers.GetMaster(pool).vSwitchNetworkBackend())
                {
                    ShowTab(NetworkOptionsEditPage = new NetworkOptionsEditPage());
                }

                if (is_pool_or_standalone && !Helpers.FeatureForbidden(xenObject.Connection, Host.RestrictCorosync))
                {
                    ShowTab(ClusteringEditPage = new ClusteringEditPage());
                }

                if (is_network)
                {
                    ShowTab(editNetworkPage = new EditNetworkPage());
                }

                if (is_vm && !wlb_enabled)
                {
                    ShowTab(HomeServerPage = new HomeServerEditPage());
                }

                if (is_vm && ((VM)xenObjectCopy).CanHaveGpu())
                {
                    if (Helpers.FeatureForbidden(xenObjectCopy, Host.RestrictGpu))
                    {
                        GpuUpsellEditPage = new UpsellPage
                        {
                            Image     = Images.StaticImages._000_GetMemoryInfo_h32bit_16,
                            Text      = Messages.GPU,
                            BlurbText = HiddenFeatures.LinkLabelHidden
                                ? Messages.UPSELL_BLURB_GPU
                                : Messages.UPSELL_BLURB_GPU + Messages.UPSELL_BLURB_TRIAL,
                            LearnMoreUrl = InvisibleMessages.UPSELL_LEARNMOREURL_TRIAL
                        };
                        ShowTab(GpuUpsellEditPage);
                    }
                    else
                    {
                        ShowTab(GpuEditPage = new GpuEditPage());
                    }
                }

                if (is_hvm && !is_template && !Helpers.FeatureForbidden(xenObjectCopy, Host.RestrictUsbPassthrough) &&
                    pool.Connection.Cache.Hosts.Any(host => host.PUSBs.Count > 0))
                {
                    usbEditPage            = new USBEditPage();
                    usbEditPage.Populated += EditPage_Populated;
                    ShowTab(usbEditPage);
                }

                if (is_hvm)
                {
                    ShowTab(VMAdvancedEditPage = new VMAdvancedEditPage());
                }

                if (is_vm && Helpers.ContainerCapability(xenObject.Connection) && ((VM)xenObjectCopy).CanBeEnlightened())
                {
                    ShowTab(VMEnlightenmentEditPage = new VMEnlightenmentEditPage());
                }

                if (is_vm && Helpers.ContainerCapability(xenObject.Connection) && ((VM)xenObjectCopy).CanHaveCloudConfigDrive())
                {
                    ShowTab(CloudConfigParametersPage = new Page_CloudConfigParameters());
                }

                if (is_VMSS)
                {
                    ShowTab(newVMSSVMsPage1 = new NewVMGroupVMsPage <VMSS> {
                        Pool = pool
                    });
                    ShowTab(newPolicyVMSSTypePage1  = new NewPolicySnapshotTypePage());
                    newPolicySnapshotFrequencyPage1 = new NewPolicySnapshotFrequencyPage {
                        Connection = pool.Connection
                    };
                    newPolicySnapshotFrequencyPage1.Populated += EditPage_Populated;
                    ShowTab(newPolicySnapshotFrequencyPage1);
                }

                if (is_VM_appliance)
                {
                    ShowTab(newVMApplianceVMsPage1 = new NewVMGroupVMsPage <VM_appliance> {
                        Pool = pool
                    });
                    ShowTab(newVmApplianceVmOrderAndDelaysPage1 = new NewVMApplianceVMOrderAndDelaysPage {
                        Pool = pool
                    });
                }

                if (is_sr && ((SR)xenObjectCopy).SupportsReadCaching() && !Helpers.FeatureForbidden(xenObjectCopy, Host.RestrictReadCaching))
                {
                    ShowTab(SrReadCachingEditPage = new SrReadCachingEditPage());
                }

                //
                // Now add one tab per VBD (for VDIs only)
                //

                if (!is_vdi)
                {
                    return;
                }

                ShowTab(vdiSizeLocation = new VDISizeLocationPage());

                VDI vdi = xenObjectCopy as VDI;

                List <VBDEditPage> vbdEditPages = new List <VBDEditPage>();

                foreach (VBD vbd in vdi.Connection.ResolveAll(vdi.VBDs))
                {
                    VBDEditPage editPage = new VBDEditPage();

                    editPage.SetXenObjects(null, vbd);
                    vbdEditPages.Add(editPage);
                    ShowTab(editPage);
                }

                if (vbdEditPages.Count <= 0)
                {
                    return;
                }

                using (var dialog = new ActionProgressDialog(
                           new DelegatedAsyncAction(vdi.Connection, Messages.DEVICE_POSITION_SCANNING,
                                                    Messages.DEVICE_POSITION_SCANNING, Messages.DEVICE_POSITION_SCANNED,
                                                    delegate(Session session)
                {
                    foreach (VBDEditPage page in vbdEditPages)
                    {
                        page.UpdateDevicePositions(session);
                    }
                }),
                           ProgressBarStyle.Continuous))
                {
                    dialog.ShowCancel = true;
                    dialog.ShowDialog(Program.MainWindow);
                }
            }
            finally
            {
                ContentPanel.ResumeLayout();
                verticalTabs.EndUpdate();
                verticalTabs.SelectedIndex = 0;
            }
        }
        private void Build()
        {
            var pool = Helpers.GetPoolOfOne(connection);

            bool is_host = xenObjectCopy is Host;
            bool is_vm   = xenObjectCopy is VM && !((VM)xenObjectCopy).is_a_snapshot;
            bool is_sr   = xenObjectCopy is SR;

            bool is_pool    = xenObjectCopy is Pool;
            bool is_vdi     = xenObjectCopy is VDI;
            bool is_network = xenObjectCopy is XenAPI.Network;

            bool is_hvm     = is_vm && ((VM)xenObjectCopy).IsHVM;
            bool is_in_pool = Helpers.GetPool(xenObjectCopy.Connection) != null;

            bool is_pool_or_standalone = is_pool || (is_host && !is_in_pool);

            bool wlb_enabled = (Helpers.WlbEnabledAndConfigured(xenObjectCopy.Connection));

            bool is_VMPP = xenObjectCopy is VMPP;

            bool is_VM_appliance = xenObjectCopy is VM_appliance;

            ContentPanel.SuspendLayout();
            verticalTabs.BeginUpdate();

            try
            {
                verticalTabs.Items.Clear();

                ShowTab(GeneralEditPage = new GeneralEditPage());

                if (!is_VMPP && !is_VM_appliance)
                {
                    ShowTab(CustomFieldsEditPage = new CustomFieldsDisplayPage {
                        AutoScroll = true
                    });
                }

                if (is_vm)
                {
                    ShowTab(VCpuMemoryEditPage     = new CPUMemoryEditPage());
                    ShowTab(StartupOptionsEditPage = new BootOptionsEditPage());

                    if (!Helpers.BostonOrGreater(xenObjectCopy.Connection) && Helpers.FeatureForbidden(xenObjectCopy, Host.RestrictHAFloodgate))
                    {
                        VMHAUpsellEditPage = new UpsellPage {
                            Image = Properties.Resources._001_PowerOn_h32bit_16, Text = Messages.START_UP_OPTIONS
                        };
                        VMHAUpsellEditPage.SetAllTexts(Messages.UPSELL_BLURB_HA, InvisibleMessages.UPSELL_LEARNMOREURL_HA);
                        ShowTab(VMHAUpsellEditPage);
                    }
                    else
                    {
                        ShowTab(VMHAEditPage = new VMHAEditPage {
                            VerticalTabs = verticalTabs
                        });
                    }
                }

                if (is_vm || is_host || (is_sr && Helpers.ClearwaterOrGreater(connection)))
                {
                    if (Helpers.FeatureForbidden(xenObjectCopy, Host.RestrictAlerts))
                    {
                        PerfmonAlertUpsellEditPage = new UpsellPage {
                            Image = Properties.Resources._000_Alert2_h32bit_16, Text = Messages.ALERTS
                        };
                        PerfmonAlertUpsellEditPage.SetAllTexts(Messages.UPSELL_BLURB_ALERTS, InvisibleMessages.UPSELL_LEARNMOREURL_ALERTS);
                        ShowTab(PerfmonAlertUpsellEditPage);
                    }
                    else
                    {
                        ShowTab(PerfmonAlertEditPage = new PerfmonAlertEditPage {
                            AutoScroll = true
                        });
                    }
                }

                if (is_pool_or_standalone)
                {
                    if (Helpers.FeatureForbidden(xenObjectCopy, Host.RestrictAlerts))
                    {
                        PerfmonAlertOptionsUpsellEditPage = new UpsellPage {
                            Image = Properties.Resources._000_Email_h32bit_16, Text = Messages.EMAIL_OPTIONS
                        };
                        PerfmonAlertOptionsUpsellEditPage.SetAllTexts(Messages.UPSELL_BLURB_ALERTS, InvisibleMessages.UPSELL_LEARNMOREURL_ALERTS);
                        ShowTab(PerfmonAlertOptionsUpsellEditPage);
                    }
                    else
                    {
                        ShowTab(PerfmonAlertOptionsEditPage = new PerfmonAlertOptionsPage());
                    }

                    if (!Helpers.FeatureForbidden(xenObjectCopy, Host.RestrictStorageChoices) &&
                        !Helpers.BostonOrGreater(xenObjectCopy.Connection) &&
                        Helpers.MidnightRideOrGreater(xenObjectCopy.Connection))
                    {
                        ShowTab(StorageLinkPage = new StorageLinkEditPage());
                    }
                }

                if (is_host)
                {
                    ShowTab(hostMultipathPage1 = new HostMultipathPage());

                    if (Helpers.MidnightRideOrGreater(xenObject.Connection))
                    {
                        ShowTab(HostPowerONEditPage = new HostPowerONEditPage());
                    }

                    ShowTab(LogDestinationEditPage = new LogDestinationEditPage());
                }

                if (is_pool && Helpers.MidnightRideOrGreater(xenObject.Connection))
                {
                    ShowTab(PoolPowerONEditPage = new PoolPowerONEditPage());
                }

                if ((is_pool_or_standalone && Helpers.VGpuCapability(xenObjectCopy.Connection)) ||
                    (is_host && ((Host)xenObjectCopy).CanEnableDisableIntegratedGpu))
                {
                    ShowTab(PoolGpuEditPage = new PoolGpuEditPage());
                }

                if (is_network)
                {
                    ShowTab(editNetworkPage = new EditNetworkPage());
                }

                if (is_vm && !wlb_enabled)
                {
                    ShowTab(HomeServerPage = new HomeServerEditPage());
                }

                if (is_vm && ((VM)xenObjectCopy).CanHaveGpu)
                {
                    if (Helpers.BostonOrGreater(xenObject.Connection))
                    {
                        if (Helpers.FeatureForbidden(xenObjectCopy, Host.RestrictGpu))
                        {
                            GpuUpsellEditPage = new UpsellPage {
                                Image = Properties.Resources._000_GetMemoryInfo_h32bit_16, Text = Messages.GPU
                            };
                            GpuUpsellEditPage.SetAllTexts(Messages.UPSELL_BLURB_GPU, InvisibleMessages.UPSELL_LEARNMOREURL_GPU);
                            ShowTab(GpuUpsellEditPage);
                        }
                        else
                        {
                            ShowTab(GpuEditPage = new GpuEditPage());
                        }
                    }
                }

                if (is_hvm)
                {
                    ShowTab(VMAdvancedEditPage = new VMAdvancedEditPage());
                }

                if (is_vm && Helpers.ContainerCapability(xenObject.Connection) && ((VM)xenObjectCopy).CanBeEnlightened)
                {
                    ShowTab(VMEnlightenmentEditPage = new VMEnlightenmentEditPage());
                }

                if (is_vm && Helpers.ContainerCapability(xenObject.Connection) && ((VM)xenObjectCopy).CanHaveCloudConfigDrive)
                {
                    ShowTab(CloudConfigParametersPage = new Page_CloudConfigParameters());
                }

                if (is_VMPP)
                {
                    ShowTab(newPolicyVMsPage1 = new NewVMGroupVMsPage <VMPP> {
                        Pool = pool
                    });
                    ShowTab(newPolicySnapshotTypePage1      = new NewPolicySnapshotTypePage());
                    ShowTab(newPolicySnapshotFrequencyPage1 = new NewPolicySnapshotFrequencyPage {
                        Pool = pool
                    });
                    ShowTab(newPolicyArchivePage1 = new NewPolicyArchivePage {
                        Pool = pool, PropertiesDialog = this
                    });
                    ShowTab(newPolicyEmailPage1 = new NewPolicyEmailPage {
                        PropertiesDialog = this
                    });
                }

                if (is_VM_appliance)
                {
                    ShowTab(newVMApplianceVMsPage1 = new NewVMGroupVMsPage <VM_appliance> {
                        Pool = pool
                    });
                    ShowTab(newVmApplianceVmOrderAndDelaysPage1 = new NewVMApplianceVMOrderAndDelaysPage {
                        Pool = pool
                    });
                }

                //
                // Now add one tab per VBD (for VDIs only)
                //

                if (!is_vdi)
                {
                    return;
                }

                ShowTab(vdiSizeLocation = new VDISizeLocationPage());

                VDI vdi = xenObjectCopy as VDI;

                List <VBDEditPage> vbdEditPages = new List <VBDEditPage>();

                foreach (VBD vbd in vdi.Connection.ResolveAll(vdi.VBDs))
                {
                    VBDEditPage editPage = new VBDEditPage();

                    editPage.SetXenObjects(null, vbd);
                    vbdEditPages.Add(editPage);
                    ShowTab(editPage);
                }

                if (vbdEditPages.Count <= 0)
                {
                    return;
                }

                ActionProgressDialog dialog = new ActionProgressDialog(
                    new DelegatedAsyncAction(vdi.Connection, Messages.DEVICE_POSITION_SCANNING,
                                             Messages.DEVICE_POSITION_SCANNING, Messages.DEVICE_POSITION_SCANNED,
                                             delegate(Session session)
                {
                    foreach (VBDEditPage page in vbdEditPages)
                    {
                        page.UpdateDevicePositions(session);
                    }
                }),
                    ProgressBarStyle.Continuous);
                dialog.ShowCancel = true;
                dialog.ShowDialog(Program.MainWindow);
            }
            finally
            {
                ContentPanel.ResumeLayout();
                verticalTabs.EndUpdate();
                verticalTabs.SelectedIndex = 0;
            }
        }