Skip to content

Commit b999f76

Browse files
committed
Update Diagnostics Extension cmdlets and tests for Swagger library
1 parent 6acecb3 commit b999f76

File tree

10 files changed

+6759
-4467
lines changed

10 files changed

+6759
-4467
lines changed

src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/ComputeTestCommon.ps1

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ function Create-VirtualMachine($rgname, $vmname, $loc)
120120
# VM Profile & Hardware
121121
$vmsize = 'Standard_A2';
122122
$p = New-AzureRmVMConfig -VMName $vmname -VMSize $vmsize;
123-
Assert-AreEqual $p.HardwareProfile.VirtualMachineSize $vmsize;
123+
Assert-AreEqual $p.HardwareProfile.VmSize $vmsize;
124124

125125
# NRP
126126
$subnet = New-AzureRmVirtualNetworkSubnetConfig -Name ('subnet' + $rgname) -AddressPrefix "10.0.0.0/24";
@@ -136,7 +136,7 @@ function Create-VirtualMachine($rgname, $vmname, $loc)
136136

137137
$p = Add-AzureRmVMNetworkInterface -VM $p -Id $nicId;
138138
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces.Count 1;
139-
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces[0].ReferenceUri $nicId;
139+
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces[0].Id $nicId;
140140

141141
# Storage Account (SA)
142142
$stoname = 'sto' + $rgname;
@@ -159,18 +159,18 @@ function Create-VirtualMachine($rgname, $vmname, $loc)
159159
$p = Add-AzureRmVMDataDisk -VM $p -Name 'testDataDisk3' -Caching 'ReadOnly' -DiskSizeInGB 12 -Lun 3 -VhdUri $dataDiskVhdUri3 -CreateOption Empty;
160160
$p = Remove-AzureRmVMDataDisk -VM $p -Name 'testDataDisk3';
161161

162-
Assert-AreEqual $p.StorageProfile.OSDisk.Caching $osDiskCaching;
163-
Assert-AreEqual $p.StorageProfile.OSDisk.Name $osDiskName;
164-
Assert-AreEqual $p.StorageProfile.OSDisk.VirtualHardDisk.Uri $osDiskVhdUri;
162+
Assert-AreEqual $p.StorageProfile.OsDisk.Caching $osDiskCaching;
163+
Assert-AreEqual $p.StorageProfile.OsDisk.Name $osDiskName;
164+
Assert-AreEqual $p.StorageProfile.OsDisk.Vhd.Uri $osDiskVhdUri;
165165
Assert-AreEqual $p.StorageProfile.DataDisks.Count 2;
166166
Assert-AreEqual $p.StorageProfile.DataDisks[0].Caching 'ReadOnly';
167167
Assert-AreEqual $p.StorageProfile.DataDisks[0].DiskSizeGB 10;
168168
Assert-AreEqual $p.StorageProfile.DataDisks[0].Lun 1;
169-
Assert-AreEqual $p.StorageProfile.DataDisks[0].VirtualHardDisk.Uri $dataDiskVhdUri1;
169+
Assert-AreEqual $p.StorageProfile.DataDisks[0].Vhd.Uri $dataDiskVhdUri1;
170170
Assert-AreEqual $p.StorageProfile.DataDisks[1].Caching 'ReadOnly';
171171
Assert-AreEqual $p.StorageProfile.DataDisks[1].DiskSizeGB 11;
172172
Assert-AreEqual $p.StorageProfile.DataDisks[1].Lun 2;
173-
Assert-AreEqual $p.StorageProfile.DataDisks[1].VirtualHardDisk.Uri $dataDiskVhdUri2;
173+
Assert-AreEqual $p.StorageProfile.DataDisks[1].Vhd.Uri $dataDiskVhdUri2;
174174

175175
# OS & Image
176176
$user = "Foo12";

src/ResourceManager/Compute/Commands.Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.DiagnosticsExtensionTests/TestDiagnosticsExtensionBasic.json

