Skip to content

AEM: Fix regex to be case insensitive #8972

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@ function Create-AdvancedVM($rgname, $vmname, $loc, $vmsize, $stotype, $nicCount,

function Get-LinuxImage
{
return Create-ComputeVMImageObject 'SUSE' 'SLES' '12-SP2' 'latest';
return Create-ComputeVMImageObject 'SUSE' 'SLES' '12-SP4' 'latest';
}

function GetWrongTestResult($TestResult, $searchFor, $level)
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/Compute/Compute/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- Additional information about change #1
-->
## Upcoming Release
* Fix issue with AEM installation if resource ids of disks had lowercase resourcegroups in resource id
* Updated cmdlets with plural nouns to singular, and deprecated plural names.

## Version 1.7.0
Expand Down
31 changes: 5 additions & 26 deletions src/Compute/Compute/Extension/AEM/AEMHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using Microsoft.Azure.Commands.Common.Authentication.Models;
using Microsoft.Azure.Commands.Compute.StorageServices;
using Microsoft.Azure.Management.Compute.Models;
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
using Microsoft.Azure.Management.Storage.Version2017_10_01;
using Microsoft.Azure.Management.Storage.Version2017_10_01.Models;
using Microsoft.WindowsAzure.Commands.Sync.Download;
Expand Down Expand Up @@ -88,29 +89,6 @@ internal StorageAccount GetStorageAccountFromCache(string accountName)

return account;
}
internal string GetResourceGroupFromId(string id)
{
var matcher = new Regex("/subscriptions/([^/]+)/resourceGroups/([^/]+)/providers/(\\w+)");
var result = matcher.Match(id);
if (!result.Success || result.Groups == null || result.Groups.Count < 3)
{
throw new InvalidOperationException(string.Format("Cannot find resource group name and storage account name from resource identity {0}", id));
}

return result.Groups[2].Value;
}

internal string GetResourceNameFromId(string id)
{
var matcher = new Regex("/subscriptions/([^/]+)/resourceGroups/([^/]+)/providers/([^/]+)/([^/]+)/([^/]+)(/\\w+)?");
var result = matcher.Match(id);
if (!result.Success || result.Groups == null || result.Groups.Count < 3)
{
throw new InvalidOperationException(string.Format("Cannot find resource group name and storage account name from resource identity {0}", id));
}

return result.Groups[5].Value;
}

