Skip to content

Commit

Permalink
Merge pull request #4 from TianoMS/MoveRG
Browse files Browse the repository at this point in the history
Fix Websites and Sql case failures.
  • Loading branch information
vivsriaus committed May 13, 2016
2 parents 52ce5cf + 4ea664f commit 04d10f7
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public override void ExecuteCmdlet()
ProjectResources.RemoveResourceGroupMessage,
Name,
() => ResourceManagerSdkClient.DeleteResourceGroup(Name));

WriteObject(true);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,7 @@
<HintPath>..\..\..\packages\Microsoft.Azure.Test.Framework.1.0.5945.28173-prerelease\lib\net45\Microsoft.Azure.Test.Framework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Test.HttpRecorder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Test.HttpRecorder.1.6.0-preview\lib\net45\Microsoft.Azure.Test.HttpRecorder.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Data.Edm">
<SpecificVersion>False</SpecificVersion>
Expand Down Expand Up @@ -143,9 +141,7 @@
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Storage.5.1.1\lib\net40\Microsoft.WindowsAzure.Management.Storage.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Storage, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\WindowsAzure.Storage.6.0.0\lib\net40\Microsoft.WindowsAzure.Storage.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Moq, Version=4.2.1510.2205, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,31 +68,31 @@ public virtual List<PSResource> FilterPSResources(BasePSResourceParameters param
throw new ArgumentException(ProjectResources.ResourceDoesntExists);
}

//resources.Add(getResult.Resource.ToPSResource(this, false));
resources.Add(getResult.Resource.ToPSResource(this, false));
}
else
{
//PSTagValuePair tagValuePair = new PSTagValuePair();
//if (parameters.Tag != null && parameters.Tag.Length == 1 && parameters.Tag[0] != null)
//{
// tagValuePair = TagsConversionHelper.Create(parameters.Tag[0]);
// if (tagValuePair == null)
// {
// throw new ArgumentException(ProjectResources.InvalidTagFormat);
// }
//}
//ResourceListResult listResult = ResourceManagementClient.Resources.List(new ResourceListParameters
//{
// ResourceGroupName = parameters.ResourceGroupName,
// ResourceType = parameters.ResourceType,
// TagName = tagValuePair.Name,
// TagValue = tagValuePair.Value
//});
PSTagValuePair tagValuePair = new PSTagValuePair();
if (parameters.Tag != null && parameters.Tag.Length == 1 && parameters.Tag[0] != null)
{
tagValuePair = TagsConversionHelper.Create(parameters.Tag[0]);
if (tagValuePair == null)
{
throw new ArgumentException(ProjectResources.InvalidTagFormat);
}
}
ResourceListResult listResult = ResourceManagementClient.Resources.List(new ResourceListParameters
{
ResourceGroupName = parameters.ResourceGroupName,
ResourceType = parameters.ResourceType,
TagName = tagValuePair.Name,
TagValue = tagValuePair.Value
});

//if (listResult.Resources != null)
//{
// resources.AddRange(listResult.Resources.Select(r => r.ToPSResource(this, false)));
//}
if (listResult.Resources != null)
{
resources.AddRange(listResult.Resources.Select(r => r.ToPSResource(this, false)));
}
}
return resources;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
using Microsoft.Azure.Commands.Common.Authentication.Models;
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Components;
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Utilities;
using Microsoft.Azure.Commands.Resources.Models.Authorization;
using Microsoft.Azure.Management.Authorization;
using Microsoft.Azure.Management.Authorization.Models;
using Microsoft.Azure.Management.Resources;
using Microsoft.Azure.Management.Resources.Models;
using Microsoft.WindowsAzure.Commands.Utilities.Common;
Expand Down Expand Up @@ -133,6 +135,20 @@ public DeploymentExtended ProvisionDeploymentStatus(string resourceGroup, string
ProvisioningState.Failed);
}

internal List<PSPermission> GetResourcePermissions(ResourceIdentifier identity)
{
PermissionGetResult permissionsResult = AuthorizationManagementClient.Permissions.ListForResource(
identity.ResourceGroupName,
identity.ToResourceIdentity());

if (permissionsResult != null)
{
return permissionsResult.Permissions.Select(p => p.ToPSPermission()).ToList();
}

return null;
}

private void WriteDeploymentProgress(string resourceGroup, string deploymentName, Deployment deployment)
{
const string normalStatusFormat = "Resource {0} '{1}' provisioning status is {2}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.Resources.Models.Authorization;
using Microsoft.Azure.Commands.Tags.Model;
using Microsoft.Azure.Gallery;
using Microsoft.Azure.Management.Resources.Models;
using Microsoft.WindowsAzure.Commands.Utilities.Common;
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using Microsoft.Azure.Commands.Common.Authentication;
using Microsoft.Azure.Commands.Resources.Models.Authorization;
using Microsoft.Azure.Commands.Tags.Model;
using Microsoft.Azure.Gallery;
using Microsoft.Azure.Management.Authorization.Models;
using Microsoft.Azure.Management.Resources.Models;
using Microsoft.WindowsAzure.Commands.Utilities.Common;
using Newtonsoft.Json;

namespace Microsoft.Azure.Commands.Resources.Models
{
Expand All @@ -40,6 +42,33 @@ public static PSGalleryItem ToPSGalleryItem(this GalleryItem gallery)
return psGalleryItem;
}

public static PSResource ToPSResource(this GenericResourceExtended resource, ResourcesClient client, bool minimal)
{
ResourceIdentifier identifier = new ResourceIdentifier(resource.Id);
return new PSResource
{
Name = identifier.ResourceName,
Location = resource.Location,
ResourceType = identifier.ResourceType,
ResourceGroupName = identifier.ResourceGroupName,
ParentResource = identifier.ParentResource,
Properties = JsonUtilities.DeserializeJson(resource.Properties),
PropertiesText = resource.Properties,
Tags = TagsConversionHelper.CreateTagHashtable(resource.Tags),
Permissions = minimal ? null : client.GetResourcePermissions(identifier),
ResourceId = identifier.ToString()
};
}

public static PSPermission ToPSPermission(this Permission permission)
{
return new PSPermission()
{
Actions = new List<string>(permission.Actions),
NotActions = new List<string>(permission.NotActions)
};
}

private static string ConstructTemplateLinkView(TemplateLink templateLink)
{
if (templateLink == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ Creates the test environment needed to perform the Sql data masking tests
function Create-DataMaskingTestEnvironment ($testSuffix)
{
$params = Get-SqlDataMaskingTestEnvironmentParameters $testSuffix
New-AzureRmResourceGroup -Name $params.rgname -Location "Australia East" -Force
New-AzureRmResourceGroupDeployment -ResourceGroupName $params.rgname -TemplateFile ".\Templates\sql-ddm-test-env-setup.json" -serverName $params.serverName -databaseName $params.databaseName -EnvLocation "Australia East" -administratorLogin $params.userName -Force
$rg = New-AzureRmResourceGroup -Name $params.rgname -Location "Australia East" -Force
$rgdeployment = New-AzureRmResourceGroupDeployment -ResourceGroupName $params.rgname -TemplateFile ".\Templates\sql-ddm-test-env-setup.json" -serverName $params.serverName -databaseName $params.databaseName -EnvLocation "Australia East" -administratorLogin $params.userName -Force
$fullServerName = $params.serverName + ".database.windows.net"

$uid = $params.userName
Expand Down

0 comments on commit 04d10f7

Please sign in to comment.