Skip to content

. #281

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 16 commits into from
Dec 30, 2015
Merged

. #281

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 @@ -48,21 +48,21 @@
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.RecoveryServices, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.RecoveryServices.1.0.1-preview\lib\net40\Microsoft.Azure.Management.RecoveryServices.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.RecoveryServices.1.0.2-preview\lib\net40\Microsoft.Azure.Management.RecoveryServices.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Resources.2.18.7-preview\lib\net40\Microsoft.Azure.ResourceManager.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Test.Framework, Version=1.0.5774.40163, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Reference Include="Microsoft.Azure.Test.Framework, Version=1.0.5799.28345, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Test.Framework.1.0.5774.40163-prerelease\lib\net45\Microsoft.Azure.Test.Framework.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Test.Framework.1.0.5799.28345-prerelease\lib\net45\Microsoft.Azure.Test.Framework.dll</HintPath>
<Private>True</Private>
</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.0.5774.40163-prerelease\lib\net45\Microsoft.Azure.Test.HttpRecorder.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Test.HttpRecorder.1.0.5799.28345-prerelease\lib\net45\Microsoft.Azure.Test.HttpRecorder.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Recovery Services Vault CRUD Tests
function Test-RecoveryServicesVaultCRUDTests
{
# Create vault
$vaultCreationResponse = New-AzureRmRecoveryServicesVault -Name rsv1 -ResouceGroupName testsitegroup -Location westus
$vaultCreationResponse = New-AzureRmRecoveryServicesVault -Name rsv1 -ResourceGroupName S91-1 -Location westus
Assert-NotNull($vaultCreationResponse.Name)
Assert-NotNull($vaultCreationResponse.ID)
Assert-NotNull($vaultCreationResponse.Type)
Expand All @@ -38,16 +38,13 @@ function Test-RecoveryServicesVaultCRUDTests
}

# Get the created vault
$vaultToBeRemoved = Get-AzureRmRecoveryServicesVault -ResourceGroupName testsitegroup -Name rsv1
$vaultToBeRemoved = Get-AzureRmRecoveryServicesVault -ResourceGroupName S91-1 -Name rsv1
Assert-NotNull($vaultToBeRemoved.Name)
Assert-NotNull($vaultToBeRemoved.ID)
Assert-NotNull($vaultToBeRemoved.Type)

# Download Vault settings file
Get-AzureRmRecoveryServicesVaultSettingsFile -Vault $vaultToBeRemoved

