Skip to content

Commit 9065ae5

Browse files
committed
Dsc Node, Dsc Configurations and Dsc MetaConfig cmdlets
1 parent 5703ce5 commit 9065ae5

17 files changed

+997
-167
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ 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
{
3131
/// <summary>
3232
/// Execute this cmdlet.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ 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
{
3131
/// <summary>
3232
/// Gets or sets the configuration name.
@@ -52,7 +52,7 @@ public override void ExecuteCmdlet()
5252
}
5353
else if (this.ParameterSetName == AutomationCmdletParameterSets.ByAll)
5454
{
55-
ret = this.AutomationClient.ListAutomationConfigurations(this.ResourceGroupName, this.AutomationAccountName);
55+
ret = this.AutomationClient.ListDscConfigurations(this.ResourceGroupName, this.AutomationAccountName);
5656
}
5757

5858
this.GenerateCmdletOutput(ret);
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+
}
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/GetDscMetaConfiguration.cs

Lines changed: 0 additions & 50 deletions
This file was deleted.

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

Lines changed: 26 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,20 @@ namespace Microsoft.Azure.Commands.Automation.Cmdlet
3131
public class ImportAzureAutomationDscConfiguration : AzureAutomationBaseCmdlet
3232
{
3333
/// <summary>
34-
/// Gets or sets the configuration name.
35-
/// </summary>
36-
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The configuration name.")]
37-
public string ConfigurationName { get; set; }
34+
/// True to overwrite the existing configuration; false otherwise.
35+
/// </summary>
36+
private bool overwriteExistingConfiguration;
37+
38+
/// <summary>
39+
/// True to publish the configuration; false otherwise.
40+
/// </summary>
41+
private bool publishConfiguration;
3842

3943
/// <summary>
4044
/// Gets or sets the source path.
4145
/// </summary>
4246
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The source path for importing the configuration script.")]
47+
[ValidateNotNullOrEmpty]
4348
public string SourcePath { get; set; }
4449

4550
/// <summary>
@@ -56,58 +61,46 @@ public class ImportAzureAutomationDscConfiguration : AzureAutomationBaseCmdlet
5661
public string Description { get; set; }
5762

5863
/// <summary>
59-
/// Gets or sets the switch parameter to
64+
/// Gets or sets the switch parameter to publish the configuration
6065
/// </summary>
61-
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Import the configuration in published state.")]
62-
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+
}
6372

6473
/// <summary>
6574
/// Gets or sets switch parameter to confirm overwriting of existing configurations.
6675
/// </summary>
67-
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Overwrites an existing configuration with same name.")]
68-
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+
}
6982

7083
/// <summary>
7184
/// Gets or sets a value indicating whether verbose logging should be turned on or off.
7285
/// </summary>
7386
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Indicate whether verbose logging should be turned on or off.")]
74-
public SwitchParameter LogVerbose { get; set; }
87+
public bool? LogVerbose { get; set; }
7588

76-
/// <summary>
77-
/// Gets or sets a value indicating whether log progress should be turned on or off.
78-
/// </summary>
79-
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Indicate whether progress logging should be turned on or off.")]
80-
public SwitchParameter LogProgress { get; set; }
81-
8289
/// <summary>
8390
/// Execute this cmdlet.
8491
/// </summary>
8592
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
8693
public override void ExecuteCmdlet()
8794
{
88-
bool logVerbose = false;
89-
if (this.LogVerbose.IsPresent) logVerbose = true;
90-
91-
bool logProgress = false;
92-
if (this.LogProgress.IsPresent) logProgress = true;
93-
94-
bool published = false;
95-
if (this.Published.IsPresent) published = true;
96-
97-
bool overWrite = false;
98-
if (this.Overwrite.IsPresent) overWrite = true;
99-
10095
var configuration = this.AutomationClient.CreateConfiguration(
10196
this.ResourceGroupName,
10297
this.AutomationAccountName,
103-
this.ConfigurationName,
10498
this.SourcePath,
10599
this.Tags,
106100
this.Description,
107-
logVerbose,
108-
logProgress,
109-
published,
110-
overWrite);
101+
this.LogVerbose,
102+
this.Published,
103+
this.Overwrite);
111104

112105
this.WriteObject(configuration);
113106
}

0 commit comments

Comments
 (0)