Skip to content

Commit 28e351f

Browse files
committed
Fixes to set and remove diag extension cmdlets
Change the set diag extension cmdlet to use an existing extension reference name. Implement the remove diag extension cmdlet
1 parent 571b6a9 commit 28e351f

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/ServiceManagement/Compute/Commands.ServiceManagement/IaaS/Extensions/Diagnostics/RemoveAzureVMDiagnosticsExtension.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ public class RemoveAzureVMDiagnosticsExtensionCommand : VirtualMachineDiagnostic
3030

3131
internal void ExecuteCommand()
3232
{
33-
// We do not support this cmdlet for now...
34-
throw new NotSupportedException();
33+
ExtensionName = DiagnosticsExtensionType;
34+
Publisher = DiagnosticsExtensionNamespace;
3535

36-
// RemovePredicateExtensions();
37-
// WriteObject(VM);
36+
RemovePredicateExtensions();
37+
WriteObject(VM);
3838
}
3939

4040
protected override void ProcessRecord()

src/ServiceManagement/Compute/Commands.ServiceManagement/IaaS/Extensions/Diagnostics/SetAzureVMDiagnosticsExtension.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
using System;
1616
using System.IO;
17+
using System.Linq;
1718
using System.Management.Automation;
1819
using System.Text;
1920
using System.Xml;
@@ -121,6 +122,17 @@ protected override void ValidateParameters()
121122
ValidateConfiguration();
122123
ExtensionName = DiagnosticsExtensionType;
123124
Publisher = DiagnosticsExtensionNamespace;
125+
126+
// If the user didn't specify an extension reference name and the input VM already has a diagnostics extension,
127+
// reuse its reference name
128+
if (string.IsNullOrEmpty(ReferenceName))
129+
{
130+
ResourceExtensionReference diagnosticsExtension = ResourceExtensionReferences.FirstOrDefault(ExtensionPredicate);
131+
if (diagnosticsExtension != null)
132+
{
133+
ReferenceName = diagnosticsExtension.ReferenceName;
134+
}
135+
}
124136
}
125137

126138
private void ValidateStorageAccount()

0 commit comments

Comments
 (0)