Skip to content

Commit 9ed5b93

Browse files
Merge pull request #1 from psap/ignite
Register DSCNode and Other fixes
2 parents 381a70e + c9b5111 commit 9ed5b93

17 files changed

+430
-98
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ 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")]
45+
[ValidateSet("Compliant", "NotCompliant", "Failed", "Pending", "Received", "Unresponsive")]
4646
public string Status { get; set; }
4747

4848
/// <summary>
@@ -55,14 +55,14 @@ public class GetAzureAutomationDscNode : AzureAutomationBaseCmdlet
5555
/// <summary>
5656
/// Gets or sets the nodeconfiguration name.
5757
/// </summary>
58-
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByNodeConfiguration, Mandatory = true, HelpMessage = "The nodeconfiguration name.")]
58+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByNodeConfiguration, Mandatory = true, HelpMessage = "Filter dsc nodes based on their node configuration name.")]
5959
[ValidateNotNullOrEmpty]
6060
public string NodeConfigurationName { get; set; }
6161

6262
/// <summary>
6363
/// Gets or sets the configuration name.
6464
/// </summary>
65-
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByConfigurationName, Mandatory = true, HelpMessage = "The configuration name.")]
65+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByConfiguration, Mandatory = true, HelpMessage = "Filter dsc nodes based on their configuration name.")]
6666
[ValidateNotNullOrEmpty]
6767
public string ConfigurationName { get; set; }
6868

@@ -97,7 +97,7 @@ public override void ExecuteCmdlet()
9797
this.NodeConfigurationName,
9898
this.Status);
9999
}
100-
else if (this.ParameterSetName == AutomationCmdletParameterSets.ByConfigurationName)
100+
else if (this.ParameterSetName == AutomationCmdletParameterSets.ByConfiguration)
101101
{
102102
ret = this.AutomationClient.ListDscNodesByConfiguration(
103103
this.ResourceGroupName,

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

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,19 @@ public class GetAzureAutomationDscOnboardingMetaconfig : AzureAutomationBaseCmdl
4040
/// <summary>
4141
/// Gets or sets the output folder for the metaconfig mof files
4242
/// </summary>
43-
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The folder where metaconfig mof files to be placed.")]
43+
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The folder where metaconfig mof folder to be placed.")]
4444
public string OutputFolder { get; set; }
4545

4646
/// <summary>
4747
/// Gets or sets the list of computer names
4848
/// </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; }
49+
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The names of computers to generate a metaconfig mof for. If not specified localhost will be used.")]
50+
public string[] ComputerName { get; set; }
5251

5352
/// <summary>
5453
/// Gets or sets switch parameter to confirm overwriting of existing configurations.
5554
/// </summary>
56-
[Parameter(Mandatory = false, HelpMessage = "Overwrites an existing configuration with same name.")]
55+
[Parameter(Mandatory = false, HelpMessage = "Forces the command to run without asking for user confirmation and overwrites an existing configuration with same name.")]
5756
public SwitchParameter Force
5857
{
5958
get { return this.overwriteExistingFile; }
@@ -66,10 +65,16 @@ public SwitchParameter Force
6665
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
6766
public override void ExecuteCmdlet()
6867
{
69-
var ret =
70-
this.AutomationClient.GetDscMetaConfig(this.ResourceGroupName, this.AutomationAccountName, this.OutputFolder, this.ComputerNames, this.Force);
71-
72-
this.WriteObject(ret, true);
68+
this.ConfirmAction(
69+
this.Force.IsPresent,
70+
string.Format(CultureInfo.CurrentCulture, Resources.DscMetaMofHasKeysWarning),
71+
string.Format(CultureInfo.CurrentCulture, Resources.DscMetaMofHasKeysDescription),
72+
this.OutputFolder,
73+
() =>
74+
{
75+
var ret = this.AutomationClient.GetDscMetaConfig(this.ResourceGroupName, this.AutomationAccountName, this.OutputFolder, this.ComputerName, this.Force);
76+
this.WriteObject(ret, true);
77+
});
7378
}
7479
}
7580
}

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ public class ImportAzureAutomationDscConfiguration : AzureAutomationBaseCmdlet
4343
/// <summary>
4444
/// Gets or sets the source path.
4545
/// </summary>
46-
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The source path for importing the configuration script.")]
46+
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Path to the configuration script .ps1 to import.")]
47+
[Alias("Path")]
4748
[ValidateNotNullOrEmpty]
4849
public string SourcePath { get; set; }
4950

@@ -73,8 +74,8 @@ public SwitchParameter Published
7374
/// <summary>
7475
/// Gets or sets switch parameter to confirm overwriting of existing configurations.
7576
/// </summary>
76-
[Parameter(Mandatory = false, HelpMessage = "Overwrites an existing configuration with same name.")]
77-
public SwitchParameter Overwrite
77+
[Parameter(Mandatory = false, HelpMessage = "Forces the command to overwrite an existing configuration.")]
78+
public SwitchParameter Force
7879
{
7980
get { return this.overwriteExistingConfiguration; }
8081
set { this.overwriteExistingConfiguration = value; }
@@ -100,7 +101,7 @@ public override void ExecuteCmdlet()
100101
this.Description,
101102
this.LogVerbose,
102103
this.Published,
103-
this.Overwrite);
104+
this.Force);
104105

