Exemplo n.º 1
0
 /// <summary>
 /// The create weekly schedule options.
 /// </summary>
 /// <param name="schedule">
 /// The schedule.
 /// </param>
 /// <returns>
 /// The <see cref="WeeklyScheduleOptions"/>.
 /// </returns>
 private WeeklyScheduleOptions CreateWeeklyScheduleOptions(Microsoft.Azure.Management.Automation.Models.Schedule schedule)
 {
     return(schedule.Properties.AdvancedSchedule == null
         ? null
         : new WeeklyScheduleOptions()
     {
         DaysOfWeek = schedule.Properties.AdvancedSchedule.WeekDays
     });
 }
 /// <summary>
 /// Initializes a new instance of the ScheduleCreateParameters class
 /// with required arguments.
 /// </summary>
 public ScheduleCreateParameters(Schedule schedule)
     : this()
 {
     if (schedule == null)
     {
         throw new ArgumentNullException("schedule");
     }
     this.Schedule = schedule;
 }
Exemplo n.º 3
0
        internal SoftwareUpdateConfiguration(string resourceGroupName, string automationAccountName, Sdk.SoftwareUpdateConfiguration suc)
        {
            this.ResourceGroupName     = resourceGroupName;
            this.AutomationAccountName = automationAccountName;
            this.CreationTime          = suc.CreationTime;
            this.Description           = suc.ScheduleInfo.Description;
            this.ErrorInfo             = suc.Error == null ? null : new ErrorInfo
            {
                Code    = suc.Error.Code,
                Message = suc.Error.Message
            };
            this.LastModifiedTime  = suc.LastModifiedTime;
            this.Name              = suc.Name;
            this.ProvisioningState = suc.ProvisioningState;
            var schedule = new Sdk.Schedule
            {
                CreationTime            = suc.ScheduleInfo.CreationTime,
                Description             = suc.ScheduleInfo.Description,
                ExpiryTime              = suc.ScheduleInfo.ExpiryTime,
                ExpiryTimeOffsetMinutes = suc.ScheduleInfo.ExpiryTimeOffsetMinutes,
                Frequency            = suc.ScheduleInfo.Frequency,
                Interval             = suc.ScheduleInfo.Interval,
                IsEnabled            = suc.ScheduleInfo.IsEnabled,
                LastModifiedTime     = suc.ScheduleInfo.LastModifiedTime,
                AdvancedSchedule     = suc.ScheduleInfo.AdvancedSchedule,
                StartTime            = suc.ScheduleInfo.StartTime,
                TimeZone             = suc.ScheduleInfo.TimeZone,
                NextRun              = suc.ScheduleInfo.NextRun,
                NextRunOffsetMinutes = suc.ScheduleInfo.NextRunOffsetMinutes
            };

            this.ScheduleConfiguration = new Schedule(resourceGroupName, automationAccountName, schedule);

            this.UpdateConfiguration = new UpdateConfiguration
            {
                OperatingSystem      = (OperatingSystemType)suc.UpdateConfiguration.OperatingSystem,
                AzureVirtualMachines = suc.UpdateConfiguration.AzureVirtualMachines,
                NonAzureComputers    = suc.UpdateConfiguration.NonAzureComputerNames,
                Duration             = suc.UpdateConfiguration.Duration,
                Linux = suc.UpdateConfiguration.OperatingSystem == Sdk.OperatingSystemType.Windows ? null :
                        new LinuxConfiguration
                {
                    IncludedPackageClassifications = StringToEnumList <LinuxPackageClasses>(suc.UpdateConfiguration.Linux.IncludedPackageClassifications),
                    IncludedPackageNameMasks       = suc.UpdateConfiguration.Linux.IncludedPackageNameMasks,
                    ExcludedPackageNameMasks       = suc.UpdateConfiguration.Linux.ExcludedPackageNameMasks
                },
                Windows = suc.UpdateConfiguration.OperatingSystem == Sdk.OperatingSystemType.Linux ? null :
                          new WindowsConfiguration
                {
                    IncludedUpdateClassifications = StringToEnumList <WindowsUpdateClasses>(suc.UpdateConfiguration.Windows.IncludedUpdateClassifications),
                    IncludedKbNumbers             = suc.UpdateConfiguration.Windows.IncludedKbNumbers,
                    ExcludedKbNumbers             = suc.UpdateConfiguration.Windows.ExcludedKbNumbers
                }
            };
        }
