private void RefreshTab(VMSS policy)
        {
            /* when a policy does not have any VMs, irrespective of
             * the snapshot type, enable Quiesce
             */

            quiesceCheckBox.Enabled = (policy.VMs.Count == 0);

            switch (policy.type)
            {
            case vmss_type.checkpoint:
                radioButtonDiskAndMemory.Checked = true;
                quiesceCheckBox.Enabled          = false;
                break;

            case vmss_type.snapshot:
                radioButtonDiskOnly.Checked = true;
                break;

            case vmss_type.snapshot_with_quiesce:
                radioButtonDiskOnly.Checked = true;

                /* when the snapshot type itself is quiesce then we need to
                 * enable it irrespective of the number of VMs ( > 1 condition)
                 */

                quiesceCheckBox.Enabled = true;
                quiesceCheckBox.Checked = true;
                break;
            }
            EnableShapshotTypes(policy.Connection, quiesceCheckBox.Enabled);
        }
예제 #2
0
 public AssignVMsToPolicyAction(VMSS policy, List <XenRef <VM> > selectedVMs, bool suppressHistory)
     : base(policy.Connection, Messages.ASSIGN_VMSS_POLICY_NOAMP, suppressHistory)
 {
     _policy      = policy;
     _selectedVMs = selectedVMs;
     Pool         = Helpers.GetPool(policy.Connection);
 }
예제 #3
0
 public PolicyRow(VMSS policy, List <XenAPI.Message> alertMessages, DateTime?serverLocalTime)
 {
     Cells.AddRange(_name, _status, _numVMs, _nextRunTime, _lastResult);
     _policy          = policy;
     _alertMessages   = alertMessages;
     _serverLocalTime = serverLocalTime;
     RefreshRow();
 }
예제 #4
0
 public PolicyRow(VMSS policy, List <XenAPI.Message> alertMessages, ServerTimeInfo?serverTimeInfo)
 {
     Cells.AddRange(_name, _status, _numVMs, _nextRunClientLocal, _nextRunServerLocal, _lastResult);
     Policy              = policy;
     AlertMessages       = alertMessages;
     this.serverTimeInfo = serverTimeInfo;
     RefreshRow();
 }
예제 #5
0
        public void Test6()
        {
            //Today already past take next day in next week
            var time = VMSS.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);
        }
예제 #6
0
        public void Test4()
        {
            //Test when the day is today but the time did not pass with more than one day
            var time = VMSS.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);
        }
예제 #7
0
        public void Test2()
        {
            //Test when the day is today but the time alreday past
            var time = VMSS.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);
        }
예제 #8
0
        public void Test1()
        {
            //Test when the day this week already past
            var time = VMSS.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);
        }
예제 #9
0
        public void Test8()
        {
            //Check Sunday and unsorted list
            var time = VMSS.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
        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));
            }
        }
예제 #11
0
 public RemoveVMsFromPolicyAction(VMSS policy, List <XenRef <VM> > selectedVMs)
     : base(policy.Connection,
            selectedVMs.Count == 1 ?
            string.Format(Messages.REMOVE_VM_FROM_VMSS, policy.Connection.Resolve(selectedVMs[0]), policy.Name) :
            string.Format(Messages.REMOVE_VMS_FROM_VMSS, policy.Name))
 {
     _policy      = policy;
     _selectedVMs = selectedVMs;
     Pool         = Helpers.GetPool(policy.Connection);
 }
예제 #12
0
 public CreateVMPolicy(VMSS 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("VMSS.async_create");
     ApiMethodsToRoleCheck.Add("VM.set_snapshot_schedule");
     ApiMethodsToRoleCheck.Add("VMSS.snapshot_now");
 }
예제 #13
0
 public PolicyRow(VMSS policy)
 {
     Cells.Add(_name);
     Cells.Add(_status);
     Cells.Add(_numVMs);
     Cells.Add(_nextRunTime);
     Cells.Add(_nextArchiveRuntime);
     Cells.Add(_lastResult);
     _policy = policy;
     RefreshRow();
 }
예제 #14
0
        protected override void Run()
        {
            bool value = !_policy.enabled;

            Description = value ? string.Format(Messages.ENABLING_VMSS, _policy.Name()) :
                          string.Format(Messages.DISABLING_VMSS, _policy.Name());

            VMSS.set_enabled(Session, _policy.opaque_ref, !_policy.enabled);

            Description = value ? string.Format(Messages.ENABLED_VMSS, _policy.Name()) :
                          string.Format(Messages.DISABLED_VMSS, _policy.Name());
        }
예제 #15
0
 public void RefreshTab(VMSS policy)
 {
     _policy = policy;
     if (_policy == null)
     {
         labelHistory.Text = "";
         comboBox1.Enabled = false;
     }
     else
     {
         comboBox1.Enabled = true;
         StartRefreshTab();
     }
 }
