Skip to content

Commit 3f12cbe

Browse files
committed
nodeConfiguraionByConfiguration & rollupstatus
1 parent e136749 commit 3f12cbe

File tree

5 files changed

+43
-37
lines changed

5 files changed

+43
-37
lines changed

src/ResourceManager/Automation/Commands.Automation/Cmdlet/GetAzureAutomationDscCompilationJob.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,30 +40,30 @@ public class GetAzureAutomationDscCompilationJob : AzureAutomationBaseCmdlet
4040
/// <summary>
4141
/// Gets or sets the runbook name of the job.
4242
/// </summary>
43-
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByConfigurationName, Mandatory = true, HelpMessage = "The configuration name of the job.")]
43+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByConfigurationName, Mandatory = true, HelpMessage = "The configuration name of the compilation job.")]
4444
[Alias("Name")]
4545
public string ConfigurationName { get; set; }
4646

4747
/// <summary>
4848
/// Gets or sets the status of a job.
4949
/// </summary>
50-
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByConfigurationName, Mandatory = false, HelpMessage = "The configuration name of the job.")]
50+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByConfigurationName, Mandatory = false, HelpMessage = "Filter jobs based on their status.")]
5151
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByAll, Mandatory = false, HelpMessage = "Filter jobs based on their status.")]
5252
[ValidateSet("Completed", "Failed", "Queued", "Starting", "Resuming", "Running", "Stopped", "Stopping", "Suspended", "Suspending", "Activating")]
5353
public string Status { get; set; }
5454

5555
/// <summary>
5656
/// Gets or sets the start time filter.
5757
/// </summary>
58-
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByConfigurationName, Mandatory = false, HelpMessage = "The configuration name of the job.")]
59-
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByAll, Mandatory = false, HelpMessage = "Filter jobs so that job start time >= StartTime.")]
58+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByConfigurationName, Mandatory = false, HelpMessage = "Filter compilation jobs so that the compilation job start time >= StartTime.")]
59+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByAll, Mandatory = false, HelpMessage = "Filter compilation jobs so that the compilation job start time >= StartTime.")]
6060
public DateTimeOffset? StartTime { get; set; }
6161

6262
/// <summary>
6363
/// Gets or sets the end time filter.
6464
/// </summary>
65-
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByConfigurationName, Mandatory = false, HelpMessage = "The configuration name of the job.")]
66-
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByAll, Mandatory = false, HelpMessage = "Filter jobs so that job end time <= EndTime.")]
65+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByConfigurationName, Mandatory = false, HelpMessage = "Filter compilation jobs so that the compilation job end time <= EndTime.")]
66+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByAll, Mandatory = false, HelpMessage = "Filter compilation jobs so that the compilation job end time <= EndTime.")]
6767
public DateTimeOffset? EndTime { get; set; }
6868

6969
/// <summary>

src/ResourceManager/Automation/Commands.Automation/Cmdlet/GetAzureAutomationDscCompilationJobOutput.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ public class GetAzureAutomationDscCompilationJobOutput : AzureAutomationBaseCmdl
3434
/// Gets or sets the job id
3535
/// </summary>
3636
[Alias("JobId")]
37-
[Parameter(Mandatory = true, Position = 2, ValueFromPipelineByPropertyName = true, HelpMessage = "The job Id")]
37+
[Parameter(Mandatory = true, Position = 2, ValueFromPipelineByPropertyName = true, HelpMessage = "The compilation job Id")]
3838
public Guid Id { get; set; }
3939

40-
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The stream type. Defaults to Any.")]
40+
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The stream type.")]
41+
[ValidateSet("Output", "Warning", "Error", "Debug", "Verbose", "Any")]
4142
public StreamType Stream { get; set; }
4243

4344
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Retrieves output created after this time")]

src/ResourceManager/Automation/Commands.Automation/Cmdlet/StartAzureAutomationDscCompilationJob.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace Microsoft.Azure.Commands.Automation.Cmdlet
2525
/// <summary>
2626
/// starts azure automation compilation job
2727
/// </summary>
28-
[Cmdlet(VerbsLifecycle.Start, "AzureAutomationDscCompilationJob", DefaultParameterSetName = AutomationCmdletParameterSets.ByConfigurationName)]
28+
[Cmdlet(VerbsLifecycle.Start, "AzureAutomationDscCompilationJob")]
2929
[OutputType(typeof(CompilationJob))]
3030
public class StartAzureAutomationDscCompilationJob : AzureAutomationBaseCmdlet
3131
{
@@ -38,7 +38,7 @@ public class StartAzureAutomationDscCompilationJob : AzureAutomationBaseCmdlet
3838
/// <summary>
3939
/// Gets or sets the configuration parameters.
4040
/// </summary>
41-
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The configuration parameters.")]
41+
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The compilation job parameters.")]
4242
public IDictionary Parameters { get; set; }
4343

4444
/// <summary>

src/ResourceManager/Automation/Commands.Automation/Common/AutomationClientDSC.cs

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -845,15 +845,7 @@ public Model.NodeConfiguration GetNodeConfiguration(string resourceGroupName, st
845845
string.Format(CultureInfo.CurrentCulture, Resources.NodeConfigurationNotFound, nodeConfigurationName));
846846
}
847847

