Skip to content

Revert "[MaintenanceService] Added Support for InGuestPatch maintenance scope. (#15827) #15967

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Maintenance/Maintenance.Test/Maintenance.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.Maintenance" Version="1.4.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.Maintenance" Version="1.3.0" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions src/Maintenance/Maintenance.Test/ScenarioTests/Common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,17 @@ function Get-ProviderLocation($provider)

if ($location -eq $null)
{
return "eastus2euap"
return "westus"
} else
{
return $location.Locations[0].ToLower() -replace '\s',''
}
}

return "eastus2euap"
return "westus"
}

return "eastus2euap"
return "westus"
}

<#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,6 @@ public void TestMaintenanceConfiguration()
TestController.NewInstance.RunPowerShellTest(_logger, "Test-AzMaintenanceConfiguration");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestMaintenanceConfigurationInGuestPatch()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-AzMaintenanceConfigurationInGuestPatch");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestConfigurationAssignment()
Expand Down
166 changes: 18 additions & 148 deletions src/Maintenance/Maintenance.Test/ScenarioTests/MaintenanceTests.ps1

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

This file was deleted.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

9 changes: 3 additions & 6 deletions src/Maintenance/Maintenance.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31328.270
# Visual Studio 15
VisualStudioVersion = 15.0.27703.2042
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Maintenance", "Maintenance\Maintenance.csproj", "{0E11B67A-1257-40D0-BD33-8315759FDB01}"
EndProject
Expand Down Expand Up @@ -38,10 +39,6 @@ Global
{142D7B0B-388A-4CEB-A228-7F6D423C5C2E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{142D7B0B-388A-4CEB-A228-7F6D423C5C2E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{142D7B0B-388A-4CEB-A228-7F6D423C5C2E}.Release|Any CPU.Build.0 = Release|Any CPU
{6BD6B80A-06AF-4B5B-9230-69CCFC6C8D64}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6BD6B80A-06AF-4B5B-9230-69CCFC6C8D64}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6BD6B80A-06AF-4B5B-9230-69CCFC6C8D64}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6BD6B80A-06AF-4B5B-9230-69CCFC6C8D64}.Release|Any CPU.Build.0 = Release|Any CPU
{FF81DC73-B8EC-4082-8841-4FBF2B16E7CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FF81DC73-B8EC-4082-8841-4FBF2B16E7CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FF81DC73-B8EC-4082-8841-4FBF2B16E7CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
1 change: 0 additions & 1 deletion src/Maintenance/Maintenance/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
-->

## Upcoming Release
* Added Guest patch maintenance support.

## Version 1.1.1
* Bumped API version to stable 2021-05-01.
Expand Down
2 changes: 1 addition & 1 deletion src/Maintenance/Maintenance/Maintenance.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<ItemGroup>
<PackageReference Include="AutoMapper" Version="6.2.2" />
<PackageReference Include="Microsoft.Azure.Management.Maintenance" Version="1.4.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.Maintenance" Version="1.3.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
using Microsoft.Azure.Management.Maintenance;
using Microsoft.Azure.Management.Maintenance.Models;
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
Expand Down Expand Up @@ -86,74 +85,6 @@ public override void ExecuteCmdlet()
{
configuration.Visibility = this.Visibility;
}

if (this.InstallPatchRebootSetting != null)
{
configuration.InstallPatches = configuration.InstallPatches ?? new InputPatchConfiguration();
configuration.InstallPatches.RebootSetting = this.InstallPatchRebootSetting;
}

if (this.WindowParameterClassificationToInclude != null)
{
configuration.InstallPatches = configuration.InstallPatches ?? new InputPatchConfiguration();
configuration.InstallPatches.WindowsParameters = configuration.InstallPatches.WindowsParameters ?? new InputWindowsParameters();
configuration.InstallPatches.WindowsParameters.ClassificationsToInclude = this.WindowParameterClassificationToInclude.ToList();
}

if (this.WindowParameterExcludeKbRequiringReboot.HasValue)
{
configuration.InstallPatches = configuration.InstallPatches ?? new InputPatchConfiguration();
configuration.InstallPatches.WindowsParameters = configuration.InstallPatches.WindowsParameters ?? new InputWindowsParameters();
configuration.InstallPatches.WindowsParameters.ExcludeKbsRequiringReboot = this.WindowParameterExcludeKbRequiringReboot;
}

if (this.WindowParameterKbNumberToExclude != null)
{
configuration.InstallPatches = configuration.InstallPatches ?? new InputPatchConfiguration();
configuration.InstallPatches.WindowsParameters = configuration.InstallPatches.WindowsParameters ?? new InputWindowsParameters();
configuration.InstallPatches.WindowsParameters.KbNumbersToExclude = this.WindowParameterKbNumberToExclude.ToList();
}

if (this.WindowParameterKbNumberToInclude != null)
{
configuration.InstallPatches = configuration.InstallPatches ?? new InputPatchConfiguration();
configuration.InstallPatches.WindowsParameters = configuration.InstallPatches.WindowsParameters ?? new InputWindowsParameters();
configuration.InstallPatches.WindowsParameters.KbNumbersToInclude = this.WindowParameterKbNumberToInclude.ToList();
}

if (this.LinuxParameterClassificationToInclude!= null)
{
configuration.InstallPatches = configuration.InstallPatches ?? new InputPatchConfiguration();
configuration.InstallPatches.LinuxParameters = configuration.InstallPatches.LinuxParameters ?? new InputLinuxParameters();
configuration.InstallPatches.LinuxParameters.ClassificationsToInclude = this.LinuxParameterClassificationToInclude.ToList();
}

if (this.LinuxParameterPackageNameMaskToExclude != null)
{
configuration.InstallPatches = configuration.InstallPatches ?? new InputPatchConfiguration();
configuration.InstallPatches.LinuxParameters = configuration.InstallPatches.LinuxParameters ?? new InputLinuxParameters();
configuration.InstallPatches.LinuxParameters.PackageNameMasksToExclude= this.LinuxParameterPackageNameMaskToExclude.ToList();
}

if (this.LinuxParameterPackageNameMaskToInclude != null)
{
configuration.InstallPatches = configuration.InstallPatches ?? new InputPatchConfiguration();
configuration.InstallPatches.LinuxParameters = configuration.InstallPatches.LinuxParameters ?? new InputLinuxParameters();
configuration.InstallPatches.LinuxParameters.PackageNameMasksToInclude= this.LinuxParameterPackageNameMaskToInclude.ToList();
}

if (this.PreTask != null)
{
configuration.InstallPatches = configuration.InstallPatches ?? new InputPatchConfiguration();
configuration.InstallPatches.PreTasks = JsonConvert.DeserializeObject<List<TaskProperties>>(this.PreTask);
}

if (this.PostTask != null)
{
configuration.InstallPatches = configuration.InstallPatches ?? new InputPatchConfiguration();
configuration.InstallPatches.PreTasks = JsonConvert.DeserializeObject<List<TaskProperties>>(this.PostTask);
}

var result = MaintenanceConfigurationsClient.CreateOrUpdate(resourceGroupName, resourceName, configuration);
var psObject = new PSMaintenanceConfiguration();
MaintenanceAutomationAutoMapperProfile.Mapper.Map<MaintenanceConfiguration, PSMaintenanceConfiguration>(result, psObject);
Expand Down Expand Up @@ -232,55 +163,6 @@ public override void ExecuteCmdlet()
HelpMessage = "The Recurrence interval.")]
public string RecurEvery { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "List of packages to include during vm patch operation")]
public HashSet<string> LinuxParameterPackageNameMaskToInclude { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "List of packages to exclude during vm patch operation")]
public HashSet<string> LinuxParameterPackageNameMaskToExclude { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "List of linux patch classifications")]
public HashSet<string> LinuxParameterClassificationToInclude { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "List of KBs to include during vm patch operation")]
public HashSet<string> WindowParameterKbNumberToInclude { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "List of KBs to exclude during vm patch operationn")]
public HashSet<string> WindowParameterKbNumberToExclude { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "List of windows patch classification")]
public HashSet<string> WindowParameterClassificationToInclude { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "Exclude KBs which require reboot")]
public bool? WindowParameterExcludeKbRequiringReboot { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "List of tasks executed before schedule. e.g. [{'source' :'runbook', 'taskScope': 'Global', 'parameters': { 'arg1': 'value1'}}]")]
public string PreTask { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "List of tasks executed after schedule. [{'source' :'runbook', 'taskScope': 'Resource', 'parameters': { 'arg1': 'value1'}}]")]
public string PostTask { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "Install Patch Reboot Option. Allowed values Never, IfRequired, Always")]
public string InstallPatchRebootSetting { get; set; }

