Skip to content

Commit b976625

Browse files
author
Maddie Clayton
authored
Merge pull request Azure#8972 from MSSedusch/master
AEM: Fix regex to be case insensitive
2 parents 1c43800 + 44a2174 commit b976625

17 files changed

+14009
-20275
lines changed

src/Compute/Compute.Test/ScenarioTests/AEMExtensionTests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,7 @@ function Create-AdvancedVM($rgname, $vmname, $loc, $vmsize, $stotype, $nicCount,
961961

962962
function Get-LinuxImage
963963
{
964-
return Create-ComputeVMImageObject 'SUSE' 'SLES' '12-SP2' 'latest';
964+
return Create-ComputeVMImageObject 'SUSE' 'SLES' '12-SP4' 'latest';
965965
}
966966

967967
function GetWrongTestResult($TestResult, $searchFor, $level)

src/Compute/Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.AEMExtensionTests/TestAEMExtensionAdvancedLinux.json

Lines changed: 1164 additions & 1485 deletions
Large diffs are not rendered by default.

src/Compute/Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.AEMExtensionTests/TestAEMExtensionAdvancedLinuxMD.json

Lines changed: 1322 additions & 2221 deletions
Large diffs are not rendered by default.

src/Compute/Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.AEMExtensionTests/TestAEMExtensionAdvancedLinuxMD_DSeries.json

Lines changed: 1123 additions & 1473 deletions
Large diffs are not rendered by default.

src/Compute/Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.AEMExtensionTests/TestAEMExtensionAdvancedLinuxMD_ESeries.json

Lines changed: 1423 additions & 3246 deletions
Large diffs are not rendered by default.

src/Compute/Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.AEMExtensionTests/TestAEMExtensionAdvancedLinuxWAD.json

Lines changed: 1019 additions & 1629 deletions
Large diffs are not rendered by default.

src/Compute/Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.AEMExtensionTests/TestAEMExtensionAdvancedWindows.json

Lines changed: 1090 additions & 2094 deletions
Large diffs are not rendered by default.

src/Compute/Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.AEMExtensionTests/TestAEMExtensionAdvancedWindowsMD.json

Lines changed: 1376 additions & 1299 deletions
Large diffs are not rendered by default.

src/Compute/Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.AEMExtensionTests/TestAEMExtensionAdvancedWindowsWAD.json

Lines changed: 1179 additions & 1606 deletions
Large diffs are not rendered by default.

src/Compute/Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.AEMExtensionTests/TestAEMExtensionBasicLinux.json

Lines changed: 1319 additions & 1181 deletions
Large diffs are not rendered by default.

src/Compute/Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.AEMExtensionTests/TestAEMExtensionBasicLinuxWAD.json

Lines changed: 935 additions & 1423 deletions
Large diffs are not rendered by default.

src/Compute/Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.AEMExtensionTests/TestAEMExtensionBasicWindows.json

Lines changed: 893 additions & 1377 deletions
Large diffs are not rendered by default.

src/Compute/Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.AEMExtensionTests/TestAEMExtensionBasicWindowsWAD.json

Lines changed: 1142 additions & 1203 deletions
Large diffs are not rendered by default.

src/Compute/Compute/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
- Additional information about change #1
2020
-->
2121
## Upcoming Release
22+
* Fix issue with AEM installation if resource ids of disks had lowercase resourcegroups in resource id
2223
* Updated cmdlets with plural nouns to singular, and deprecated plural names.
2324

2425
## Version 1.7.0

src/Compute/Compute/Extension/AEM/AEMHelper.cs

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using Microsoft.Azure.Commands.Common.Authentication.Models;
1717
using Microsoft.Azure.Commands.Compute.StorageServices;
1818
using Microsoft.Azure.Management.Compute.Models;
19+
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
1920
using Microsoft.Azure.Management.Storage.Version2017_10_01;
2021
using Microsoft.Azure.Management.Storage.Version2017_10_01.Models;
2122
using Microsoft.WindowsAzure.Commands.Sync.Download;
@@ -88,29 +89,6 @@ internal StorageAccount GetStorageAccountFromCache(string accountName)
8889

8990
return account;
9091
}
91-
internal string GetResourceGroupFromId(string id)
92-
{
93-
var matcher = new Regex("/subscriptions/([^/]+)/resourceGroups/([^/]+)/providers/(\\w+)");
94-
var result = matcher.Match(id);
95-
if (!result.Success || result.Groups == null || result.Groups.Count < 3)
96-
{
97-
throw new InvalidOperationException(string.Format("Cannot find resource group name and storage account name from resource identity {0}", id));
98-
}
99-
100-
return result.Groups[2].Value;
101-
}
102-
103-
internal string GetResourceNameFromId(string id)
104-
{
105-
var matcher = new Regex("/subscriptions/([^/]+)/resourceGroups/([^/]+)/providers/([^/]+)/([^/]+)/([^/]+)(/\\w+)?");
106-
var result = matcher.Match(id);
107-
if (!result.Success || result.Groups == null || result.Groups.Count < 3)
108-
{
109-
throw new InvalidOperationException(string.Format("Cannot find resource group name and storage account name from resource identity {0}", id));
110-
}
111-
112-
return result.Groups[5].Value;
113-
}
11492

