Skip to content

Commit 1c56062

Browse files
Merge pull request #4 from psap/ignite
Code review fixes and minorstring changes
2 parents c080696 + 1d233d4 commit 1c56062

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("Any", "Compliant", "NotCompliant", "Failed", "Pending", "Received", "Unresponsive")]
45+
[ValidateSet("Any", "Compliant", "NotCompliant", "Failed", "Pending", "Received", "Unresponsive", IgnoreCase = true)]
4646
public DscNodeStatus 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
@@ -663,11 +663,25 @@ public void RegisterDscNode(string resourceGroupName,
663663
int refreshFrequencyMins,
664664
bool rebootFlag,
665665
string actionAfterReboot,
666-
bool moduleOverwriteFlag)
666+
bool moduleOverwriteFlag,
667+
string azureVmResourceGroup,
668+
string azureVmLocation)
667669
{
668670
// get the location from AutomationAccountName. This will validate the account too
669671
string location = this.GetAutomationAccount(resourceGroupName, automationAccountName).Location;
670672

673+
// if vm location is specified, use that
674+
if (!String.IsNullOrEmpty(azureVmLocation))
675+
{
676+
location = azureVmLocation;
677+
}
678+
679+
// if azureVmResourceGroup not specified, use the resource group
680+
if (String.IsNullOrEmpty(azureVmResourceGroup))
681+
{
682+
azureVmResourceGroup = resourceGroupName;
683+
}
684+
671685
string deploymentName = System.DateTimeOffset.Now.LocalDateTime.ToString("yyyyMMddhhmmss");
672686

673687
// get the endpoint and keys
@@ -696,7 +710,7 @@ public void RegisterDscNode(string resourceGroupName,
696710
{
697711
Command invokeCommand = new Command("New-AzureResourceGroupDeployment");
698712
invokeCommand.Parameters.Add("Name", deploymentName);
699-
invokeCommand.Parameters.Add("ResourceGroupName", resourceGroupName);
713+
invokeCommand.Parameters.Add("ResourceGroupName", azureVmResourceGroup);
700714
invokeCommand.Parameters.Add("TemplateParameterObject", templateParameters);
701715
invokeCommand.Parameters.Add("TemplateFile", Constants.TemplateFile);
702716

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

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

102102
void DeleteDscNode(string resourceGroupName, string automationAccountName, Guid nodeId);
103103

104-
void RegisterDscNode(string resourceGroupName, string automationAccountName, string azureVMName, string nodeconfigurationName, string configurationMode, int configurationModeFrequencyMins, int refreshFrequencyMins, bool rebootFlag, string actionAfterReboot, bool moduleOverwriteFlag);
104+
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);
105105

106106
#endregion
107107

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
@@ -322,7 +322,7 @@
322322
<comment>Automation</comment>
323323
</data>
324324
<data name="RemoveDscNodeWarning" xml:space="preserve">
325-
<value>Are you sure you want to unregister Dsc node from Azure Automation?</value>
325+
<value>Are you sure you want to unregister this node from Azure Automation DSC?</value>
326326
<comment>Automation</comment>
327327
</data>
328328
<data name="RemoveDscNodeDescription" xml:space="preserve">

0 commit comments

Comments
 (0)