Skip to content

Commit f2aeb45

Browse files
author
Samuel Anudeep
committed
Merge pull request #308 from MabOneSdk/anudeeb-dev1
Implementing Code Review Comments
2 parents 250e454 + 63e1e26 commit f2aeb45

File tree

79 files changed

+766
-781
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+766
-781
lines changed

setup/azurecmdfiles.wxi

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2002,9 +2002,6 @@
20022002
<Component Id="cmp131A9DE83A67006D51F1314A42E399CA" Guid="*">
20032003
<File Id="filA2C0D97A8033046D96249BA12C24D9D4" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.RecoveryServices.Backup\AzureRM.RecoveryServices.Backup.psd1" />
20042004
</Component>
2005-
<Component Id="cmpEB886EAAAF58ED0808ACCABDCC7707CA" Guid="*">
2006-
<File Id="filB0E96893813842B67380A6863ABBCC0D" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.RecoveryServices.Backup\AzureRM.RecoveryServices.psd1" />
2007-
</Component>
20082005
<Component Id="cmpB35FF47D728C871816F14A3529260DE9" Guid="*">
20092006
<File Id="fil4BCDE7803B14A0BC88A83E82379716A7" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.RecoveryServices.Backup\Hyak.Common.dll" />
20102007
</Component>
@@ -5717,7 +5714,6 @@
57175714
<ComponentRef Id="cmpC00974919B90C9055BED1F2A9DA95441" />
57185715
<ComponentRef Id="cmpE300D8B185C427E05E95BA97413F6CC8" />
57195716
<ComponentRef Id="cmp131A9DE83A67006D51F1314A42E399CA" />
5720-
<ComponentRef Id="cmpEB886EAAAF58ED0808ACCABDCC7707CA" />
57215717
<ComponentRef Id="cmpB35FF47D728C871816F14A3529260DE9" />
57225718
<ComponentRef Id="cmp99A277F4A4EF20D7BFBB171691A4B7E7" />
57235719
<ComponentRef Id="cmp1675F88279F58B72A180AF1411111337" />

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Helpers/Commands.RecoveryServices.Backup.Helpers.csproj

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<Reference Include="Microsoft.Azure.Common">
3737
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.dll</HintPath>
3838
</Reference>
39-
<Reference Include="Microsoft.Azure.Management.RecoveryServices.Backup, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
39+
<Reference Include="Microsoft.Azure.Management.RecoveryServices.Backup, Version=0.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
4040
<SpecificVersion>False</SpecificVersion>
4141
<HintPath>..\..\..\packages\Microsoft.Azure.Management.RecoveryServices.Backup.0.1.0-preview\lib\net40\Microsoft.Azure.Management.RecoveryServices.Backup.dll</HintPath>
4242
</Reference>
@@ -52,23 +52,19 @@
5252
<ItemGroup>
5353
<Compile Include="Conversions\JobConversions.cs" />
5454
<Compile Include="Conversions\RecoveryPointConversions.cs" />
55-
<Compile Include="Utils.cs" />
55+
<Compile Include="HelperUtils.cs" />
5656
<Compile Include="Validations\PolicyValidations.cs" />
5757
<Compile Include="Conversions\SchedulePolicyConversions.cs" />
5858
<Compile Include="Conversions\RetentionPolicyConversions.cs" />
5959
<Compile Include="Conversions\ConversionHelpers.cs" />
60-
<Compile Include="HydraHelpers.cs" />
60+
<Compile Include="ServiceClientHelpers.cs" />
6161
<Compile Include="Properties\AssemblyInfo.cs" />
6262
</ItemGroup>
6363
<ItemGroup>
6464
<ProjectReference Include="..\..\..\Common\Commands.Common\Commands.Common.csproj">
6565
<Project>{5ee72c53-1720-4309-b54b-5fb79703195f}</Project>
6666
<Name>Commands.Common</Name>
6767
</ProjectReference>
68-
<ProjectReference Include="..\Commands.RecoveryServices.Backup.HydraAdapter\Commands.RecoveryServices.Backup.HydraAdapter.csproj">
69-
<Project>{b758fec1-35c1-4f93-a954-66dd33f6e0ec}</Project>
70-
<Name>Commands.RecoveryServices.Backup.HydraAdapter</Name>
71-
</ProjectReference>
7268
<ProjectReference Include="..\Commands.RecoveryServices.Backup.Logger\Commands.RecoveryServices.Backup.Logger.csproj">
7369
<Project>{5e675749-6139-464a-904c-59c0ffdfec82}</Project>
7470
<Name>Commands.RecoveryServices.Backup.Logger</Name>

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Helpers/Conversions/ConversionHelpers.cs

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,25 @@
1919
using System.Threading.Tasks;
2020
using Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models;
2121
using Microsoft.Azure.Commands.RecoveryServices.Backup.Properties;
22-
using Microsoft.Azure.Management.RecoveryServices.Backup.Models;
22+
using ServiceClientModel = Microsoft.Azure.Management.RecoveryServices.Backup.Models;
2323