11593
internal bool IsPremiumStorageAccount(string accountName)
11694
{
@@ -138,7 +116,8 @@ internal bool IsPremiumStorageAccount(string accountName)
138116
try
139117
{
140118
var account = this.GetStorageAccountFromCache(accountName);
141-
var resGroupName = this.GetResourceGroupFromId(account.Id);
119+
120+
var resGroupName = new ResourceIdentifier(account.Id).ResourceGroupName;
142121
StorageCredentialsFactory storageCredentialsFactory = new StorageCredentialsFactory(resGroupName,
143122
this._StorageClient, this._Subscription);
144123
StorageCredentials sc = storageCredentialsFactory.Create(blobUri);
@@ -368,7 +347,7 @@ internal string GetAzureStorageKeyFromCache(string accountName)
368347
}
369348

370349
var account = this.GetStorageAccountFromCache(accountName);
371-
var resourceGroup = this.GetResourceGroupFromId(account.Id);
350+
var resourceGroup = new ResourceIdentifier(account.Id).ResourceGroupName;
372351
var keys = this._StorageClient.StorageAccounts.ListKeys(resourceGroup, account.Name);
373352

374353
_StorageKeyCache.Add(account.Name, keys.GetKey1());
@@ -442,7 +421,7 @@ internal AzureSLA GetDiskSLA(int? diskSize, VirtualHardDisk vhd)
442421
{
443422
// P4
444423
sla.IOPS = 120;
445-
sla.TP = 125;
424+
sla.TP = 25;
446425
}
447426
else if (diskSize > 0 && diskSize <= 64)
448427
{

src/Compute/Compute/Extension/AEM/SetAzureRmVMAEMExtension.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
2323
using Microsoft.Azure.Management.Compute;
2424
using Microsoft.Azure.Management.Compute.Models;
25+
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
2526
using Microsoft.Azure.Management.Storage.Version2017_10_01;
2627
using Microsoft.WindowsAzure.Storage;
2728
using Microsoft.WindowsAzure.Storage.Auth;
@@ -206,14 +207,15 @@ public override void ExecuteCmdlet()
206207
}
207208
else
208209
{
209-
var osDiskMD = ComputeClient.ComputeManagementClient.Disks.Get(this._Helper.GetResourceGroupFromId(osdisk.ManagedDisk.Id),
210-
this._Helper.GetResourceNameFromId(osdisk.ManagedDisk.Id));
210+
var resId = new ResourceIdentifier(osdisk.ManagedDisk.Id);
211+
212+
var osDiskMD = ComputeClient.ComputeManagementClient.Disks.Get(resId.ResourceGroupName, resId.ResourceName);
211213
if (osDiskMD.Sku.Name == StorageAccountTypes.PremiumLRS)
212214
{
213215
WriteVerbose("OS Disk is a Premium Managed Disk - adding SLAs for OS disk");
214216
var sla = this._Helper.GetDiskSLA(osDiskMD.DiskSizeGB, null);
215217
var caching = osdisk.Caching;
216-
sapmonPublicConfig.Add(new KeyValuePair() { Key = "osdisk.name", Value = this._Helper.GetResourceNameFromId(osdisk.ManagedDisk.Id) });
218+
sapmonPublicConfig.Add(new KeyValuePair() { Key = "osdisk.name", Value = resId.ResourceName });
217219
sapmonPublicConfig.Add(new KeyValuePair() { Key = "osdisk.caching", Value = caching });
218220
sapmonPublicConfig.Add(new KeyValuePair() { Key = "osdisk.type", Value = AEMExtensionConstants.DISK_TYPE_PREMIUM_MD });
219221
sapmonPublicConfig.Add(new KeyValuePair() { Key = "osdisk.sla.throughput", Value = sla.TP });
@@ -231,16 +233,17 @@ public override void ExecuteCmdlet()
231233
{
232234
if (disk.ManagedDisk != null)
233235
{
234-
var diskMD = ComputeClient.ComputeManagementClient.Disks.Get(this._Helper.GetResourceGroupFromId(disk.ManagedDisk.Id),
235-
this._Helper.GetResourceNameFromId(disk.ManagedDisk.Id));
236+
var resId = new ResourceIdentifier(disk.ManagedDisk.Id);
237+
238+
var diskMD = ComputeClient.ComputeManagementClient.Disks.Get(resId.ResourceGroupName, resId.ResourceName);
236239

237240
if (diskMD.Sku.Name == StorageAccountTypes.PremiumLRS)
238241
{
239242
this._Helper.WriteVerbose("Data Disk {0} is a Premium Managed Disk - adding SLAs for disk", diskNumber.ToString());
240243
var sla = this._Helper.GetDiskSLA(diskMD.DiskSizeGB, null);
241244
var cachingMD = disk.Caching;
242245
sapmonPublicConfig.Add(new KeyValuePair() { Key = "disk.lun." + diskNumber, Value = disk.Lun });
243-
sapmonPublicConfig.Add(new KeyValuePair() { Key = "disk.name." + diskNumber, Value = this._Helper.GetResourceNameFromId(disk.ManagedDisk.Id) });
246+
sapmonPublicConfig.Add(new KeyValuePair() { Key = "disk.name." + diskNumber, Value = resId.ResourceName });
244247
sapmonPublicConfig.Add(new KeyValuePair() { Key = "disk.caching." + diskNumber, Value = cachingMD });
245248
sapmonPublicConfig.Add(new KeyValuePair() { Key = "disk.type." + diskNumber, Value = AEMExtensionConstants.DISK_TYPE_PREMIUM_MD });
246249
sapmonPublicConfig.Add(new KeyValuePair() { Key = "disk.sla.throughput." + diskNumber, Value = sla.TP });
@@ -253,7 +256,7 @@ public override void ExecuteCmdlet()
253256
var sla = this._Helper.GetDiskSLA(diskMD.DiskSizeGB, null);
254257
var cachingMD = disk.Caching;
255258
sapmonPublicConfig.Add(new KeyValuePair() { Key = "disk.lun." + diskNumber, Value = disk.Lun });
256-
sapmonPublicConfig.Add(new KeyValuePair() { Key = "disk.name." + diskNumber, Value = this._Helper.GetResourceNameFromId(disk.ManagedDisk.Id) });
259+
sapmonPublicConfig.Add(new KeyValuePair() { Key = "disk.name." + diskNumber, Value = resId.ResourceName });
257260
sapmonPublicConfig.Add(new KeyValuePair() { Key = "disk.caching." + diskNumber, Value = cachingMD });
258261
sapmonPublicConfig.Add(new KeyValuePair() { Key = "disk.type." + diskNumber, Value = AEMExtensionConstants.DISK_TYPE_ULTRA_MD });
259262
sapmonPublicConfig.Add(new KeyValuePair() { Key = "disk.sla.throughput." + diskNumber, Value = diskMD.DiskMBpsReadWrite });

src/Compute/Compute/Extension/AEM/TestAzureRmVMAEMExtension.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
2222
using Microsoft.Azure.Management.Compute;
2323
using Microsoft.Azure.Management.Compute.Models;
24+
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
2425
using Microsoft.Azure.Management.Storage.Version2017_10_01;
2526
using Microsoft.Azure.Management.Storage.Version2017_10_01.Models;
2627
using Newtonsoft.Json;
@@ -360,8 +361,9 @@ public override void ExecuteCmdlet()
360361
}
361362
else
362363
{
363-
var osDiskMD = ComputeClient.ComputeManagementClient.Disks.Get(this._Helper.GetResourceGroupFromId(osdisk.ManagedDisk.Id),
364-
this._Helper.GetResourceNameFromId(osdisk.ManagedDisk.Id));
364+
var resId = new ResourceIdentifier(osdisk.ManagedDisk.Id);
365+
366+
var osDiskMD = ComputeClient.ComputeManagementClient.Disks.Get(resId.ResourceGroupName, resId.ResourceName);
365367
if (osDiskMD.Sku.Name == StorageAccountTypes.PremiumLRS)
366368
{
367369
var sla = this._Helper.GetDiskSLA(osDiskMD.DiskSizeGB, null);
@@ -387,8 +389,9 @@ public override void ExecuteCmdlet()
387389
{
388390
if (disk.ManagedDisk != null)
389391
{
390-
var diskMD = ComputeClient.ComputeManagementClient.Disks.Get(this._Helper.GetResourceGroupFromId(disk.ManagedDisk.Id),
391-
this._Helper.GetResourceNameFromId(disk.ManagedDisk.Id));
392+
var resId = new ResourceIdentifier(disk.ManagedDisk.Id);
393+
394+
var diskMD = ComputeClient.ComputeManagementClient.Disks.Get(resId.ResourceGroupName, resId.ResourceName);
392395

393396
if (diskMD.Sku.Name == StorageAccountTypes.PremiumLRS)
394397
{

0 commit comments

Comments
 (0)