Ejemplo n.º 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;
        }
Ejemplo n.º 2
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_Cloud        = new Page_Cloud();
            page_6b_LunPerVdi = new LunPerVdiNewVMMappingPage {
                Connection = xenConnection
            };

            #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
                RBACWarningPage.WizardPermissionCheck 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
                RBACWarningPage.WizardPermissionCheck 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
                RBACWarningPage.WizardPermissionCheck 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, delegate
                    {
                        RefreshProgress();
                    });
                });

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

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