Esempio n. 1
0
        protected override void Run()
        {
            if (FullCopySR != null)
            {
                // VM.copy is the best call to make if all target disks are on the same SR.
                // however, if the target disks are on the same SR as the source disks, then the user is
                // given the choice of a fast-clone (VM.clone) or a full-copy (VM.copy) on the storage page of the wizard. If the
                // user chose a VM.clone, then FullCopySR will be null.

                RelatedTask = VM.async_copy(Session, Template.opaque_ref, HiddenVmName, FullCopySR.opaque_ref);
            }
            else
            {
                // if the target disks are on mixed storage or the user chose to a do a fast-clone on the storage
                // page then we end up here.

                RelatedTask = VM.async_clone(Session, Template.opaque_ref, HiddenVmName);
            }

            Description = string.Format(Messages.CLONING_TEMPLATE, Helpers.GetName(Template));
            PollToCompletion(0, 10);

            VM = Connection.WaitForCache(new XenRef <VM>(Result));

            ApplyRecommendationsForVendorDevice();
            CopyBiosStrings();
            SetXenCenterProperties();
            ProvisionVM();
            SetVMParams();
            SetVMBootParams();
            AddCdDrive();
            AddDisks();
            AddNetworks();
            XenAdminConfigManager.Provider.ShowObject(VM.opaque_ref);
            VM.IsBeingCreated = false;
            PointOfNoReturn   = true;

            CloudCreateConfigDrive();

            AssignVgpu();

            if (StartAfter)
            {
                Description = Messages.STARTING_VM;
                var startAction = new VMStartAction(VM, _warningDialogHAInvalidConfig, _startDiagnosisForm);
                startAction.RunAsync();
            }

            Description = Messages.VM_SUCCESSFULLY_CREATED;
        }
Esempio n. 2
0
        protected override void Run()
        {
            ActionCountCompleted = 0;
            ActionCountTotal     = VmsToResume.Count + VmsToStart.Count;

            foreach (VM vm in VmsToResume)
            {
                Description = string.Format(Messages.ACTION_RESUMEANDSTARTVMS_RESUMINGN, ActionCountCompleted, VmsToResume.Count);

                AsyncAction action;
                if (CanVMBootOnHost(vm, Host))
                {
                    action = new VMResumeOnAction(vm, Host, _warningDialogHAInvalidConfig, _startDiagnosisForm);
                }
                else
                {
                    action = new VMResumeAction(vm, _warningDialogHAInvalidConfig, _startDiagnosisForm);
                }

                action.Changed += action_Changed;
                action.RunExternal(Session);
                ActionCountCompleted++;
            }

            foreach (VM vm in VmsToStart)
            {
                Description = string.Format(Messages.ACTION_RESUMEANDSTARTVMS_STARTINGN, ActionCountCompleted - VmsToResume.Count, VmsToStart.Count);

                AsyncAction action;
                if (CanVMBootOnHost(vm, Host))
                {
                    action = new VMStartOnAction(vm, Host, _warningDialogHAInvalidConfig, _startDiagnosisForm);
                }
                else
                {
                    action = new VMStartAction(vm, _warningDialogHAInvalidConfig, _startDiagnosisForm);
                }

                action.Changed += action_Changed;
                action.RunExternal(Session);
                ActionCountCompleted++;
            }
        }
 static void createAction_Completed(object sender, EventArgs e)
 {
     CreateVMFastAction action = (CreateVMFastAction) sender;
     var startAction = new VMStartAction(action.Connection.Resolve(new XenRef<VM>(action.Result)), VMOperationCommand.WarningDialogHAInvalidConfig, VMOperationCommand.StartDiagnosisForm);
     startAction.RunAsync();
 }
        protected override void Run()
        {
            ActionCountCompleted = 0;
            ActionCountTotal = VmsToResume.Count + VmsToStart.Count;

            foreach (VM vm in VmsToResume)
            {
                Description = string.Format("Resuming VM {0} of {1}", ActionCountCompleted, VmsToResume.Count);

                AsyncAction action;
                if (CanVMBootOnHost(vm, Host))
                    action = new VMResumeOnAction(vm, Host, _warningDialogHAInvalidConfig, _startDiagnosisForm);
                else
                    action = new VMResumeAction(vm, _warningDialogHAInvalidConfig, _startDiagnosisForm);

                action.Changed += action_Changed;
                action.RunExternal(Session);
                ActionCountCompleted++;
            }

            foreach (VM vm in VmsToStart)
            {
                Description = string.Format("Starting VM {0} of {1}", ActionCountCompleted - VmsToResume.Count, VmsToStart.Count);

                AsyncAction action;
                if (CanVMBootOnHost(vm, Host))
                    action = new VMStartOnAction(vm, Host, _warningDialogHAInvalidConfig, _startDiagnosisForm);
                else
                    action = new VMStartAction(vm, _warningDialogHAInvalidConfig, _startDiagnosisForm);

                action.Changed += action_Changed;
                action.RunExternal(Session);
                ActionCountCompleted++;
            }
        }
