Skip to content

Dev1 pikumar git2 #121

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 2 commits into from
Aug 18, 2015
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 @@ -40,7 +40,7 @@ public override void ExecuteCmdlet()
{
base.ExecuteCmdlet();

WriteDebug(String.Format("Cmdlet called for ResourceGroupName: {0}, ResourceName: {1}", RecoveryPoint.ResourceGroupName, RecoveryPoint.ResourceName));
WriteDebug(String.Format(Resources.CmdletCalled, RecoveryPoint.ResourceGroupName, RecoveryPoint.ResourceName, RecoveryPoint.Location));
InitializeAzureBackupCmdlet(RecoveryPoint.ResourceGroupName, RecoveryPoint.ResourceName);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void CheckProtectionPolicyNameAvailability(string resourceGroupName, stri
var policy = GetProtectionPolicyByName(resourceGroupName, resourceName, name);
if (policy != null)
{
var exception = new ArgumentException("A protection policy with the specified name already exists.");
var exception = new ArgumentException(Resources.PolicyAlreadyExist);
throw exception;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected void InitializeAzureBackupCmdlet(string rgName, string rName)
var cloudServicesClient = AzureSession.ClientFactory.CreateClient<CloudServiceManagementClient>(Profile, Profile.Context.Subscription, AzureEnvironment.Endpoint.ResourceManager);
azureBackupClientAdapter = new AzureBackupClientAdapter(cloudServicesClient.Credentials, cloudServicesClient.BaseUri);

WriteDebug(string.Format("Initialized AzureBackup Cmdlet, ClientRequestId: {0}, ResourceGroupName: {1}, ResourceName : {2}", azureBackupClientAdapter.GetClientRequestId(), rgName, rName));
WriteDebug(string.Format(Resources.InitializingClient, azureBackupClientAdapter.GetClientRequestId(), rgName, rName));
}

/// <summary>
Expand All @@ -79,7 +79,7 @@ protected void ExecutionBlock(Action execAction)
}
catch (Exception exception)
{
WriteDebug(String.Format("Caught exception, type: {0}", exception.GetType()));
WriteDebug(String.Format(Resources.ExceptionInExecution, exception.GetType()));
HandleException(exception);
}
}
Expand All @@ -93,7 +93,7 @@ private void HandleException(Exception exception)
if (exception is AggregateException && ((AggregateException)exception).InnerExceptions != null
&& ((AggregateException)exception).InnerExceptions.Count != 0)
{
WriteDebug("Handling aggregate exception");
WriteDebug(Resources.AggregateException);
foreach (var innerEx in ((AggregateException)exception).InnerExceptions)
{
HandleException(innerEx);
Expand All @@ -110,14 +110,14 @@ private void HandleException(Exception exception)
var cloudEx = exception as CloudException;
if (cloudEx.Response != null && cloudEx.Response.StatusCode == HttpStatusCode.NotFound)
{
WriteDebug(String.Format("Received CloudException, StatusCode: {0}", cloudEx.Response.StatusCode));
WriteDebug(String.Format(Resources.CloudExceptionCodeNotFound, cloudEx.Response.StatusCode));

targetEx = new Exception(Resources.ResourceNotFoundMessage);
targetErrorCategory = ErrorCategory.InvalidArgument;
}
else if (cloudEx.Error != null)
{
WriteDebug(String.Format("Received CloudException, ErrorCode: {0}, Message: {1}", cloudEx.Error.Code, cloudEx.Error.Message));
WriteDebug(String.Format(Resources.CloudException, cloudEx.Error.Code, cloudEx.Error.Message));

targetErrorId = cloudEx.Error.Code;
targetErrorCategory = ErrorCategory.InvalidOperation;
Expand All @@ -126,13 +126,13 @@ private void HandleException(Exception exception)
else if (exception is WebException)
{
var webEx = exception as WebException;
WriteDebug(string.Format("Received WebException, Response: {0}, Status: {1}", webEx.Response, webEx.Status));
WriteDebug(string.Format(Resources.WebException, webEx.Response, webEx.Status));

targetErrorCategory = ErrorCategory.ConnectionError;
}
else if (exception is ArgumentException || exception is ArgumentNullException)
{
WriteDebug(string.Format("Received ArgumentException"));
WriteDebug(string.Format(Resources.ArgumentException));
targetErrorCategory = ErrorCategory.InvalidArgument;
}

Expand Down Expand Up @@ -169,7 +169,7 @@ internal CSMOperationResult TrackOperation(string resourceGroupName, string reso

if (response.Status != CSMAzureBackupOperationStatus.InProgress.ToString())
{
WriteDebug(String.Format("OperationStatus : {0}", response.Status));
WriteDebug(String.Format(Resources.OperationStatus, response.Status));
break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public override void ExecuteCmdlet()
{
base.ExecuteCmdlet();

WriteDebug(String.Format("Cmdlet called for ResourceGroupName: {0}, ResourceName: {1}, Location: {2}", Container.ResourceGroupName, Container.ResourceName, Container.Location));
WriteDebug(String.Format(Resources.CmdletCalled, Container.ResourceGroupName, Container.ResourceName, Container.Location));

InitializeAzureBackupCmdlet(Container.ResourceGroupName, Container.ResourceName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public override void ExecuteCmdlet()
{
base.ExecuteCmdlet();

WriteDebug(String.Format("Cmdlet called for ResourceGroupName: {0}, ResourceName: {1}", Item.ResourceGroupName, Item.ResourceName));
WriteDebug(String.Format(Resources.CmdletCalled, Item.ResourceGroupName, Item.ResourceName, Item.Location));

InitializeAzureBackupCmdlet(Item.ResourceGroupName, Item.ResourceName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public abstract class AzureRMBackupItemCmdletBase : AzureBackupCmdletBase
public override void ExecuteCmdlet()
{
base.ExecuteCmdlet();
WriteDebug(String.Format("Cmdlet called for ResourceGroupName: {0}, ResourceName: {1}, Location: {2}", Item.ResourceGroupName, Item.ResourceName, Item.Location));
WriteDebug(String.Format(Resources.CmdletCalled, Item.ResourceGroupName, Item.ResourceName, Item.Location));
InitializeAzureBackupCmdlet(Item.ResourceGroupName, Item.ResourceName);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public override void ExecuteCmdlet()
{
base.ExecuteCmdlet();

WriteDebug(String.Format("Cmdlet called for ResourceGroupName: {0}, ResourceName: {1}, Location: {2}",
WriteDebug(String.Format(Resources.CmdletCalled,
ProtectionPolicy.ResourceGroupName, ProtectionPolicy.ResourceName, ProtectionPolicy.Location));

InitializeAzureBackupCmdlet(ProtectionPolicy.ResourceGroupName, ProtectionPolicy.ResourceName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using Microsoft.Azure.Management.BackupServices.Models;
using MBS = Microsoft.Azure.Management.BackupServices;
using Microsoft.Azure.Commands.AzureBackup.Models;
using Microsoft.Azure.Commands.AzureBackup.Properties;

namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets
{
Expand All @@ -35,10 +36,10 @@ public override void ExecuteCmdlet()
{
base.ExecuteCmdlet();

WriteDebug("Making client call");
WriteDebug(Resources.MakingClientCall);
Guid operationId = AzureBackupClient.TriggerBackup(Item.ResourceGroupName, Item.ResourceName, Item.ContainerUniqueName, Item.ItemName);

WriteDebug(string.Format("Triggered backup. Converting response {0}", operationId));
WriteDebug(string.Format(Resources.TriggeringBackup, operationId));

var operationStatus = TrackOperation(Item.ResourceGroupName, Item.ResourceName, operationId);
WriteObject(GetCreatedJobs(Item.ResourceGroupName, Item.ResourceName, new Models.AzureRMBackupVault(Item.ResourceGroupName, Item.ResourceName, Item.Location), operationStatus.JobList).FirstOrDefault());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public override void ExecuteCmdlet()
AzureBackupClient.EnableMachineContainerReregistration(Container.ResourceGroupName, Container.ResourceName, Container.Id);
break;
default:
throw new ArgumentException("Reregistration can be enable only for machine containers.");
throw new ArgumentException(Resources.CannotEnableRegistration);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using Microsoft.Azure.Commands.AzureBackup.Helpers;
using Microsoft.Azure.Commands.AzureBackup.Library;
using Microsoft.Azure.Commands.AzureBackup.Models;
using Microsoft.Azure.Commands.AzureBackup.Properties;
using Microsoft.Azure.Management.BackupServices.Models;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -123,7 +124,7 @@ private List<AzureRMBackupContainer> GetManagedContainers(string resourceGroupNa

List<CSMContainerResponse> containers = new List<CSMContainerResponse>();
containers.AddRange(AzureBackupClient.ListContainers(resourceGroupName, resourceName, parameters));
WriteDebug(string.Format("Fetched {0} containers", containers.Count()));
WriteDebug(string.Format(Resources.FetchedContainer , containers.Count()));

// When resource group name is specified, remove all containers whose resource group name
// doesn't match the given resource group name
Expand All @@ -134,7 +135,7 @@ private List<AzureRMBackupContainer> GetManagedContainers(string resourceGroupNa
string rgName = ContainerHelpers.GetRGNameFromId(container.Properties.ParentContainerId);
return rgName != ManagedResourceGroupName;
});
WriteDebug(string.Format("Count of containers after resource group filter = {0}", containers.Count));
WriteDebug(string.Format(Resources.ContainerCountAfterFilter, containers.Count));
}

// TODO: Container friendly name is not captures in Container response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,20 @@ public override void ExecuteCmdlet()
{
vmName = Name;
rgName = ServiceName;
WriteDebug(String.Format("Registering ARM-V1 VM, VMName: {0}, CloudServiceName: {1}", vmName, rgName));
WriteDebug(String.Format(Resources.RegisteringARMVM1, vmName, rgName));
ServiceOrRG = "CloudServiceName";
}
else if(this.ParameterSetName == V2VMParameterSet)
{
vmName = Name;
rgName = ResourceGroupName;
WriteDebug(String.Format("Registering ARM-V2 VM, VMName: {0}, ResourceGroupName: {1}", vmName, rgName));
WriteDebug(String.Format(Resources.RegisteringARMVM2, vmName, rgName));
ServiceOrRG = "ResourceGroupName";
}

else
{
throw new PSArgumentException("Please make sure you have pass right set of parameters"); //TODO: PM scrub needed
throw new PSArgumentException(Resources.PSArgumentException); //TODO: PM scrub needed
}

Guid jobId = Guid.Empty;
Expand All @@ -87,20 +87,20 @@ public override void ExecuteCmdlet()
isDiscoveryNeed = IsDiscoveryNeeded(vmName, rgName, out container);
if(isDiscoveryNeed)
{
WriteDebug(String.Format("VM {0} is not yet discovered. Triggering Discovery", vmName));
WriteDebug(String.Format(Resources.VMNotDiscovered, vmName));
RefreshContainer(Vault.ResourceGroupName, Vault.Name);
isDiscoveryNeed = IsDiscoveryNeeded(vmName, rgName, out container);
if ((isDiscoveryNeed == true) || (container == null))
{
//Container is not discovered. Throw exception
string errMsg = String.Format("Failed to discover VM {0} under {1} {2}. Please make sure names are correct and VM is not deleted", vmName, ServiceOrRG, rgName);
string errMsg = String.Format(Resources.DiscoveryFailure, vmName, ServiceOrRG, rgName);
WriteDebug(errMsg);
ThrowTerminatingError(new ErrorRecord(new Exception(Resources.AzureVMNotFound), string.Empty, ErrorCategory.InvalidArgument, null));
}
}

//Container is discovered. Register the container
WriteDebug(String.Format("Going to register VM {0}", vmName));
WriteDebug(String.Format(Resources.RegisteringVM, vmName));
var operationId = AzureBackupClient.RegisterContainer(Vault.ResourceGroupName, Vault.Name, container.Name);

var operationStatus = GetOperationStatus(Vault.ResourceGroupName, Vault.Name, operationId);
Expand Down Expand Up @@ -141,13 +141,13 @@ private bool WaitForDiscoveryToComplete(string resourceGroupName, string resourc
{
isDiscoverySuccessful = false;
errorMessage = status.Error.Message;
WriteDebug(String.Format("Discovery operation failed with ErrorCode: {0}", status.Error.Code));
WriteDebug(String.Format(Resources.DiscoveryFailureErrorCode, status.Error.Code));
if ((status.Error.Code == AzureBackupOperationErrorCode.DiscoveryInProgress.ToString() ||
(status.Error.Code == AzureBackupOperationErrorCode.BMSUserErrorObjectLocked.ToString())))
{
//Need to retry for this errors
isRetryNeeded = true;
WriteDebug(String.Format("Going to retry Discovery if retry count is not exceeded"));
WriteDebug(String.Format(Resources.RertyDiscovery));
}
}
return isRetryNeeded;
Expand All @@ -164,11 +164,11 @@ private bool IsDiscoveryNeeded(string vmName, string rgName, out CSMContainerRes

//First check if container is discovered or not
var containers = AzureBackupClient.ListContainers(Vault.ResourceGroupName, Vault.Name, parameters);
WriteDebug(String.Format("Container count returned from service: {0}.", containers.Count()));
WriteDebug(String.Format(Resources.ContainerCountFromService, containers.Count()));
if (containers.Count() == 0)
{
//Container is not discover
WriteDebug("Container is not discovered");
WriteDebug(Resources.ContainerNotDiscovered);
container = null;
isDiscoveryNeed = true;
}
Expand All @@ -180,7 +180,7 @@ private bool IsDiscoveryNeeded(string vmName, string rgName, out CSMContainerRes
if (container == null)
{
//Container is not in list of registered container
WriteDebug(String.Format("Desired Container is not found. Returning with isDiscoveryNeed = true"));
WriteDebug(String.Format(Resources.DesiredContainerNotFound));
isDiscoveryNeed = true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.AzureBackup.Models;
using Microsoft.Azure.Commands.AzureBackup.Properties;
using Microsoft.Azure.Management.BackupServices;
using Microsoft.Azure.Management.BackupServices.Models;
using System;
Expand Down Expand Up @@ -51,7 +52,7 @@ public override void ExecuteCmdlet()
{
base.ExecuteCmdlet();
Guid operationId = Guid.Empty;
WriteDebug("Making client call");
WriteDebug(Resources.MakingClientCall);

if (!this.DeleteBackupData)
{
Expand All @@ -71,7 +72,7 @@ public override void ExecuteCmdlet()
}


WriteDebug("Received disable azure backup protection response");
WriteDebug(Resources.DisableAzureBackupProtection);
var operationStatus = TrackOperation(Item.ResourceGroupName, Item.ResourceName, operationId);
this.WriteObject(GetCreatedJobs(Item.ResourceGroupName,
Item.ResourceName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using System.Runtime.Serialization;
using Microsoft.Azure.Management.BackupServices;
using Microsoft.Azure.Commands.AzureBackup.Models;
using Microsoft.Azure.Commands.AzureBackup.Properties;

namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets
{
Expand All @@ -41,7 +42,7 @@ public override void ExecuteCmdlet()
{
base.ExecuteCmdlet();

WriteDebug("Making client call");
WriteDebug(Resources.MakingClientCall);
string itemName = string.Empty;

CSMSetProtectionRequest input = new CSMSetProtectionRequest();
Expand All @@ -55,24 +56,25 @@ public override void ExecuteCmdlet()

else if (Item.GetType() == typeof(AzureRMBackupContainer))
{
WriteDebug("Input is container Type = " + Item.GetType());
WriteDebug(String.Format(Resources.ContainerTypeInput, Item.GetType()));

if ((Item as AzureRMBackupContainer).ContainerType == AzureBackupContainerType.AzureVM.ToString())
{
itemName = (Item as AzureRMBackupContainer).ContainerUniqueName;
}
else
{
throw new Exception("Unknown item type");
throw new Exception(Resources.UnknownItemType);
}
}

else
{
throw new Exception("Unknown item type");
throw new Exception(Resources.UnknownItemType);
}

var operationId = AzureBackupClient.EnableProtection(Item.ResourceGroupName, Item.ResourceName, Item.ContainerUniqueName, itemName, input);
WriteDebug("Received enable azure backup protection response");
WriteDebug(Resources.EnableAzureBackupProtection);

var operationStatus = TrackOperation(Item.ResourceGroupName, Item.ResourceName, operationId);
this.WriteObject(GetCreatedJobs(Item.ResourceGroupName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using System.Collections.Specialized;
using Microsoft.Azure.Common.OData;
using Microsoft.Azure.Commands.AzureBackup.Models;
using Microsoft.Azure.Commands.AzureBackup.Properties;

namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets
{
Expand Down Expand Up @@ -52,7 +53,7 @@ public override void ExecuteCmdlet()
List<CSMProtectedItemResponse> azureBackupDatasourceObjects = null;
List<CSMItemResponse> azureBackupPOObjects = null;

WriteDebug("Making client call");
WriteDebug(Resources.MakingClientCall);
CSMProtectedItemQueryObject DSQueryParam = new CSMProtectedItemQueryObject()
{
ProtectionStatus = this.ProtectionStatus,
Expand Down Expand Up @@ -82,7 +83,7 @@ public override void ExecuteCmdlet()
}
}

WriteDebug("Received azure backup item response");
WriteDebug(Resources.AzureBackupItemResponse);
WriteAzureBackupItem(azureBackupDatasourceObjects, azureBackupPOObjects, Container);
});
}
Expand Down
Loading