[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")]
public SwitchParameter AsJob { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ public override void ExecuteCmdlet()
if (!string.IsNullOrEmpty(resourceGroupName) && !string.IsNullOrEmpty(name))
{
var result = MaintenanceConfigurationsClient.Get(resourceGroupName, name);
PSMaintenanceConfiguration psMaintenanceConfiguration = new PSMaintenanceConfiguration();
MaintenanceAutomationAutoMapperProfile.Mapper.Map<MaintenanceConfiguration, PSMaintenanceConfiguration>(result, psMaintenanceConfiguration);
WriteObject(psMaintenanceConfiguration);
WriteObject(result);
}

else
Expand Down
75 changes: 4 additions & 71 deletions src/Maintenance/Maintenance/Models/MaintenanceAutoMapperProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
// ----------------------------------------------------------------------------------

using AutoMapper;
using System.Collections.Generic;
using System.Linq;
using FROM = Microsoft.Azure.Management.Maintenance.Models;
using TO = Microsoft.Azure.Commands.Maintenance.Models;

Expand Down Expand Up @@ -52,81 +50,16 @@ private static void Initialize()
var config = new MapperConfiguration(cfg =>
{
cfg.CreateMap<FROM.ApplyUpdate, TO.PSApplyUpdate>();
cfg.CreateMap<TO.PSApplyUpdate, FROM.ApplyUpdate>()
.ForMember(src => src.SystemData, s => s.Ignore());
cfg.CreateMap<TO.PSApplyUpdate, FROM.ApplyUpdate>();
cfg.CreateMap<FROM.ConfigurationAssignment, TO.PSConfigurationAssignment>();
cfg.CreateMap<TO.PSConfigurationAssignment, FROM.ConfigurationAssignment>()
.ForMember(src => src.SystemData, s => s.Ignore());
cfg.CreateMap<FROM.MaintenanceConfiguration, TO.PSMaintenanceConfiguration>()
.ForMember(dest => dest.InstallPatchRebootSetting, opt => opt.MapFrom(src => src.InstallPatches.RebootSetting))
.ForMember(dest => dest.LinuxParameterClassificationToInclude, opt => opt.MapFrom(src => src.InstallPatches.LinuxParameters.ClassificationsToInclude))
.ForMember(dest => dest.LinuxParameterPackageNameMaskToExclude, opt => opt.MapFrom(src => src.InstallPatches.LinuxParameters.PackageNameMasksToExclude))
.ForMember(dest => dest.LinuxParameterPackageNameMaskToInclude, opt => opt.MapFrom(src => src.InstallPatches.LinuxParameters.PackageNameMasksToInclude))
.ForMember(dest => dest.WindowParameterClassificationToInclude, opt => opt.MapFrom(src => src.InstallPatches.WindowsParameters.ClassificationsToInclude))
.ForMember(dest => dest.WindowParameterExcludeKbRequiringReboot, opt => opt.MapFrom(src => src.InstallPatches.WindowsParameters.ExcludeKbsRequiringReboot))
.ForMember(dest => dest.WindowParameterKbNumberToExclude, opt => opt.MapFrom(src => src.InstallPatches.WindowsParameters.KbNumbersToExclude))
.ForMember(dest => dest.WindowParameterKbNumberToInclude, opt => opt.MapFrom(src => src.InstallPatches.WindowsParameters.KbNumbersToInclude))
.ForMember(dest => dest.PreTask, opt => opt.MapFrom(src => src.InstallPatches.PreTasks))
.ForMember(dest => dest.PostTask, opt => opt.MapFrom(src => src.InstallPatches.PostTasks))
.ForMember(dest => dest.InstallPatchRebootSetting, opt => opt.MapFrom(src => src.InstallPatches.RebootSetting))
.ForSourceMember(src => src.SystemData, s => s.Ignore())
.ForSourceMember(src => src.InstallPatches, s => s.Ignore())
.ForPath(dst => dst.PostTask, s => s.Ignore())
.ForPath(dst => dst.PreTask, s => s.Ignore())
.AfterMap((src, dst) => {
if (src?.InstallPatches?.PreTasks?.Any() ?? false)
{
dst.PreTask = Newtonsoft.Json.JsonConvert.SerializeObject(src.InstallPatches.PreTasks);
}
if (src?.InstallPatches?.PostTasks?.Any() ?? false)
{
dst.PostTask = Newtonsoft.Json.JsonConvert.SerializeObject(src.InstallPatches.PostTasks);
}
});
cfg.CreateMap<TO.PSMaintenanceConfiguration, FROM.MaintenanceConfiguration>()
.ForPath(dest => dest.InstallPatches.LinuxParameters.ClassificationsToInclude, src => src.MapFrom(o => o.LinuxParameterClassificationToInclude))
.ForPath(dest => dest.InstallPatches.LinuxParameters.PackageNameMasksToInclude, src => src.MapFrom(o => o.LinuxParameterPackageNameMaskToInclude))
.ForPath(dest => dest.InstallPatches.LinuxParameters.PackageNameMasksToExclude, src => src.MapFrom(o => o.LinuxParameterPackageNameMaskToExclude))
.ForPath(dest => dest.InstallPatches.WindowsParameters.ClassificationsToInclude, src => src.MapFrom(o => o.WindowParameterClassificationToInclude))
.ForPath(dest => dest.InstallPatches.WindowsParameters.ExcludeKbsRequiringReboot, src => src.MapFrom(o => o.WindowParameterExcludeKbRequiringReboot))
.ForPath(dest => dest.InstallPatches.WindowsParameters.KbNumbersToExclude, src => src.MapFrom(o => o.WindowParameterKbNumberToExclude))
.ForPath(dest => dest.InstallPatches.WindowsParameters.KbNumbersToInclude, src => src.MapFrom(o => o.WindowParameterKbNumberToInclude))
.AfterMap((src, dst) => {
if (string.IsNullOrEmpty(src.InstallPatchRebootSetting) &&
string.IsNullOrEmpty(src.PostTask) &&
string.IsNullOrEmpty(src.PreTask) &&
!src.WindowParameterExcludeKbRequiringReboot.HasValue &&
IsEmpty(src.LinuxParameterClassificationToInclude) &&
IsEmpty(src.LinuxParameterPackageNameMaskToExclude) &&
IsEmpty(src.LinuxParameterPackageNameMaskToInclude) &&
IsEmpty(src.WindowParameterClassificationToInclude) &&
IsEmpty(src.WindowParameterKbNumberToExclude) &&
IsEmpty(src.WindowParameterKbNumberToInclude))
{
dst.InstallPatches = null;
}
else
{
if(string.IsNullOrEmpty(src.PreTask))
{
dst.InstallPatches.PreTasks = Newtonsoft.Json.JsonConvert.DeserializeObject<List<FROM.TaskProperties>>(src.PreTask);
dst.InstallPatches.PostTasks = Newtonsoft.Json.JsonConvert.DeserializeObject<List<FROM.TaskProperties>>(src.PostTask);
}
}
})
.ForPath(dest => dest.InstallPatches.PostTasks, s => s.Ignore())
.ForPath(dest => dest.InstallPatches.PreTasks, s => s.Ignore())
.ForMember(dest => dest.SystemData, s => s.Ignore());
cfg.CreateMap<TO.PSConfigurationAssignment, FROM.ConfigurationAssignment>();
cfg.CreateMap<FROM.MaintenanceConfiguration, TO.PSMaintenanceConfiguration>();
cfg.CreateMap<TO.PSMaintenanceConfiguration, FROM.MaintenanceConfiguration>();
cfg.CreateMap<FROM.Update, TO.PSUpdate>();
cfg.CreateMap<TO.PSUpdate, FROM.Update>();

});
_mapper = config.CreateMapper();
config.AssertConfigurationIsValid();
}
public static bool IsEmpty<T>(IEnumerable<T> collection)
{
return !(collection != null && collection.Any());
}
}
}
10 changes: 0 additions & 10 deletions src/Maintenance/Maintenance/Models/PSMaintenanceConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,6 @@ public partial class PSMaintenanceConfiguration
public string Timezone { get; set; }
public string Visibility { get; set; }
public string RecurEvery { get; set; }
public HashSet<string> LinuxParameterClassificationToInclude { get; set; }
public HashSet<string> LinuxParameterPackageNameMaskToExclude { get; set; }
public HashSet<string> LinuxParameterPackageNameMaskToInclude { get; set; }
public HashSet<string> WindowParameterKbNumberToInclude { get; set; }
public HashSet<string> WindowParameterKbNumberToExclude { get; set; }
public HashSet<string> WindowParameterClassificationToInclude { get; set; }
public bool? WindowParameterExcludeKbRequiringReboot { get; set; }
public string PreTask { get; set; }
public string PostTask { get; set; }
public string InstallPatchRebootSetting { get; set; }

}
}
Loading