848-
string computedRollupStatus = "Good";
849-
var nodes = this.ListDscNodesByNodeConfiguration(resourceGroupName, automationAccountName, nodeConfigurationName, null);
850-
foreach (var node in nodes)
851-
{
852-
if (node.Status.Equals("Not Compliant") || node.Status.Equals("Failed") || node.Status.Equals("Unresponsive"))
853-
{
854-
computedRollupStatus = "Bad";
855-
}
856-
}
848+
string computedRollupStatus = GetRollupStatus(resourceGroupName, automationAccountName, nodeConfigurationName);
857849

858850
if (string.IsNullOrEmpty(rollupStatus) || (rollupStatus != null && computedRollupStatus.Equals(rollupStatus)))
859851
{
@@ -883,9 +875,18 @@ public Model.NodeConfiguration GetNodeConfiguration(string resourceGroupName, st
883875
return new ResponseWithSkipToken<AutomationManagement.Models.DscNodeConfiguration>(response, response.DscNodeConfigurations);
884876
});
885877

886-
string computedRollUpStatus = "Good";
878+
var nodeConfigurations = new List<Model.NodeConfiguration>();
879+
foreach (var nodeConfiguration in nodeConfigModels)
880+
{
881+
string computedRollupStatus = GetRollupStatus(resourceGroupName, automationAccountName, nodeConfiguration.Name);
882+
883+
if (string.IsNullOrEmpty(rollupStatus) || (rollupStatus != null && computedRollupStatus.Equals(rollupStatus)))
884+
{
885+
nodeConfigurations.Add(new Model.NodeConfiguration(automationAccountName, nodeConfiguration, computedRollupStatus));
886+
}
887+
}
887888

888-
return nodeConfigModels.Select(nodeConfigModel => new Commands.Automation.Model.NodeConfiguration(automationAccountName, nodeConfigModel, computedRollUpStatus));
889+
return nodeConfigurations.AsEnumerable<Model.NodeConfiguration>();
889890
}
890891
}
891892

@@ -909,16 +910,8 @@ public Model.NodeConfiguration GetNodeConfiguration(string resourceGroupName, st
909910
var nodeConfigurations = new List<Model.NodeConfiguration>();
910911
foreach (var nodeConfiguration in nodeConfigModels)
911912
{
912-
string computedRollupStatus = "Good";
913-
var configName = nodeConfiguration.Configuration != null ? nodeConfiguration.Configuration.Name : null;
914-
var nodes = this.ListDscNodesByNodeConfiguration(resourceGroupName, automationAccountName, configName, null);
915-
foreach (var node in nodes)
916-
{
917-
if (node.Status.Equals("Not Compliant") || node.Status.Equals("Failed") || node.Status.Equals("Unresponsive"))
918-
{
919-
computedRollupStatus = "Bad";
920-
}
921-
}
913+
string computedRollupStatus = GetRollupStatus(resourceGroupName, automationAccountName, nodeConfiguration.Name);
914+
922915
if (string.IsNullOrEmpty(rollupStatus) || (rollupStatus != null && computedRollupStatus.Equals(rollupStatus)))
923916
{
924917
nodeConfigurations.Add(new Model.NodeConfiguration(automationAccountName, nodeConfiguration, computedRollupStatus));
@@ -929,6 +922,9 @@ public Model.NodeConfiguration GetNodeConfiguration(string resourceGroupName, st
929922
}
930923
}
931924

925+
#endregion
926+
927+
#region privatemethods
932928
/// <summary>
933929
/// Enumerate the list of NodeConfigurations for given configuration - without any rollup status
934930
/// </summary>
@@ -955,14 +951,23 @@ public Model.NodeConfiguration GetNodeConfiguration(string resourceGroupName, st
955951
return new ResponseWithSkipToken<AutomationManagement.Models.DscNodeConfiguration>(response, response.DscNodeConfigurations);
956952
});
957953

958-
959-
return nodeConfigModels.Select(nodeConfigModel => new Commands.Automation.Model.NodeConfiguration(automationAccountName, nodeConfigModel));
954+
return nodeConfigModels.Select(nodeConfigModel => new Commands.Automation.Model.NodeConfiguration(automationAccountName, nodeConfigModel, null));
960955
}
961956
}
962957

963-
#endregion
958+
private string GetRollupStatus(string resourceGroupName, string automationAccountName, string nodeConfigurationName)
959+
{
960+
var nodes = this.ListDscNodesByNodeConfiguration(resourceGroupName, automationAccountName, nodeConfigurationName, null);
961+
foreach (var node in nodes)
962+
{
963+
if (node.Status.Equals("Not Compliant") || node.Status.Equals("Failed") || node.Status.Equals("Unresponsive"))
964+
{
965+
return "Bad";
966+
}
967+
}
964968

965-
#region privatemethods
969+
return "Good";
970+
}
966971

967972
private string FormatDateTime(DateTimeOffset dateTime)
968973
{

src/ResourceManager/Automation/Commands.Automation/Model/JobStream.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
using System;
1616
using Microsoft.Azure.Commands.Automation.Common;
1717

18+
using AutomationManagement = Microsoft.Azure.Management.Automation;
19+
1820
namespace Microsoft.Azure.Commands.Automation.Model
1921
{
20-
using AutomationManagement = Microsoft.Azure.Management.Automation;
21-
2222
/// <summary>
2323
/// The Job Stream.
2424
/// </summary>

0 commit comments

Comments
 (0)