Esempio n. 5
0
        protected override void Run()
        {
            if (FullCopySR != null)
            {
                // VM.copy is the best call to make if all target disks are on the same SR.
                // however, if the target disks are on the same SR as the source disks, then the user is
                // given the choice of a fast-clone (VM.clone) or a full-copy (VM.copy) on the storage page of the wizard. If the
                // user chose a VM.clone, then FullCopySR will be null.

                RelatedTask = VM.async_copy(Session, Template.opaque_ref, HiddenVmName, FullCopySR.opaque_ref);
            }
            else
            {
                // if the target disks are on mixed storage or the user chose to a do a fast-clone on the storage
                // page then we end up here.

                RelatedTask = VM.async_clone(Session, Template.opaque_ref, HiddenVmName);
            }

            Description = string.Format(Messages.CLONING_TEMPLATE, Helpers.GetName(Template));
            PollToCompletion(0, 10);

            VM = Connection.WaitForCache(new XenRef<VM>(Result));

            CopyBiosStrings();
            SetXenCenterProperties();
            ProvisionVM();
            SetVMParams();
            SetVMBootParams();
            AddCdDrive();
            AddDisks();
            AddNetworks();
            XenAdminConfigManager.Provider.ShowObject(VM.opaque_ref);
            PointOfNoReturn = true;

            CloudCreateConfigDrive();

            AssignVgpu();

            if (StartAfter)
            {
                Description = Messages.STARTING_VM;
                var startAction = new VMStartAction(VM, _warningDialogHAInvalidConfig, _startDiagnosisForm);
                startAction.RunAsync();
            }

            Description = Messages.VM_SUCCESSFULLY_CREATED;
        }
        protected override void Run()
        {
            if (VmsToStart.Count == 0 && VmAppliancesToStart.Count == 0)
            {
                throw new Exception(Messages.ACTION_START_VMS_AND_APPLIANCES_NONE_SELECTED);
            }

            ActionCountCompleted = 0;
            ActionCountTotal = 100 / (VmsToStart.Count + VmAppliancesToStart.Count);

            foreach (VM vm in VmsToStart)
            {
                VMStartAbstractAction action;
                if (paused)
                    action = new VMStartPausedAction(vm, _warningDialogHAInvalidConfig, _startDiagnosisForm);
                else
                    action = new VMStartAction(vm, _warningDialogHAInvalidConfig, _startDiagnosisForm);
                Description = action.Title;
                action.Changed += action_Changed;
                action.RunExternal(Session);
                ActionCountCompleted++;
            }

            foreach (VM_appliance vmAppliance in VmAppliancesToStart)
            {
                var action = new StartApplianceAction(vmAppliance, paused);
                Description = action.Title;
                action.Changed += action_Changed;
                action.RunExternal(Session);
                ActionCountCompleted++;
            }
        }