Lines changed: 1683 additions & 1864 deletions
Large diffs are not rendered by default.

src/ResourceManager/Compute/Commands.Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.DiagnosticsExtensionTests/TestDiagnosticsExtensionCantListSepcifyStorageAccountKey.json

Lines changed: 1915 additions & 1060 deletions
Large diffs are not rendered by default.

src/ResourceManager/Compute/Commands.Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.DiagnosticsExtensionTests/TestDiagnosticsExtensionSepcifyStorageAccountName.json

Lines changed: 3134 additions & 1504 deletions
Large diffs are not rendered by default.

src/ResourceManager/Compute/Commands.Compute/Common/DiagnosticsHelper.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,6 @@ public static class DiagnosticsHelper
3333
private static string StorageAccountKeyTag = "storageAccountKey";
3434
private static string StorageAccountEndPointTag = "storageAccountEndPoint";
3535

36-
public static string GetJsonSerializedPublicDiagnosticsConfigurationFromFile(string configurationPath,
37-
string storageAccountName)
38-
{
39-
return
40-
JsonConvert.SerializeObject(
41-
DiagnosticsHelper.GetPublicDiagnosticsConfigurationFromFile(configurationPath, storageAccountName));
42-
}
43-
4436
public static Hashtable GetPublicDiagnosticsConfigurationFromFile(string configurationPath, string storageAccountName)
4537
{
4638
using (StreamReader reader = new StreamReader(configurationPath))
@@ -107,12 +99,6 @@ public static Hashtable GetPublicDiagnosticsConfiguration(string config, string
10799
return hashTable;
108100
}
109101

110-
public static string GetJsonSerializedPrivateDiagnosticsConfiguration(string storageAccountName,
111-
string storageKey, string endpoint)
112-
{
113-
return JsonConvert.SerializeObject(GetPrivateDiagnosticsConfiguration( storageAccountName, storageKey, endpoint));
114-
}
115-
116102
public static Hashtable GetPrivateDiagnosticsConfiguration(string storageAccountName, string storageKey, string endpoint)
117103
{
118104
var hashTable = new Hashtable();

src/ResourceManager/Compute/Commands.Compute/Extension/AzureDiskEncryption/SetAzureDiskEncryptionExtension.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,11 +424,11 @@ public override void ExecuteCmdlet()
424424

425425
VirtualMachineExtension parameters = GetVmExtensionParameters(virtualMachineResponse);
426426

427-
this.VirtualMachineExtensionClient.CreateOrUpdate(
427+
this.VirtualMachineExtensionClient.CreateOrUpdateWithHttpMessagesAsync(
428428
this.ResourceGroupName,
429429
this.VMName,
430430
this.Name,
431-
parameters);
431+
parameters).GetAwaiter().GetResult();
432432

433433
var op = UpdateVmEncryptionSettings();
434434
var result = Mapper.Map<PSAzureOperationResponse>(op);

src/ResourceManager/Compute/Commands.Compute/Extension/CustomScript/SetAzureVMCustomScriptExtensionCommand.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,11 @@ public override void ExecuteCmdlet()
225225

226226
try
227227
{
228-
var op = this.VirtualMachineExtensionClient.CreateOrUpdate(
228+
var op = this.VirtualMachineExtensionClient.CreateOrUpdateWithHttpMessagesAsync(
229229
this.ResourceGroupName,
230230
this.VMName,
231231
this.Name,
232-
parameters);
232+
parameters).GetAwaiter().GetResult();
233233
var result = Mapper.Map<PSAzureOperationResponse>(op);
234234
WriteObject(result);
235235

src/ResourceManager/Compute/Commands.Compute/Extension/Diagnostics/SetAzureRmVMDiagnosticsExtension.cs

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

1515
using System;
16+
using System.Collections;
1617
using System.Globalization;
1718
using System.Linq;
1819
using System.Management.Automation;
@@ -40,8 +41,8 @@ namespace Microsoft.Azure.Commands.Compute
4041
[OutputType(typeof(PSAzureOperationResponse))]
4142
public class SetAzureRmVMDiagnosticsExtensionCommand : VirtualMachineExtensionBaseCmdlet
4243
{
43-
private string publicConfiguration;
44-
private string privateConfiguration;
44+
private Hashtable publicConfiguration;
45+
private Hashtable privateConfiguration;
4546
private string extensionName = "Microsoft.Insights.VMDiagnosticsSettings";
4647
private string location;
4748
private string version = "1.5";
@@ -179,29 +180,30 @@ public bool AutoUpgradeMinorVersion
179180
}
180181
}
181182

182-
private string PublicConfiguration
183+
private Hashtable PublicConfiguration
183184
{
184185
get
185186
{
186-
if (string.IsNullOrEmpty(this.publicConfiguration))
187+
if (this.publicConfiguration == null)
187188
{
188189
this.publicConfiguration =
189-
DiagnosticsHelper.GetJsonSerializedPublicDiagnosticsConfigurationFromFile(
190-
this.DiagnosticsConfigurationPath, this.StorageAccountName);
190+
DiagnosticsHelper.GetPublicDiagnosticsConfigurationFromFile(this.DiagnosticsConfigurationPath,
191+
this.StorageAccountName);
191192
}
192193

193194
return this.publicConfiguration;
194195
}
195196
}
196197

197-
private string PrivateConfiguration
198+
private Hashtable PrivateConfiguration
198199
{
199200
get
200201
{
201-
if (string.IsNullOrEmpty(this.privateConfiguration))
202+
if (this.privateConfiguration == null)
202203
{
203-
this.privateConfiguration = DiagnosticsHelper.GetJsonSerializedPrivateDiagnosticsConfiguration(this.StorageAccountName, this.StorageAccountKey,
204-
this.StorageAccountEndpoint);
204+
this.privateConfiguration = DiagnosticsHelper.GetPrivateDiagnosticsConfiguration(this.StorageAccountName,
205+
this.StorageAccountKey,
206+
this.StorageAccountEndpoint);
205207
}
206208

207209
return this.privateConfiguration;
@@ -237,11 +239,11 @@ private void ExecuteCommand()
237239
AutoUpgradeMinorVersion = this.AutoUpgradeMinorVersion
238240
};
239241

240-
var op = this.VirtualMachineExtensionClient.CreateOrUpdate(
242+
var op = this.VirtualMachineExtensionClient.CreateOrUpdateWithHttpMessagesAsync(
241243
this.ResourceGroupName,
242244
this.VMName,
243245
this.Name,
244-
parameters);
246+
parameters).GetAwaiter().GetResult();
245247

246248
var result = Mapper.Map<PSAzureOperationResponse>(op);
247249
WriteObject(result);

src/ResourceManager/Compute/Commands.Compute/RemoteDesktop/GetAzureRemoteDesktopFileCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public override void ExecuteCmdlet()
8989
// Get Azure VM
9090
var vmResponse = this.VirtualMachineClient.Get(this.ResourceGroupName, this.Name);
9191

92-
var nicId = vmResponse.VirtualMachine.NetworkProfile.NetworkInterfaces.First().ReferenceUri;
92+
var nicId = vmResponse.NetworkProfile.NetworkInterfaces.First().Id;
9393

9494
// Get the NIC
9595
var nicResourceGroupName = this.GetResourceGroupName(nicId);

src/ResourceManager/Compute/Commands.Compute/VirtualMachine/Operation/GetAzureVMCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public override void ExecuteCmdlet()
127127
foreach (var item in vmListResult.Body)
128128
{
129129
var psItem = Mapper.Map<PSVirtualMachine>(item);
130-
psItem = Mapper.Map<Rest.Azure.AzureOperationResponse<IPage<VirtualMachine>>, PSVirtualMachine>(vmListResult, psItem);
130+
psItem = Mapper.Map(vmListResult, psItem);
131131
psResultList.Add(psItem);
132132
}
133133
}

0 commit comments

Comments
 (0)