internal bool IsPremiumStorageAccount(string accountName)
{
Expand Down Expand Up @@ -138,7 +116,8 @@ internal bool IsPremiumStorageAccount(string accountName)
try
{
var account = this.GetStorageAccountFromCache(accountName);
var resGroupName = this.GetResourceGroupFromId(account.Id);

var resGroupName = new ResourceIdentifier(account.Id).ResourceGroupName;
StorageCredentialsFactory storageCredentialsFactory = new StorageCredentialsFactory(resGroupName,
this._StorageClient, this._Subscription);
StorageCredentials sc = storageCredentialsFactory.Create(blobUri);
Expand Down Expand Up @@ -368,7 +347,7 @@ internal string GetAzureStorageKeyFromCache(string accountName)
}

var account = this.GetStorageAccountFromCache(accountName);
var resourceGroup = this.GetResourceGroupFromId(account.Id);
var resourceGroup = new ResourceIdentifier(account.Id).ResourceGroupName;
var keys = this._StorageClient.StorageAccounts.ListKeys(resourceGroup, account.Name);

_StorageKeyCache.Add(account.Name, keys.GetKey1());
Expand Down Expand Up @@ -442,7 +421,7 @@ internal AzureSLA GetDiskSLA(int? diskSize, VirtualHardDisk vhd)
{
// P4
sla.IOPS = 120;
sla.TP = 125;
sla.TP = 25;
}
else if (diskSize > 0 && diskSize <= 64)
{
Expand Down
17 changes: 10 additions & 7 deletions src/Compute/Compute/Extension/AEM/SetAzureRmVMAEMExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
using Microsoft.Azure.Management.Compute;
using Microsoft.Azure.Management.Compute.Models;
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
using Microsoft.Azure.Management.Storage.Version2017_10_01;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Auth;
Expand Down Expand Up @@ -206,14 +207,15 @@ public override void ExecuteCmdlet()
}
else
{
var osDiskMD = ComputeClient.ComputeManagementClient.Disks.Get(this._Helper.GetResourceGroupFromId(osdisk.ManagedDisk.Id),
this._Helper.GetResourceNameFromId(osdisk.ManagedDisk.Id));
var resId = new ResourceIdentifier(osdisk.ManagedDisk.Id);

var osDiskMD = ComputeClient.ComputeManagementClient.Disks.Get(resId.ResourceGroupName, resId.ResourceName);
if (osDiskMD.Sku.Name == StorageAccountTypes.PremiumLRS)
{
WriteVerbose("OS Disk is a Premium Managed Disk - adding SLAs for OS disk");
var sla = this._Helper.GetDiskSLA(osDiskMD.DiskSizeGB, null);
var caching = osdisk.Caching;
sapmonPublicConfig.Add(new KeyValuePair() { Key = "osdisk.name", Value = this._Helper.GetResourceNameFromId(osdisk.ManagedDisk.Id) });
sapmonPublicConfig.Add(new KeyValuePair() { Key = "osdisk.name", Value = resId.ResourceName });
sapmonPublicConfig.Add(new KeyValuePair() { Key = "osdisk.caching", Value = caching });
sapmonPublicConfig.Add(new KeyValuePair() { Key = "osdisk.type", Value = AEMExtensionConstants.DISK_TYPE_PREMIUM_MD });
sapmonPublicConfig.Add(new KeyValuePair() { Key = "osdisk.sla.throughput", Value = sla.TP });
Expand All @@ -231,16 +233,17 @@ public override void ExecuteCmdlet()
{
if (disk.ManagedDisk != null)
{
var diskMD = ComputeClient.ComputeManagementClient.Disks.Get(this._Helper.GetResourceGroupFromId(disk.ManagedDisk.Id),
this._Helper.GetResourceNameFromId(disk.ManagedDisk.Id));
var resId = new ResourceIdentifier(disk.ManagedDisk.Id);

var diskMD = ComputeClient.ComputeManagementClient.Disks.Get(resId.ResourceGroupName, resId.ResourceName);

if (diskMD.Sku.Name == StorageAccountTypes.PremiumLRS)
{
this._Helper.WriteVerbose("Data Disk {0} is a Premium Managed Disk - adding SLAs for disk", diskNumber.ToString());
var sla = this._Helper.GetDiskSLA(diskMD.DiskSizeGB, null);
var cachingMD = disk.Caching;
sapmonPublicConfig.Add(new KeyValuePair() { Key = "disk.lun." + diskNumber, Value = disk.Lun });
sapmonPublicConfig.Add(new KeyValuePair() { Key = "disk.name." + diskNumber, Value = this._Helper.GetResourceNameFromId(disk.ManagedDisk.Id) });
sapmonPublicConfig.Add(new KeyValuePair() { Key = "disk.name." + diskNumber, Value = resId.ResourceName });
sapmonPublicConfig.Add(new KeyValuePair() { Key = "disk.caching." + diskNumber, Value = cachingMD });
sapmonPublicConfig.Add(new KeyValuePair() { Key = "disk.type." + diskNumber, Value = AEMExtensionConstants.DISK_TYPE_PREMIUM_MD });
sapmonPublicConfig.Add(new KeyValuePair() { Key = "disk.sla.throughput." + diskNumber, Value = sla.TP });
Expand All @@ -253,7 +256,7 @@ public override void ExecuteCmdlet()
var sla = this._Helper.GetDiskSLA(diskMD.DiskSizeGB, null);
var cachingMD = disk.Caching;
sapmonPublicConfig.Add(new KeyValuePair() { Key = "disk.lun." + diskNumber, Value = disk.Lun });
sapmonPublicConfig.Add(new KeyValuePair() { Key = "disk.name." + diskNumber, Value = this._Helper.GetResourceNameFromId(disk.ManagedDisk.Id) });
sapmonPublicConfig.Add(new KeyValuePair() { Key = "disk.name." + diskNumber, Value = resId.ResourceName });
sapmonPublicConfig.Add(new KeyValuePair() { Key = "disk.caching." + diskNumber, Value = cachingMD });
sapmonPublicConfig.Add(new KeyValuePair() { Key = "disk.type." + diskNumber, Value = AEMExtensionConstants.DISK_TYPE_ULTRA_MD });
sapmonPublicConfig.Add(new KeyValuePair() { Key = "disk.sla.throughput." + diskNumber, Value = diskMD.DiskMBpsReadWrite });
Expand Down
11 changes: 7 additions & 4 deletions src/Compute/Compute/Extension/AEM/TestAzureRmVMAEMExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
using Microsoft.Azure.Management.Compute;
using Microsoft.Azure.Management.Compute.Models;
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
using Microsoft.Azure.Management.Storage.Version2017_10_01;
using Microsoft.Azure.Management.Storage.Version2017_10_01.Models;
using Newtonsoft.Json;
Expand Down Expand Up @@ -360,8 +361,9 @@ public override void ExecuteCmdlet()
}
else
{
var osDiskMD = ComputeClient.ComputeManagementClient.Disks.Get(this._Helper.GetResourceGroupFromId(osdisk.ManagedDisk.Id),
this._Helper.GetResourceNameFromId(osdisk.ManagedDisk.Id));
var resId = new ResourceIdentifier(osdisk.ManagedDisk.Id);

var osDiskMD = ComputeClient.ComputeManagementClient.Disks.Get(resId.ResourceGroupName, resId.ResourceName);
if (osDiskMD.Sku.Name == StorageAccountTypes.PremiumLRS)
{
var sla = this._Helper.GetDiskSLA(osDiskMD.DiskSizeGB, null);
Expand All @@ -387,8 +389,9 @@ public override void ExecuteCmdlet()
{
if (disk.ManagedDisk != null)
{
var diskMD = ComputeClient.ComputeManagementClient.Disks.Get(this._Helper.GetResourceGroupFromId(disk.ManagedDisk.Id),
this._Helper.GetResourceNameFromId(disk.ManagedDisk.Id));
var resId = new ResourceIdentifier(disk.ManagedDisk.Id);

var diskMD = ComputeClient.ComputeManagementClient.Disks.Get(resId.ResourceGroupName, resId.ResourceName);

if (diskMD.Sku.Name == StorageAccountTypes.PremiumLRS)
{
Expand Down