Skip to content

Commit c79ca8e

Browse files
committed
Merge pull request #121 from MabOneSdk/dev1-pikumar-git2
Dev1 pikumar git2
2 parents 1b2399f + 54e546f commit c79ca8e

32 files changed

+1448
-136
lines changed

src/ResourceManager/AzureBackup/Commands.AzureBackup/AzureBackUpRestoreBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public override void ExecuteCmdlet()
4040
{
4141
base.ExecuteCmdlet();
4242

43-
WriteDebug(String.Format("Cmdlet called for ResourceGroupName: {0}, ResourceName: {1}", RecoveryPoint.ResourceGroupName, RecoveryPoint.ResourceName));
43+
WriteDebug(String.Format(Resources.CmdletCalled, RecoveryPoint.ResourceGroupName, RecoveryPoint.ResourceName, RecoveryPoint.Location));
4444
InitializeAzureBackupCmdlet(RecoveryPoint.ResourceGroupName, RecoveryPoint.ResourceName);
4545
}
4646
}

src/ResourceManager/AzureBackup/Commands.AzureBackup/AzureBackupClientAdapter/PolicyAdapter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public void CheckProtectionPolicyNameAvailability(string resourceGroupName, stri
9494
var policy = GetProtectionPolicyByName(resourceGroupName, resourceName, name);
9595
if (policy != null)
9696
{
97-
var exception = new ArgumentException("A protection policy with the specified name already exists.");
97+
var exception = new ArgumentException(Resources.PolicyAlreadyExist);
9898
throw exception;
9999
}
100100
}

src/ResourceManager/AzureBackup/Commands.AzureBackup/AzureBackupCmdletBase.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ protected void InitializeAzureBackupCmdlet(string rgName, string rName)
5959
var cloudServicesClient = AzureSession.ClientFactory.CreateClient<CloudServiceManagementClient>(Profile, Profile.Context.Subscription, AzureEnvironment.Endpoint.ResourceManager);
6060
azureBackupClientAdapter = new AzureBackupClientAdapter(cloudServicesClient.Credentials, cloudServicesClient.BaseUri);
6161

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