예제 #16
0
        private void PopulateTab()
        {
            try
            {
                updating = true;

                if (_policyCopy == null || !_serverTimeInfo.HasValue)
                {
                    return;
                }

                var nextRunOnServer = _policyCopy.GetNextRunTime(_serverTimeInfo.Value.ServerLocalTime);
                if (!nextRunOnServer.HasValue)
                {
                    return;
                }

                var nextRunOnClient = HelpersGUI.RoundToNearestQuarter(nextRunOnServer.Value + _serverTimeInfo.Value.ServerClientTimeZoneDiff);

                switch (_policyCopy.frequency)
                {
                case vmss_frequency.hourly:
                    SetHourlyMinutes(nextRunOnClient.Minute);
                    radioButtonHourly.Checked = true;
                    break;

                case vmss_frequency.daily:
                    dateTimePickerDaily.Value = new DateTime(1970, 1, 1, nextRunOnClient.Hour, nextRunOnClient.Minute, 0);
                    radioButtonDaily.Checked  = true;
                    break;

                case vmss_frequency.weekly:
                    dateTimePickerWeekly.Value      = new DateTime(1970, 1, 1, nextRunOnClient.Hour, nextRunOnClient.Minute, 0);
                    daysWeekCheckboxes.SelectedDays = VMSS.BackUpScheduleDays(_policyCopy.schedule);
                    radioButtonWeekly.Checked       = true;
                    break;
                }

                numericUpDownRetention.Value = _policyCopy.retained_snapshots;
            }
            finally
            {
                updating = false;
                RecalculateSchedule();
            }
        }
예제 #17
0
        protected override void FinishWizard()
        {
            var vmss = new VMSS
            {
                name_label         = xenTabPagePolicy.PolicyName,
                name_description   = xenTabPagePolicy.PolicyDescription,
                type               = xenTabPageSnapshotType.BackupType,
                frequency          = xenTabPageSnapshotFrequency.Frequency,
                schedule           = xenTabPageSnapshotFrequency.Schedule,
                retained_snapshots = xenTabPageSnapshotFrequency.BackupRetention,
                enabled            = xenTabPageVMsPage.SelectedVMs.Count != 0,
                Connection         = Pool.Connection
            };

            var action = new CreateVMPolicy(vmss, xenTabPageVMsPage.SelectedVMs, xenTabPageFinish.RunNow);

            action.RunAsync();
            base.FinishWizard();
        }
예제 #18
0
        private void RefreshButtons()
        {
            if (dataGridView1.SelectedRows.Count == 1)
            {
                currentSelected          = ((PolicyRow)dataGridView1.SelectedRows[0])._policy;
                buttonEnable.Text        = currentSelected.enabled? Messages.DISABLE : Messages.ENABLE;
                buttonEnable.Enabled     = currentSelected.VMs.Count == 0 && !currentSelected.enabled? false : true;
                buttonProperties.Enabled = true;
                buttonRunNow.Enabled     = currentSelected.enabled && !currentSelected.is_running;
            }
            else
            {
                currentSelected          = null;
                buttonProperties.Enabled = buttonEnable.Enabled = buttonRunNow.Enabled = false;
                policyHistory1.Clear();
            }

            policyHistory1.RefreshTab(currentSelected);
            buttonDelete.Enabled = (dataGridView1.SelectedRows.Count != 0);
        }
