Skip to content

Commit 20beff0

Browse files
committed
Register Node Code Review Fixes and minor string changes
1 parent 990433a commit 20beff0

File tree

6 files changed

+55
-11
lines changed

6 files changed

+55
-11
lines changed

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

Lines changed: 1 addition & 1 deletion
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", "NotCompliant", "Failed", "Pending", "Received", "Unresponsive")]
45+
[ValidateSet("Compliant", "NotCompliant", "Failed", "Pending", "Received", "Unresponsive", IgnoreCase = true)]
4646
public string Status { get; set; }
4747

4848
/// <summary>

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

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ public class RegisterAzureAutomationDscNode : AzureAutomationBaseCmdlet
6767
/// </summary>
6868
private string configurationMode = "ApplyAndMonitor";
6969

70+
/// <summary>
71+
/// Default value for AzureVMResourceGroup
72+
/// </summary>
73+
private string azureVmResourceGroup = String.Empty;
74+
75+
/// <summary>
76+
/// Default value for AzureVmLocation
77+
/// </summary>
78+
private string azureVmLocation = String.Empty;
79+
7080
/// <summary>
7181
/// Gets or sets the VM name.
7282
/// </summary>
@@ -88,7 +98,7 @@ public string NodeConfigurationName
8898
/// Gets or sets the configuration mode
8999
/// </summary>
90100
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "DSC configuration mode.")]
91-
[ValidateSet("ApplyAndMonitor", "ApplyAndAutocorrect", "ApplyOnly")]
101+
[ValidateSet("ApplyAndMonitor", "ApplyAndAutocorrect", "ApplyOnly", IgnoreCase = true)]
92102
public string ConfigurationMode
93103
{
94104
get { return this.configurationMode; }
@@ -111,10 +121,10 @@ public int ConfigurationModeFrequencyMins
111121
/// </summary>
112122
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Represents the frequency (in minutes) at which the Local Configuration Manager contacts the Azure Automation DSC pull server to download the latest node configuration.")]
113123
[ValidateRange(30, 44640)]
114-
public int RefreshFrequencyMins
124+
public int RefreshFrequencyMins
115125
{
116126
get { return this.refreshFrequencyMins; }
117-
set { this.refreshFrequencyMins = value; }
127+
set { this.refreshFrequencyMins = value; }
118128
}
119129

120130
/// <summary>
@@ -131,7 +141,7 @@ public bool RebootNodeIfNeeded
131141
/// Gets or sets the action to perform post reboot.
132142
/// </summary>
133143
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Action to perform after a reboot.")]
134-
[ValidateSet("ContinueConfiguration", "StopConfiguration")]
144+
[ValidateSet("ContinueConfiguration", "StopConfiguration", IgnoreCase = true)]
135145
public string ActionAfterReboot
136146
{
137147
get { return this.actionAfterReboot; }
@@ -149,13 +159,33 @@ public bool AllowModuleOverwrite
149159
set { this.overwriteModulesFlag = value; }
150160
}
151161

162+
/// <summary>
163+
/// Gets or sets the azure VM resource group name.
164+
/// </summary>
165+
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The azure VM resource group name.")]
166+
public string AzureVMResourceGroup
167+
{
168+
get { return this.azureVmResourceGroup; }
169+
set { this.azureVmResourceGroup = value; }
170+
}
171+
172+
/// <summary>
173+
/// Gets or sets the azure VM location.
174+
/// </summary>
175+
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The azure VM location.")]
176+
public string AzureVMLocation
177+
{
178+
get { return this.azureVmLocation; }
179+
set { this.azureVmLocation = value; }
180+
}
181+
152182
/// <summary>
153183
/// Execute this cmdlet.
154184
/// </summary>
155185
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
156186
public override void ExecuteCmdlet()
157187
{
158-
this.AutomationClient.RegisterDscNode(this.ResourceGroupName, this.AutomationAccountName,this.AzureVMName, this.NodeConfigurationName, this.ConfigurationMode, this.ConfigurationModeFrequencyMins, this.RefreshFrequencyMins, this.RebootNodeIfNeeded, this.ActionAfterReboot, this.AllowModuleOverwrite);
188+
this.AutomationClient.RegisterDscNode(this.ResourceGroupName, this.AutomationAccountName, this.AzureVMName, this.NodeConfigurationName, this.ConfigurationMode, this.ConfigurationModeFrequencyMins, this.RefreshFrequencyMins, this.RebootNodeIfNeeded, this.ActionAfterReboot, this.AllowModuleOverwrite, this.AzureVMResourceGroup, this.AzureVMLocation);
159189
}
160190
}
161191
}

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -622,11 +622,25 @@ public void RegisterDscNode(string resourceGroupName,
622622
int refreshFrequencyMins,
623623
bool rebootFlag,
624624
string actionAfterReboot,
625-
bool moduleOverwriteFlag)
625+
bool moduleOverwriteFlag,
626+
string azureVmResourceGroup,
627+
string azureVmLocation)
626628
{
627629
// get the location from AutomationAccountName. This will validate the account too
628630
string location = this.GetAutomationAccount(resourceGroupName, automationAccountName).Location;
629631

632+
// if vm location is specified, use that
633+
if (!String.IsNullOrEmpty(azureVmLocation))
634+
{
635+
location = azureVmLocation;
636+
}
637+
638+
// if azureVmResourceGroup not specified, use the resource group
639+
if (String.IsNullOrEmpty(azureVmResourceGroup))
640+
{
641+
azureVmResourceGroup = resourceGroupName;
642+
}
643+
630644
string deploymentName = System.DateTimeOffset.Now.LocalDateTime.ToString("yyyyMMddhhmmss");
631645

632646
// get the endpoint and keys
@@ -655,7 +669,7 @@ public void RegisterDscNode(string resourceGroupName,
655669
{
656670
Command invokeCommand = new Command("New-AzureResourceGroupDeployment");
657671
invokeCommand.Parameters.Add("Name", deploymentName);
658-
invokeCommand.Parameters.Add("ResourceGroupName", resourceGroupName);
672+
invokeCommand.Parameters.Add("ResourceGroupName", azureVmResourceGroup);
659673
invokeCommand.Parameters.Add("TemplateParameterObject", templateParameters);
660674
invokeCommand.Parameters.Add("TemplateFile", Constants.TemplateFile);
661675

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ IEnumerable<DscNode> ListDscNodesByConfiguration(
9999

100100
void DeleteDscNode(string resourceGroupName, string automationAccountName, Guid nodeId);
101101

102-
void RegisterDscNode(string resourceGroupName, string automationAccountName, string azureVMName, string nodeconfigurationName, string configurationMode, int configurationModeFrequencyMins, int refreshFrequencyMins, bool rebootFlag, string actionAfterReboot, bool moduleOverwriteFlag);
102+
void RegisterDscNode(string resourceGroupName, string automationAccountName, string azureVMName, string nodeconfigurationName, string configurationMode, int configurationModeFrequencyMins, int refreshFrequencyMins, bool rebootFlag, string actionAfterReboot, bool moduleOverwriteFlag, string azureVmResourceGroup, string azureVmLocation);
103103

104104
#endregion
105105

src/ResourceManager/Automation/Commands.Automation/Properties/Resources.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ResourceManager/Automation/Commands.Automation/Properties/Resources.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@
319319
<comment>Automation</comment>
320320
</data>
321321
<data name="RemoveDscNodeWarning" xml:space="preserve">
322-
<value>Are you sure you want to unregister Dsc node from Azure Automation?</value>
322+
<value>Are you sure you want to unregister this node from Azure Automation DSC?</value>
323323
<comment>Automation</comment>
324324
</data>
325325
<data name="RemoveDscNodeDescription" xml:space="preserve">

0 commit comments

Comments
 (0)