Skip to content

Commit ce2ffc2

Browse files
committed
Deleting node config if there is no mapping also without switch parameter
1 parent 0d3cd53 commit ce2ffc2

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class RemoveAzureAutomationDscNodeConfiguration : AzureAutomationBaseCmdl
3636
[Parameter(Position = 3, HelpMessage = "Force confirmation of the removal of the node configuration")]
3737
public SwitchParameter Force { get; set; }
3838

39-
[Parameter(Position = 4, HelpMessage = "Delete even if the node configuration is mapped to a node")]
39+
[Parameter(Position = 4, HelpMessage = "Remove the node configuration even if the node configuration is mapped to one or more nodes")]
4040
public SwitchParameter IgnoreNodeMappings { get; set; }
4141

4242
/// <summary>

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,18 +1297,21 @@ public void DeleteNodeConfiguration(string resourceGroupName, string automationA
12971297
{
12981298
if (ignoreNodeMappings)
12991299
{
1300-
this.automationManagementClient.NodeConfigurations.Delete(resourceGroupName, automationAccountName,
1301-
name);
1300+
this.automationManagementClient.NodeConfigurations.Delete(resourceGroupName, automationAccountName, name);
13021301
}
13031302
else
13041303
{
13051304
var nodeList = this.ListDscNodesByNodeConfiguration(resourceGroupName, automationAccountName, name, null);
13061305
if (nodeList.Any())
13071306
{
1308-
throw new ResourceNotFoundException(
1309-
typeof(Model.NodeConfiguration),
1307+
throw new ResourceCommonException(
1308+
typeof (Model.NodeConfiguration),
13101309
string.Format(CultureInfo.CurrentCulture, Resources.CannotDeleteNodeConfiguration, name));
13111310
}
1311+
else
1312+
{
1313+
this.automationManagementClient.NodeConfigurations.Delete(resourceGroupName, automationAccountName, name);
1314+
}
13121315
}
13131316
}
13141317
catch (CloudException cloudException)

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
@@ -389,7 +389,7 @@
389389
<comment>Automation</comment>
390390
</data>
391391
<data name="CannotDeleteNodeConfiguration" xml:space="preserve">
392-
<value>The Node configuration is mapped a node. Specify IgnoreNodeMappings to delete the node configuration {0}.</value>
392+
<value>The node configuration '{0}' is currently assigned to one or more nodes. Either specify the IgnoreNodeMappings parameter, or reassign these nodes to a different node configuration, to delete this node configuration.</value>
393393
<comment>Automation</comment>
394394
</data>
395395
<data name="WebhookNotFound" xml:space="preserve">

0 commit comments

Comments
 (0)