105106
this.WriteObject(configuration);
106107
}
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
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;
17+
using System.Collections.Generic;
18+
using System.Globalization;
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+
/// Registers the dsc node.
30+
/// </summary>
31+
[Cmdlet(VerbsLifecycle.Register, "AzureAutomationDscNode")]
32+
// [OutputType(typeof(DscNode))]
33+
public class RegisterAzureAutomationDscNode : AzureAutomationBaseCmdlet
34+
{
35+
/// <summary>
36+
/// True to reboot the node if needed. False otherwise.
37+
/// </summary>
38+
private bool rebootIfNeeded = false;
39+
40+
/// <summary>
41+
/// True to overwrite modules. False otherwise.
42+
/// </summary>
43+
private bool overwriteModulesFlag = false;
44+
45+
/// <summary>
46+
/// Default value for ConfigurationModeFrequencyMins
47+
/// </summary>
48+
private int configurationModeFrequencyMins = 15;
49+
50+
/// <summary>
51+
/// Default value for RefreshFrequencyMins
52+
/// </summary>
53+
private int refreshFrequencyMins = 30;
54+
55+
/// <summary>
56+
/// Default value for ActionAfterReboot
57+
/// </summary>
58+
private string actionAfterReboot = "ContinueConfiguration";
59+
60+
/// <summary>
61+
/// Default value for NodeConfigurationName
62+
/// </summary>
63+
private string nodeConfigurationName = String.Empty;
64+
65+
/// <summary>
66+
/// Default value for ConfigurationMode
67+
/// </summary>
68+
private string configurationMode = "ApplyAndMonitor";
69+
70+
/// <summary>
71+
/// Gets or sets the VM name.
72+
/// </summary>
73+
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The name of the Azure virtual machine to register for management with Azure Automation DSC.")]
74+
[ValidateNotNullOrEmpty]
75+
public string AzureVMName { get; set; }
76+
77+
/// <summary>
78+
/// Gets or sets the node configuration name.
79+
/// </summary>
80+
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The node configuration name the VM should be configured to grab from Azure Automation DSC.")]
81+
public string NodeConfigurationName
82+
{
83+
get { return this.nodeConfigurationName; }
84+
set { this.nodeConfigurationName = value; }
85+
}
86+
87+
/// <summary>
88+
/// Gets or sets the configuration mode
89+
/// </summary>
90+
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "DSC configuration mode.")]
91+
[ValidateSet("ApplyAndMonitor", "ApplyAndAutocorrect", "ApplyOnly")]
92+
public string ConfigurationMode
93+
{
94+
get { return this.configurationMode; }
95+
set { this.configurationMode = value; }
96+
}
97+
98+
/// <summary>
99+
/// Gets or sets the configuration mode frequency in minutes.
100+
/// </summary>
101+
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Represents the frequency (in minutes) at which the background application of DSC attempts to implement the current configuration on the target node.")]
102+
[ValidateRange(15, 44640)]
103+
public int ConfigurationModeFrequencyMins
104+
{
105+
get { return this.configurationModeFrequencyMins; }
106+
set { this.configurationModeFrequencyMins = value; }
107+
}
108+
109+
/// <summary>
110+
/// Gets or sets the refresh frequency in minutes.
111+
/// </summary>
112+
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Represents the frequency (in minutes) at which the Local Configuration Manager contacts the pull server to download the current configuration.")]
113+
[ValidateRange(30, 44640)]
114+
public int RefreshFrequencyMins
115+
{
116+
get { return this.refreshFrequencyMins; }
117+
set { this.refreshFrequencyMins = value; }
118+
}
119+
120+
/// <summary>
121+
/// Gets or sets a value indicating whether to reboot the node if needed.
122+
/// </summary>
123+
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "True to Reboot the node if needed.")]
124+
public bool RebootNodeIfNeeded
125+
{
126+
get { return this.rebootIfNeeded; }
127+
set { this.rebootIfNeeded = value; }
128+
}
129+
130+
/// <summary>
131+
/// Gets or sets the action to perform post reboot.
132+
/// </summary>
133+
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Action to perform after a reboot.")]
134+
[ValidateSet("ContinueConfiguration", "StopConfiguration")]
135+
public string ActionAfterReboot
136+
{
137+
get { return this.actionAfterReboot; }
138+
set { this.actionAfterReboot = value; }
139+
}
140+
141+
/// <summary>
142+
/// Gets or sets a value indicating whether to overwrite the module.
143+
/// </summary>
144+
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true,
145+
HelpMessage = "Controls whether new configurations downloaded from the configuration server are allowed to overwrite the old ones on the target node.")]
146+
public bool AllowModuleOverwrite
147+
{
148+
get { return this.overwriteModulesFlag; }
149+
set { this.overwriteModulesFlag = value; }
150+
}
151+
152+
/// <summary>
153+
/// Execute this cmdlet.
154+
/// </summary>
155+
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
156+
public override void ExecuteCmdlet()
157+
{
158+
this.AutomationClient.RegisterDscNode(this.ResourceGroupName, this.AutomationAccountName,this.AzureVMName, this.NodeConfigurationName, this.ConfigurationMode, this.ConfigurationModeFrequencyMins, this.RefreshFrequencyMins, this.RebootNodeIfNeeded, this.ActionAfterReboot, this.AllowModuleOverwrite);
159+
}
160+
}
161+
}

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

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@
1515
using System;
1616
using System.Collections;
1717
using System.Collections.Generic;
18+
using System.Globalization;
1819
using System.Management.Automation;
1920
using System.Security.Permissions;
2021
using Microsoft.Azure.Commands.Automation.Common;
2122
using Microsoft.Azure.Commands.Automation.Model;
23+
using Microsoft.Azure.Commands.Automation.Properties;
2224
using Microsoft.WindowsAzure.Commands.Utilities.Common;
2325