Exemplo n.º 4
0
 /// <summary>
 /// The create monthly schedule options.
 /// </summary>
 /// <param name="schedule">
 /// The schedule.
 /// </param>
 /// <returns>
 /// The <see cref="MonthlyScheduleOptions"/>.
 /// </returns>
 private MonthlyScheduleOptions CreateMonthlyScheduleOptions(
     Microsoft.Azure.Management.Automation.Models.Schedule schedule)
 {
     return(schedule.Properties.AdvancedSchedule == null ||
            (schedule.Properties.AdvancedSchedule.MonthDays == null && schedule.Properties.AdvancedSchedule.MonthlyOccurrences == null)
         ? null
         : new MonthlyScheduleOptions()
     {
         DaysOfMonth = this.GetDaysOfMonth(schedule.Properties.AdvancedSchedule.MonthDays),
         DayOfWeek = this.IsMonthlyOccurrenceNull(schedule.Properties.AdvancedSchedule)
                 ? null
                 : new DayOfWeek()
         {
             Day = schedule.Properties.AdvancedSchedule.MonthlyOccurrences.First().Day,
             Occurrence = this.GetDayOfWeekOccurrence(schedule.Properties.AdvancedSchedule.MonthlyOccurrences.First().Occurrence)
         }
     });
 }
