示例#1
0
        protected override void FinishWizard()
        {
            var vmpp = new VMPP
            {
                name_label             = xenTabPagePolicy.PolicyName,
                name_description       = xenTabPagePolicy.PolicyDescription,
                backup_type            = xenTabPageSnapshotType.BackupType,
                backup_frequency       = xenTabPageSnapshotFrequency.Frequency,
                backup_schedule        = xenTabPageSnapshotFrequency.Schedule,
                backup_retention_value = xenTabPageSnapshotFrequency.BackupRetention,
                archive_frequency      = xenTabPageArchive.ArchiveFrequency,
                archive_target_config  = xenTabPageArchive.ArchiveConfig,
                archive_target_type    = xenTabPageArchive.ArchiveTargetType,
                archive_schedule       = xenTabPageArchive.Schedule,
                is_alarm_enabled       = xenTabPageEmail.EmailEnabled,
                alarm_config           = xenTabPageEmail.EmailSettings,
                is_policy_enabled      = xenTabPageVMsPage.SelectedVMs.Count == 0 ? false : true,
                Connection             = Pool.Connection
            };

            var action = new CreateVMPP(vmpp, xenTabPageVMsPage.SelectedVMs, xenTabPageFinish.RunNow);

            action.RunAsync();
            base.FinishWizard();
        }
示例#2
0
        protected override void Run()
        {
            try
            {
                Description = string.Format(Messages.ARCHIVING_SNAPSHOT_X, _snapshot.Name);
                RelatedTask = new XenRef <Task>(VMPP.archive_now(Session, _snapshot.opaque_ref));
                PollToCompletion();
                Description = string.Format(Messages.ARCHIVED_SNAPSHOT_X, _snapshot.Name);
            }
            catch (Exception e)
            {
                Failure f = e as Failure;
                if (f != null)
                {
                    string msg = "";
                    if (f.ErrorDescription.Count > 3)
                    {
                        msg = XenAPI.Message.FriendlyName(f.ErrorDescription[3]);
                    }

                    throw new Exception(msg);
                }
                throw;
            }
        }
示例#3
0
 public AssignVMsToPolicyAction(VMPP vmpp, List <XenRef <VM> > selectedVMs)
     : base(vmpp.Connection, Messages.ASSIGN_PROTECTION_POLICY_NOAMP)
 {
     _vmpp        = vmpp;
     _selectedVMs = selectedVMs;
     Pool         = Helpers.GetPool(vmpp.Connection);
 }
示例#4
0
 public RemoveVMsFromPolicyAction(VMPP vmpp, List <XenRef <VM> > selectedVMs)
     : base(vmpp.Connection, selectedVMs.Count == 1 ?
            string.Format(Messages.REMOVE_VM_FROM_POLICY, vmpp.Connection.Resolve(selectedVMs[0]), vmpp.Name)
     : string.Format(Messages.REMOVE_VMS_FROM_POLICY, vmpp.Name))
 {
     _selectedVMs = selectedVMs;
     Pool         = Helpers.GetPool(vmpp.Connection);
 }
示例#5
0
        public void Test4()
        {
            //Test when the day is today but the time did not pass with more than one day
            var time = VMPP.GetWeeklyDate(new DateTime(2010, 10, 20, 10, 00, 0), 10, 15, new List <DayOfWeek> {
                DayOfWeek.Wednesday, DayOfWeek.Monday
            });

            Assert.AreEqual(new DateTime(2010, 10, 20, 10, 15, 0), time);
        }
        protected override void Run()
        {
            bool value = !_vmpp.is_policy_enabled;

            Description = value ? string.Format(Messages.ENABLING_VMPP, _vmpp.Name) : string.Format(Messages.DISABLING_VMPP, _vmpp.Name);

            VMPP.set_is_policy_enabled(Session, _vmpp.opaque_ref, !_vmpp.is_policy_enabled);
            Description = value ? string.Format(Messages.ENABLED_VMPP, _vmpp.Name) : string.Format(Messages.DISABLED_VMPP, _vmpp.Name);
        }
