Skip to content

Commit 2066366

Browse files
committed
fixed few minor issues
1 parent 32a8ada commit 2066366

9 files changed

+97
-32
lines changed

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,15 @@ namespace Microsoft.Azure.Commands.Automation.Cmdlet
2626
/// <summary>
2727
/// Gets configuration script for given configuration name and account name.
2828
/// </summary>
29-
[Cmdlet(VerbsData.Export, "AzureAutomationDscConfiguration")]
29+
[Cmdlet(VerbsData.Export, "AzureAutomationDscConfiguration", DefaultParameterSetName = AutomationCmdletParameterSets.ByAll)]
3030
[OutputType(typeof(DirectoryInfo))]
3131
public class ExportAzureAutomationDscConfiguration : AzureAutomationBaseCmdlet
3232
{
33+
/// <summary>
34+
/// True to overwrite the existing dsc configuration; false otherwise.
35+
/// </summary>
36+
private bool overwriteExistingFile;
37+
3338
/// <summary>
3439
/// Gets or sets the configfuration name.
3540
/// </summary>
@@ -51,6 +56,16 @@ public class ExportAzureAutomationDscConfiguration : AzureAutomationBaseCmdlet
5156
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The folder where configuration script to be placed.")]
5257
public string OutputFolder { get; set; }
5358

59+
/// <summary>
60+
/// Gets or sets switch parameter to confirm overwriting of existing configuration script.
61+
/// </summary>
62+
[Parameter(Mandatory = false, HelpMessage = "Forces the command to run without asking for user confirmation and overwrites an existing configuration with same name.")]
63+
public SwitchParameter Force
64+
{
65+
get { return this.overwriteExistingFile; }
66+
set { this.overwriteExistingFile = value; }
67+
}
68+
5469
/// <summary>
5570
/// Execute this cmdlet.
5671
/// </summary>
@@ -59,7 +74,7 @@ public override void ExecuteCmdlet()
5974
{
6075
bool? isDraft = this.IsDraft();
6176

62-
var ret = this.AutomationClient.GetConfigurationContent(this.ResourceGroupName, this.AutomationAccountName, this.Name, isDraft, OutputFolder, true);
77+
var ret = this.AutomationClient.GetConfigurationContent(this.ResourceGroupName, this.AutomationAccountName, this.Name, isDraft, OutputFolder, this.Force);
6378

6479
this.WriteObject(ret, true);
6580
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace Microsoft.Azure.Commands.Automation.Cmdlet
2727
/// <summary>
2828
/// Gets node report for a given node and report id
2929
/// </summary>
30-
[Cmdlet(VerbsData.Export, "AzureAutomationDscNodeReportContent")]
30+
[Cmdlet(VerbsData.Export, "AzureAutomationDscNodeReportContent", DefaultParameterSetName = AutomationCmdletParameterSets.ByAll)]
3131
[OutputType(typeof(DirectoryInfo))]
3232
public class ExportAzureAutomationDscNodeReportContent : AzureAutomationBaseCmdlet
3333
{

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ public class GetAzureAutomationDscCompilationJobOutput : AzureAutomationBaseCmdl
3838
public Guid Id { get; set; }
3939

4040
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The stream type.")]
41-
[ValidateSet("Output", "Warning", "Error", "Debug", "Verbose", "Any")]
42-
public StreamType Stream { get; set; }
41+
[ValidateSet("Warning", "Error", "Debug", "Verbose", "Any")]
42+
public CompilationJobStreamType Stream { get; set; }
4343

4444
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Retrieves output created after this time")]
4545
public DateTimeOffset? StartTime { get; set; }
@@ -50,11 +50,6 @@ public class GetAzureAutomationDscCompilationJobOutput : AzureAutomationBaseCmdl
5050
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
5151
protected override void AutomationExecuteCmdlet()
5252
{
53-
if (Stream.Equals(StreamType.Progress))
54-
{
55-
Stream = StreamType.Any;
56-
}
57-
5853
var ret = this.AutomationClient.GetDscCompilationJobStream(this.ResourceGroupName, this.AutomationAccountName, this.Id, this.StartTime, this.Stream.ToString());
5954

6055
this.GenerateCmdletOutput(ret);

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ public class GetAzureAutomationDscNode : AzureAutomationBaseCmdlet
4242
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByName, Mandatory = false, HelpMessage = "Filter dsc nodes based on their status.")]
4343
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByNodeConfiguration, Mandatory = false, HelpMessage = "Filter dsc nodes based on their status.")]
4444
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByAll, Mandatory = false, HelpMessage = "Filter dsc nodes based on their status.")]
45-
[ValidateSet("Compliant", "Not Compliant", "Failed", "Pending", "Received", "Unresponsive")]
46-
public string Status { get; set; }
45+
[ValidateSet("Any", "Compliant", "Not Compliant", "Failed", "Pending", "Received", "Unresponsive")]
46+
public DscNodeStatus Status { get; set; }
4747