Exemplo n.º 5
0
 /// <summary>
 /// The create monthly schedule options.
 /// </summary>
 /// <param name="schedule">
 /// The schedule.
 /// </param>
 /// <returns>
 /// The <see cref="MonthlyScheduleOptions"/>.
 /// </returns>
 private MonthlyScheduleOptions CreateMonthlyScheduleOptions(
     Microsoft.Azure.Management.Automation.Models.Schedule schedule)
 {
     return(CreateMonthlyScheduleOptions(schedule.AdvancedSchedule));
 }
        internal SoftwareUpdateConfiguration(string resourceGroupName, string automationAccountName, Sdk.SoftwareUpdateConfiguration suc)
        {
            this.ResourceGroupName     = resourceGroupName;
            this.AutomationAccountName = automationAccountName;
            this.CreationTime          = suc.CreationTime;
            this.Description           = suc.ScheduleInfo.Description;
            this.ErrorInfo             = suc.Error == null ? null : new ErrorInfo
            {
                Code    = suc.Error.Code,
                Message = suc.Error.Message
            };
            this.LastModifiedTime  = suc.LastModifiedTime;
            this.Name              = suc.Name;
            this.ProvisioningState = suc.ProvisioningState;
            var schedule = new Sdk.Schedule
            {
                CreationTime            = suc.ScheduleInfo.CreationTime,
                Description             = suc.ScheduleInfo.Description,
                ExpiryTime              = suc.ScheduleInfo.ExpiryTime,
                ExpiryTimeOffsetMinutes = suc.ScheduleInfo.ExpiryTimeOffsetMinutes,
                Frequency            = suc.ScheduleInfo.Frequency,
                Interval             = suc.ScheduleInfo.Interval,
                IsEnabled            = suc.ScheduleInfo.IsEnabled,
                LastModifiedTime     = suc.ScheduleInfo.LastModifiedTime,
                AdvancedSchedule     = suc.ScheduleInfo.AdvancedSchedule,
                StartTime            = suc.ScheduleInfo.StartTime,
                TimeZone             = suc.ScheduleInfo.TimeZone,
                NextRun              = suc.ScheduleInfo.NextRun,
                NextRunOffsetMinutes = suc.ScheduleInfo.NextRunOffsetMinutes
            };

            this.Tasks = suc.Tasks != null ? new Tasks
            {
                PreTask = suc.Tasks.PreTask != null ? new Task {
                    source = suc.Tasks.PreTask.Source, parameters = suc.Tasks.PreTask.Parameters
                } : null,
                PostTask = suc.Tasks.PostTask != null ? new Task {
                    source = suc.Tasks.PostTask.Source, parameters = suc.Tasks.PostTask.Parameters
                } : null
            } : null;

            IList <AzureQueryProperties> azureQueries = null;

            if (suc.UpdateConfiguration != null && suc.UpdateConfiguration.Targets != null && suc.UpdateConfiguration.Targets.AzureQueries != null)
            {
                azureQueries = new List <AzureQueryProperties>();

                foreach (var query in suc.UpdateConfiguration.Targets.AzureQueries)
                {
                    var tags = new Dictionary <string, List <string> >();
                    if (query != null && query.TagSettings != null && query.TagSettings.Tags != null)
                    {
                        foreach (var tag in query.TagSettings.Tags)
                        {
                            tags.Add(tag.Key, new List <string>(tag.Value));
                        }
                    }
                    var azureQueryProperty = new AzureQueryProperties
                    {
                        Locations   = (query == null || query.Locations == null) ? null : query.Locations.ToArray(),
                        Scope       = (query == null || query.Scope == null) ? null : query.Scope.ToArray(),
                        TagSettings = (query == null || query.TagSettings == null) ? null : new TagSettings
                        {
                            Tags           = query.TagSettings.Tags == null ? null : tags,
                            FilterOperator = query.TagSettings.FilterOperator == null ? TagOperators.Any : (TagOperators)query.TagSettings.FilterOperator
                        }
                    };
                    azureQueries.Add(azureQueryProperty);
                }
            }

            IList <NonAzureQueryProperties> nonAzureQueries = null;

            if (suc.UpdateConfiguration != null && suc.UpdateConfiguration.Targets != null && suc.UpdateConfiguration.Targets.NonAzureQueries != null)
            {
                nonAzureQueries = new List <NonAzureQueryProperties>();

                foreach (var query in suc.UpdateConfiguration.Targets.NonAzureQueries)
                {
                    var nonAzureQuery = new NonAzureQueryProperties
                    {
                        FunctionAlias       = query.FunctionAlias,
                        WorkspaceResourceId = query.WorkspaceId
                    };
                    nonAzureQueries.Add(nonAzureQuery);
                }
            }

            var updateTarget = suc.UpdateConfiguration.Targets == null
                ? null
                : new UpdateTargets
            {
                AzureQueries    = azureQueries,
                NonAzureQueries = nonAzureQueries
            };

            this.ScheduleConfiguration = new Schedule(resourceGroupName, automationAccountName, schedule);

            this.UpdateConfiguration = new UpdateConfiguration
            {
                OperatingSystem      = (OperatingSystemType)suc.UpdateConfiguration.OperatingSystem,
                AzureVirtualMachines = suc.UpdateConfiguration.AzureVirtualMachines,
                NonAzureComputers    = suc.UpdateConfiguration.NonAzureComputerNames,
                Targets  = updateTarget,
                Duration = suc.UpdateConfiguration.Duration,
                Linux    = suc.UpdateConfiguration.OperatingSystem == Sdk.OperatingSystemType.Windows ? null :
                           new LinuxConfiguration
                {
                    IncludedPackageClassifications = StringToEnumList <LinuxPackageClasses>(suc.UpdateConfiguration.Linux.IncludedPackageClassifications),
                    IncludedPackageNameMasks       = suc.UpdateConfiguration.Linux.IncludedPackageNameMasks,
                    ExcludedPackageNameMasks       = suc.UpdateConfiguration.Linux.ExcludedPackageNameMasks,
                    rebootSetting = (RebootSetting)Enum.Parse(typeof(RebootSetting), suc.UpdateConfiguration.Linux.RebootSetting, true)
                },
                Windows = suc.UpdateConfiguration.OperatingSystem == Sdk.OperatingSystemType.Linux ? null :
                          new WindowsConfiguration
                {
                    IncludedUpdateClassifications = StringToEnumList <WindowsUpdateClasses>(suc.UpdateConfiguration.Windows.IncludedUpdateClassifications),
                    IncludedKbNumbers             = suc.UpdateConfiguration.Windows.IncludedKbNumbers,
                    ExcludedKbNumbers             = suc.UpdateConfiguration.Windows.ExcludedKbNumbers,
                    rebootSetting = (RebootSetting)Enum.Parse(typeof(RebootSetting), suc.UpdateConfiguration.Windows.RebootSetting, true)
                }
            };
        }
 public void UpdateSchedule(Schedule schedule)
 {
     AutomationClient.Schedules.Patch(resourceGroup, automationAccount, new  SchedulePatchParameters
     {
         Name = schedule.Name,
         Properties = new SchedulePatchProperties
         {
             IsEnabled = schedule.Properties.IsEnabled,
             Description = schedule.Properties.Description
         }
     });
 }