示例#7
0
        private void RefreshTab(VMPP vmpp)
        {
            sectionLabelSchedule.LineColor = sectionLabelDest.LineColor =
                PropertiesDialog == null ? SystemColors.Window : SystemColors.ActiveBorder;

            switch (vmpp.archive_frequency)
            {
            case vmpp_archive_frequency.always_after_backup:
                radioButtonArchiveASAP.Checked = true;
                break;

            case vmpp_archive_frequency.daily:

                radioButtonArchiveDaily.Checked = true;
                dateTimePickerDaily.Value       = new DateTime(1970, 1, 1, Convert.ToInt32(vmpp.archive_schedule["hour"]),
                                                               Convert.ToInt32(vmpp.archive_schedule["min"]), 0);
                break;

            case vmpp_archive_frequency.weekly:

                radioButtonArchiveWeekly.Checked = true;
                dateTimePickerWeekly.Value       = new DateTime(1970, 1, 1, Convert.ToInt32(vmpp.archive_schedule["hour"]),
                                                                Convert.ToInt32(vmpp.archive_schedule["min"]), 0);
                daysWeekCheckboxes1.Days = vmpp.archive_schedule["days"];


                break;

            case vmpp_archive_frequency.never:
                radioButtonDoNotArchive.Checked = true;
                break;
            }
            if (vmpp.archive_frequency != vmpp_archive_frequency.never)
            {
                if (vmpp.archive_target_type == vmpp_archive_target_type.nfs)
                {
                    textBoxPath.Text = vmpp.archive_target_config_location;
                }
                else
                {
                    textBoxPath.Text = vmpp.archive_target_config_location;
                }
                if (vmpp.archive_target_type == vmpp_archive_target_type.cifs)
                {
                    if (vmpp.archive_target_config_username != "")
                    {
                        checkBoxCredentials.Checked = true;

                        textBoxUser.Text     = vmpp.archive_target_config_username;
                        textBoxPassword.Text = vmpp.archive_target_config_password_value;
                    }
                }
            }

            RefreshDailyEnabled(vmpp.backup_frequency);
            RefreshEnablementCheckBoxes();
        }
示例#8
0
        public void Test6()
        {
            //Today already past take next day in next week
            var time = VMPP.GetWeeklyDate(new DateTime(2010, 10, 20, 10, 30, 0), 10, 15, new List <DayOfWeek> {
                DayOfWeek.Wednesday, DayOfWeek.Monday
            });

            Assert.AreEqual(new DateTime(2010, 10, 25, 10, 15, 0), time);
        }
示例#9
0
        public void Test8()
        {
            //Check Sunday and unsorted list
            var time = VMPP.GetWeeklyDate(new DateTime(2010, 10, 24, 10, 16, 0), 10, 15, new List <DayOfWeek> {
                DayOfWeek.Sunday, DayOfWeek.Monday
            });

            Assert.AreEqual(new DateTime(2010, 10, 25, 10, 15, 0), time);
        }
示例#10
0
        public void Test1()
        {
            //Test when the day this week already past
            var time = VMPP.GetWeeklyDate(new DateTime(2010, 10, 20, 10, 59, 0), 10, 15, new List <DayOfWeek> {
                DayOfWeek.Tuesday
            });

            Assert.AreEqual(new DateTime(2010, 10, 26, 10, 15, 0), time);
        }
示例#11
0
        public void Test2()
        {
            //Test when the day is today but the time alreday past
            var time = VMPP.GetWeeklyDate(new DateTime(2010, 10, 20, 10, 59, 0), 10, 15, new List <DayOfWeek> {
                DayOfWeek.Wednesday
            });

            Assert.AreEqual(new DateTime(2010, 10, 27, 10, 15, 0), time);
        }
示例#12
0
        internal static AsyncAction VMCreateObjectAction(
            string _name_label,
            string _name_description,
            policy_backup_type _backup_type,
            policy_frequency _backup_frequency,
            Dictionary <string, string> _backup_schedule,
            long _backup_retention_value,
            vmpp_archive_frequency _archive_frequency,
            Dictionary <string, string> _archive_target_config,
            vmpp_archive_target_type _archive_target_type,
            Dictionary <string, string> _archive_schedule,
            bool _is_alarm_enabled,
            Dictionary <string, string> _alarm_config,
            bool _is_policy_enabled,
            List <VM> vms,
            bool runNow,
            IXenConnection _connection)
        {
            if (typeof(T) == typeof(VMPP))
            {
                var vmpp = new VMPP
                {
                    name_label             = _name_label,
                    name_description       = _name_description,
                    backup_type            = (vmpp_backup_type)_backup_type,
                    backup_frequency       = (vmpp_backup_frequency)_backup_frequency,
                    backup_schedule        = _backup_schedule,
                    backup_retention_value = _backup_retention_value,
                    archive_frequency      = _archive_frequency,
                    archive_target_config  = _archive_target_config,
                    archive_target_type    = _archive_target_type,
                    archive_schedule       = _archive_schedule,
                    is_alarm_enabled       = _is_alarm_enabled,
                    alarm_config           = _alarm_config,
                    is_policy_enabled      = _is_policy_enabled,
                    Connection             = _connection
                };
                return(new CreateVMPolicy <VMPP>(vmpp, vms, runNow));
            }
            else
            {
                var vmss = new VMSS
                {
                    name_label         = _name_label,
                    name_description   = _name_description,
                    type               = (vmss_type)_backup_type,
                    frequency          = (vmss_frequency)_backup_frequency,
                    schedule           = _backup_schedule,
                    retained_snapshots = _backup_retention_value,
                    enabled            = _is_policy_enabled,
                    Connection         = _connection
                };

                return(new CreateVMPolicy <VMSS>(vmss, vms, runNow));
            }
        }