2424
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Helpers
2525
{
2626
public class ConversionHelpers
2727
{
2828
#region containers
29-
public static AzureRmRecoveryServicesBackupContainerBase GetContainerModel(ProtectionContainerResource protectionContainer)
29+
public static ContainerBase GetContainerModel(ServiceClientModel.ProtectionContainerResource protectionContainer)
3030
{
31-
AzureRmRecoveryServicesBackupContainerBase containerModel = null;
31+
ContainerBase containerModel = null;
3232

3333
if (protectionContainer != null &&
3434
protectionContainer.Properties != null)
3535
{
36-
if (protectionContainer.Properties.GetType().IsSubclassOf(typeof(AzureIaaSVMProtectionContainer)))
36+
if (protectionContainer.Properties.GetType().IsSubclassOf(typeof(ServiceClientModel.AzureIaaSVMProtectionContainer)))
3737
{
38-
containerModel = new AzureRmRecoveryServicesBackupIaasVmContainer(protectionContainer);
38+
containerModel = new AzureVmContainer(protectionContainer);
3939
}
40-
if (protectionContainer.Properties.GetType() == typeof(MabProtectionContainer))
40+
if (protectionContainer.Properties.GetType() == typeof(ServiceClientModel.MabProtectionContainer))
4141
{
4242
containerModel = new AzureRmRecoveryServicesBackupMabContainer(protectionContainer);
4343
}
@@ -46,18 +46,18 @@ public static AzureRmRecoveryServicesBackupContainerBase GetContainerModel(Prote
4646
return containerModel;
4747
}
4848

49-
public static AzureRmRecoveryServicesBackupEngineBase GetBackupEngineModel(BackupEngineResource backupEngine)
49+
public static BackupEngineBase GetBackupEngineModel(ServiceClientModel.BackupEngineResource backupEngine)
5050
{
51-
AzureRmRecoveryServicesBackupEngineBase backupEngineModel = null;
51+
BackupEngineBase backupEngineModel = null;
5252

5353
if (backupEngine != null &&
5454
backupEngine.Properties != null)
5555
{
56-
if (backupEngine.Properties.GetType() == (typeof(DpmBackupEngine)))
56+
if (backupEngine.Properties.GetType() == (typeof(ServiceClientModel.DpmBackupEngine)))
5757
{
58-
backupEngineModel = new AzureRmRecoveryServicesBackupDpmBackupEngine(backupEngine);
58+
backupEngineModel = new DpmBackupEngine(backupEngine);
5959
}
60-
else if (backupEngine.Properties.GetType() == (typeof(AzureBackupServerEngine)))
60+
else if (backupEngine.Properties.GetType() == (typeof(ServiceClientModel.AzureBackupServerEngine)))
6161
{
6262
backupEngineModel = new AzureRmRecoveryServicesBackupAzureBackupServerEngine(backupEngine);
6363
}
@@ -66,9 +66,9 @@ public static AzureRmRecoveryServicesBackupEngineBase GetBackupEngineModel(Backu
6666
return backupEngineModel;
6767
}
6868

69-
public static List<AzureRmRecoveryServicesBackupContainerBase> GetContainerModelList(IEnumerable<ProtectionContainerResource> protectionContainers)
69+
public static List<ContainerBase> GetContainerModelList(IEnumerable<ServiceClientModel.ProtectionContainerResource> protectionContainers)
7070
{
71-
List<AzureRmRecoveryServicesBackupContainerBase> containerModels = new List<AzureRmRecoveryServicesBackupContainerBase>();
71+
List<ContainerBase> containerModels = new List<ContainerBase>();
7272

7373
foreach (var protectionContainer in protectionContainers)
7474
{
@@ -78,9 +78,9 @@ public static List<AzureRmRecoveryServicesBackupContainerBase> GetContainerModel
7878
return containerModels;
7979
}
8080

81-
public static List<AzureRmRecoveryServicesBackupEngineBase> GetBackupEngineModelList(IEnumerable<BackupEngineResource> backupEngines)
81+
public static List<BackupEngineBase> GetBackupEngineModelList(IEnumerable<ServiceClientModel.BackupEngineResource> backupEngines)
8282
{
83-
List<AzureRmRecoveryServicesBackupEngineBase> backupEngineModel = new List<AzureRmRecoveryServicesBackupEngineBase>();
83+
List<BackupEngineBase> backupEngineModel = new List<BackupEngineBase>();
8484

8585
foreach (var backupEngine in backupEngines)
8686
{
@@ -93,75 +93,75 @@ public static List<AzureRmRecoveryServicesBackupEngineBase> GetBackupEngineModel
9393
#endregion
9494

9595
#region policy
96-
public static AzureRmRecoveryServicesBackupPolicyBase GetPolicyModel(ProtectionPolicyResource hydraResponse)
96+
public static PolicyBase GetPolicyModel(ServiceClientModel.ProtectionPolicyResource serviceClientResponse)
9797
{
98-
AzureRmRecoveryServicesBackupPolicyBase policyModel = null;
98+
PolicyBase policyModel = null;
9999

100-
if (hydraResponse == null || hydraResponse.Properties == null)
100+
if (serviceClientResponse == null || serviceClientResponse.Properties == null)
101101
{
102-
Logger.Instance.WriteDebug("Policy Hydra response is Null/Empty");
103-
throw new ArgumentException(Resources.EmptyHydraResponseException);
102+
Logger.Instance.WriteDebug("Policy Service Client response is Null/Empty");
103+
throw new ArgumentException(Resources.EmptyServiceClientResponseException);
104104
}
105105

106-
if (hydraResponse.Properties.GetType() == typeof(AzureIaaSVMProtectionPolicy))
106+
if (serviceClientResponse.Properties.GetType() == typeof(ServiceClientModel.AzureIaaSVMProtectionPolicy))
107107
{
108-
if (((AzureIaaSVMProtectionPolicy)hydraResponse.Properties).RetentionPolicy.GetType() !=
109-
typeof(LongTermRetentionPolicy))
108+
if (((ServiceClientModel.AzureIaaSVMProtectionPolicy)serviceClientResponse.Properties).RetentionPolicy.GetType() !=
109+
typeof(ServiceClientModel.LongTermRetentionPolicy))
110110
{
111111
Logger.Instance.WriteDebug("Unknown RetentionPolicy object received: " +
112-
((AzureIaaSVMProtectionPolicy)hydraResponse.Properties).RetentionPolicy.GetType());
112+
((ServiceClientModel.AzureIaaSVMProtectionPolicy)serviceClientResponse.Properties).RetentionPolicy.GetType());
113113
Logger.Instance.WriteWarning(Resources.UpdateToNewAzurePowershellWarning);
114114
return null;
115115
}
116116

117-
if (((AzureIaaSVMProtectionPolicy)hydraResponse.Properties).SchedulePolicy.GetType() !=
118-
typeof(SimpleSchedulePolicy))
117+
if (((ServiceClientModel.AzureIaaSVMProtectionPolicy)serviceClientResponse.Properties).SchedulePolicy.GetType() !=
118+
typeof(ServiceClientModel.SimpleSchedulePolicy))
119119
{
120120
Logger.Instance.WriteDebug("Unknown SchedulePolicy object received: " +
121-
((AzureIaaSVMProtectionPolicy)hydraResponse.Properties).SchedulePolicy.GetType());
121+
((ServiceClientModel.AzureIaaSVMProtectionPolicy)serviceClientResponse.Properties).SchedulePolicy.GetType());
122122
Logger.Instance.WriteWarning(Resources.UpdateToNewAzurePowershellWarning);
123123
return null;
124124
}
125125

126-
policyModel = new AzureRmRecoveryServicesBackupIaasVmPolicy();
127-
AzureRmRecoveryServicesBackupIaasVmPolicy iaasPolicyModel = policyModel as AzureRmRecoveryServicesBackupIaasVmPolicy;
126+
policyModel = new AzureVmPolicy();
127+
AzureVmPolicy iaasPolicyModel = policyModel as AzureVmPolicy;
128128
iaasPolicyModel.WorkloadType = Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models.WorkloadType.AzureVM;
129129
iaasPolicyModel.BackupManagementType = Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models.BackupManagementType.AzureVM;
130-
iaasPolicyModel.RetentionPolicy = PolicyHelpers.GetPSLongTermRetentionPolicy((LongTermRetentionPolicy)
131-
((AzureIaaSVMProtectionPolicy)hydraResponse.Properties).RetentionPolicy);
132-
iaasPolicyModel.SchedulePolicy = PolicyHelpers.GetPSSimpleSchedulePolicy((SimpleSchedulePolicy)
133-
((AzureIaaSVMProtectionPolicy)hydraResponse.Properties).SchedulePolicy);
130+
iaasPolicyModel.RetentionPolicy = PolicyHelpers.GetPSLongTermRetentionPolicy((ServiceClientModel.LongTermRetentionPolicy)
131+
((ServiceClientModel.AzureIaaSVMProtectionPolicy)serviceClientResponse.Properties).RetentionPolicy);
132+
iaasPolicyModel.SchedulePolicy = PolicyHelpers.GetPSSimpleSchedulePolicy((ServiceClientModel.SimpleSchedulePolicy)
133+
((ServiceClientModel.AzureIaaSVMProtectionPolicy)serviceClientResponse.Properties).SchedulePolicy);
134134
}
135135
else
136136
{
137137
// we will enter this case when service supports new workload and customer
138138
// still using old version of azure powershell. Trace warning message, ignore and return
139139
Logger.Instance.WriteDebug("Unknown Policy object received: " +
140-
hydraResponse.Properties.GetType());
140+
serviceClientResponse.Properties.GetType());
141141
Logger.Instance.WriteWarning(Resources.UpdateToNewAzurePowershellWarning);
142142
return null;
143143
}
144144

145-
policyModel.Name = hydraResponse.Name;
146-
policyModel.Id = hydraResponse.Id;
145+
policyModel.Name = serviceClientResponse.Name;
146+
policyModel.Id = serviceClientResponse.Id;
147147

148148
return policyModel;
149149
}
150150

151-
public static List<AzureRmRecoveryServicesBackupPolicyBase> GetPolicyModelList(
152-
ProtectionPolicyListResponse hydraListResponse)
151+
public static List<PolicyBase> GetPolicyModelList(
152+
ServiceClientModel.ProtectionPolicyListResponse serviceClientListResponse)
153153
{
154-
if (hydraListResponse == null || hydraListResponse.ItemList == null ||
155-
hydraListResponse.ItemList.Value == null || hydraListResponse.ItemList.Value.Count == 0)
154+
if (serviceClientListResponse == null || serviceClientListResponse.ItemList == null ||
155+
serviceClientListResponse.ItemList.Value == null || serviceClientListResponse.ItemList.Value.Count == 0)
156156
{
157157
Logger.Instance.WriteDebug("Received empty list of policies from service");
158158
return null;
159159
}
160160

161-
List<AzureRmRecoveryServicesBackupPolicyBase> policyModels = new List<AzureRmRecoveryServicesBackupPolicyBase>();
162-
AzureRmRecoveryServicesBackupPolicyBase policyModel = null;
161+
List<PolicyBase> policyModels = new List<PolicyBase>();
162+
PolicyBase policyModel = null;
163163

164-
foreach (ProtectionPolicyResource resource in hydraListResponse.ItemList.Value)
164+
foreach (ServiceClientModel.ProtectionPolicyResource resource in serviceClientListResponse.ItemList.Value)
165165
{
166166
policyModel = GetPolicyModel(resource);
167167
if (policyModel != null)
@@ -178,17 +178,17 @@ public static List<AzureRmRecoveryServicesBackupPolicyBase> GetPolicyModelList(
178178

179179
#region Item
180180

181-
public static AzureRmRecoveryServicesBackupItemBase GetItemModel(ProtectedItemResource protectedItem)
181+
public static ItemBase GetItemModel(ServiceClientModel.ProtectedItemResource protectedItem)
182182
{
183-
AzureRmRecoveryServicesBackupItemBase itemModel = null;
183+
ItemBase itemModel = null;
184184

185185
if (protectedItem != null &&
186186
protectedItem.Properties != null)
187187
{
188-
if (protectedItem.Properties.GetType().IsSubclassOf(typeof(AzureIaaSVMProtectedItem)))
188+
if (protectedItem.Properties.GetType().IsSubclassOf(typeof(ServiceClientModel.AzureIaaSVMProtectedItem)))
189189
{
190190
string policyName = null;
191-
string policyId = ((AzureIaaSVMProtectedItem)protectedItem.Properties).PolicyId;
191+
string policyId = ((ServiceClientModel.AzureIaaSVMProtectedItem)protectedItem.Properties).PolicyId;
192192
if (!string.IsNullOrEmpty(policyId))
193193
{
194194
Dictionary<UriEnums, string> keyValueDict =
@@ -200,7 +200,7 @@ public static AzureRmRecoveryServicesBackupItemBase GetItemModel(ProtectedItemRe
200200
HelperUtils.ParseUri(protectedItem.Id),
201201
protectedItem.Id);
202202

203-
itemModel = new AzureRmRecoveryServicesBackupIaasVmItem(
203+
itemModel = new AzureVmItem(
204204
protectedItem,
205205
IdUtils.GetNameFromUri(containerUri),
206206
Cmdlets.Models.ContainerType.AzureVM,
@@ -211,9 +211,9 @@ public static AzureRmRecoveryServicesBackupItemBase GetItemModel(ProtectedItemRe
211211
return itemModel;
212212
}
213213

214-
public static List<AzureRmRecoveryServicesBackupItemBase> GetItemModelList(IEnumerable<ProtectedItemResource> protectedItems)
214+
public static List<ItemBase> GetItemModelList(IEnumerable<ServiceClientModel.ProtectedItemResource> protectedItems)
215215
{
216-
List<AzureRmRecoveryServicesBackupItemBase> itemModels = new List<AzureRmRecoveryServicesBackupItemBase>();
216+
List<ItemBase> itemModels = new List<ItemBase>();
217217

218218
foreach (var protectedItem in protectedItems)
219219
{

0 commit comments

Comments
 (0)