|
25 | 25 | namespace Microsoft.Azure.Commands.Compute.Extension.Chef
|
26 | 26 | {
|
27 | 27 | [Cmdlet(
|
28 |
| - VerbsCommon.Remove, |
29 |
| - ProfileNouns.VirtualMachineChefExtension)] |
| 28 | + VerbsCommon.Remove, ProfileNouns.VirtualMachineChefExtension, SupportsShouldProcess = true)] |
30 | 29 | [OutputType(typeof(PSAzureOperationResponse))]
|
31 | 30 | public class RemoveAzureRmVMChefExtension : VirtualMachineExtensionBaseCmdlet
|
32 | 31 | {
|
@@ -97,36 +96,37 @@ public override void ExecuteCmdlet()
|
97 | 96 | this.Name = ExtensionDefaultName;
|
98 | 97 | }
|
99 | 98 |
|
100 |
| - ExecuteClientAction(() => |
101 |
| - { |
102 |
| - if (string.IsNullOrEmpty(this.Name)) |
| 99 | + ConfirmAction("Remove Chef Extension", this.VMName, |
| 100 | + () => |
103 | 101 | {
|
104 |
| - VirtualMachine virtualMachine = ComputeClient.ComputeManagementClient.VirtualMachines.Get( |
105 |
| - this.ResourceGroupName, this.VMName); |
106 |
| - var chefExtension = virtualMachine.Resources != null |
107 |
| - ? virtualMachine.Resources.FirstOrDefault(extension => |
108 |
| - extension.Publisher.Equals(ExtensionDefaultPublisher, StringComparison.InvariantCultureIgnoreCase) && |
109 |
| - extension.VirtualMachineExtensionType.Equals(this.Name, StringComparison.InvariantCultureIgnoreCase)) |
110 |
| - : null; |
111 |
| - |
112 |
| - if (chefExtension == null) |
| 102 | + if (string.IsNullOrEmpty(this.Name)) |
113 | 103 | {
|
114 |
| - WriteWarning(string.Format(CultureInfo.InvariantCulture, Properties.Resources.ChefExtensionNotFound, this.ResourceGroupName, this.VMName)); |
115 |
| - return; |
116 |
| - } |
117 |
| - else |
118 |
| - { |
119 |
| - this.Name = chefExtension.Name; |
| 104 | + VirtualMachine virtualMachine = ComputeClient.ComputeManagementClient.VirtualMachines.Get( |
| 105 | + this.ResourceGroupName, this.VMName); |
| 106 | + var chefExtension = virtualMachine.Resources != null |
| 107 | + ? virtualMachine.Resources.FirstOrDefault(extension => |
| 108 | + extension.Publisher.Equals(ExtensionDefaultPublisher, StringComparison.InvariantCultureIgnoreCase) && |
| 109 | + extension.VirtualMachineExtensionType.Equals(this.Name, StringComparison.InvariantCultureIgnoreCase)) |
| 110 | + : null; |
| 111 | + |
| 112 | + if (chefExtension == null) |
| 113 | + { |
| 114 | + WriteWarning(string.Format(CultureInfo.InvariantCulture, Properties.Resources.ChefExtensionNotFound, this.ResourceGroupName, this.VMName)); |
| 115 | + return; |
| 116 | + } |
| 117 | + else |
| 118 | + { |
| 119 | + this.Name = chefExtension.Name; |
| 120 | + } |
120 | 121 | }
|
121 |
| - } |
122 | 122 |
|
123 |
| - var op = this.VirtualMachineExtensionClient.DeleteWithHttpMessagesAsync( |
124 |
| - this.ResourceGroupName, |
125 |
| - this.VMName, |
126 |
| - this.Name).GetAwaiter().GetResult(); |
127 |
| - var result = Mapper.Map<PSAzureOperationResponse>(op); |
128 |
| - WriteObject(result); |
129 |
| - }); |
| 123 | + var op = this.VirtualMachineExtensionClient.DeleteWithHttpMessagesAsync( |
| 124 | + this.ResourceGroupName, |
| 125 | + this.VMName, |
| 126 | + this.Name).GetAwaiter().GetResult(); |
| 127 | + var result = Mapper.Map<PSAzureOperationResponse>(op); |
| 128 | + WriteObject(result); |
| 129 | + }); |
130 | 130 | }
|
131 | 131 | }
|
132 | 132 | }
|
0 commit comments