示例#1
0
        public NewVMWizard(IXenConnection connection, VM template, Host affinity)
            : base(connection)
        {
            InitializeComponent();

            page_1_Template = new Page_Template();
            page_1b_BiosLocking = new Page_CopyBiosStrings();
            page_2_Name = new Page_Name();
            page_3_InstallationMedia = new Page_InstallationMedia();
            page_4_HomeServer = new Page_HomeServer();
            page_5_CpuMem = new Page_CpuMem();
            page_6_Storage = new Page_Storage();
            page_7_Networking = new Page_Networking();
            page_8_Finish = new Page_Finish();
            page_RbacWarning = new RBACWarningPage();
            page_6b_LunPerVdi = new LunPerVdiNewVMMappingPage { Connection = xenConnection };
            pageVgpu = new GpuEditPage();
            page_CloudConfigParameters = new Page_CloudConfigParameters();

            #region RBAC Warning Page Checks
            if (connection.Session.IsLocalSuperuser || Helpers.GetMaster(connection).external_auth_type == Auth.AUTH_TYPE_NONE)
            {
                //page_RbacWarning.DisableStep = true;
            }
            else
            {
                // Check to see if they can even create a VM
                var createCheck = new RBACWarningPage.WizardPermissionCheck(Messages.RBAC_WARNING_VM_WIZARD_BLOCK);
                foreach (RbacMethod method in CreateVMAction.StaticRBACDependencies)
                    createCheck.AddApiCheck(method);
                createCheck.Blocking = true;

                // Check to see if they can set memory values
                var memCheck = new RBACWarningPage.WizardPermissionCheck(Messages.RBAC_WARNING_VM_WIZARD_MEM);
                memCheck.AddApiCheck("vm.set_memory_limits");
                memCheck.WarningAction = new RBACWarningPage.PermissionCheckActionDelegate(delegate()
                {
                    // no point letting them continue
                    page_5_CpuMem.DisableMemoryControls();
                });

                // Check to see if they can set the VM's affinity
                var affinityCheck = new RBACWarningPage.WizardPermissionCheck(Messages.RBAC_WARNING_VM_WIZARD_AFFINITY);
                affinityCheck.ApiCallsToCheck.Add("vm.set_affinity");
                affinityCheck.WarningAction = new RBACWarningPage.PermissionCheckActionDelegate(delegate()
                {
                    page_4_HomeServer.DisableStep = true;
                    BlockAffinitySelection = true;
                    Program.Invoke(this, RefreshProgress);
                });

                page_RbacWarning.AddPermissionChecks(xenConnection, createCheck, affinityCheck, memCheck);

                if (Helpers.ClearwaterSp1OrGreater(xenConnection) && Helpers.GpuCapability(xenConnection))
                {
                    var vgpuCheck = new RBACWarningPage.WizardPermissionCheck(Messages.RBAC_WARNING_VM_WIZARD_GPU);
                    vgpuCheck.ApiCallsToCheck.Add("vgpu.create");
                    vgpuCheck.WarningAction = new RBACWarningPage.PermissionCheckActionDelegate(() =>
                    {
                        pageVgpu.DisableStep = true;
                        Program.Invoke(this, RefreshProgress);
                    });

                    page_RbacWarning.AddPermissionChecks(xenConnection, vgpuCheck);
                }

                AddPage(page_RbacWarning, 0);
            }
            #endregion

            page_8_Finish.SummaryRetreiver = GetSummary;

            AddPages(page_1_Template, page_2_Name, page_3_InstallationMedia, page_4_HomeServer,
                     page_5_CpuMem, page_6_Storage, page_7_Networking, page_8_Finish);

            m_affinity = affinity;
            page_1_Template.SelectedTemplate = template;
            page_1b_BiosLocking.Affinity = affinity;
            page_3_InstallationMedia.Affinity = affinity;
            page_4_HomeServer.Affinity = affinity;
            page_6_Storage.Affinity = affinity;
        }
示例#2
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_pool_or_standalone && Helpers.DundeeOrGreater(xenObject.Connection))
                    ShowTab(SecurityEditPage = new SecurityEditPage());

                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;
            }
        }