Skip to content

Commit 561fa8c

Browse files
Merge pull request #2 from psap/dev
Dsc Node, Dsc Configurations and Dsc MetaConfig cmdlets
2 parents e89a6f0 + cb6d075 commit 561fa8c

22 files changed

+1192
-125
lines changed

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,8 @@ namespace Microsoft.Azure.Commands.Automation.Cmdlet
2626
/// </summary>
2727
[Cmdlet(VerbsCommon.Get, "AzureAutomationRegistrationInfo")]
2828
[OutputType(typeof(AgentRegistration))]
29-
public class GetAzureAutomationAgentRegistrationInformation : AzureAutomationBaseCmdlet
29+
public class GetAzureAutomationRegistrationInfo : AzureAutomationBaseCmdlet
3030
{
31-
/// <summary>
32-
/// Gets or sets the automation account name.
33-
/// </summary>
34-
[Parameter(Position = 1, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The automation account name.")]
35-
[ValidateNotNullOrEmpty]
36-
public string AutomationAccountName { get; set; }
37-
3831
/// <summary>
3932
/// Execute this cmdlet.
4033
/// </summary>

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

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,8 @@ namespace Microsoft.Azure.Commands.Automation.Cmdlet
2626
/// </summary>
2727
[Cmdlet(VerbsCommon.Get, "AzureAutomationDscConfiguration", DefaultParameterSetName = AutomationCmdletParameterSets.ByAll)]
2828
[OutputType(typeof(DscConfiguration))]
29-
public class GetAzureAutomationConfiguration : AzureAutomationBaseCmdlet
29+
public class GetAzureAutomationDscConfiguration : AzureAutomationBaseCmdlet
3030
{
31-
/// <summary>
32-
/// Gets or sets the automation account name.
33-
/// </summary>
34-
[Parameter(Position = 1, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The automation account name.")]
35-
[ValidateNotNullOrEmpty]
36-
public string AutomationAccountName { get; set; }
37-
3831
/// <summary>
3932
/// Gets or sets the configuration name.
4033
/// </summary>
@@ -59,7 +52,7 @@ public override void ExecuteCmdlet()
5952
}
6053
else if (this.ParameterSetName == AutomationCmdletParameterSets.ByAll)
6154
{
62-
ret = this.AutomationClient.ListAutomationConfigurations(this.ResourceGroupName, this.AutomationAccountName);
55+
ret = this.AutomationClient.ListDscConfigurations(this.ResourceGroupName, this.AutomationAccountName);
6356
}
6457

6558
this.GenerateCmdletOutput(ret);

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,6 @@ namespace Microsoft.Azure.Commands.Automation.Cmdlet
3030
[OutputType(typeof(CompilationJob))]
3131
public class GetAzureAutomationDscCompilationJob : AzureAutomationBaseCmdlet
3232
{
33-
/// <summary>
34-
/// Gets or sets the automation account name.
35-
/// </summary>
36-
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The automation account name.")]
37-
[ValidateNotNullOrEmpty]
38-
public string AutomationAccountName { get; set; }
39-
4033
/// <summary>
4134
/// Gets or sets the job id.
4235
/// </summary>

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,6 @@ namespace Microsoft.Azure.Commands.Automation.Cmdlet
3030
[OutputType(typeof(JobStream))]
3131
public class GetAzureAutomationDscCompilationJobOutput : AzureAutomationBaseCmdlet
3232
{
33-
/// <summary>
34-
/// Gets or sets the automation account name.
35-
/// </summary>
36-
[Parameter(Position = 1, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The automation account name.")]
37-
[ValidateNotNullOrEmpty]
38-
public string AutomationAccountName { get; set; }
39-
4033
/// <summary>
4134
/// Gets or sets the job id
4235
/// </summary>
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
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+
using System;
16+
using System.Collections.Generic;
17+
using System.Management.Automation;
18+
using System.Security.Permissions;
19+
using Microsoft.Azure.Commands.Automation.Common;
20+
using Microsoft.Azure.Commands.Automation.Model;
21+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
22+
23+
namespace Microsoft.Azure.Commands.Automation.Cmdlet
24+
{
25+
/// <summary>
26+
/// Gets azure automation dsc node.
27+
/// </summary>
28+
[Cmdlet(VerbsCommon.Get, "AzureAutomationDscNode", DefaultParameterSetName = AutomationCmdletParameterSets.ByAll)]
29+
[OutputType(typeof(DscNode))]
30+
public class GetAzureAutomationDscNode : AzureAutomationBaseCmdlet
31+
{
32+
/// <summary>
33+
/// Gets or sets the job id.
34+
/// </summary>
35+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ById, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The dsc node id.")]
36+
[Alias("NodeId")]
37+
public Guid Id { get; set; }
38+
39+
/// <summary>
40+
/// Gets or sets the status of a dsc node.
41+
/// </summary>
42+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByName, Mandatory = false, HelpMessage = "Filter dsc nodes based on their status.")]
43+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByNodeConfiguration, Mandatory = false, HelpMessage = "Filter dsc nodes based on their status.")]
44+
[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; }
47+
48+
/// <summary>
49+
/// Gets or sets the node name.
50+
/// </summary>
51+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByName, Mandatory = true, ValueFromPipeline = true, HelpMessage = "The node name.")]
52+
[ValidateNotNullOrEmpty]
53+
public string Name { get; set; }
54+
55+
/// <summary>
56+
/// Gets or sets the nodeconfiguration name.
57+
/// </summary>
58+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByNodeConfiguration, Mandatory = true, HelpMessage = "The nodeconfiguration name.")]
59+
[ValidateNotNullOrEmpty]
60+
public string NodeConfigurationName { get; set; }
61+
62+
/// <summary>
63+
/// Execute this cmdlet.
64+
/// </summary>
65+
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
66+
public override void ExecuteCmdlet()
67+
{
68+
IEnumerable<DscNode> ret = null;
69+
70+
if (this.ParameterSetName == AutomationCmdletParameterSets.ById)
71+
{
72+
ret = new List<DscNode>
73+
{
74+
this.AutomationClient.GetDscNodeById(this.ResourceGroupName, this.AutomationAccountName, this.Id)
75+
};
76+
}
77+
else if (this.ParameterSetName == AutomationCmdletParameterSets.ByName)
78+
{
79+
ret = this.AutomationClient.ListDscNodesByName(
80+
this.ResourceGroupName,
81+
this.AutomationAccountName,
82+
this.Name,
83+
this.Status);
84+
}
85+
else if (this.ParameterSetName == AutomationCmdletParameterSets.ByNodeConfiguration)
86+
{
87+
ret = this.AutomationClient.ListDscNodesByNodeConfiguration(
88+
this.ResourceGroupName,
89+
this.AutomationAccountName,
90+
this.NodeConfigurationName,
91+
this.Status);
92+
}
93+
else
94+
{
95+
// ByAll
96+
ret = this.AutomationClient.ListDscNodes(this.ResourceGroupName, this.AutomationAccountName, this.Status);
97+
}
98+
99+
this.GenerateCmdletOutput(ret);
100+
}
101+
}
102+
}

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,6 @@ namespace Microsoft.Azure.Commands.Automation.Cmdlet
3030
[OutputType(typeof(CompilationJob))]
3131
public class GetAzureAutomationDscNodeConfiguration : AzureAutomationBaseCmdlet
3232
{
33-
/// <summary>
34-
/// Gets or sets the automation account name.
35-
/// </summary>
36-
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The automation account name.")]
37-
[ValidateNotNullOrEmpty]
38-
public string AutomationAccountName { get; set; }
39-
4033
/// <summary>
4134
/// Gets or sets the job id.
4235
/// </summary>
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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+
using System;
16+
using System.Collections.Generic;
17+
using System.Globalization;
18+
using System.IO;
19+
using System.Management.Automation;
20+
using System.Security.Permissions;
21+
using Microsoft.Azure.Commands.Automation.Common;
22+
using Microsoft.Azure.Commands.Automation.Model;
23+
using Microsoft.Azure.Commands.Automation.Properties;
24+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
25+
26+
namespace Microsoft.Azure.Commands.Automation.Cmdlet
27+
{
28+
/// <summary>
29+
/// Gets azure automation dsc onboarding meta configuration information for a given account.
30+
/// </summary>
31+
[Cmdlet(VerbsCommon.Get, "AzureAutomationDscOnboardingMetaconfig")]
32+
[OutputType(typeof(DscOnboardingMetaconfig))]
33+
public class GetAzureAutomationDscOnboardingMetaconfig : AzureAutomationBaseCmdlet
34+
{
35+
/// <summary>
36+
/// True to overwrite the existing meta.mof; false otherwise.
37+
/// </summary>
38+
private bool overwriteExistingFile;
39+
40+
/// <summary>
41+
/// Gets or sets the output folder for the metaconfig mof files
42+
/// </summary>
43+
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The folder where metaconfig mof files to be placed.")]
44+
public string OutputFolder { get; set; }
45+
46+
/// <summary>
47+
/// Gets or sets the list of computer names
48+
/// </summary>
49+
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The names of computers. If not specified Localhost will be used.")]
50+
[Alias("ComputerName")]
51+
public string[] ComputerNames { get; set; }
52+
53+
/// <summary>
54+
/// Gets or sets switch parameter to confirm overwriting of existing configurations.
55+
/// </summary>
56+
[Parameter(Mandatory = false, HelpMessage = "Overwrites an existing configuration with same name.")]
57+
public SwitchParameter Force
58+
{
59+
get { return this.overwriteExistingFile; }
60+
set { this.overwriteExistingFile = value; }
61+
}
62+
63+
/// <summary>
64+
/// Execute this cmdlet.
65+
/// </summary>
66+
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
67+
public override void ExecuteCmdlet()
68+
{
69+
var ret =
70+
this.AutomationClient.GetDscMetaConfig(this.ResourceGroupName, this.AutomationAccountName, this.OutputFolder, this.ComputerNames, this.Force);
71+
72+
this.WriteObject(ret, true);
73+
}
74+
}
75+
}

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

Lines changed: 43 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using System;
16+
using System.Collections;
1517
using System.Collections.Generic;
1618
using System.Management.Automation;
1719
using System.Security.Permissions;
@@ -29,55 +31,77 @@ namespace Microsoft.Azure.Commands.Automation.Cmdlet
2931
public class ImportAzureAutomationDscConfiguration : AzureAutomationBaseCmdlet
3032
{
3133
/// <summary>
32-
/// Gets or sets the automation account name.
33-
/// </summary>
34-
[Parameter(Position = 1, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The automation account name.")]
35-
[ValidateNotNullOrEmpty]
36-
public string AutomationAccountName { get; set; }
34+
/// True to overwrite the existing configuration; false otherwise.
35+
/// </summary>
36+
private bool overwriteExistingConfiguration;
3737

3838
/// <summary>
39-
/// Gets or sets the configuration name.
40-
/// </summary>
41-
[Parameter(Position = 2, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The configuration name.")]
42-
public string ConfigurationName { get; set; }
39+
/// True to publish the configuration; false otherwise.
40+
/// </summary>
41+
private bool publishConfiguration;
4342

4443
/// <summary>
4544
/// Gets or sets the source path.
4645
/// </summary>
47-
[Parameter(Position = 3, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The source path for importing the configuration script.")]
46+
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The source path for importing the configuration script.")]
47+
[ValidateNotNullOrEmpty]
4848
public string SourcePath { get; set; }
4949

50+
/// <summary>
51+
/// Gets or sets the configuration tags.
52+
/// </summary>
53+
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The dsc configuration tags.")]
54+
[Alias("Tag")]
55+
public IDictionary Tags { get; set; }
56+
5057
/// <summary>
5158
/// Gets or sets the description.
5259
/// </summary>
53-
[Parameter(Position = 4, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The description of the configuration being imported.")]
60+
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The description of the configuration being imported.")]
5461
public string Description { get; set; }
5562

5663
/// <summary>
57-
/// Gets or sets the switch parameter to
64+
/// Gets or sets the switch parameter to publish the configuration
5865
/// </summary>
59-
[Parameter(Position = 5, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Import the configuration in published state.")]
60-
public SwitchParameter Published { get; set; }
66+
[Parameter(Mandatory = false, HelpMessage = "Import the configuration in published state.")]
67+
public SwitchParameter Published
68+
{
69+
get { return this.publishConfiguration; }
70+
set { this.publishConfiguration = value; }
71+
}
6172

6273
/// <summary>
6374
/// Gets or sets switch parameter to confirm overwriting of existing configurations.
6475
/// </summary>
65-
[Parameter(Position = 6, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Overwrites an existing configuration with same name.")]
66-
public SwitchParameter Overwrite { get; set; }
76+
[Parameter(Mandatory = false, HelpMessage = "Overwrites an existing configuration with same name.")]
77+
public SwitchParameter Overwrite
78+
{
79+
get { return this.overwriteExistingConfiguration; }
80+
set { this.overwriteExistingConfiguration = value; }
81+
}
6782

6883
/// <summary>
6984
/// Gets or sets a value indicating whether verbose logging should be turned on or off.
7085
/// </summary>
71-
[Parameter(Position = 7, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Indicate whether verbose logging should be turned on or off.")]
86+
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Indicate whether verbose logging should be turned on or off.")]
7287
public bool? LogVerbose { get; set; }
73-
88+
7489
/// <summary>
7590
/// Execute this cmdlet.
7691
/// </summary>
7792
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
7893
public override void ExecuteCmdlet()
7994
{
80-
var configuration = this.AutomationClient.CreateConfiguration(this.ResourceGroupName, this.AutomationAccountName, this.ConfigurationName, this.SourcePath, this.Description, this.LogVerbose);
95+
var configuration = this.AutomationClient.CreateConfiguration(
96+
this.ResourceGroupName,
97+
this.AutomationAccountName,
98+
this.SourcePath,
99+
this.Tags,
100+
this.Description,
101+
this.LogVerbose,
102+
this.Published,
103+
this.Overwrite);
104+
81105
this.WriteObject(configuration);
82106
}
83107
}

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,6 @@ namespace Microsoft.Azure.Commands.Automation.Cmdlet
2828
[OutputType(typeof(AgentRegistration))]
2929
public class NewAzureAutomationKey : AzureAutomationBaseCmdlet
3030
{
31-
/// <summary>
32-
/// Gets or sets the automation account name.
33-
/// </summary>
34-
[Parameter(Position = 1, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The automation account name.")]
35-
[ValidateNotNullOrEmpty]
36-
public string AutomationAccountName { get; set; }
37-
3831
/// <summary>
3932
/// Gets or sets the KeyType.
4033
/// </summary>

0 commit comments

Comments
 (0)