示例#13
0
 private void RefreshTab(VMPP vmpp)
 {
     checkBox1.Checked = vmpp.is_alarm_enabled;
     if (vmpp.is_alarm_enabled)
     {
         textBoxSMTP.Text         = vmpp.alarm_config_smtp_server;
         textBoxPort.Text         = vmpp.alarm_config_smtp_port;
         textBoxEmailAddress.Text = vmpp.alarm_config_email_address;
     }
 }
示例#14
0
 public CreateVMPP(VMPP record, List <VM> vms, bool runNow)
     : base(record.Connection, Messages.CREATE_POLICY)
 {
     _record = record;
     _vms    = vms;
     _runNow = runNow;
     Pool    = Helpers.GetPool(record.Connection);
     ApiMethodsToRoleCheck.Add("VMPP.async_create");
     ApiMethodsToRoleCheck.Add("VM.set_protection_policy");
     ApiMethodsToRoleCheck.Add("VMPP.protect_now");
 }
示例#15
0
 public PolicyRow(VMPP policy)
 {
     Cells.Add(_name);
     Cells.Add(_status);
     Cells.Add(_numVMs);
     Cells.Add(_nextRunTime);
     Cells.Add(_nextArchiveRuntime);
     Cells.Add(_lastResult);
     VMPP = policy;
     RefreshRow();
 }
示例#16
0
 public void SetXenObjects(IXenObject orig, IXenObject clone)
 {
     if (_clone != null && clone == null)
     {
         RefreshDailyEnabled(_clone.backup_frequency);
         RefreshEnablementCheckBoxes();
     }
     else
     {
         _clone = (VMPP)clone;
         RefreshTab(_clone);
     }
 }
        private void RefreshTab(VMPP vmpp)
        {
            switch (vmpp.backup_type)
            {
            case vmpp_backup_type.checkpoint:
                radioButtonDiskAndMemory.Checked = true;
                break;

            case vmpp_backup_type.snapshot:
                radioButtonDiskOnly.Checked = true;
                break;
            }
            EnableShapshotTypes(vmpp.Connection);
        }
示例#18
0
 public void RefreshTab(VMPP vmpp)
 {
     _vmpp = vmpp;
     if (_vmpp == null)
     {
         labelHistory.Text = "";
         comboBox1.Enabled = false;
     }
     else
     {
         comboBox1.Enabled = true;
         RefreshGrid(_vmpp.RecentAlerts);
     }
 }
示例#19
0
 private void RefreshButtons()
 {
     if (dataGridView1.SelectedRows.Count == 1)
     {
         currentSelected          = (VMPP)((PolicyRow)dataGridView1.SelectedRows[0]).VMPP;
         buttonEnable.Text        = currentSelected.is_policy_enabled ? Messages.DISABLE : Messages.ENABLE;
         buttonEnable.Enabled     = currentSelected.VMs.Count == 0 && !currentSelected.is_policy_enabled ? false : true;
         buttonProperties.Enabled = true;
         buttonRunNow.Enabled     = currentSelected.is_policy_enabled && !currentSelected.is_backup_running && !currentSelected.is_archive_running;
     }
     else
     {
         currentSelected          = null;
         buttonProperties.Enabled = buttonEnable.Enabled = buttonRunNow.Enabled = false;
         policyHistory1.Clear();
     }
     policyHistory1.RefreshTab(currentSelected);
     buttonDelete.Enabled = (dataGridView1.SelectedRows.Count != 0);
 }