# Remove Vault
Remove-AzureRmRecoveryServicesVault -Vault $vaultToBeRemoved
$vaults = Get-AzureRmRecoveryServicesVault -ResourceGroupName testsitegroup -Name rsv1
$vaults = Get-AzureRmRecoveryServicesVault -ResourceGroupName S91-1 -Name rsv1
Assert-True { $vaults.Count -eq 0 }
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ public static T GetServiceClient<T>() where T : class
if (testEnvironment.UsesCustomUri())
{
client = new RecoveryServicesManagementClient(
"Microsoft.RecoveryServices",
"Microsoft.RecoveryServicesBVTD2",
testEnvironment.Credentials as SubscriptionCloudCredentials,
testEnvironment.BaseUri);
}
else
{
client = new RecoveryServicesManagementClient(
"Microsoft.RecoveryServices",
"Microsoft.RecoveryServicesBVTD2",
testEnvironment.Credentials as SubscriptionCloudCredentials);
}
return GetServiceClient<T>(factory, client);
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
<package id="Microsoft.Azure.Common" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.Azure.Common.Authentication" version="1.5.1-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Management.RecoveryServices" version="1.0.1-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.RecoveryServices" version="1.0.2-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Resources" version="2.18.7-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Test.Framework" version="1.0.5774.40163-prerelease" targetFramework="net45" />
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.0.5774.40163-prerelease" targetFramework="net45" />
<package id="Microsoft.Azure.Test.Framework" version="1.0.5799.28345-prerelease" targetFramework="net45" />
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.0.5799.28345-prerelease" targetFramework="net45" />
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net45" />
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net45" />
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.RecoveryServices, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.RecoveryServices.1.0.1-preview\lib\net40\Microsoft.Azure.Management.RecoveryServices.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.RecoveryServices.1.0.2-preview\lib\net40\Microsoft.Azure.Management.RecoveryServices.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory, Version=2.18.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public partial class PSRecoveryServicesClient
/// <returns>vault list response object.</returns>
public VaultListResponse GetVaultsInResouceGroup(string resouceGroupName)
{
return this.GetRecoveryServicesClient.Vaults.Get(resouceGroupName, this.GetRequestHeaders());
return this.GetRecoveryServicesClient.Vaults.List(resouceGroupName, this.GetRequestHeaders());
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
using Hyak.Common;
using Microsoft.WindowsAzure.Commands.Utilities.Common;
using Microsoft.Azure.Commands.ResourceManager.Common;
using Newtonsoft.Json;
using System.Text;

namespace Microsoft.Azure.Commands.RecoveryServices
{
Expand Down Expand Up @@ -68,36 +70,46 @@ public void HandleException(Exception ex)
CloudException cloudException = ex as CloudException;
if (cloudException != null)
{
Error error = null;
ARMError error = null;
try
{
using (Stream stream = new MemoryStream())
if (cloudException.Message != null)
{
if (cloudException.Message != null)
{
byte[] data = System.Text.Encoding.UTF8.GetBytes(cloudException.Message);
stream.Write(data, 0, data.Length);
stream.Position = 0;
string originalMessage = cloudException.Error.OriginalMessage;
error = JsonConvert.DeserializeObject<ARMError>(originalMessage);

StringBuilder exceptionMessage = new StringBuilder();
exceptionMessage.Append(Properties.Resources.CloudExceptionDetails);

var deserializer = new DataContractSerializer(typeof(ErrorInException));
error = (Error)deserializer.ReadObject(stream);
if (error.Error.Details != null)
{
foreach (ARMExceptionDetails detail in error.Error.Details)
{
if (!string.IsNullOrEmpty(detail.ErrorCode))
exceptionMessage.AppendLine("ErrorCode: " + detail.ErrorCode);
if (!string.IsNullOrEmpty(detail.Message))
exceptionMessage.AppendLine("Message: " + detail.Message);

throw new InvalidOperationException(
string.Format(
Properties.Resources.CloudExceptionDetails,
error.Message,
error.PossibleCauses,
error.RecommendedAction,
error.ClientRequestId));
exceptionMessage.AppendLine();
}
}
else
{
throw new Exception(
string.Format(
Properties.Resources.InvalidCloudExceptionErrorMessage,
clientRequestIdMsg + ex.Message),
ex);
if (!string.IsNullOrEmpty(error.Error.ErrorCode))
exceptionMessage.AppendLine("ErrorCode: " + error.Error.ErrorCode);
if (!string.IsNullOrEmpty(error.Error.Message))
exceptionMessage.AppendLine("Message: " + error.Error.Message);
}

throw new InvalidOperationException(exceptionMessage.ToString());
}
else
{
throw new Exception(
string.Format(
Properties.Resources.InvalidCloudExceptionErrorMessage,
clientRequestIdMsg + ex.Message),
ex);
}
}
catch (XmlException)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using System.Text;
using Microsoft.Azure.Commands.RecoveryServices;
using Microsoft.Azure.Management.RecoveryServices.Models;
using Newtonsoft.Json;

namespace Microsoft.Azure.Commands.RecoveryServices
{
Expand Down Expand Up @@ -86,15 +87,107 @@ public enum RpErrorCode
}

/// <summary>
/// Error contract returned when some exception occurs in ASR REST API.
/// ARM specified Error
/// </summary>
[SuppressMessage(
public class ARMError
{
/// <summary>
/// Gets ARM formatted exception.
/// </summary>
[JsonProperty(PropertyName = "error")]
public ARMException Error { get; private set; }
}

/// <summary>
/// ARM exception class.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage(
"Microsoft.StyleCop.CSharp.MaintainabilityRules",
"SA1402:FileMayOnlyContainASingleClass",
Justification = "Keeping all contracts together.")]
[DataContract]
public class ErrorInException : Error
Justification = "Keeping all related classes together.")]
public class ARMException
{
/// <summary>
/// Gets HTTP status code for the error.
/// </summary>
[JsonProperty(PropertyName = "code")]
public string ErrorCode { get; private set; }

/// <summary>
/// Gets exception message.
/// </summary>
[JsonProperty(PropertyName = "message")]
public string Message { get; private set; }

/// <summary>
/// Gets exception target.
/// </summary>
[JsonProperty(PropertyName = "target",
NullValueHandling = NullValueHandling.Ignore,
DefaultValueHandling = DefaultValueHandling.Ignore)]
public string Target { get; private set; }

/// <summary>
/// Gets service based error details.
/// </summary>
[JsonProperty(PropertyName = "details")]
public List<ARMExceptionDetails> Details { get; private set; }
}

/// <summary>
/// Service based exception details.
/// </summary>
public class ARMExceptionDetails
{
/// <summary>
/// Gets service error code.
/// </summary>
[JsonProperty(PropertyName = "code")]
public string ErrorCode { get; private set; }

/// <summary>
/// Gets error message.
/// </summary>
[JsonProperty(PropertyName = "message")]
public string Message { get; private set; }

/// <summary>
/// Gets possible cause for error.
/// </summary>
[JsonProperty(PropertyName = "possibleCauses",
NullValueHandling = NullValueHandling.Ignore,
DefaultValueHandling = DefaultValueHandling.Ignore)]
public string PossibleCauses { get; private set; }

/// <summary>
/// Gets recommended action for the error.
/// </summary>
[JsonProperty(PropertyName = "recommendedAction",
NullValueHandling = NullValueHandling.Ignore,
DefaultValueHandling = DefaultValueHandling.Ignore)]
public string RecommendedAction { get; private set; }

/// <summary>
/// Gets the client request Id for the session.
/// </summary>
[JsonProperty(PropertyName = "clientRequestId",
NullValueHandling = NullValueHandling.Ignore,
DefaultValueHandling = DefaultValueHandling.Ignore)]
public string ClientRequestId { get; private set; }

/// <summary>
/// Gets the activity Id for the session.
/// </summary>
[JsonProperty(PropertyName = "activityId")]
public string ActivityId { get; private set; }

/// <summary>
/// Gets exception target.
/// </summary>
[JsonProperty(PropertyName = "target",
NullValueHandling = NullValueHandling.Ignore,
DefaultValueHandling = DefaultValueHandling.Ignore)]
public string Target { get; private set; }
}

/// <summary>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,7 @@
</resheader>
<data name="CloudExceptionDetails" xml:space="preserve">
<value>Operation Failed.
Message: {0}
Possible Causes: {1}
Recommended Action: {2}
ClientRequestId: {3}</value>
</value>
</data>
<data name="CloudServiceNameNullOrEmpty" xml:space="preserve">
<value>Cloud Service name mentioned is either null or empty</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ public class NewAzureRmRecoveryServicesVault : RecoveryServicesCmdletBase
public string Name { get; set; }

/// <summary>
/// Gets or sets the resouce group name
/// Gets or sets the resource group name
/// </summary>
[Parameter(Mandatory = true)]
[ValidateNotNullOrEmpty]
public string ResouceGroupName { get; set; }
public string ResourceGroupName { get; set; }

/// <summary>
/// Gets or sets the location of the vault
Expand All @@ -62,7 +62,7 @@ public override void ExecuteCmdlet()
vaultCreateArgs.Sku = new VaultSku();
vaultCreateArgs.Sku.Name = "standard";

VaultCreateResponse response = RecoveryServicesClient.CreateVault(this.ResouceGroupName, this.Name, vaultCreateArgs);
VaultCreateResponse response = RecoveryServicesClient.CreateVault(this.ResourceGroupName, this.Name, vaultCreateArgs);

this.WriteObject(new ARSVault(response));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<package id="Microsoft.Azure.Common" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.Azure.Common.Authentication" version="1.5.1-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Management.RecoveryServices" version="1.0.1-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.RecoveryServices" version="1.0.2-preview" targetFramework="net45" />
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net45" />
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net45" />
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.SiteRecovery, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.SiteRecovery.1.0.1-preview\lib\net40\Microsoft.Azure.Management.SiteRecovery.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.SiteRecovery.1.0.2-preview\lib\net40\Microsoft.Azure.Management.SiteRecovery.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
Expand Down
Loading