2426
namespace Microsoft.Azure.Commands.Automation.Cmdlet
@@ -46,14 +48,14 @@ public class SetAzureAutomationDscNode : AzureAutomationBaseCmdlet
4648
/// <summary>
4749
/// Gets or sets the nodeconfiguration name.
4850
/// </summary>
49-
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The nodeconfiguration name.")]
51+
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The node configuration name.")]
5052
[ValidateNotNullOrEmpty]
5153
public string NodeConfigurationName { get; set; }
5254

5355
/// <summary>
5456
/// Gets or sets switch parameter to confirm overwriting of existing nodeconfigurations.
5557
/// </summary>
56-
[Parameter(Mandatory = false, HelpMessage = "Overwrites an existing nodeconfiguration with same name.")]
58+
[Parameter(Mandatory = false, HelpMessage = "Forces the command to run without asking for user confirmation.")]
5759
public SwitchParameter Force
5860
{
5961
get { return this.overwriteExistingNodeConfiguration; }
@@ -66,8 +68,17 @@ public SwitchParameter Force
6668
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
6769
public override void ExecuteCmdlet()
6870
{
69-
var node = this.AutomationClient.SetDscNodeById(this.ResourceGroupName, this.AutomationAccountName, this.Id, this.NodeConfigurationName, this.Force);
70-
this.WriteObject(node);
71+
this.ConfirmAction(
72+
this.Force.IsPresent,
73+
string.Format(CultureInfo.CurrentCulture, Resources.SetnodeconfigurationWarning),
74+
string.Format(CultureInfo.CurrentCulture, Resources.SetnodeconfigurationDescription),
75+
this.NodeConfigurationName,
76+
() =>
77+
{
78+
var node = this.AutomationClient.SetDscNodeById(this.ResourceGroupName, this.AutomationAccountName, this.Id, this.NodeConfigurationName);
79+
this.WriteObject(node);
80+
});
81+
7182
}
7283
}
7384
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public override void ExecuteCmdlet()
5454
{
5555
this.ConfirmAction(
5656
this.Force.IsPresent,
57-
string.Format(CultureInfo.CurrentCulture, Resources.RemovDscNodeWarning),
57+
string.Format(CultureInfo.CurrentCulture, Resources.RemoveDscNodeWarning),
5858
string.Format(CultureInfo.CurrentCulture, Resources.RemoveDscNodeDescription, this.Id.ToString()),
5959
this.Id.ToString(),
6060
() =>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@
122122
<Compile Include="Cmdlet\GetAzureAutomationDscNodeConfiguration.cs" />
123123
<Compile Include="Cmdlet\GetAzureAutomationModule.cs" />
124124
<Compile Include="Cmdlet\NewAzureAutomationModule.cs" />
125+
<Compile Include="Cmdlet\RegisterAzureAutomationDscNode.cs" />
125126
<Compile Include="Cmdlet\RemoveAzureAutomationModule.cs" />
126127
<Compile Include="Cmdlet\SetAzureAutomationModule.cs" />
127128
<Compile Include="Cmdlet\StartAzureAutomationDscCompilationJob.cs" />

0 commit comments

Comments
 (0)