4848
/// <summary>
4949
/// Gets or sets the node name.
@@ -74,6 +74,12 @@ public override void ExecuteCmdlet()
7474
{
7575
IEnumerable<DscNode> ret = null;
7676

77+
var nodeStatus = this.Status.ToString();
78+
if (nodeStatus.Equals(DscNodeStatus.Any))
79+
{
80+
nodeStatus = string.Empty;
81+
}
82+
7783
if (this.ParameterSetName == AutomationCmdletParameterSets.ById)
7884
{
7985
ret = new List<DscNode>
@@ -87,28 +93,28 @@ public override void ExecuteCmdlet()
8793
this.ResourceGroupName,
8894
this.AutomationAccountName,
8995
this.Name,
90-
this.Status);
96+
nodeStatus);
9197
}
9298
else if (this.ParameterSetName == AutomationCmdletParameterSets.ByNodeConfiguration)
9399
{
94100
ret = this.AutomationClient.ListDscNodesByNodeConfiguration(
95101
this.ResourceGroupName,
96102
this.AutomationAccountName,
97103
this.NodeConfigurationName,
98-
this.Status);
104+
nodeStatus);
99105
}
100106
else if (this.ParameterSetName == AutomationCmdletParameterSets.ByConfigurationName)
101107
{
102108
ret = this.AutomationClient.ListDscNodesByConfiguration(
103109
this.ResourceGroupName,
104110
this.AutomationAccountName,
105111
this.ConfigurationName,
106-
this.Status);
112+
nodeStatus);
107113
}
108114
else
109115
{
110116
// ByAll
111-
ret = this.AutomationClient.ListDscNodes(this.ResourceGroupName, this.AutomationAccountName, this.Status);
117+
ret = this.AutomationClient.ListDscNodes(this.ResourceGroupName, this.AutomationAccountName, nodeStatus);
112118
}
113119

114120
this.GenerateCmdletOutput(ret);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public class StartAzureAutomationDscCompilationJob : AzureAutomationBaseCmdlet
3333
/// Gets or sets the configuration name.
3434
/// </summary>
3535
[Parameter(Position = 2, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The configuration name.")]
36+
[Alias("Name")]
3637
public string ConfigurationName { get; set; }
3738

3839
/// <summary>

src/ResourceManager/Automation/Commands.Automation/Commands.ResourceManagement.Automation.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@
145145
<Compile Include="Common\AutomationCmdletParameterSet.cs" />
146146
<Compile Include="Common\AzureAutomationOperationException.cs" />
147147
<Compile Include="Common\Constants.cs" />
148+
<Compile Include="Common\DscNodeStatus.cs" />
148149
<Compile Include="Common\IAutomationClient.cs" />
149150
<Compile Include="Common\PowerShellJsonConverter.cs" />
150151
<Compile Include="Common\RequestSettings.cs" />
@@ -181,7 +182,7 @@
181182
</Content>
182183
</ItemGroup>
183184
<ItemGroup>
184-
<Compile Include="Common\StreamType.cs" />
185+
<Compile Include="Common\CompilationJobStreamType.cs" />
185186
<None Include="MSSharedLibKey.snk" />
186187
<None Include="packages.config">
187188
<SubType>Designer</SubType>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ public Model.CompilationJob StartCompilationJob(string resourceGroupName, string
868868
}
869869
else
870870
{
871-
listParams.StreamType = StreamType.Any.ToString();
871+
listParams.StreamType = CompilationJobStreamType.Any.ToString();
872872
}
873873

874874
var jobStreams = this.automationManagementClient.JobStreams.List(resourceGroupName, automationAccountName, jobId, listParams).JobStreams;

src/ResourceManager/Automation/Commands.Automation/Common/StreamType.cs renamed to src/ResourceManager/Automation/Commands.Automation/Common/CompilationJobStreamType.cs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,12 @@ namespace Microsoft.Azure.Commands.Automation.Common
1818
/// <summary>
1919
/// StreamType enum represents the 6 types of Powershell Streams supported.
2020
/// </summary>
21-
public enum StreamType
21+
public enum CompilationJobStreamType
2222
{
2323
/// <summary>
24-
/// Indicates Progress Record streams
25-
/// </summary>
26-
Progress,
27-
28-
/// <summary>
29-
/// Indicates Output Record streams
24+
/// Indicates Generic stream. Used for querying all the streams regardless of the type.
3025
/// </summary>
31-
Output,
26+
Any,
3227

3328
/// <summary>
3429
/// Indicates Warning Record streams
@@ -48,11 +43,6 @@ public enum StreamType
4843
/// <summary>
4944
/// Indicates Verbose Record streams
5045
/// </summary>
51-
Verbose,
52-
53-
/// <summary>
54-
/// Indicates Generic stream. Used for querying all the streams regardless of the type.
55-
/// </summary>
56-
Any
46+
Verbose
5747
}
5848
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
namespace Microsoft.Azure.Commands.Automation.Common
16+
{
17+
/// <summary>
18+
/// DscNodeStatus enum represents the all the available states of the node while applying nodeconfiguration
19+
/// </summary>
20+
public enum DscNodeStatus
21+
{
22+
/// <summary>
23+
/// Indicates Generic status. used for queries all the nodes irrespective of state of the node.
24+
/// </summary>
25+
Any,
26+
27+
/// <summary>
28+
/// Indicates Compliant status.
29+
/// </summary>
30+
Compliant,
31+
32+
/// <summary>
33+
/// Indicates Not Compliant status.
34+
/// </summary>
35+
NotCompliant,
36+
37+
/// <summary>
38+
/// Indicates Failed status.
39+
/// </summary>
40+
Failed,
41+
42+
/// <summary>
43+
/// Indicates Pending status.
44+
/// </summary>
45+
Pending,
46+
47+
/// <summary>
48+
/// Indicates received status.
49+
/// </summary>
50+
Received,
51+
52+
/// <summary>
53+
/// Indicates Unresponsive status
54+
/// </summary>
55+
Unresponsive
56+
}
57+
}

0 commit comments

Comments
 (0)