示例#20
0
        protected override void Run()
        {
            Description = string.Format(Messages.CREATING_VMPP, _record.Name);
            RelatedTask = VMPP.async_create(Session, _record);
            PollToCompletion();
            var vmppref = new XenRef <VMPP>(Result);

            Connection.WaitForCache(vmppref);
            foreach (var selectedVM in _vms)
            {
                VM.set_protection_policy(Session, selectedVM.opaque_ref, vmppref.opaque_ref);
            }
            Description     = string.Format(Messages.CREATED_VMPP, _record.Name);
            PercentComplete = 60;
            if (_runNow)
            {
                VMPP.protect_now(Session, vmppref);
            }
            PercentComplete = 100;
        }
        private void RefreshTab(VMPP vmpp)
        {
            if (ParentForm != null)
            {
                var parentFormType = ParentForm.GetType();

                if (parentFormType == typeof(XenWizardBase))
                {
                    sectionLabelSchedule.LineColor = sectionLabelNumber.LineColor = SystemColors.Window;
                }
                else if (parentFormType == typeof(PropertiesDialog))
                {
                    sectionLabelSchedule.LineColor = sectionLabelNumber.LineColor = SystemColors.ActiveBorder;
                }
            }

            switch (vmpp.backup_frequency)
            {
            case vmpp_backup_frequency.hourly:
                radioButtonHourly.Checked = true;
                SetHourlyMinutes(Convert.ToDecimal(vmpp.backup_schedule_min));
                break;

            case vmpp_backup_frequency.daily:
                radioButtonDaily.Checked  = true;
                dateTimePickerDaily.Value = new DateTime(1970, 1, 1, Convert.ToInt32(vmpp.backup_schedule_hour),
                                                         Convert.ToInt32(vmpp.backup_schedule_min), 0);
                break;

            case vmpp_backup_frequency.weekly:
                radioButtonWeekly.Checked  = true;
                dateTimePickerWeekly.Value = new DateTime(1970, 1, 1, Convert.ToInt32(vmpp.backup_schedule_hour),
                                                          Convert.ToInt32(vmpp.backup_schedule_min), 0);
                daysWeekCheckboxes.Days = vmpp.backup_schedule_days;
                break;
            }

            numericUpDownRetention.Value = vmpp.backup_retention_value;
        }
 protected override void Run()
 {
     foreach (var vmpp in _selectedToDelete)
     {
         Description = string.Format(Messages.DELETING_VMPP, vmpp.Name);
         foreach (var vmref in vmpp.VMs)
         {
             VM.set_protection_policy(Session, vmref.opaque_ref, null);
         }
         try
         {
             VMPP.destroy(Session, vmpp.opaque_ref);
         }
         catch (Exception e)
         {
             if (!e.Message.StartsWith("Object has been deleted"))
             {
                 throw e;
             }
         }
     }
     Description = Messages.DELETED_VMPP;
 }
 public ChangePolicyEnabledAction(VMPP vmpp)
     : base(vmpp.Connection, string.Format(Messages.CHANGE_POLICY_STATUS, vmpp.Name))
 {
     _vmpp = vmpp;
     Pool  = Helpers.GetPool(vmpp.Connection);
 }
 public void SetXenObjects(IXenObject orig, IXenObject clone)
 {
     _clone = (VMPP)clone;
     RefreshTab(_clone);
 }
 protected override void Run()
 {
     Result      = VMPP.protect_now(Session, _vmpp.opaque_ref);
     Description = string.Format(Messages.RUN_POLICY_STARTED, _vmpp.Name);
 }
 public RunPolicyNowAction(VMPP vmpp)
     : base(vmpp.Connection, string.Format(Messages.RUN_POLICY, vmpp.Name))
 {
     _vmpp = vmpp;
     Pool  = Helpers.GetPool(vmpp.Connection);
 }
示例#27
0
 public void SetXenObjects(IXenObject orig, IXenObject clone)
 {
     _clone = (VMPP)clone;
     Pool   = Helpers.GetPoolOfOne(_clone.Connection);
     RefreshTab(_clone);
 }
示例#28
0
 public GetVMPPAlertsAction(VMPP vmpp, int hoursfromNow)
     : base(vmpp.Connection, "", true)
 {
     VMPP          = vmpp;
     _hoursFromNow = hoursfromNow;
 }
 private void RefreshTab(VMPP vmpp)
 {
     textBoxName.Text        = vmpp.Name;
     textBoxDescription.Text = vmpp.Description;
     labelwizard.Visible     = false;
 }