예제 #19
0
        protected override void Run()
        {
            Description = string.Format(Messages.CREATING_VMSS, _record.Name());
            RelatedTask = VMSS.async_create(Session, _record);
            PollToCompletion();
            var vmssref = new XenRef <VMSS>(Result);

            Connection.WaitForCache(vmssref);
            foreach (var selectedVM in _vms)
            {
                VM.set_snapshot_schedule(Session, selectedVM.opaque_ref, vmssref.opaque_ref);
            }
            Description     = string.Format(Messages.CREATED_VMSS, _record.Name());
            PercentComplete = 60;
            if (_runNow)
            {
                VMSS.snapshot_now(Session, vmssref);
            }
            PercentComplete = 100;
        }
        private void RefreshTab(VMSS policy)
        {
            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 (policy.frequency)
            {
            case vmss_frequency.hourly:
                radioButtonHourly.Checked = true;
                SetHourlyMinutes(Convert.ToDecimal(policy.backup_schedule_min));
                break;

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

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

            numericUpDownRetention.Value = policy.retained_snapshots;
        }
 protected override void Run()
 {
     foreach (var policy in _selectedToDelete)
     {
         Description = string.Format(Messages.DELETING_VMSS, policy.Name());
         foreach (var vmref in policy.VMs)
         {
             VM.set_snapshot_schedule(Session, vmref.opaque_ref, null);
         }
         try
         {
             VMSS.destroy(Session, policy.opaque_ref);
         }
         catch (Exception e)
         {
             if (!e.Message.StartsWith("Object has been deleted"))
             {
                 throw e;
             }
         }
     }
     Description = Messages.DELETED_VMSS;
 }
예제 #22
0
 public ChangePolicyEnabledAction(VMSS policy)
     : base(policy.Connection, string.Format(Messages.CHANGE_POLICY_STATUS, policy.Name()))
 {
     _policy = policy;
     Pool    = Helpers.GetPool(_policy.Connection);
 }
예제 #23
0
 public GetVMSSAlertsAction(VMSS vmss, int hoursfromNow)
     : base(vmss.Connection, "", true)
 {
     VMSS          = vmss;
     _hoursFromNow = hoursfromNow;
 }
예제 #24
0
 public void SetXenObjects(IXenObject orig, IXenObject clone)
 {
     _policy = (VMSS)clone;
     EnableShapshotTypes(_policy.Connection);
 }
 public void SetXenObjects(IXenObject orig, IXenObject clone)
 {
     _policyCopy = (VMSS)clone;
     RefreshTab(_policyCopy);
 }
예제 #26
0
 protected override void Run()
 {
     Result      = VMSS.snapshot_now(Session, _policy.opaque_ref);
     Description = string.Format(Messages.RUN_POLICY_STARTED, _policy.Name);
 }
예제 #27
0
 public RunPolicyNowAction(VMSS policy)
     : base(policy.Connection, string.Format(Messages.RUN_POLICY, policy.Name))
 {
     _policy = policy;
     Pool    = Helpers.GetPool(policy.Connection);
 }
예제 #28
0
        private void RecalculateSchedule()
        {
            if (updating)
            {
                return;
            }

            Schedule = new Dictionary <string, string>();
            DateTime?nextRunOnClient = null;
            DateTime?nextRunOnServer = null;

            if (radioButtonHourly.Checked && int.TryParse(comboBoxMin.SelectedItem.ToString(), out int min))
            {
                SubText         = FormattedSchedule = string.Format(Messages.HOURLY_SCHEDULE_FORMAT, min);
                nextRunOnClient = VMSS.GetHourlyDate(DateTime.Now, min);

                if (_serverTimeInfo.HasValue)
                {
                    nextRunOnServer = HelpersGUI.RoundToNearestQuarter(nextRunOnClient.Value - _serverTimeInfo.Value.ServerClientTimeZoneDiff);
                    Schedule["min"] = nextRunOnServer.Value.Minute.ToString();
                }
            }
            else if (radioButtonDaily.Checked)
            {
                SubText = FormattedSchedule = string.Format(Messages.DAILY_SCHEDULE_FORMAT,
                                                            HelpersGUI.DateTimeToString(dateTimePickerDaily.Value, Messages.DATEFORMAT_HM, true));
                nextRunOnClient = VMSS.GetDailyDate(DateTime.Now, dateTimePickerDaily.Value.Minute, dateTimePickerDaily.Value.Hour);

                if (_serverTimeInfo.HasValue)
                {
                    nextRunOnServer  = HelpersGUI.RoundToNearestQuarter(nextRunOnClient.Value - _serverTimeInfo.Value.ServerClientTimeZoneDiff);
                    Schedule["hour"] = nextRunOnServer.Value.Hour.ToString();
                    Schedule["min"]  = nextRunOnServer.Value.Minute.ToString();
                }
            }
            else if (radioButtonWeekly.Checked && daysWeekCheckboxes.AnySelected())
            {
                var days        = daysWeekCheckboxes.SelectedDays;
                var longString  = string.Join(", ", days.Select(d => HelpersGUI.DayOfWeekToString(d)));
                var shortString = string.Join(", ", days.Select(d => HelpersGUI.DayOfWeekToShortString(d)));

                FormattedSchedule = string.Format(Messages.WEEKLY_SCHEDULE_FORMAT,
                                                  HelpersGUI.DateTimeToString(dateTimePickerWeekly.Value, Messages.DATEFORMAT_HM, true), longString);
                SubText = string.Format(Messages.WEEKLY_SCHEDULE_FORMAT,
                                        HelpersGUI.DateTimeToString(dateTimePickerWeekly.Value, Messages.DATEFORMAT_HM, true), shortString);

                var nextClientRuns = VMSS.GetWeeklyDates(DateTime.Now, dateTimePickerWeekly.Value.Minute,
                                                         dateTimePickerWeekly.Value.Hour, days);

                if (_serverTimeInfo.HasValue && nextClientRuns.Count > 0)
                {
                    nextRunOnClient = nextClientRuns[0];
                    var nextServerRuns = nextClientRuns.Select(n =>
                                                               HelpersGUI.RoundToNearestQuarter(n - _serverTimeInfo.Value.ServerClientTimeZoneDiff)).ToList();
                    nextRunOnServer = nextServerRuns[0];

                    Schedule["hour"] = nextRunOnServer.Value.Hour.ToString();
                    Schedule["min"]  = nextRunOnServer.Value.Minute.ToString();
                    Schedule["days"] = string.Join(",", nextServerRuns.Select(n => n.DayOfWeek.ToString())).ToLower();
                }
            }

            if (string.IsNullOrEmpty(FormattedSchedule))
            {
                FormattedSchedule = Messages.UNKNOWN;
            }
            if (string.IsNullOrEmpty(SubText))
            {
                SubText = Messages.UNKNOWN;
            }

            RefreshTime(nextRunOnServer, nextRunOnClient);
            OnPageUpdated();

            if (Populated != null)
            {
                Populated();
            }
        }
예제 #29
0
 public void SetXenObjects(IXenObject orig, IXenObject clone)
 {
     _policyCopy = (VMSS)clone;
     GetServerTime();
 }