6565
/// <summary>
@@ -79,7 +79,7 @@ protected void ExecutionBlock(Action execAction)
7979
}
8080
catch (Exception exception)
8181
{
82-
WriteDebug(String.Format("Caught exception, type: {0}", exception.GetType()));
82+
WriteDebug(String.Format(Resources.ExceptionInExecution, exception.GetType()));
8383
HandleException(exception);
8484
}
8585
}
@@ -93,7 +93,7 @@ private void HandleException(Exception exception)
9393
if (exception is AggregateException && ((AggregateException)exception).InnerExceptions != null
9494
&& ((AggregateException)exception).InnerExceptions.Count != 0)
9595
{
96-
WriteDebug("Handling aggregate exception");
96+
WriteDebug(Resources.AggregateException);
9797
foreach (var innerEx in ((AggregateException)exception).InnerExceptions)
9898
{
9999
HandleException(innerEx);
@@ -110,14 +110,14 @@ private void HandleException(Exception exception)
110110
var cloudEx = exception as CloudException;
111111
if (cloudEx.Response != null && cloudEx.Response.StatusCode == HttpStatusCode.NotFound)
112112
{
113-
WriteDebug(String.Format("Received CloudException, StatusCode: {0}", cloudEx.Response.StatusCode));
113+
WriteDebug(String.Format(Resources.CloudExceptionCodeNotFound, cloudEx.Response.StatusCode));
114114

115115
targetEx = new Exception(Resources.ResourceNotFoundMessage);
116116
targetErrorCategory = ErrorCategory.InvalidArgument;
117117
}
118118
else if (cloudEx.Error != null)
119119
{
120-
WriteDebug(String.Format("Received CloudException, ErrorCode: {0}, Message: {1}", cloudEx.Error.Code, cloudEx.Error.Message));
120+
WriteDebug(String.Format(Resources.CloudException, cloudEx.Error.Code, cloudEx.Error.Message));
121121

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

131131
targetErrorCategory = ErrorCategory.ConnectionError;
132132
}
133133
else if (exception is ArgumentException || exception is ArgumentNullException)
134134
{
135-
WriteDebug(string.Format("Received ArgumentException"));
135+
WriteDebug(string.Format(Resources.ArgumentException));
136136
targetErrorCategory = ErrorCategory.InvalidArgument;
137137
}
138138

@@ -169,7 +169,7 @@ internal CSMOperationResult TrackOperation(string resourceGroupName, string reso
169169

170170
if (response.Status != CSMAzureBackupOperationStatus.InProgress.ToString())
171171
{
172-
WriteDebug(String.Format("OperationStatus : {0}", response.Status));
172+
WriteDebug(String.Format(Resources.OperationStatus, response.Status));
173173
break;
174174
}
175175

src/ResourceManager/AzureBackup/Commands.AzureBackup/AzureBackupContainerCmdletBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public override void ExecuteCmdlet()
3737
{
3838
base.ExecuteCmdlet();
3939

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

4242
InitializeAzureBackupCmdlet(Container.ResourceGroupName, Container.ResourceName);
4343
}

src/ResourceManager/AzureBackup/Commands.AzureBackup/AzureBackupDSCmdletBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public override void ExecuteCmdlet()
3737
{
3838
base.ExecuteCmdlet();
3939

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

4242
InitializeAzureBackupCmdlet(Item.ResourceGroupName, Item.ResourceName);
4343
}

src/ResourceManager/AzureBackup/Commands.AzureBackup/AzureBackupItemCmdletBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public abstract class AzureRMBackupItemCmdletBase : AzureBackupCmdletBase
3636
public override void ExecuteCmdlet()
3737
{
3838
base.ExecuteCmdlet();
39-
WriteDebug(String.Format("Cmdlet called for ResourceGroupName: {0}, ResourceName: {1}, Location: {2}", Item.ResourceGroupName, Item.ResourceName, Item.Location));
39+
WriteDebug(String.Format(Resources.CmdletCalled, Item.ResourceGroupName, Item.ResourceName, Item.Location));
4040
InitializeAzureBackupCmdlet(Item.ResourceGroupName, Item.ResourceName);
4141
}
4242
}

src/ResourceManager/AzureBackup/Commands.AzureBackup/AzureBackupPolicyCmdletBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public override void ExecuteCmdlet()
4040
{
4141
base.ExecuteCmdlet();
4242

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

4646
InitializeAzureBackupCmdlet(ProtectionPolicy.ResourceGroupName, ProtectionPolicy.ResourceName);

src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Backup/BackupAzureRMBackupItem.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
using Microsoft.Azure.Management.BackupServices.Models;
2121
using MBS = Microsoft.Azure.Management.BackupServices;
2222
using Microsoft.Azure.Commands.AzureBackup.Models;
23+
using Microsoft.Azure.Commands.AzureBackup.Properties;
2324

2425
namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets
2526
{
@@ -35,10 +36,10 @@ public override void ExecuteCmdlet()
3536
{
3637
base.ExecuteCmdlet();
3738

38-
WriteDebug("Making client call");
39+
WriteDebug(Resources.MakingClientCall);
3940
Guid operationId = AzureBackupClient.TriggerBackup(Item.ResourceGroupName, Item.ResourceName, Item.ContainerUniqueName, Item.ItemName);
4041

41-
WriteDebug(string.Format("Triggered backup. Converting response {0}", operationId));
42+
WriteDebug(string.Format(Resources.TriggeringBackup, operationId));
4243

4344
var operationStatus = TrackOperation(Item.ResourceGroupName, Item.ResourceName, operationId);
4445
WriteObject(GetCreatedJobs(Item.ResourceGroupName, Item.ResourceName, new Models.AzureRMBackupVault(Item.ResourceGroupName, Item.ResourceName, Item.Location), operationStatus.JobList).FirstOrDefault());

src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Container/EnableAzureRMBackupContainerReregistration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public override void ExecuteCmdlet()
5050
AzureBackupClient.EnableMachineContainerReregistration(Container.ResourceGroupName, Container.ResourceName, Container.Id);
5151
break;
5252
default:
53-
throw new ArgumentException("Reregistration can be enable only for machine containers.");
53+
throw new ArgumentException(Resources.CannotEnableRegistration);
5454
}
5555
});
5656
}

src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Container/GetAzureRMBackupContainer.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using Microsoft.Azure.Commands.AzureBackup.Helpers;
1616
using Microsoft.Azure.Commands.AzureBackup.Library;
1717
using Microsoft.Azure.Commands.AzureBackup.Models;
18+
using Microsoft.Azure.Commands.AzureBackup.Properties;
1819
using Microsoft.Azure.Management.BackupServices.Models;
1920
using System;
2021
using System.Collections.Generic;
@@ -123,7 +124,7 @@ private List<AzureRMBackupContainer> GetManagedContainers(string resourceGroupNa
123124

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

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

140141
// TODO: Container friendly name is not captures in Container response

src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Container/RegisterAzureRMBackupContainer.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,20 @@ public override void ExecuteCmdlet()
6464
{
6565
vmName = Name;
6666
rgName = ServiceName;
67-
WriteDebug(String.Format("Registering ARM-V1 VM, VMName: {0}, CloudServiceName: {1}", vmName, rgName));
67+
WriteDebug(String.Format(Resources.RegisteringARMVM1, vmName, rgName));
6868
ServiceOrRG = "CloudServiceName";
6969
}
7070
else if(this.ParameterSetName == V2VMParameterSet)
7171
{
7272
vmName = Name;
7373
rgName = ResourceGroupName;
74-
WriteDebug(String.Format("Registering ARM-V2 VM, VMName: {0}, ResourceGroupName: {1}", vmName, rgName));
74+
WriteDebug(String.Format(Resources.RegisteringARMVM2, vmName, rgName));
7575
ServiceOrRG = "ResourceGroupName";
7676
}
7777

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

8383
Guid jobId = Guid.Empty;
@@ -87,20 +87,20 @@ public override void ExecuteCmdlet()
8787
isDiscoveryNeed = IsDiscoveryNeeded(vmName, rgName, out container);
8888
if(isDiscoveryNeed)
8989
{
90-
WriteDebug(String.Format("VM {0} is not yet discovered. Triggering Discovery", vmName));
90+
WriteDebug(String.Format(Resources.VMNotDiscovered, vmName));
9191
RefreshContainer(Vault.ResourceGroupName, Vault.Name);
9292
isDiscoveryNeed = IsDiscoveryNeeded(vmName, rgName, out container);
9393
if ((isDiscoveryNeed == true) || (container == null))
9494
{
9595
//Container is not discovered. Throw exception
96-
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);
96+
string errMsg = String.Format(Resources.DiscoveryFailure, vmName, ServiceOrRG, rgName);
9797
WriteDebug(errMsg);
9898
ThrowTerminatingError(new ErrorRecord(new Exception(Resources.AzureVMNotFound), string.Empty, ErrorCategory.InvalidArgument, null));
9999
}
100100
}
101101

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

106106
var operationStatus = GetOperationStatus(Vault.ResourceGroupName, Vault.Name, operationId);
@@ -141,13 +141,13 @@ private bool WaitForDiscoveryToComplete(string resourceGroupName, string resourc
141141
{
142142
isDiscoverySuccessful = false;
143143
errorMessage = status.Error.Message;
144-
WriteDebug(String.Format("Discovery operation failed with ErrorCode: {0}", status.Error.Code));
144+
WriteDebug(String.Format(Resources.DiscoveryFailureErrorCode, status.Error.Code));
145145
if ((status.Error.Code == AzureBackupOperationErrorCode.DiscoveryInProgress.ToString() ||
146146
(status.Error.Code == AzureBackupOperationErrorCode.BMSUserErrorObjectLocked.ToString())))
147147
{
148148
//Need to retry for this errors
149149
isRetryNeeded = true;
150-
WriteDebug(String.Format("Going to retry Discovery if retry count is not exceeded"));
150+
WriteDebug(String.Format(Resources.RertyDiscovery));
151151
}
152152
}
153153
return isRetryNeeded;
@@ -164,11 +164,11 @@ private bool IsDiscoveryNeeded(string vmName, string rgName, out CSMContainerRes
164164

165165
//First check if container is discovered or not
166166
var containers = AzureBackupClient.ListContainers(Vault.ResourceGroupName, Vault.Name, parameters);
167-
WriteDebug(String.Format("Container count returned from service: {0}.", containers.Count()));
167+
WriteDebug(String.Format(Resources.ContainerCountFromService, containers.Count()));
168168
if (containers.Count() == 0)
169169
{
170170
//Container is not discover
171-
WriteDebug("Container is not discovered");
171+
WriteDebug(Resources.ContainerNotDiscovered);
172172
container = null;
173173
isDiscoveryNeed = true;
174174
}
@@ -180,7 +180,7 @@ private bool IsDiscoveryNeeded(string vmName, string rgName, out CSMContainerRes
180180
if (container == null)
181181
{
182182
//Container is not in list of registered container
183-
WriteDebug(String.Format("Desired Container is not found. Returning with isDiscoveryNeed = true"));
183+
WriteDebug(String.Format(Resources.DesiredContainerNotFound));
184184
isDiscoveryNeed = true;
185185
}
186186
}

src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Item/Disable-AzureRMBackupProtection .cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using Microsoft.Azure.Commands.AzureBackup.Models;
16+
using Microsoft.Azure.Commands.AzureBackup.Properties;
1617
using Microsoft.Azure.Management.BackupServices;
1718
using Microsoft.Azure.Management.BackupServices.Models;
1819
using System;
@@ -51,7 +52,7 @@ public override void ExecuteCmdlet()
5152
{
5253
base.ExecuteCmdlet();
5354
Guid operationId = Guid.Empty;
54-
WriteDebug("Making client call");
55+
WriteDebug(Resources.MakingClientCall);
5556

5657
if (!this.DeleteBackupData)
5758
{
@@ -71,7 +72,7 @@ public override void ExecuteCmdlet()
7172
}
7273

7374

74-
WriteDebug("Received disable azure backup protection response");
75+
WriteDebug(Resources.DisableAzureBackupProtection);
7576
var operationStatus = TrackOperation(Item.ResourceGroupName, Item.ResourceName, operationId);
7677
this.WriteObject(GetCreatedJobs(Item.ResourceGroupName,
7778
Item.ResourceName,

src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Item/Enable-AzureRMBackupProtection .cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
using System.Runtime.Serialization;
2323
using Microsoft.Azure.Management.BackupServices;
2424
using Microsoft.Azure.Commands.AzureBackup.Models;
25+
using Microsoft.Azure.Commands.AzureBackup.Properties;
2526

2627
namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets
2728
{
@@ -41,7 +42,7 @@ public override void ExecuteCmdlet()
4142
{
4243
base.ExecuteCmdlet();
4344

44-
WriteDebug("Making client call");
45+
WriteDebug(Resources.MakingClientCall);
4546
string itemName = string.Empty;
4647

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

5657
else if (Item.GetType() == typeof(AzureRMBackupContainer))
5758
{
58-
WriteDebug("Input is container Type = " + Item.GetType());
59+
WriteDebug(String.Format(Resources.ContainerTypeInput, Item.GetType()));
60+
5961
if ((Item as AzureRMBackupContainer).ContainerType == AzureBackupContainerType.AzureVM.ToString())
6062
{
6163
itemName = (Item as AzureRMBackupContainer).ContainerUniqueName;
6264
}
6365
else
6466
{
65-
throw new Exception("Unknown item type");
67+
throw new Exception(Resources.UnknownItemType);
6668
}
6769
}
6870

6971
else
7072
{
71-
throw new Exception("Unknown item type");
73+
throw new Exception(Resources.UnknownItemType);
7274
}
7375

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

7779
var operationStatus = TrackOperation(Item.ResourceGroupName, Item.ResourceName, operationId);
7880
this.WriteObject(GetCreatedJobs(Item.ResourceGroupName,

src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Item/GetAzureRMBackupItem.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
using System.Collections.Specialized;
2323
using Microsoft.Azure.Common.OData;
2424
using Microsoft.Azure.Commands.AzureBackup.Models;
25+
using Microsoft.Azure.Commands.AzureBackup.Properties;
2526

2627
namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets
2728
{
@@ -52,7 +53,7 @@ public override void ExecuteCmdlet()
5253
List<CSMProtectedItemResponse> azureBackupDatasourceObjects = null;
5354
List<CSMItemResponse> azureBackupPOObjects = null;
5455

55-
WriteDebug("Making client call");
56+
WriteDebug(Resources.MakingClientCall);
5657
CSMProtectedItemQueryObject DSQueryParam = new CSMProtectedItemQueryObject()
5758
{
5859
ProtectionStatus = this.ProtectionStatus,
@@ -82,7 +83,7 @@ public override void ExecuteCmdlet()
8283
}
8384
}
8485

85-
WriteDebug("Received azure backup item response");
86+
WriteDebug(Resources.AzureBackupItemResponse);
8687
WriteAzureBackupItem(azureBackupDatasourceObjects, azureBackupPOObjects, Container);
8788
});
8889
}

0 commit comments

Comments
 (0)